X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOCCViewer%2FOCCViewer_ViewWindow.h;h=28d3d8d649bf53aea819a0b044f813fa02386e1d;hb=e07448c48ea5b2127e34fc7b8c3427d01c7ce17b;hp=180e66c1975e09fb4274cb9846579ba7093bf07e;hpb=1c889394b028b786898a995d38c07c8f3d564837;p=modules%2Fgui.git diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 180e66c19..28d3d8d64 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -1,30 +1,33 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #ifndef OCCVIEWER_VIEWWINDOW_H #define OCCVIEWER_VIEWWINDOW_H #include "OCCViewer.h" +#include "Qtx.h" #include "SUIT_ViewWindow.h" #include +#include class QtxRectRubberBand; class SUIT_Desktop; @@ -34,9 +37,76 @@ class OCCViewer_ClippingDlg; class OCCViewer_AxialScaleDlg; class OCCViewer_SetRotationPointDlg; class OCCViewer_Viewer; -class viewAspect; +class OCCViewer_CubeAxesDlg; class QtxAction; +struct viewAspect +{ +public: + double scale; + double centerX; + double centerY; + double projX; + double projY; + double projZ; + double twist; + double atX; + double atY; + double atZ; + double eyeX; + double eyeY; + double eyeZ; + double scaleX; + double scaleY; + double scaleZ; + QString name; + bool isVisible; + double size; + // graduated trihedron + bool gtIsVisible; + bool gtDrawNameX; + bool gtDrawNameY; + bool gtDrawNameZ; + QString gtNameX; + QString gtNameY; + QString gtNameZ; + int gtNameColorRX; + int gtNameColorGX; + int gtNameColorBX; + int gtNameColorRY; + int gtNameColorGY; + int gtNameColorBY; + int gtNameColorRZ; + int gtNameColorGZ; + int gtNameColorBZ; + bool gtDrawValuesX; + bool gtDrawValuesY; + bool gtDrawValuesZ; + int gtNbValuesX; + int gtNbValuesY; + int gtNbValuesZ; + int gtOffsetX; + int gtOffsetY; + int gtOffsetZ; + int gtColorRX; + int gtColorGX; + int gtColorBX; + int gtColorRY; + int gtColorGY; + int gtColorBY; + int gtColorRZ; + int gtColorGZ; + int gtColorBZ; + bool gtDrawTickmarksX; + bool gtDrawTickmarksY; + bool gtDrawTickmarksZ; + int gtTickmarkLengthX; + int gtTickmarkLengthY; + int gtTickmarkLengthZ; +}; + +typedef QList viewAspectList; + #ifdef WIN32 #pragma warning( disable:4251 ) #endif @@ -47,76 +117,123 @@ class OCCVIEWER_EXPORT OCCViewer_ViewWindow : public SUIT_ViewWindow public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, - ChangeRotationPointId, RotationId, - FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId, AxialScaleId }; + ChangeRotationPointId, RotationId, + FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, + ResetId, CloneId, ClippingId, MemId, RestoreId, + TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId, + SwitchInteractionStyleId, SwitchZoomingStyleId, MaximizedId, SynchronizeId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, - PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, - FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW }; + PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, + FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW, + CLOCKWISEVIEW, ANTICLOCKWISEVIEW }; enum RotationPointType{ GRAVITY, SELECTED }; enum SketchingType { NoSketching, Rect, Polygon }; + enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; + + OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); - OCCViewer_ViewPort3d* getViewPort(); + virtual OCCViewer_ViewWindow* getView( const int ) const; + + virtual OCCViewer_ViewPort3d* getViewPort(); - bool eventFilter(QObject* watched, QEvent* e); + virtual bool eventFilter(QObject* watched, QEvent* e); - void performRestoring( const viewAspect& ); + virtual void performRestoring( const viewAspect&, bool = false ); virtual void initLayout(); - void updateEnabledDrawMode(); + virtual void updateEnabledDrawMode(); - void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, - const double dx = 0, const double dy = 0, const double dz = 1); + virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, + const double dx = 0, const double dy = 0, const double dz = 1); - bool isCuttingPlane(); + virtual void setCuttingPlane( bool on, const gp_Pln thePln ); + + virtual bool isCuttingPlane(); virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& parameters ); - virtual void initSketchers(); - OCCViewer_ViewSketcher* getSketcher( const int ); + virtual void initSketchers(); + virtual OCCViewer_ViewSketcher* getSketcher( const int ); + + virtual void activateSketching( int ); - void activateSketching( int ); + virtual int interactionStyle() const; + virtual void setInteractionStyle( const int ); + + virtual int zoomingStyle() const; + virtual void setZoomingStyle( const int ); + void setTransformEnabled( const OperationType, const bool ); + bool transformEnabled( const OperationType ) const; + + + void set2dMode( Mode2dType ); + Mode2dType get2dMode() const { return my2dMode; } + + void setMaximized( bool, bool = true ); + bool isMaximized() const; + + void setSketcherStyle( bool enable ); + bool isSketcherStyle() const; + + virtual QColor backgroundColor() const; // obsolete + virtual void setBackgroundColor( const QColor& ); // obsolete + + virtual Qtx::BackgroundData background() const; + virtual void setBackground( const Qtx::BackgroundData& ); + + virtual const viewAspectList& getViewAspects(); + virtual void appendViewAspect( const viewAspect& ); + virtual void updateViewAspects( const viewAspectList& ); + virtual void clearViewAspects(); + public slots: - void onFrontView(); - void onViewFitAll(); - void onBackView(); - void onTopView(); - void onBottomView(); - void onLeftView(); - void onRightView(); - void onResetView(); - void onFitAll(); - void activateZoom(); - void activateWindowFit(); - void activateRotation(); - void activatePanning(); - void activateGlobalPanning(); - void onSetRotationPoint( bool on ); - void onCloneView(); - void onClipping( bool on ); - void onAxialScale(); - void onMemorizeView(); - void onRestoreView(); - void onTrihedronShow(); - void setRestoreFlag(); - - void activateSetRotationGravity(); - void activateSetRotationSelected( double theX, double theY, double theZ ); - void activateStartPointSelection(); - void updateGravityCoords(); + virtual void onFrontView(); + virtual void onViewFitAll(); + virtual void onBackView(); + virtual void onTopView(); + virtual void onBottomView(); + virtual void onLeftView(); + virtual void onRightView(); + virtual void onClockWiseView(); + virtual void onAntiClockWiseView(); + virtual void onResetView(); + virtual void onFitAll(); + virtual void activateZoom(); + virtual void activateWindowFit(); + virtual void activateRotation(); + virtual void activatePanning(); + virtual void activateGlobalPanning(); + virtual void onSetRotationPoint( bool on ); + virtual void onCloneView(); + virtual void onClipping( bool on ); + virtual void onAxialScale(); + virtual void onGraduatedAxes(); + virtual void onAmbientToogle(); + virtual void onMemorizeView(); + virtual void onRestoreView(); + virtual void onTrihedronShow(); + virtual void setRestoreFlag(); + virtual void onSwitchInteractionStyle( bool on ); + virtual void onSwitchZoomingStyle( bool on ); + + virtual void activateSetRotationGravity(); + virtual void activateSetRotationSelected( double theX, double theY, double theZ ); + virtual void activateStartPointSelection(); + virtual void updateGravityCoords(); virtual void showEvent( QShowEvent * ); virtual void hideEvent( QHideEvent * ); + virtual void onMaximizedView(); signals: void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type); @@ -125,19 +242,22 @@ signals: void Show( QShowEvent * ); void Hide( QHideEvent * ); + void maximized( OCCViewer_ViewWindow*, bool ); -protected: +public: virtual QImage dumpView(); virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); + +protected: virtual QString filter() const; /* Transformation selected but not started yet */ bool transformRequested() const; - void setTransformRequested ( OperationType ); + bool setTransformRequested ( OperationType ); /* Transformation is selected and already started */ - bool transformInProcess() const; - void setTransformInProcess( bool ); + bool transformInProcess() const; + void setTransformInProcess( bool ); void vpMousePressEvent(QMouseEvent* theEvent); void vpMouseReleaseEvent(QMouseEvent* theEvent); @@ -150,7 +270,7 @@ protected: void createActions(); void createToolBar(); - virtual OperationType getButtonState(QMouseEvent* theEvent); + virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle); viewAspect getViewParams() const; @@ -170,28 +290,38 @@ protected: OCCViewer_Viewer* myModel; OCCViewer_ViewPort3d* myViewPort; + OCCViewer_CubeAxesDlg* myCubeAxesDlg; + RotationPointType myCurrPointType; RotationPointType myPrevPointType; gp_Pnt mySelectedPoint; bool myRotationPointSelection; - int myRestoreFlag; + int myRestoreFlag; - int myStartX; - int myStartY; - int myCurrX; - int myCurrY; + int myStartX; + int myStartY; + int myCurrX; + int myCurrY; - bool myEventStarted; // set when transformation is in process - bool myCursorIsHand; - bool myDrawRect; // set when a rect is used for selection or magnify - bool myEnableDrawMode; - bool myPaintersRedrawing; // set to draw with external painters - - QCursor myCursor; + bool myEventStarted; // set when transformation is in process + bool myCursorIsHand; + bool myDrawRect; // set when a rect is used for selection or magnify + bool myEnableDrawMode; + bool myPaintersRedrawing; // set to draw with external painters + bool IsSketcherStyle; + + QCursor myCursor; double myCurScale; +private slots: + void onSynchronizeView(bool); + void updateSyncViews(); + +private: + static void synchronizeView( OCCViewer_ViewWindow*, int ); + private: OCCViewer_ClippingDlg* myClippingDlg; QtxAction* myClippingAction; @@ -202,6 +332,17 @@ private: QtxAction* mySetRotationPointAction; QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band + + int myInteractionStyle; + + typedef QMap MapOfTransformStatus; + MapOfTransformStatus myStatus; + + Mode2dType my2dMode; + + Handle(V3d_Plane) myReserveClippingPlane; + + viewAspectList myViewAspects; }; #ifdef WIN32