1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef OCCVIEWER_VIEWWINDOW_H
20 #define OCCVIEWER_VIEWWINDOW_H
22 #include "OCCViewer_ViewModel.h"
23 #include "OCCViewer_ViewSketcher.h"
25 #include "SUIT_ViewWindow.h"
27 #include "QtxAction.h"
30 #include <qvaluelist.h>
33 class OCCViewer_ViewPort3d;
35 class OCCViewer_ClippingDlg;
36 class OCCViewer_SetRotationPointDlg;
39 #pragma warning( disable:4251 )
42 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
47 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
48 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
49 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
51 enum RotationPointType{ GRAVITY, SELECTED };
53 enum SketchingType { NoSketching, Rect, Polygon };
55 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
56 virtual ~OCCViewer_ViewWindow() {};
58 OCCViewer_ViewPort3d* getViewPort() { return myViewPort; }
60 bool eventFilter(QObject* watched, QEvent* e);
62 QToolBar* getToolBar() { return myToolBar; }
64 void performRestoring( const viewAspect& );
66 virtual void initLayout();
68 void updateEnabledDrawMode();
70 void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
71 const double dx = 0, const double dy = 0, const double dz = 1);
73 bool isCuttingPlane();
75 virtual QString getVisualParameters();
76 virtual void setVisualParameters( const QString& parameters );
78 virtual void initSketchers();
79 OCCViewer_ViewSketcher* getSketcher( const int );
81 void activateSketching( int );
94 void activateWindowFit();
95 void activateRotation();
96 void activatePanning();
97 void activateGlobalPanning();
98 void onSetRotationPoint( bool on );
100 void onClipping( bool on );
101 void onMemorizeView();
102 void onRestoreView();
103 void onTrihedronShow();
104 void setRestoreFlag();
106 void activateSetRotationGravity();
107 void activateSetRotationSelected( double theX, double theY, double theZ );
108 void activateStartPointSelection();
109 void updateGravityCoords();
111 virtual void showEvent( QShowEvent * );
112 virtual void hideEvent( QHideEvent * );
115 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
116 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
119 void Show( QShowEvent * );
120 void Hide( QHideEvent * );
123 enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
124 ChangeRotationPointId, RotationId,
125 FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
128 typedef QMap<int, QtxAction*> ActionsMap;
132 /* Transformation selected but not started yet */
133 bool transformRequested() const { return ( myOperation != NOTHING ); }
134 void setTransformRequested ( OperationType op );
136 /* Transformation is selected and already started */
137 bool transformInProcess() const { return myEventStarted; }
138 void setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
140 void vpMousePressEvent(QMouseEvent* theEvent);
141 void vpMouseReleaseEvent(QMouseEvent* theEvent);
142 void vpMouseMoveEvent(QMouseEvent* theEvent);
147 void createActions();
148 void createToolBar();
150 virtual OperationType getButtonState(QMouseEvent* theEvent);
152 viewAspect getViewParams() const;
154 bool computeGravityCenter( double& theX, double& theY, double& theZ );
156 virtual void onSketchingStarted();
157 virtual void onSketchingFinished();
159 virtual OCCViewer_ViewSketcher* createSketcher( int );
161 OCCViewer_ViewSketcher* mypSketcher;
162 QList<OCCViewer_ViewSketcher> mySketchers;
166 OperationType myOperation;
167 OCCViewer_Viewer* myModel;
168 OCCViewer_ViewPort3d* myViewPort;
170 RotationPointType myCurrPointType;
171 RotationPointType myPrevPointType;
172 gp_Pnt mySelectedPoint;
173 bool myRotationPointSelection;
182 bool myEventStarted; // set when transformation is in process
184 bool myDrawRect; // set when a rect is used for selection or magnify
185 bool myEnableDrawMode;
186 bool myPaintersRedrawing; // set to draw with external painters
192 ActionsMap myActionsMap;
197 OCCViewer_ClippingDlg* myClippingDlg;
198 QtxAction* myClippingAction;
200 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
201 QtxAction* mySetRotationPointAction;
206 #pragma warning( default:4251 )