1 // Copyright (C) 2007-2019 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 ActionId { 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,
154 OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
155 RectangleSelectionStyleId, CircleSelectionStyleId,
158 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
159 PANGLOBAL, WINDOWFIT, FITALLVIEW, FITSELECTION, RESETVIEW,
160 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
161 CLOCKWISEVIEW, ANTICLOCKWISEVIEW, PROJECTION };
163 enum RotationPointType{ BBCENTER, SELECTED };
165 enum SketchingType { NoSketching, Rect, Polygon };
167 enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane };
169 enum ProjectionType { Orthographic, Perspective, Stereo };
171 enum StereoType { QuadBuffer, Anaglyph, RowInterlaced, ColumnInterlaced, ChessBoard, SideBySide, OverUnder, SoftPageFlip, NumberOfModes };
173 enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta };
175 enum FocusIODType { Absolute, Relative };
177 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
178 virtual ~OCCViewer_ViewWindow();
180 virtual OCCViewer_ViewWindow* getView( const int ) const;
182 virtual OCCViewer_ViewPort3d* getViewPort();
184 virtual bool eventFilter(QObject* watched, QEvent* e);
186 virtual void performRestoring( const viewAspect&, bool = false );
188 virtual void initLayout();
190 virtual bool enableDrawMode( bool );
192 virtual void updateEnabledDrawMode();
194 virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
195 const double dx = 0, const double dy = 0, const double dz = 1);
197 virtual void setCuttingPlane( bool on, const gp_Pln thePln );
199 virtual bool isCuttingPlane();
201 virtual QString getVisualParameters();
202 virtual void setVisualParameters( const QString& parameters );
204 virtual void initSketchers();
205 virtual OCCViewer_ViewSketcher* getSketcher( const int ) const;
207 virtual void activateSketching( int );
209 virtual int interactionStyle() const;
210 virtual void setInteractionStyle( const int );
212 virtual int zoomingStyle() const;
213 virtual void setZoomingStyle( const int );
215 virtual bool isPreselectionEnabled() const;
216 virtual void enablePreselection( bool );
217 virtual bool isSelectionEnabled() const;
218 virtual void enableSelection( bool );
220 virtual int projectionType() const;
221 virtual void setProjectionType( int );
223 virtual int selectionStyle() const;
224 virtual void setSelectionStyle(int);
226 virtual int stereoType() const;
227 virtual void setStereoType( const int );
229 virtual int anaglyphFilter() const;
230 virtual void setAnaglyphFilter( const int );
232 virtual void setStereographicFocus( const int, const double );
233 virtual int stereographicFocusType() const;
234 virtual double stereographicFocusValue() const;
236 virtual void setInterocularDistance( const int, const double );
237 virtual int interocularDistanceType() const;
238 virtual double interocularDistanceValue() const;
240 virtual bool isReverseStereo() const;
241 virtual void setReverseStereo( const bool );
243 virtual bool isVSync() const;
244 virtual void setVSync( const bool );
246 virtual bool isQuadBufferSupport() const;
247 virtual void setQuadBufferSupport( const bool );
249 virtual bool isAutomaticZoom() const;
250 virtual void setAutomaticZoom( const bool );
252 void setTransformEnabled( const OperationType, const bool );
253 bool transformEnabled( const OperationType ) const;
255 void set2dMode( Mode2dType );
256 Mode2dType get2dMode() const { return my2dMode; }
258 void setMaximized( bool, bool = true );
259 bool isMaximized() const;
260 void setReturnedTo3dView( bool = true );
262 void setSketcherStyle( bool enable );
263 bool isSketcherStyle() const;
265 virtual QColor backgroundColor() const; // obsolete
266 virtual void setBackgroundColor( const QColor& ); // obsolete
268 virtual void showStaticTrihedron( bool );
270 virtual Qtx::BackgroundData background() const;
271 virtual void setBackground( const Qtx::BackgroundData& );
273 virtual const viewAspectList& getViewAspects();
274 virtual void appendViewAspect( const viewAspect& );
275 virtual void updateViewAspects( const viewAspectList& );
276 virtual void clearViewAspects();
278 virtual SUIT_CameraProperties cameraProperties();
280 bool isActionVisible( ActionId theId ) const;
281 void setActionVisible( ActionId theId, bool isVisible );
286 virtual void onFrontView();
287 virtual void onViewFitAll();
288 virtual void onBackView();
289 virtual void onClipping(bool on);
290 virtual void onTopView();
291 virtual void onBottomView();
292 virtual void onLeftView();
293 virtual void onRightView();
294 virtual void onClockWiseView();
295 virtual void onAntiClockWiseView();
296 virtual void onProjectionType( QAction* theAction );
297 virtual void onStereoType( bool activate );
298 virtual void onProjectionType();
299 virtual void onResetView();
300 virtual void onFitAll();
301 virtual void onFitSelection();
302 virtual void activateZoom();
303 virtual void activateWindowFit();
304 virtual void activateRotation();
305 virtual void activatePanning();
306 virtual void activateGlobalPanning();
307 virtual void onSetRotationPoint( bool on );
308 virtual void onCloneView();
309 virtual void onAxialScale();
310 virtual void onGraduatedAxes();
311 virtual void onAmbientToogle();
312 virtual void onMemorizeView();
313 virtual void onRestoreView();
314 virtual void onTrihedronShow(bool);
315 virtual void setRestoreFlag();
316 virtual void onSwitchInteractionStyle( bool on );
317 virtual void onSwitchZoomingStyle( bool on );
318 virtual void onSwitchPreselection( bool on );
319 virtual void onSwitchSelection( bool on );
320 virtual void onSwitchSelectionStyle(QAction* theAction);
321 virtual void onRayTracing();
322 virtual void onEnvTexture();
323 virtual void onLightSource();
324 virtual void onPanning();
326 virtual void activateSetRotationGravity();
327 virtual void activateSetRotationSelected( double theX, double theY, double theZ );
328 virtual void activateStartPointSelection( TopAbs_ShapeEnum );
329 virtual void updateGravityCoords();
331 virtual void showEvent( QShowEvent * );
332 virtual void hideEvent( QHideEvent * );
334 virtual void onMaximizedView();
335 virtual void returnTo3dView();
338 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
339 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
340 void viewCloned( SUIT_ViewWindow* );
342 void Show( QShowEvent * );
343 void Hide( QHideEvent * );
344 void maximized( OCCViewer_ViewWindow*, bool );
345 void returnedTo3d( );
348 void synchronize( SUIT_ViewWindow* );
351 virtual QImage dumpView();
352 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
355 virtual QString filter() const;
357 bool isOpenGlStereoSupport() const;
359 /* Transformation selected but not started yet */
360 bool transformRequested() const;
361 bool setTransformRequested ( OperationType );
363 /* Transformation is selected and already started */
364 bool transformInProcess() const;
365 void setTransformInProcess( bool );
367 void vpMousePressEvent(QMouseEvent* theEvent);
368 void vpMouseReleaseEvent(QMouseEvent* theEvent);
369 void vpMouseMoveEvent(QMouseEvent* theEvent);
374 void createActions();
375 void createToolBar();
377 virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
379 viewAspect getViewParams() const;
381 bool computeGravityCenter( double& theX, double& theY, double& theZ );
383 void projAndPanToGravity(V3d_TypeOfOrientation CamOri);
385 virtual void onSketchingStarted();
386 virtual void onSketchingFinished();
388 virtual OCCViewer_ViewSketcher* createSketcher( int );
392 OCCViewer_ViewSketcher* mypSketcher;
393 QList<OCCViewer_ViewSketcher*> mySketchers;
397 OperationType myOperation;
398 OCCViewer_Viewer* myModel;
399 OCCViewer_ViewPort3d* myViewPort;
401 OCCViewer_CubeAxesDlg* myCubeAxesDlg;
403 RotationPointType myCurrPointType;
404 RotationPointType myPrevPointType;
405 gp_Pnt mySelectedPoint;
406 bool myRotationPointSelection;
415 bool myEventStarted; // set when transformation is in process
417 bool myDrawRect; // set when a rect is used for selection or magnify
418 bool myEnableDrawMode;
419 bool myDrawRectEnabled;
420 bool myPaintersRedrawing; // set to draw with external painters
421 bool IsSketcherStyle;
423 bool myAutomaticZoom;
429 OCCViewer_AxialScaleDlg* myScalingDlg;
431 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
432 QtxAction* mySetRotationPointAction;
434 QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
436 bool mySelectionEnabled;
437 bool myPreselectionEnabled;
438 int myInteractionStyle;
440 typedef QMap<OperationType, bool> MapOfTransformStatus;
441 MapOfTransformStatus myStatus;
445 Handle(V3d_Plane) myReserveClipPlane;
447 viewAspectList myViewAspects;
452 #pragma warning( default:4251 )