1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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>
31 #include <TopAbs_ShapeEnum.hxx>
33 class QtxRectRubberBand;
35 class OCCViewer_ViewPort3d;
36 class OCCViewer_ViewSketcher;
37 class OCCViewer_AxialScaleDlg;
38 class OCCViewer_SetRotationPointDlg;
39 class OCCViewer_Viewer;
40 class OCCViewer_CubeAxesDlg;
47 double centerX; // deprecated since OCCT 6.7.1
48 double centerY; // deprecated since OCCT 6.7.1
65 // graduated trihedron
100 bool gtDrawTickmarksX;
101 bool gtDrawTickmarksY;
102 bool gtDrawTickmarksZ;
103 int gtTickmarkLengthX;
104 int gtTickmarkLengthY;
105 int gtTickmarkLengthZ;
110 centerX( 0.0 ), centerY( 0.0 ),
111 projX( 0.0 ), projY( 0.0 ), projZ( 0.0 ),
113 atX( 0.0 ), atY( 0.0 ), atZ( 0.0 ),
114 eyeX( 0.0 ), eyeY( 0.0 ), eyeZ( 0.0 ),
115 scaleX( 0.0 ), scaleY( 0.0 ), scaleZ( 0.0 ),
119 gtIsVisible( false ),
120 gtDrawNameX( false ), gtDrawNameY( false ), gtDrawNameZ( false ),
121 gtNameX(), gtNameY(), gtNameZ(),
122 gtNameColorRX( 0 ), gtNameColorGX( 0 ), gtNameColorBX( 0 ),
123 gtNameColorRY( 0 ), gtNameColorGY( 0 ), gtNameColorBY( 0 ),
124 gtNameColorRZ( 0 ), gtNameColorGZ( 0 ), gtNameColorBZ( 0 ),
125 gtDrawValuesX( false ), gtDrawValuesY( false ), gtDrawValuesZ( false ),
126 gtNbValuesX( 0 ), gtNbValuesY( 0 ), gtNbValuesZ( 0 ),
127 gtOffsetX( 0 ), gtOffsetY( 0 ), gtOffsetZ( 0 ),
128 gtColorRX( 0 ), gtColorGX( 0 ), gtColorBX( 0 ),
129 gtColorRY( 0 ), gtColorGY( 0 ), gtColorBY( 0 ),
130 gtColorRZ( 0 ), gtColorGZ( 0 ), gtColorBZ( 0 ),
131 gtDrawTickmarksX( false ), gtDrawTickmarksY( false ), gtDrawTickmarksZ( false ),
132 gtTickmarkLengthX( 0 ), gtTickmarkLengthY( 0 ), gtTickmarkLengthZ( 0 ) {}
135 typedef QList<viewAspect> viewAspectList;
138 #pragma warning( disable:4251 )
141 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
146 enum { DumpId, FitAllId, FitRectId, FitSelectionId, ZoomId, PanId, GlobalPanId,
147 ChangeRotationPointId, RotationId,
148 FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
149 ResetId, CloneId, ClippingId, MemId, RestoreId,
150 TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
151 SwitchInteractionStyleId, SwitchZoomingStyleId,
152 SwitchPreselectionId, SwitchSelectionId,
153 MaximizedId, SynchronizeId, ReturnTo3dViewId,
156 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
157 PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW,
158 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
159 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
161 enum RotationPointType{ GRAVITY, SELECTED };
163 enum SketchingType { NoSketching, Rect, Polygon };
165 enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
168 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
169 virtual ~OCCViewer_ViewWindow();
171 virtual OCCViewer_ViewWindow* getView( const int ) const;
173 virtual OCCViewer_ViewPort3d* getViewPort();
175 virtual bool eventFilter(QObject* watched, QEvent* e);
177 virtual void performRestoring( const viewAspect&, bool = false );
179 virtual void initLayout();
181 virtual void updateEnabledDrawMode();
183 virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
184 const double dx = 0, const double dy = 0, const double dz = 1);
186 virtual void setCuttingPlane( bool on, const gp_Pln thePln );
188 virtual bool isCuttingPlane();
190 virtual QString getVisualParameters();
191 virtual void setVisualParameters( const QString& parameters );
193 virtual void initSketchers();
194 virtual OCCViewer_ViewSketcher* getSketcher( const int );
196 virtual void activateSketching( int );
198 virtual int interactionStyle() const;
199 virtual void setInteractionStyle( const int );
201 virtual int zoomingStyle() const;
202 virtual void setZoomingStyle( const int );
204 virtual bool isPreselectionEnabled() const;
205 virtual void enablePreselection( bool );
206 virtual bool isSelectionEnabled() const;
207 virtual void enableSelection( bool );
209 void setTransformEnabled( const OperationType, const bool );
210 bool transformEnabled( const OperationType ) const;
213 void set2dMode( Mode2dType );
214 Mode2dType get2dMode() const { return my2dMode; }
216 void setMaximized( bool, bool = true );
217 bool isMaximized() const;
218 void setReturnedTo3dView( bool = true );
220 void setSketcherStyle( bool enable );
221 bool isSketcherStyle() const;
223 virtual QColor backgroundColor() const; // obsolete
224 virtual void setBackgroundColor( const QColor& ); // obsolete
226 virtual void showStaticTrihedron( bool );
228 virtual Qtx::BackgroundData background() const;
229 virtual void setBackground( const Qtx::BackgroundData& );
231 virtual const viewAspectList& getViewAspects();
232 virtual void appendViewAspect( const viewAspect& );
233 virtual void updateViewAspects( const viewAspectList& );
234 virtual void clearViewAspects();
236 virtual SUIT_CameraProperties cameraProperties();
239 virtual void onFrontView();
240 virtual void onViewFitAll();
241 virtual void onBackView();
242 virtual void onClipping(bool on);
243 virtual void onTopView();
244 virtual void onBottomView();
245 virtual void onLeftView();
246 virtual void onRightView();
247 virtual void onClockWiseView();
248 virtual void onAntiClockWiseView();
249 virtual void onResetView();
250 virtual void onFitAll();
251 virtual void onFitSelection();
252 virtual void activateZoom();
253 virtual void activateWindowFit();
254 virtual void activateRotation();
255 virtual void activatePanning();
256 virtual void activateGlobalPanning();
257 virtual void onSetRotationPoint( bool on );
258 virtual void onCloneView();
259 virtual void onAxialScale();
260 virtual void onGraduatedAxes();
261 virtual void onAmbientToogle();
262 virtual void onMemorizeView();
263 virtual void onRestoreView();
264 virtual void onTrihedronShow(bool);
265 virtual void setRestoreFlag();
266 virtual void onSwitchInteractionStyle( bool on );
267 virtual void onSwitchZoomingStyle( bool on );
268 virtual void onSwitchPreselection( bool on );
269 virtual void onSwitchSelection( bool on );
271 virtual void activateSetRotationGravity();
272 virtual void activateSetRotationSelected( double theX, double theY, double theZ );
273 virtual void activateStartPointSelection( TopAbs_ShapeEnum );
274 virtual void updateGravityCoords();
276 virtual void showEvent( QShowEvent * );
277 virtual void hideEvent( QHideEvent * );
279 virtual void onMaximizedView();
280 virtual void returnTo3dView();
283 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
284 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
285 void viewCloned( SUIT_ViewWindow* );
287 void Show( QShowEvent * );
288 void Hide( QHideEvent * );
289 void maximized( OCCViewer_ViewWindow*, bool );
290 void returnedTo3d( );
293 void synchronize( SUIT_ViewWindow* );
296 virtual QImage dumpView();
297 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
300 virtual QString filter() const;
302 /* Transformation selected but not started yet */
303 bool transformRequested() const;
304 bool setTransformRequested ( OperationType );
306 /* Transformation is selected and already started */
307 bool transformInProcess() const;
308 void setTransformInProcess( bool );
310 void vpMousePressEvent(QMouseEvent* theEvent);
311 void vpMouseReleaseEvent(QMouseEvent* theEvent);
312 void vpMouseMoveEvent(QMouseEvent* theEvent);
318 void createActions();
319 void createToolBar();
321 virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
323 viewAspect getViewParams() const;
325 bool computeGravityCenter( double& theX, double& theY, double& theZ );
327 virtual void onSketchingStarted();
328 virtual void onSketchingFinished();
330 virtual OCCViewer_ViewSketcher* createSketcher( int );
334 OCCViewer_ViewSketcher* mypSketcher;
335 QList<OCCViewer_ViewSketcher*> mySketchers;
339 OperationType myOperation;
340 OCCViewer_Viewer* myModel;
341 OCCViewer_ViewPort3d* myViewPort;
343 OCCViewer_CubeAxesDlg* myCubeAxesDlg;
345 RotationPointType myCurrPointType;
346 RotationPointType myPrevPointType;
347 gp_Pnt mySelectedPoint;
348 bool myRotationPointSelection;
357 bool myEventStarted; // set when transformation is in process
359 bool myDrawRect; // set when a rect is used for selection or magnify
360 bool myEnableDrawMode;
361 bool myPaintersRedrawing; // set to draw with external painters
362 bool IsSketcherStyle;
370 OCCViewer_AxialScaleDlg* myScalingDlg;
372 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
373 QtxAction* mySetRotationPointAction;
375 QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
377 bool mySelectionEnabled;
378 bool myPreselectionEnabled;
379 int myInteractionStyle;
381 typedef QMap<OperationType, bool> MapOfTransformStatus;
382 MapOfTransformStatus myStatus;
386 Handle(V3d_Plane) myReserveClipPlane;
388 viewAspectList myViewAspects;
392 #pragma warning( default:4251 )