1 #ifndef XGUI_ViewWindow_H
2 #define XGUI_ViewWindow_H
5 #include "XGUI_Constants.h"
6 #include "XGUI_ViewBackground.h"
14 #include <V3d_View.hxx>
15 #include <V3d_Viewer.hxx>
21 class XGUI_RectRubberBand;
25 \class XGUI_ViewWindow
27 \brief Implements a one view window of 3d viewer object.
28 It contains a view port object (drawing area) and toolbars for view camera and window management.
29 Also it managements events in view port
31 class XGUI_EXPORT XGUI_ViewWindow: public QFrame
35 //! Types of viewer operations
56 XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType);
58 virtual ~XGUI_ViewWindow();
60 //! Returns view port object
61 XGUI_ViewPort* viewPort() const
66 //! Retrurns current interaction style
67 XGUI::InteractionStyle interactionStyle() const
69 return myInteractionStyle;
72 //! Disable or enable given operation type
73 void setTransformEnabled(const OperationType, const bool);
75 //! Returns true if the given operation type is enabled
76 bool transformEnabled(const OperationType) const;
78 //! Returns View background object
79 XGUI_ViewBackground background() const;
81 //! Sets View background object
82 void setBackground(const XGUI_ViewBackground& theBackground);
84 //! Returns true if the current view window can be closed
85 bool closable() const { return myClosable; }
87 //! Sets the current view window closable or not
88 void setClosable( const bool isClosable ) { myClosable = isClosable; }
90 //! Enable/Disable drawing of ribbon line
91 void enableDrawMode(bool toEnable) { myEnableDrawMode = toEnable; }
93 //! Returns true if ribbon line drawing enabled
94 bool isDrawModeEnabled() const { return myEnableDrawMode; }
97 //! Emited whien view transformation operation is started
98 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
100 //! Emited whien view transformation operation is finished
101 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
103 //void Show(QShowEvent *);
104 //void Hide(QHideEvent *);
105 //void maximized(XGUI_ViewWindow*, bool);
106 //void returnedTo3d();
108 //! Emited before the window closing
109 void tryClosing(XGUI_ViewWindow*);
111 //! Emited when window is closing
112 void closed( QMdiSubWindow* );
114 //! Emited on mouse press in view port
115 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
117 //! Emited on mouse release in view port
118 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
120 //! Emited on mouse double click in view port
121 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
123 //! Emited on mouse moving in view port
124 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
126 //! Emited on key press in view port
127 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
129 //! Emited on key release in view port
130 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
132 //! Emited on context menu request in view port
133 void contextMenuRequested(QContextMenuEvent *e);
135 //void viewModified(XGUI_ViewWindow*);
136 void viewCloned( QMdiSubWindow* theView );
139 //! Start zooming operation
142 //! Start rotation operation
143 void activateRotation();
145 //! Start panning operation
146 void activatePanning();
148 //! Start window fit operation
149 void activateWindowFit();
151 //! Start global panning operation
152 void activateGlobalPanning();
154 //! Clone the view window preserving a view point of the current view
157 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
181 //! Reset point of view
184 void windowActivated();
186 void windowDeactivated();
189 virtual void changeEvent(QEvent* theEvent);
191 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
193 virtual void showEvent(QShowEvent* theEvent);
200 void updateToolBar();
201 // void repaintToolBar();
211 bool processWindowControls(QObject *theObj, QEvent *theEvent);
212 bool processViewPort(QEvent *theEvent);
214 void vpMousePressEvent(QMouseEvent* theEvent);
215 void vpMouseReleaseEvent(QMouseEvent* theEvent);
216 void vpMouseMoveEvent(QMouseEvent* theEvent);
218 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
224 bool transformRequested() const;
225 bool setTransformRequested(OperationType);
227 // Transformation is selected and already started
228 bool transformInProcess() const
230 return myEventStarted;
232 void setTransformInProcess(bool bOn)
234 myEventStarted = bOn;
238 XGUI_Viewer* myViewer;
241 ViewerLabel* myGripWgt;
242 XGUI_ViewPort* myViewPort;
243 ViewerToolbar* myViewBar;
244 ViewerToolbar* myWindowBar;
245 QAction* myMinimizeBtn;
246 QAction* myMaximizeBtn;
256 WindowState myLastState;
263 XGUI::InteractionStyle myInteractionStyle;
264 OperationType myOperation;
265 XGUI::Mode2dType my2dMode;
268 bool myDrawRect; // set when a rect is used for selection or magnify
269 bool myEnableDrawMode;
270 bool myRotationPointSelection;
273 bool myEventStarted; // set when transformation is in process
279 XGUI::RotationPointType myCurrPointType;
280 XGUI::RotationPointType myPrevPointType;
282 gp_Pnt mySelectedPoint;
284 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
286 typedef QMap<OperationType, bool> MapOfTransformStatus;
287 MapOfTransformStatus myStatus;
292 //******************************************************
296 \brief Provides a toolbar widget with treansparent background over OCCT View window
298 class ViewerToolbar: public QToolBar
302 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
303 : QToolBar(theParent), myVPort(thePort)
305 setBackgroundRole(QPalette::NoRole);
306 setAttribute(Qt::WA_NoSystemBackground);
307 //setAttribute(Qt::WA_PaintOnScreen);
308 setAutoFillBackground(false);
312 virtual void paintEvent(QPaintEvent* theEvent);
315 XGUI_ViewPort* myVPort;
318 //******************************************************
322 \brief Provides a Label widget with treansparent background over OCCT View window
324 class ViewerLabel: public QLabel
328 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
329 : QLabel(theParent), myVPort(thePort)
331 setBackgroundRole(QPalette::NoRole);
332 setAttribute(Qt::WA_NoSystemBackground);
333 //setAttribute(Qt::WA_PaintOnScreen);
334 setAutoFillBackground(false);
337 void repaintBackground();
340 virtual void paintEvent(QPaintEvent* theEvent);
343 XGUI_ViewPort* myVPort;