1 // Copyright (C) 2007-2013 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,
125 SwitchPreselectionId, SwitchSelectionId,
126 MaximizedId, SynchronizeId, ReturnTo3dViewId,
129 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
130 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
131 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
132 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
134 enum RotationPointType{ GRAVITY, SELECTED };
136 enum SketchingType { NoSketching, Rect, Polygon };
138 enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
141 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
142 virtual ~OCCViewer_ViewWindow();
144 virtual OCCViewer_ViewWindow* getView( const int ) const;
146 virtual OCCViewer_ViewPort3d* getViewPort();
148 virtual bool eventFilter(QObject* watched, QEvent* e);
150 virtual void performRestoring( const viewAspect&, bool = false );
152 virtual void initLayout();
154 virtual void updateEnabledDrawMode();
156 virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
157 const double dx = 0, const double dy = 0, const double dz = 1);
159 virtual void setCuttingPlane( bool on, const gp_Pln thePln );
161 virtual bool isCuttingPlane();
163 virtual QString getVisualParameters();
164 virtual void setVisualParameters( const QString& parameters );
166 virtual void initSketchers();
167 virtual OCCViewer_ViewSketcher* getSketcher( const int );
169 virtual void activateSketching( int );
171 virtual int interactionStyle() const;
172 virtual void setInteractionStyle( const int );
174 virtual int zoomingStyle() const;
175 virtual void setZoomingStyle( const int );
177 virtual bool isPreselectionEnabled() const;
178 virtual void enablePreselection( bool );
179 virtual bool isSelectionEnabled() const;
180 virtual void enableSelection( bool );
182 void setTransformEnabled( const OperationType, const bool );
183 bool transformEnabled( const OperationType ) const;
186 void set2dMode( Mode2dType );
187 Mode2dType get2dMode() const { return my2dMode; }
189 void setMaximized( bool, bool = true );
190 bool isMaximized() const;
191 void setReturnedTo3dView( bool = true );
193 void setSketcherStyle( bool enable );
194 bool isSketcherStyle() const;
196 virtual QColor backgroundColor() const; // obsolete
197 virtual void setBackgroundColor( const QColor& ); // obsolete
199 virtual Qtx::BackgroundData background() const;
200 virtual void setBackground( const Qtx::BackgroundData& );
202 virtual const viewAspectList& getViewAspects();
203 virtual void appendViewAspect( const viewAspect& );
204 virtual void updateViewAspects( const viewAspectList& );
205 virtual void clearViewAspects();
207 virtual SUIT_CameraProperties cameraProperties();
210 virtual void onFrontView();
211 virtual void onViewFitAll();
212 virtual void onBackView();
213 virtual void onTopView();
214 virtual void onBottomView();
215 virtual void onLeftView();
216 virtual void onRightView();
217 virtual void onClockWiseView();
218 virtual void onAntiClockWiseView();
219 virtual void onResetView();
220 virtual void onFitAll();
221 virtual void activateZoom();
222 virtual void activateWindowFit();
223 virtual void activateRotation();
224 virtual void activatePanning();
225 virtual void activateGlobalPanning();
226 virtual void onSetRotationPoint( bool on );
227 virtual void onCloneView();
228 virtual void onClipping( bool on );
229 virtual void onAxialScale();
230 virtual void onGraduatedAxes();
231 virtual void onAmbientToogle();
232 virtual void onMemorizeView();
233 virtual void onRestoreView();
234 virtual void onTrihedronShow();
235 virtual void setRestoreFlag();
236 virtual void onSwitchInteractionStyle( bool on );
237 virtual void onSwitchZoomingStyle( bool on );
238 virtual void onSwitchPreselection( bool on );
239 virtual void onSwitchSelection( bool on );
241 virtual void activateSetRotationGravity();
242 virtual void activateSetRotationSelected( double theX, double theY, double theZ );
243 virtual void activateStartPointSelection();
244 virtual void updateGravityCoords();
246 virtual void showEvent( QShowEvent * );
247 virtual void hideEvent( QHideEvent * );
249 virtual void onMaximizedView();
250 virtual void returnTo3dView();
253 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
254 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
255 void viewCloned( SUIT_ViewWindow* );
257 void Show( QShowEvent * );
258 void Hide( QHideEvent * );
259 void maximized( OCCViewer_ViewWindow*, bool );
260 void returnedTo3d( );
263 void synchronize( SUIT_ViewWindow* );
266 virtual QImage dumpView();
267 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
270 virtual QString filter() const;
272 /* Transformation selected but not started yet */
273 bool transformRequested() const;
274 bool setTransformRequested ( OperationType );
276 /* Transformation is selected and already started */
277 bool transformInProcess() const;
278 void setTransformInProcess( bool );
280 void vpMousePressEvent(QMouseEvent* theEvent);
281 void vpMouseReleaseEvent(QMouseEvent* theEvent);
282 void vpMouseMoveEvent(QMouseEvent* theEvent);
288 void createActions();
289 void createToolBar();
291 virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
293 viewAspect getViewParams() const;
295 bool computeGravityCenter( double& theX, double& theY, double& theZ );
297 virtual void onSketchingStarted();
298 virtual void onSketchingFinished();
300 virtual OCCViewer_ViewSketcher* createSketcher( int );
302 OCCViewer_ViewSketcher* mypSketcher;
303 QList<OCCViewer_ViewSketcher*> mySketchers;
307 OperationType myOperation;
308 OCCViewer_Viewer* myModel;
309 OCCViewer_ViewPort3d* myViewPort;
311 OCCViewer_CubeAxesDlg* myCubeAxesDlg;
313 RotationPointType myCurrPointType;
314 RotationPointType myPrevPointType;
315 gp_Pnt mySelectedPoint;
316 bool myRotationPointSelection;
325 bool myEventStarted; // set when transformation is in process
327 bool myDrawRect; // set when a rect is used for selection or magnify
328 bool myEnableDrawMode;
329 bool myPaintersRedrawing; // set to draw with external painters
330 bool IsSketcherStyle;
338 OCCViewer_ClippingDlg* myClippingDlg;
339 QtxAction* myClippingAction;
341 OCCViewer_AxialScaleDlg* myScalingDlg;
343 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
344 QtxAction* mySetRotationPointAction;
346 QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
348 bool mySelectionEnabled;
349 bool myPreselectionEnabled;
350 int myInteractionStyle;
352 typedef QMap<OperationType, bool> MapOfTransformStatus;
353 MapOfTransformStatus myStatus;
357 Handle(V3d_Plane) myReserveClippingPlane;
359 viewAspectList myViewAspects;
363 #pragma warning( default:4251 )