1 // Copyright (C) 2007-2008 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
22 #ifndef OCCVIEWER_VIEWWINDOW_H
23 #define OCCVIEWER_VIEWWINDOW_H
25 #include "OCCViewer.h"
26 #include "SUIT_ViewWindow.h"
29 class QtxRectRubberBand;
31 class OCCViewer_ViewPort3d;
32 class OCCViewer_ViewSketcher;
33 class OCCViewer_ClippingDlg;
34 class OCCViewer_AxialScaleDlg;
35 class OCCViewer_SetRotationPointDlg;
36 class OCCViewer_Viewer;
41 #pragma warning( disable:4251 )
44 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
49 enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
50 ChangeRotationPointId, RotationId,
51 FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
52 TrihedronShowId, AxialScaleId };
54 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
55 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
56 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW };
58 enum RotationPointType{ GRAVITY, SELECTED };
60 enum SketchingType { NoSketching, Rect, Polygon };
62 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
63 virtual ~OCCViewer_ViewWindow();
65 OCCViewer_ViewPort3d* getViewPort();
67 bool eventFilter(QObject* watched, QEvent* e);
69 void performRestoring( const viewAspect& );
71 virtual void initLayout();
73 void updateEnabledDrawMode();
75 void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
76 const double dx = 0, const double dy = 0, const double dz = 1);
78 bool isCuttingPlane();
80 virtual QString getVisualParameters();
81 virtual void setVisualParameters( const QString& parameters );
83 virtual void initSketchers();
84 OCCViewer_ViewSketcher* getSketcher( const int );
86 void activateSketching( int );
99 void activateWindowFit();
100 void activateRotation();
101 void activatePanning();
102 void activateGlobalPanning();
103 void onSetRotationPoint( bool on );
105 void onClipping( bool on );
107 void onMemorizeView();
108 void onRestoreView();
109 void onTrihedronShow();
110 void setRestoreFlag();
112 void activateSetRotationGravity();
113 void activateSetRotationSelected( double theX, double theY, double theZ );
114 void activateStartPointSelection();
115 void updateGravityCoords();
117 virtual void showEvent( QShowEvent * );
118 virtual void hideEvent( QHideEvent * );
122 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
123 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
124 void viewCloned( SUIT_ViewWindow* );
126 void Show( QShowEvent * );
127 void Hide( QHideEvent * );
130 virtual QImage dumpView();
131 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
132 virtual QString filter() const;
134 /* Transformation selected but not started yet */
135 bool transformRequested() const;
136 void setTransformRequested ( OperationType );
138 /* Transformation is selected and already started */
139 bool transformInProcess() const;
140 void setTransformInProcess( bool );
142 void vpMousePressEvent(QMouseEvent* theEvent);
143 void vpMouseReleaseEvent(QMouseEvent* theEvent);
144 void vpMouseMoveEvent(QMouseEvent* theEvent);
150 void createActions();
151 void createToolBar();
153 virtual OperationType getButtonState(QMouseEvent* theEvent);
155 viewAspect getViewParams() const;
157 bool computeGravityCenter( double& theX, double& theY, double& theZ );
159 virtual void onSketchingStarted();
160 virtual void onSketchingFinished();
162 virtual OCCViewer_ViewSketcher* createSketcher( int );
164 OCCViewer_ViewSketcher* mypSketcher;
165 QList<OCCViewer_ViewSketcher*> mySketchers;
169 OperationType myOperation;
170 OCCViewer_Viewer* myModel;
171 OCCViewer_ViewPort3d* myViewPort;
173 RotationPointType myCurrPointType;
174 RotationPointType myPrevPointType;
175 gp_Pnt mySelectedPoint;
176 bool myRotationPointSelection;
185 bool myEventStarted; // set when transformation is in process
187 bool myDrawRect; // set when a rect is used for selection or magnify
188 bool myEnableDrawMode;
189 bool myPaintersRedrawing; // set to draw with external painters
196 OCCViewer_ClippingDlg* myClippingDlg;
197 QtxAction* myClippingAction;
199 OCCViewer_AxialScaleDlg* myScalingDlg;
201 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
202 QtxAction* mySetRotationPointAction;
204 QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
208 #pragma warning( default:4251 )