Back to index

salome-gui  6.5.0
QxGraph_CanvasView.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME QxGraph : build Supervisor viewer into desktop
00024 //
00025 #ifndef QXGRAPH_CANVASVIEW_H
00026 #define QXGRAPH_CANVASVIEW_H
00027 
00028 #include "QxGraph.h"
00029 
00030 #include <qcanvas.h>
00031 #include <qcursor.h>
00032 #include <qtimer.h>
00033 #include <qtooltip.h>
00034 
00035 class QxGraph_Canvas;
00036 class QxGraph_ViewWindow;
00037 class QxGraph_ActiveItem;
00038 
00039 class QXGRAPH_EXPORT QxGraph_CanvasView : public QCanvasView {
00040   Q_OBJECT
00041 
00042  public:
00043   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, PANGLOBAL, 
00044                       WINDOWFIT, FITALLVIEW, RESETVIEW };
00045   
00046   QxGraph_CanvasView(QxGraph_Canvas* theCanvas, QxGraph_ViewWindow* theViewWindow);
00047   virtual ~QxGraph_CanvasView();
00048 
00049   QxGraph_ViewWindow* getViewWindow() const;
00050 
00051   void activateFitAll();
00052   void activateFitRect();
00053   void activateZoom();
00054   void activatePanning();
00055   void activateGlobalPanning();
00056   void activateReset();
00057 
00058   void itemRemoved( QCanvasItem* );
00059 
00060   void setSelectedItem( QxGraph_ActiveItem* theItem );
00061   QxGraph_ActiveItem* getSelectedItem() const;
00062 
00063  signals:
00064   void viewOperationDone();
00065 
00066  public slots:
00067   void onTimeout();
00068    //void changeBackground();
00069 
00070  protected:
00071   void contentsMousePressEvent(QMouseEvent* theEvent); 
00072   void contentsMouseMoveEvent(QMouseEvent* theEvent);
00073   void contentsMouseReleaseEvent(QMouseEvent* theEvent); 
00074   void contentsMouseDoubleClickEvent(QMouseEvent* theEvent);
00075 
00076   bool isSelectedItemInCanvas();
00077 
00078  private:
00079   // for moving items
00080   QCanvasItem*      myCurrentItem;
00081   QPoint            myPoint;
00082   QPoint            myGlobalPoint;
00083   bool              myMovingDone;
00084   QPoint            myCenter;
00085   
00086   // for control toolbar actions
00087   OperationType     myOperation;
00088   QCursor           myCursor;
00089   QCanvasRectangle* mySelectedRect;
00090 
00091   // for automatic content scrolling if mouse is outside
00092   QTimer*           myTimer;
00093   int               myDX;
00094   int               myDY;
00095 
00096   // for hilight
00097   QxGraph_ActiveItem* myHilightedItem;
00098 
00099   // for selection
00100   QxGraph_ActiveItem* mySelectedItem;
00101 };
00102 
00103 
00104 class QxGraph_ToolTip: public QToolTip {
00105   
00106  public:
00107   QxGraph_ToolTip(QWidget* theWidget, QToolTipGroup* theGroup = 0):
00108     QToolTip(theWidget, theGroup) {}
00109   ~QxGraph_ToolTip() { remove(parentWidget()); }
00110     
00111   virtual void maybeTip(const QPoint& theMousePos);
00112 };
00113 
00114 #endif