1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef OCCVIEWER_VIEWWINDOW_H
24 #define OCCVIEWER_VIEWWINDOW_H
26 #include "OCCViewer.h"
28 #include "SUIT_ViewWindow.h"
30 #include <V3d_Plane.hxx>
32 class QtxRectRubberBand;
34 class OCCViewer_ViewPort3d;
35 class OCCViewer_ViewSketcher;
36 class OCCViewer_ClippingDlg;
37 class OCCViewer_AxialScaleDlg;
38 class OCCViewer_SetRotationPointDlg;
39 class OCCViewer_Viewer;
40 class OCCViewer_CubeAxesDlg;
65 // graduated trihedron
100 bool gtDrawTickmarksX;
101 bool gtDrawTickmarksY;
102 bool gtDrawTickmarksZ;
103 int gtTickmarkLengthX;
104 int gtTickmarkLengthY;
105 int gtTickmarkLengthZ;
108 typedef QList<viewAspect> viewAspectList;
111 #pragma warning( disable:4251 )
114 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
119 enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
120 ChangeRotationPointId, RotationId,
121 FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
122 ResetId, CloneId, ClippingId, MemId, RestoreId,
123 TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
124 SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId };
126 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
127 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
128 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
129 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
131 enum RotationPointType{ GRAVITY, SELECTED };
133 enum SketchingType { NoSketching, Rect, Polygon };
135 enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
138 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
139 virtual ~OCCViewer_ViewWindow();
141 virtual OCCViewer_ViewWindow* getView( const int ) const;
143 virtual OCCViewer_ViewPort3d* getViewPort();
145 virtual bool eventFilter(QObject* watched, QEvent* e);
147 virtual void performRestoring( const viewAspect&, bool = false );
149 virtual void initLayout();
151 virtual void updateEnabledDrawMode();
153 virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
154 const double dx = 0, const double dy = 0, const double dz = 1);
156 virtual void setCuttingPlane( bool on, const gp_Pln thePln );
158 virtual bool isCuttingPlane();
160 virtual QString getVisualParameters();
161 virtual void setVisualParameters( const QString& parameters );
163 virtual void initSketchers();
164 virtual OCCViewer_ViewSketcher* getSketcher( const int );
166 virtual void activateSketching( int );
168 virtual int interactionStyle() const;
169 virtual void setInteractionStyle( const int );
171 virtual int zoomingStyle() const;
172 virtual void setZoomingStyle( const int );
174 void setTransformEnabled( const OperationType, const bool );
175 bool transformEnabled( const OperationType ) const;
178 void set2dMode( Mode2dType );
179 Mode2dType get2dMode() const { return my2dMode; }
181 void setMaximized( bool, bool = true );
182 bool isMaximized() const;
184 void setSketcherStyle( bool enable );
185 bool isSketcherStyle() const;
187 virtual QColor backgroundColor() const; // obsolete
188 virtual void setBackgroundColor( const QColor& ); // obsolete
190 virtual Qtx::BackgroundData background() const;
191 virtual void setBackground( const Qtx::BackgroundData& );
193 virtual const viewAspectList& getViewAspects();
194 virtual void appendViewAspect( const viewAspect& );
195 virtual void updateViewAspects( const viewAspectList& );
196 virtual void clearViewAspects();
199 virtual void onFrontView();
200 virtual void onViewFitAll();
201 virtual void onBackView();
202 virtual void onTopView();
203 virtual void onBottomView();
204 virtual void onLeftView();
205 virtual void onRightView();
206 virtual void onClockWiseView();
207 virtual void onAntiClockWiseView();
208 virtual void onResetView();
209 virtual void onFitAll();
210 virtual void activateZoom();
211 virtual void activateWindowFit();
212 virtual void activateRotation();
213 virtual void activatePanning();
214 virtual void activateGlobalPanning();
215 virtual void onSetRotationPoint( bool on );
216 virtual void onCloneView();
217 virtual void onClipping( bool on );
218 virtual void onAxialScale();
219 virtual void onGraduatedAxes();
220 virtual void onAmbientToogle();
221 virtual void onMemorizeView();
222 virtual void onRestoreView();
223 virtual void onTrihedronShow();
224 virtual void setRestoreFlag();
225 virtual void onSwitchInteractionStyle( bool on );
226 virtual void onSwitchZoomingStyle( bool on );
228 virtual void activateSetRotationGravity();
229 virtual void activateSetRotationSelected( double theX, double theY, double theZ );
230 virtual void activateStartPointSelection();
231 virtual void updateGravityCoords();
233 virtual void showEvent( QShowEvent * );
234 virtual void hideEvent( QHideEvent * );
236 virtual void onMaximizedView();
239 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
240 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
241 void viewCloned( SUIT_ViewWindow* );
243 void Show( QShowEvent * );
244 void Hide( QHideEvent * );
245 void maximized( OCCViewer_ViewWindow*, bool );
248 virtual QImage dumpView();
249 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
252 virtual QString filter() const;
254 /* Transformation selected but not started yet */
255 bool transformRequested() const;
256 bool setTransformRequested ( OperationType );
258 /* Transformation is selected and already started */
259 bool transformInProcess() const;
260 void setTransformInProcess( bool );
262 void vpMousePressEvent(QMouseEvent* theEvent);
263 void vpMouseReleaseEvent(QMouseEvent* theEvent);
264 void vpMouseMoveEvent(QMouseEvent* theEvent);
270 void createActions();
271 void createToolBar();
273 virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
275 viewAspect getViewParams() const;
277 bool computeGravityCenter( double& theX, double& theY, double& theZ );
279 virtual void onSketchingStarted();
280 virtual void onSketchingFinished();
282 virtual OCCViewer_ViewSketcher* createSketcher( int );
284 OCCViewer_ViewSketcher* mypSketcher;
285 QList<OCCViewer_ViewSketcher*> mySketchers;
289 OperationType myOperation;
290 OCCViewer_Viewer* myModel;
291 OCCViewer_ViewPort3d* myViewPort;
293 OCCViewer_CubeAxesDlg* myCubeAxesDlg;
295 RotationPointType myCurrPointType;
296 RotationPointType myPrevPointType;
297 gp_Pnt mySelectedPoint;
298 bool myRotationPointSelection;
307 bool myEventStarted; // set when transformation is in process
309 bool myDrawRect; // set when a rect is used for selection or magnify
310 bool myEnableDrawMode;
311 bool myPaintersRedrawing; // set to draw with external painters
312 bool IsSketcherStyle;
319 void onSynchronizeView(bool);
320 void updateSyncViews();
323 static void synchronizeView( OCCViewer_ViewWindow*, int );
326 OCCViewer_ClippingDlg* myClippingDlg;
327 QtxAction* myClippingAction;
329 OCCViewer_AxialScaleDlg* myScalingDlg;
331 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
332 QtxAction* mySetRotationPointAction;
334 QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
336 int myInteractionStyle;
338 typedef QMap<OperationType, bool> MapOfTransformStatus;
339 MapOfTransformStatus myStatus;
343 Handle(V3d_Plane) myReserveClippingPlane;
345 viewAspectList myViewAspects;
349 #pragma warning( default:4251 )