]> SALOME platform Git repositories - modules/gui.git/blob - src/OCCViewer/OCCViewer_ViewWindow.h
Salome HOME
14ee51c3b2463b011ca10774984af824ae9182c5
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewWindow.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef OCCVIEWER_VIEWWINDOW_H
20 #define OCCVIEWER_VIEWWINDOW_H
21
22 #include "OCCViewer_ViewModel.h"
23
24 #include "SUIT_ViewWindow.h"
25
26 #include "QtxAction.h"
27
28 #include <qcursor.h>
29 #include <qvaluelist.h>
30
31 class SUIT_Desktop;
32 class OCCViewer_ViewPort3d;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow  
39 {
40   Q_OBJECT
41
42 public:
43   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
44                       FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
45
46   OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
47         virtual ~OCCViewer_ViewWindow() {};
48
49   OCCViewer_ViewPort3d* getViewPort() { return myViewPort; }
50
51   bool eventFilter(QObject* watched, QEvent* e);
52
53   QToolBar* getToolBar() { return myToolBar; }
54
55   void performRestoring( const viewAspect& );
56   
57   virtual void initLayout();
58
59   void updateEnabledDrawMode();
60
61 public slots:
62   void onFrontView();
63   void onViewFitAll();
64   void onBackView();
65   void onTopView();
66   void onBottomView();
67   void onLeftView();
68   void onRightView();
69   void onResetView();
70   void onFitAll();
71   void activateZoom();
72   void activateWindowFit();
73   void activateRotation();
74   void activatePanning();
75   void activateGlobalPanning();
76   void onCloneView();
77   void onMemorizeView();
78   void onRestoreView();
79   void onTrihedronShow();
80   void setRestoreFlag();
81   
82 signals:
83   void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
84   void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
85   void cloneView();
86
87 protected:
88   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
89          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, MemId, RestoreId,
90          TrihedronShowId };
91
92   typedef QMap<int, QtxAction*> ActionsMap;
93
94   QImage dumpView();
95
96   /* Transformation selected but not started yet */
97   bool transformRequested() const { return ( myOperation != NOTHING ); }
98   void setTransformRequested ( OperationType op );
99
100   /* Transformation is selected and already started */
101   bool          transformInProcess() const { return myEventStarted; }
102   void          setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
103
104   void vpMousePressEvent(QMouseEvent* theEvent);
105   void vpMouseReleaseEvent(QMouseEvent* theEvent);
106   void vpMouseMoveEvent(QMouseEvent* theEvent);
107
108   void resetState();
109   void drawRect();
110
111   void createActions();
112   void createToolBar();
113  
114   virtual OperationType getButtonState(QMouseEvent* theEvent);
115
116   OperationType         myOperation;
117   OCCViewer_Viewer*     myModel;
118   OCCViewer_ViewPort3d* myViewPort;
119
120   int                                   myRestoreFlag;
121
122   int                                   myStartX;
123   int                                   myStartY;
124   int                                   myCurrX;
125   int                                   myCurrY;
126
127   bool                  myEventStarted;       // set when transformation is in process 
128   bool                  myCursorIsHand;                 
129   bool                  myDrawRect;           // set when a rect is used for selection or magnify 
130   bool                  myEnableDrawMode;
131   bool                  myPaintersRedrawing;  // set to draw with external painters 
132  
133   QRect                 myRect;                         
134   QCursor               myCursor;
135
136   QToolBar*  myToolBar;
137   ActionsMap myActionsMap;
138
139   double myCurScale;
140 };
141
142 #ifdef WIN32
143 #pragma warning( default:4251 )
144 #endif
145
146 #endif