00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OCCVIEWER_VIEWWINDOW_H
00024 #define OCCVIEWER_VIEWWINDOW_H
00025
00026 #include "OCCViewer.h"
00027 #include "SUIT_ViewWindow.h"
00028 #include <gp_Pnt.hxx>
00029 #include <V3d_Plane.hxx>
00030
00031 class QtxRectRubberBand;
00032 class SUIT_Desktop;
00033 class OCCViewer_ViewPort3d;
00034 class OCCViewer_ViewSketcher;
00035 class OCCViewer_ClippingDlg;
00036 class OCCViewer_AxialScaleDlg;
00037 class OCCViewer_SetRotationPointDlg;
00038 class OCCViewer_Viewer;
00039 class OCCViewer_CubeAxesDlg;
00040 class QtxAction;
00041
00042 struct viewAspect
00043 {
00044 public:
00045 double scale;
00046 double centerX;
00047 double centerY;
00048 double projX;
00049 double projY;
00050 double projZ;
00051 double twist;
00052 double atX;
00053 double atY;
00054 double atZ;
00055 double eyeX;
00056 double eyeY;
00057 double eyeZ;
00058 double scaleX;
00059 double scaleY;
00060 double scaleZ;
00061 QString name;
00062 bool isVisible;
00063 double size;
00064
00065 bool gtIsVisible;
00066 bool gtDrawNameX;
00067 bool gtDrawNameY;
00068 bool gtDrawNameZ;
00069 QString gtNameX;
00070 QString gtNameY;
00071 QString gtNameZ;
00072 int gtNameColorRX;
00073 int gtNameColorGX;
00074 int gtNameColorBX;
00075 int gtNameColorRY;
00076 int gtNameColorGY;
00077 int gtNameColorBY;
00078 int gtNameColorRZ;
00079 int gtNameColorGZ;
00080 int gtNameColorBZ;
00081 bool gtDrawValuesX;
00082 bool gtDrawValuesY;
00083 bool gtDrawValuesZ;
00084 int gtNbValuesX;
00085 int gtNbValuesY;
00086 int gtNbValuesZ;
00087 int gtOffsetX;
00088 int gtOffsetY;
00089 int gtOffsetZ;
00090 int gtColorRX;
00091 int gtColorGX;
00092 int gtColorBX;
00093 int gtColorRY;
00094 int gtColorGY;
00095 int gtColorBY;
00096 int gtColorRZ;
00097 int gtColorGZ;
00098 int gtColorBZ;
00099 bool gtDrawTickmarksX;
00100 bool gtDrawTickmarksY;
00101 bool gtDrawTickmarksZ;
00102 int gtTickmarkLengthX;
00103 int gtTickmarkLengthY;
00104 int gtTickmarkLengthZ;
00105 };
00106
00107 typedef QList<viewAspect> viewAspectList;
00108
00109 #ifdef WIN32
00110 #pragma warning( disable:4251 )
00111 #endif
00112
00113 class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow
00114 {
00115 Q_OBJECT
00116
00117 public:
00118 enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
00119 ChangeRotationPointId, RotationId,
00120 FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
00121 ResetId, CloneId, ClippingId, MemId, RestoreId,
00122 TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId,
00123 SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, UserId };
00124
00125 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
00126 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
00127 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
00128 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
00129
00130 enum RotationPointType{ GRAVITY, SELECTED };
00131
00132 enum SketchingType { NoSketching, Rect, Polygon };
00133
00134 enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane};
00135
00136
00137 OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
00138 virtual ~OCCViewer_ViewWindow();
00139
00140 virtual OCCViewer_ViewPort3d* getViewPort();
00141
00142 virtual bool eventFilter(QObject* watched, QEvent* e);
00143
00144 virtual void performRestoring( const viewAspect& );
00145
00146 virtual void initLayout();
00147
00148 virtual void updateEnabledDrawMode();
00149
00150 virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0,
00151 const double dx = 0, const double dy = 0, const double dz = 1);
00152
00153 virtual void setCuttingPlane( bool on, const gp_Pln thePln );
00154
00155 virtual bool isCuttingPlane();
00156
00157 virtual QString getVisualParameters();
00158 virtual void setVisualParameters( const QString& parameters );
00159
00160 virtual void initSketchers();
00161 virtual OCCViewer_ViewSketcher* getSketcher( const int );
00162
00163 virtual void activateSketching( int );
00164
00165 virtual int interactionStyle() const;
00166 virtual void setInteractionStyle( const int );
00167
00168 virtual int zoomingStyle() const;
00169 virtual void setZoomingStyle( const int );
00170
00171 void setTransformEnabled( const OperationType, const bool );
00172 bool transformEnabled( const OperationType ) const;
00173
00174
00175 void set2dMode( Mode2dType );
00176 Mode2dType get2dMode() const { return my2dMode; }
00177
00178 void setMaximized( bool, bool = true );
00179 bool isMaximized() const;
00180
00181 virtual QColor backgroundColor() const;
00182 virtual void setBackgroundColor( const QColor& );
00183
00184 virtual const viewAspectList& getViewAspects();
00185 virtual void appendViewAspect( const viewAspect& );
00186 virtual void updateViewAspects( const viewAspectList& );
00187 virtual void clearViewAspects();
00188
00189 public slots:
00190 virtual void onFrontView();
00191 virtual void onViewFitAll();
00192 virtual void onBackView();
00193 virtual void onTopView();
00194 virtual void onBottomView();
00195 virtual void onLeftView();
00196 virtual void onRightView();
00197 virtual void onClockWiseView();
00198 virtual void onAntiClockWiseView();
00199 virtual void onResetView();
00200 virtual void onFitAll();
00201 virtual void activateZoom();
00202 virtual void activateWindowFit();
00203 virtual void activateRotation();
00204 virtual void activatePanning();
00205 virtual void activateGlobalPanning();
00206 virtual void onSetRotationPoint( bool on );
00207 virtual void onCloneView();
00208 virtual void onClipping( bool on );
00209 virtual void onAxialScale();
00210 virtual void onGraduatedAxes();
00211 virtual void onAmbientToogle();
00212 virtual void onMemorizeView();
00213 virtual void onRestoreView();
00214 virtual void onTrihedronShow();
00215 virtual void setRestoreFlag();
00216 virtual void onSwitchInteractionStyle( bool on );
00217 virtual void onSwitchZoomingStyle( bool on );
00218
00219 virtual void activateSetRotationGravity();
00220 virtual void activateSetRotationSelected( double theX, double theY, double theZ );
00221 virtual void activateStartPointSelection();
00222 virtual void updateGravityCoords();
00223
00224 virtual void showEvent( QShowEvent * );
00225 virtual void hideEvent( QHideEvent * );
00226
00227 virtual void onMaximizedView();
00228
00229 signals:
00230 void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type);
00231 void vpTransformationFinished(OCCViewer_ViewWindow::OperationType type);
00232 void viewCloned( SUIT_ViewWindow* );
00233
00234 void Show( QShowEvent * );
00235 void Hide( QHideEvent * );
00236 void maximized( OCCViewer_ViewWindow*, bool );
00237
00238 public:
00239 virtual QImage dumpView();
00240 virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
00241
00242 protected:
00243 virtual QString filter() const;
00244
00245
00246 bool transformRequested() const;
00247 bool setTransformRequested ( OperationType );
00248
00249
00250 bool transformInProcess() const;
00251 void setTransformInProcess( bool );
00252
00253 void vpMousePressEvent(QMouseEvent* theEvent);
00254 void vpMouseReleaseEvent(QMouseEvent* theEvent);
00255 void vpMouseMoveEvent(QMouseEvent* theEvent);
00256
00257 void resetState();
00258 void drawRect();
00259 void endDrawRect();
00260
00261 void createActions();
00262 void createToolBar();
00263
00264 virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
00265
00266 viewAspect getViewParams() const;
00267
00268 bool computeGravityCenter( double& theX, double& theY, double& theZ );
00269
00270 virtual void onSketchingStarted();
00271 virtual void onSketchingFinished();
00272
00273 virtual OCCViewer_ViewSketcher* createSketcher( int );
00274
00275 OCCViewer_ViewSketcher* mypSketcher;
00276 QList<OCCViewer_ViewSketcher*> mySketchers;
00277
00278 int myCurSketch;
00279
00280 OperationType myOperation;
00281 OCCViewer_Viewer* myModel;
00282 OCCViewer_ViewPort3d* myViewPort;
00283
00284 OCCViewer_CubeAxesDlg* myCubeAxesDlg;
00285
00286 RotationPointType myCurrPointType;
00287 RotationPointType myPrevPointType;
00288 gp_Pnt mySelectedPoint;
00289 bool myRotationPointSelection;
00290
00291 int myRestoreFlag;
00292
00293 int myStartX;
00294 int myStartY;
00295 int myCurrX;
00296 int myCurrY;
00297
00298 bool myEventStarted;
00299 bool myCursorIsHand;
00300 bool myDrawRect;
00301 bool myEnableDrawMode;
00302 bool myPaintersRedrawing;
00303
00304 QCursor myCursor;
00305
00306 double myCurScale;
00307
00308 private:
00309 OCCViewer_ClippingDlg* myClippingDlg;
00310 QtxAction* myClippingAction;
00311
00312 OCCViewer_AxialScaleDlg* myScalingDlg;
00313
00314 OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
00315 QtxAction* mySetRotationPointAction;
00316
00317 QtxRectRubberBand* myRectBand;
00318
00319 int myInteractionStyle;
00320
00321 typedef QMap<OperationType, bool> MapOfTransformStatus;
00322 MapOfTransformStatus myStatus;
00323
00324 Mode2dType my2dMode;
00325
00326 Handle(V3d_Plane) myReserveClippingPlane;
00327
00328 viewAspectList myViewAspects;
00329 };
00330
00331 #ifdef WIN32
00332 #pragma warning( default:4251 )
00333 #endif
00334
00335 #endif