X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ViewWindow.h;h=65c2ae273cc87b9c50a25f7636d97de8515aff75;hb=a3b2736968186ac435b1e05e530c40becbc82301;hp=1d794e94d6a4a57f93854e2289ac54909312e2d0;hpb=580494d5bfe1c80d9195ebbf7a18826f67595a91;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 1d794e94d..65c2ae273 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -1,6 +1,7 @@ #ifndef XGUI_ViewWindow_H #define XGUI_ViewWindow_H +#include "XGUI.h" #include "XGUI_Constants.h" #include "XGUI_ViewBackground.h" @@ -18,180 +19,327 @@ class XGUI_Viewer; class ViewerToolbar; class ViewerLabel; class XGUI_RectRubberBand; - -class XGUI_ViewWindow : public QFrame +class QMdiSubWindow; + +/*! + \class XGUI_ViewWindow + \ingroup GUI + \brief Implements a one view window of 3d viewer object. + It contains a view port object (drawing area) and toolbars for view camera and window management. + Also it managements events in view port +*/ +class XGUI_EXPORT XGUI_ViewWindow: public QFrame { - Q_OBJECT +Q_OBJECT public: - enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, - PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, - FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW, - CLOCKWISEVIEW, ANTICLOCKWISEVIEW }; + //! Types of viewer operations + enum OperationType + { + NOTHING, + PANVIEW, + ZOOMVIEW, + ROTATE, + PANGLOBAL, + WINDOWFIT, + FITALLVIEW, + RESETVIEW, + FRONTVIEW, + BACKVIEW, + TOPVIEW, + BOTTOMVIEW, + LEFTVIEW, + RIGHTVIEW, + CLOCKWISEVIEW, + ANTICLOCKWISEVIEW + }; + + XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType); + + virtual ~XGUI_ViewWindow(); + + //! Returns view port object + XGUI_ViewPort* viewPort() const + { + return myViewPort; + } + + //! Retrurns current interaction style + XGUI::InteractionStyle interactionStyle() const + { + return myInteractionStyle; + } + + //! Disable or enable given operation type + void setTransformEnabled(const OperationType, const bool); + + //! Returns true if the given operation type is enabled + bool transformEnabled(const OperationType) const; + + //! Returns View background object + XGUI_ViewBackground background() const; + + //! Sets View background object + void setBackground(const XGUI_ViewBackground& theBackground); + + //! Returns true if the current view window can be closed + bool closable() const { return myClosable; } + + //! Sets the current view window closable or not + void setClosable( const bool isClosable ) { myClosable = isClosable; } + + //! Enable/Disable drawing of ribbon line + void enableDrawMode(bool toEnable) { myEnableDrawMode = toEnable; } + + //! Returns true if ribbon line drawing enabled + bool isDrawModeEnabled() const { return myEnableDrawMode; } + + //! Updates drawing mode in the view window + void updateEnabledDrawMode(); - XGUI_ViewWindow(XGUI_Viewer* theViewer, - V3d_TypeOfView theType); +signals: + //! Emited whien view transformation operation is started + void vpTransformationStarted(XGUI_ViewWindow::OperationType type); - virtual ~XGUI_ViewWindow(); + //! Emited whien view transformation operation is finished + void vpTransformationFinished(XGUI_ViewWindow::OperationType type); - XGUI_ViewPort* viewPort() const { return myViewPort; } + //void Show(QShowEvent *); + //void Hide(QHideEvent *); + //void maximized(XGUI_ViewWindow*, bool); + //void returnedTo3d(); + //! Emited before the window closing + void tryClosing(XGUI_ViewWindow*); - XGUI::InteractionStyle interactionStyle() const { return myInteractionStyle; } + //! Emited when window is closing + void closed( QMdiSubWindow* ); - void setTransformEnabled( const OperationType, const bool ); - bool transformEnabled( const OperationType ) const; + //! Emited on mouse press in view port + void mousePressed(XGUI_ViewWindow*, QMouseEvent*); - XGUI_ViewBackground background() const; - void setBackground( const XGUI_ViewBackground& theBackground ); + //! Emited on mouse release in view port + void mouseReleased(XGUI_ViewWindow*, QMouseEvent*); -signals: - void vpTransformationStarted(XGUI_ViewWindow::OperationType type); - void vpTransformationFinished(XGUI_ViewWindow::OperationType type); - //void viewCloned( XGUI_ViewWindow* ); - - void Show( QShowEvent * ); - void Hide( QHideEvent * ); - void maximized( XGUI_ViewWindow*, bool ); - void returnedTo3d( ); - - - void tryClosing( XGUI_ViewWindow* ); - void closing( XGUI_ViewWindow* ); - void mousePressed( XGUI_ViewWindow*, QMouseEvent* ); - void mouseReleased( XGUI_ViewWindow*, QMouseEvent* ); - void mouseDoubleClicked( XGUI_ViewWindow*, QMouseEvent* ); - void mouseMoving( XGUI_ViewWindow*, QMouseEvent* ); - void wheeling( XGUI_ViewWindow*, QWheelEvent* ); - void keyPressed( XGUI_ViewWindow*, QKeyEvent* ); - void keyReleased( XGUI_ViewWindow*, QKeyEvent* ); - void contextMenuRequested( QContextMenuEvent *e ); - void viewModified( XGUI_ViewWindow* ); + //! Emited on mouse double click in view port + void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on mouse moving in view port + void mouseMoving(XGUI_ViewWindow*, QMouseEvent*); + + //! Emited on key press in view port + void keyPressed(XGUI_ViewWindow*, QKeyEvent*); + + //! Emited on key release in view port + void keyReleased(XGUI_ViewWindow*, QKeyEvent*); + + //! Emited on context menu request in view port + void contextMenuRequested(QContextMenuEvent *e); + + //void viewModified(XGUI_ViewWindow*); + void viewCloned( QMdiSubWindow* theView ); public slots: - void activateZoom(); - void activateRotation(); - void activatePanning(); + //! Start zooming operation + void activateZoom(); + + //! Start rotation operation + void activateRotation(); + + //! Start panning operation + void activatePanning(); + + //! Start window fit operation + void activateWindowFit(); + + //! Start global panning operation + void activateGlobalPanning(); + + //! Clone the view window preserving a view point of the current view + void cloneView(); + + //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps) + void dumpView(); + + //! Fit all command + void fitAll(); + + //! Set front view + void frontView(); + + //! Set back view + void backView(); + + //! Set top view + void topView(); + + //! Set bottom view + void bottomView(); + + //! Set left view + void leftView(); + + //! Set right view + void rightView(); + + //! Reset point of view + void reset(); + + void windowActivated(); + + void windowDeactivated(); protected: - virtual void resizeEvent(QResizeEvent* theEvent); + virtual void changeEvent(QEvent* theEvent); - virtual void changeEvent(QEvent* theEvent); + virtual bool eventFilter(QObject *theObj, QEvent *theEvent); - virtual void enterEvent(QEvent* theEvent); - virtual void leaveEvent(QEvent* theEvent); + virtual void showEvent(QShowEvent* theEvent); - virtual bool eventFilter(QObject *theObj, QEvent *theEvent); + virtual void contextMenuEvent(QContextMenuEvent* theEvent); private slots: - void onClose(); - void onMinimize(); - void onMaximize(); + void onClose(); + void onMinimize(); + void onMaximize(); + + void updateToolBar(); +// void repaintToolBar(); private: - enum WindowState { MinimizedState, MaximizedState, NormalState }; + enum WindowState + { + MinimizedState, + MaximizedState, + WindowNormalState + }; + + bool processWindowControls(QObject *theObj, QEvent *theEvent); + bool processViewPort(QEvent *theEvent); + + void vpMousePressEvent(QMouseEvent* theEvent); + void vpMouseReleaseEvent(QMouseEvent* theEvent); + void vpMouseMoveEvent(QMouseEvent* theEvent); + + OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle); + + void resetState(); + void drawRect(); + void endDrawRect(); + + bool transformRequested() const; + bool setTransformRequested(OperationType); + + // Transformation is selected and already started + bool transformInProcess() const + { + return myEventStarted; + } + void setTransformInProcess(bool bOn) + { + myEventStarted = bOn; + } - bool processWindowControls(QObject *theObj, QEvent *theEvent); - bool processViewPort(QEvent *theEvent); +private: + XGUI_Viewer* myViewer; - void vpMousePressEvent(QMouseEvent* theEvent); - void vpMouseReleaseEvent(QMouseEvent* theEvent); - void vpMouseMoveEvent(QMouseEvent* theEvent); + QLabel* myPicture; + ViewerLabel* myGripWgt; + XGUI_ViewPort* myViewPort; + ViewerToolbar* myViewBar; + ViewerToolbar* myWindowBar; + QAction* myMinimizeBtn; + QAction* myMaximizeBtn; - OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle); - - void resetState(); - void drawRect(); - void endDrawRect(); + QIcon MinimizeIco; + QIcon MaximizeIco; + QIcon CloseIco; + QIcon RestoreIco; - bool transformRequested() const; - bool setTransformRequested ( OperationType ); + bool myMoving; + QPoint myMousePnt; - // Transformation is selected and already started - bool transformInProcess() const { return myEventStarted; } - void setTransformInProcess( bool bOn ) { myEventStarted = bOn; } + WindowState myLastState; -private: - XGUI_Viewer* myViewer; - - QLabel* myPicture; - ViewerLabel* myGripWgt; - XGUI_ViewPort* myViewPort; - ViewerToolbar* myViewBar; - ViewerToolbar* myWindowBar; - QAction* myMinimizeBtn; - QAction* myMaximizeBtn; - - QIcon MinimizeIco; - QIcon MaximizeIco; - QIcon CloseIco; - QIcon RestoreIco; - - bool myMoving; - QPoint myMousePnt; - - WindowState myLastState; - - int myStartX; - int myStartY; - int myCurrX; - int myCurrY; - - XGUI::InteractionStyle myInteractionStyle; - OperationType myOperation; - XGUI::Mode2dType my2dMode; - - int myCurSketch; - bool myDrawRect; // set when a rect is used for selection or magnify - bool myEnableDrawMode; - bool myRotationPointSelection; - bool myCursorIsHand; - bool myIsKeyFree; - bool myEventStarted; // set when transformation is in process - - QCursor myCursor; - - XGUI::RotationPointType myCurrPointType; - XGUI::RotationPointType myPrevPointType; - - gp_Pnt mySelectedPoint; - - XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band - - typedef QMap MapOfTransformStatus; - MapOfTransformStatus myStatus; - - double myCurScale; -}; + int myStartX; + int myStartY; + int myCurrX; + int myCurrY; + + XGUI::InteractionStyle myInteractionStyle; + OperationType myOperation; + XGUI::Mode2dType my2dMode; + + int myCurSketch; + bool myDrawRect; // set when a rect is used for selection or magnify + bool myEnableDrawMode; + bool myRotationPointSelection; + bool myCursorIsHand; + bool myIsKeyFree; + bool myEventStarted; // set when transformation is in process + bool myClosable; + bool myIsActive; + + QCursor myCursor; + XGUI::RotationPointType myCurrPointType; + XGUI::RotationPointType myPrevPointType; + + gp_Pnt mySelectedPoint; + + XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band + + typedef QMap MapOfTransformStatus; + MapOfTransformStatus myStatus; + + double myCurScale; +}; //****************************************************** -class ViewerToolbar : public QToolBar +/*! + \class ViewerToolbar + \ingroup GUI + \brief Provides a toolbar widget with treansparent background over OCCT View window +*/ +class ViewerToolbar: public QToolBar { - Q_OBJECT +Q_OBJECT public: - ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort) : - QToolBar(theParent), myVPort(thePort) {} + ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort); + +protected slots: + void onViewPortResized() { myResize = true; } protected: - virtual void paintEvent( QPaintEvent* theEvent); + virtual void paintEvent(QPaintEvent* theEvent); + + private: - XGUI_ViewPort* myVPort; + XGUI_ViewPort* myVPort; + bool myResize; }; //****************************************************** -class ViewerLabel : public QLabel +/*! + \class ViewerToolbar + \ingroup GUI + \brief Provides a Label widget with treansparent background over OCCT View window +*/ +class ViewerLabel: public QLabel { - Q_OBJECT +Q_OBJECT public: - ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort) : - QLabel(theParent), myVPort(thePort) {} + ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort); + +protected slots: + void onViewPortResized() { myResize = true; } protected: - virtual void paintEvent( QPaintEvent* theEvent); + virtual void paintEvent(QPaintEvent* theEvent); private: - XGUI_ViewPort* myVPort; + XGUI_ViewPort* myVPort; + bool myResize; }; -#endif \ No newline at end of file +#endif