Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[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 class OCCViewer_ClippingDlg;
35
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39
40 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow  
41 {
42   Q_OBJECT
43
44 public:
45   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
46                       FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
47
48   OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
49         virtual ~OCCViewer_ViewWindow() {};
50
51   OCCViewer_ViewPort3d* getViewPort() { return myViewPort; }
52
53   bool eventFilter(QObject* watched, QEvent* e);
54
55   QToolBar* getToolBar() { return myToolBar; }
56
57   void performRestoring( const viewAspect& );
58   
59   virtual void initLayout();
60
61   void updateEnabledDrawMode();
62
63   void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
64                                  const double dx = 0, const double dy = 0, const double dz = 1);
65
66   virtual QString   getVisualParameters();
67   virtual void      setVisualParameters( const QString& parameters );
68  
69 public slots:
70   void onFrontView();
71   void onViewFitAll();
72   void onBackView();
73   void onTopView();
74   void onBottomView();
75   void onLeftView();
76   void onRightView();
77   void onResetView();
78   void onFitAll();
79   void activateZoom();
80   void activateWindowFit();
81   void activateRotation();
82   void activatePanning();
83   void activateGlobalPanning();
84   void onCloneView();
85   void onClipping( bool on );
86   void onMemorizeView();
87   void onRestoreView();
88   void onTrihedronShow();
89   void setRestoreFlag();
90   
91 signals:
92   void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
93   void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
94   void cloneView();
95
96 protected:
97   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
98          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
99          TrihedronShowId };
100
101   typedef QMap<int, QtxAction*> ActionsMap;
102
103   QImage dumpView();
104
105   /* Transformation selected but not started yet */
106   bool transformRequested() const { return ( myOperation != NOTHING ); }
107   void setTransformRequested ( OperationType op );
108
109   /* Transformation is selected and already started */
110   bool          transformInProcess() const { return myEventStarted; }
111   void          setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
112
113   void vpMousePressEvent(QMouseEvent* theEvent);
114   void vpMouseReleaseEvent(QMouseEvent* theEvent);
115   void vpMouseMoveEvent(QMouseEvent* theEvent);
116
117   void resetState();
118   void drawRect();
119
120   void createActions();
121   void createToolBar();
122  
123   virtual OperationType getButtonState(QMouseEvent* theEvent);
124
125   viewAspect getViewParams() const;
126
127   OperationType         myOperation;
128   OCCViewer_Viewer*     myModel;
129   OCCViewer_ViewPort3d* myViewPort;
130
131   int                                   myRestoreFlag;
132
133   int                                   myStartX;
134   int                                   myStartY;
135   int                                   myCurrX;
136   int                                   myCurrY;
137
138   bool                  myEventStarted;       // set when transformation is in process 
139   bool                  myCursorIsHand;                 
140   bool                  myDrawRect;           // set when a rect is used for selection or magnify 
141   bool                  myEnableDrawMode;
142   bool                  myPaintersRedrawing;  // set to draw with external painters 
143  
144   QRect                 myRect;                         
145   QCursor               myCursor;
146
147   QToolBar*  myToolBar;
148   ActionsMap myActionsMap;
149
150   double myCurScale;
151
152 private:
153   OCCViewer_ClippingDlg* myClippingDlg;
154   
155 };
156
157 #ifdef WIN32
158 #pragma warning( default:4251 )
159 #endif
160
161 #endif