Salome HOME
Merge branch 'master' of newgeom:newgeom.git into BR_PYTHON_PLUGIN
[modules/shaper.git] / src / XGUI / XGUI_ViewWindow.h
index de6837a5a4e0770c84aad9f4e434a5ff80162cc2..bd2aef20eacc7f510421e0608527ba68bb89d541 100644 (file)
@@ -1,8 +1,10 @@
 #ifndef XGUI_ViewWindow_H
 #define XGUI_ViewWindow_H
 
+#include "XGUI.h"
 #include "XGUI_Constants.h"
-#include "XGUI_ViewBackground.h"
+
+#include <Qtx.h>
 
 #include <QFrame>
 #include <QIcon>
@@ -20,10 +22,18 @@ class ViewerLabel;
 class XGUI_RectRubberBand;
 class QMdiSubWindow;
 
-class XGUI_ViewWindow: public QFrame
+/*!
+ \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
-public:
+ public:
+  //! Types of viewer operations
   enum OperationType
   {
     NOTHING,
@@ -48,84 +58,172 @@ public:
 
   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;
 
-  XGUI_ViewBackground background() const;
-  void setBackground(const XGUI_ViewBackground& theBackground);
+  //! Returns View background object
+  Qtx::BackgroundData background() const;
+
+  //! Sets View background object
+  void setBackground(const Qtx::BackgroundData& 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;
+  }
 
-    bool closable() const { return myClosable; }
-    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();
 
 signals:
+  //! Emited whien view transformation operation is started
   void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
+
+  //! Emited whien view transformation operation is finished
   void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
 
-  void Show(QShowEvent *);
-  void Hide(QHideEvent *);
-  void maximized(XGUI_ViewWindow*, bool);
-  void returnedTo3d();
+  //void Show(QShowEvent *);
+  //void Hide(QHideEvent *);
+  //void maximized(XGUI_ViewWindow*, bool);
+  //void returnedTo3d();
 
+  //! Emited before the window closing
   void tryClosing(XGUI_ViewWindow*);
-    void closed( QMdiSubWindow* );
+
+  //! Emited when window is closing
+  void closed(QMdiSubWindow*);
+
+  //! Emited on mouse press in view port
   void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
+
+  //! Emited on mouse release in view port
   void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
+
+  //! 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 );
+  //void viewModified(XGUI_ViewWindow*);
+  void viewCloned(QMdiSubWindow* theView);
 
-public slots:
+ public slots:
+  //! Start zooming operation
   void activateZoom();
+
+  //! Start rotation operation
   void activateRotation();
+
+  //! Start panning operation
   void activatePanning();
-    void activateWindowFit();
-    void activateGlobalPanning();
-
-    void cloneView();
-    void dumpView();
-    void fitAll();
-    
-    void frontView();
-    void backView();
-    void topView();
-    void bottomView();
-    void leftView();
-    void rightView();
-
-protected:
-  virtual void resizeEvent(QResizeEvent* theEvent);
 
-  virtual void changeEvent(QEvent* theEvent);
+  //! 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();
 
-  virtual void enterEvent(QEvent* theEvent);
-  virtual void leaveEvent(QEvent* theEvent);
+  //! Set left view
+  void leftView();
+
+  //! Set right view
+  void rightView();
+
+  //! Reset point of view
+  void reset();
+
+  void windowActivated();
+
+  void windowDeactivated();
+
+ protected:
+  virtual void changeEvent(QEvent* theEvent);
 
   virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
 
-private slots:
+  virtual void showEvent(QShowEvent* theEvent);
+
+  virtual void contextMenuEvent(QContextMenuEvent* theEvent);
+
+ private slots:
   void onClose();
   void onMinimize();
   void onMaximize();
 
-private:
+  void updateToolBar();
+//  void repaintToolBar();
+
+ private:
   enum WindowState
   {
-    MinimizedState, MaximizedState, NormalState
+    MinimizedState,
+    MaximizedState,
+    WindowNormalState
   };
 
   bool processWindowControls(QObject *theObj, QEvent *theEvent);
@@ -154,7 +252,7 @@ private:
     myEventStarted = bOn;
   }
 
-private:
+ private:
   XGUI_Viewer* myViewer;
 
   QLabel* myPicture;
@@ -191,7 +289,8 @@ private:
   bool myCursorIsHand;
   bool myIsKeyFree;
   bool myEventStarted;       // set when transformation is in process 
-    bool myClosable;
+  bool myClosable;
+  bool myIsActive;
 
   QCursor myCursor;
 
@@ -200,7 +299,7 @@ private:
 
   gp_Pnt mySelectedPoint;
 
-  XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
+  XGUI_RectRubberBand* myRectBand;  //!< selection rectangle rubber band
 
   typedef QMap<OperationType, bool> MapOfTransformStatus;
   MapOfTransformStatus myStatus;
@@ -209,37 +308,55 @@ private:
 };
 
 //******************************************************
-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
-public:
-  ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
-      : QToolBar(theParent), myVPort(thePort)
+ public:
+  ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
+
+ protected slots:
+  void onViewPortResized()
   {
+    myResize = true;
   }
 
-protected:
+ protected:
   virtual void paintEvent(QPaintEvent* theEvent);
 
-private:
+ private:
   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
-public:
-  ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
-      : QLabel(theParent), myVPort(thePort)
+ public:
+  ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
+
+ protected slots:
+  void onViewPortResized()
   {
+    myResize = true;
   }
 
-protected:
+ protected:
   virtual void paintEvent(QPaintEvent* theEvent);
 
-private:
+ private:
   XGUI_ViewPort* myVPort;
+  bool myResize;
 };
 
 #endif