Salome HOME
Initial version
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.h
1 #ifndef OCCVIEWER_VIEWWINDOW_H
2 #define OCCVIEWER_VIEWWINDOW_H
3
4 #include "OCCViewer_ViewModel.h"
5
6 #include "SUIT_ViewWindow.h"
7
8 #include "QtxAction.h"
9
10 #include <qcursor.h>
11 #include <qvaluelist.h>
12
13 class SUIT_Desktop;
14 class OCCViewer_ViewPort3d;
15
16 #ifdef WIN32
17 #pragma warning( disable:4251 )
18 #endif
19
20 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow  
21 {
22   Q_OBJECT
23
24 public:
25   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
26                       FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
27
28   OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
29         virtual ~OCCViewer_ViewWindow() {};
30
31   OCCViewer_ViewPort3d* getViewPort() { return myViewPort; }
32
33   bool eventFilter(QObject* watched, QEvent* e);
34
35   QToolBar* getToolBar() { return myToolBar; }
36
37   void performRestoring( const viewAspect& );
38   
39   virtual void initLayout();
40
41 public slots:
42   void onFrontView();
43   void onViewFitAll();
44   void onBackView();
45   void onTopView();
46   void onBottomView();
47   void onLeftView();
48   void onRightView();
49   void onResetView();
50   void onFitAll();
51   void onDumpView();
52   void activateZoom();
53   void activateWindowFit();
54   void activateRotation();
55   void activatePanning();
56   void activateGlobalPanning();
57   void onCloneView();
58   void onMemorizeView();
59   void onRestoreView();
60   void setRestoreFlag();
61   
62 signals:
63   void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
64   void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
65   void cloneView();
66
67 protected:
68   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
69          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, MemId, RestoreId };
70   typedef QMap<int, QtxAction*> ActionsMap;
71
72
73   /* Transformation selected but not started yet */
74   bool transformRequested() const { return ( myOperation != NOTHING ); }
75   void setTransformRequested ( OperationType op );
76
77   /* Transformation is selected and already started */
78   bool          transformInProcess() const { return myEventStarted; }
79   void          setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
80
81   void vpMousePressEvent(QMouseEvent* theEvent);
82   void vpMouseReleaseEvent(QMouseEvent* theEvent);
83   void vpMouseMoveEvent(QMouseEvent* theEvent);
84
85   void resetState();
86   void drawRect();
87
88   void createActions();
89   void createToolBar();
90  
91   virtual OperationType getButtonState(QMouseEvent* theEvent);
92
93   OperationType         myOperation;
94   OCCViewer_Viewer*     myModel;
95   OCCViewer_ViewPort3d* myViewPort;
96
97   int                                   myRestoreFlag;
98
99   int                                   myStartX;
100   int                                   myStartY;
101   int                                   myCurrX;
102   int                                   myCurrY;
103
104   bool                  myEventStarted;       // set when transformation is in process 
105   bool                  myCursorIsHand;                 
106   bool                  myDrawRect;           // set when a rect is used for selection or magnify 
107   bool                  myEnableDrawMode;
108   bool                  myPaintersRedrawing;  // set to draw with external painters 
109  
110   QRect                 myRect;                         
111   QCursor               myCursor;
112
113   QToolBar*  myToolBar;
114   ActionsMap myActionsMap;
115
116   double myCurScale;
117 };
118
119 #ifdef WIN32
120 #pragma warning( default:4251 )
121 #endif
122
123 #endif