Salome HOME
Show/Hide trihedron command
[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 onTrihedronShow();
61   void setRestoreFlag();
62   
63 signals:
64   void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
65   void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
66   void cloneView();
67
68 protected:
69   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
70          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, MemId, RestoreId,
71          TrihedronShowId };
72
73   typedef QMap<int, QtxAction*> ActionsMap;
74
75
76   /* Transformation selected but not started yet */
77   bool transformRequested() const { return ( myOperation != NOTHING ); }
78   void setTransformRequested ( OperationType op );
79
80   /* Transformation is selected and already started */
81   bool          transformInProcess() const { return myEventStarted; }
82   void          setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
83
84   void vpMousePressEvent(QMouseEvent* theEvent);
85   void vpMouseReleaseEvent(QMouseEvent* theEvent);
86   void vpMouseMoveEvent(QMouseEvent* theEvent);
87
88   void resetState();
89   void drawRect();
90
91   void createActions();
92   void createToolBar();
93  
94   virtual OperationType getButtonState(QMouseEvent* theEvent);
95
96   OperationType         myOperation;
97   OCCViewer_Viewer*     myModel;
98   OCCViewer_ViewPort3d* myViewPort;
99
100   int                                   myRestoreFlag;
101
102   int                                   myStartX;
103   int                                   myStartY;
104   int                                   myCurrX;
105   int                                   myCurrY;
106
107   bool                  myEventStarted;       // set when transformation is in process 
108   bool                  myCursorIsHand;                 
109   bool                  myDrawRect;           // set when a rect is used for selection or magnify 
110   bool                  myEnableDrawMode;
111   bool                  myPaintersRedrawing;  // set to draw with external painters 
112  
113   QRect                 myRect;                         
114   QCursor               myCursor;
115
116   QToolBar*  myToolBar;
117   ActionsMap myActionsMap;
118
119   double myCurScale;
120 };
121
122 #ifdef WIN32
123 #pragma warning( default:4251 )
124 #endif
125
126 #endif