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; }
96 //! Updates drawing mode in the view window
97 void updateEnabledDrawMode();
100 //! Emited whien view transformation operation is started
101 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
103 //! Emited whien view transformation operation is finished
104 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
106 //void Show(QShowEvent *);
107 //void Hide(QHideEvent *);
108 //void maximized(XGUI_ViewWindow*, bool);
109 //void returnedTo3d();
111 //! Emited before the window closing
112 void tryClosing(XGUI_ViewWindow*);
114 //! Emited when window is closing
115 void closed( QMdiSubWindow* );
117 //! Emited on mouse press in view port
118 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
120 //! Emited on mouse release in view port
121 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
123 //! Emited on mouse double click in view port
124 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
126 //! Emited on mouse moving in view port
127 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
129 //! Emited on key press in view port
130 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
132 //! Emited on key release in view port
133 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
135 //! Emited on context menu request in view port
136 void contextMenuRequested(QContextMenuEvent *e);
138 //void viewModified(XGUI_ViewWindow*);
139 void viewCloned( QMdiSubWindow* theView );
142 //! Start zooming operation
145 //! Start rotation operation
146 void activateRotation();
148 //! Start panning operation
149 void activatePanning();
151 //! Start window fit operation
152 void activateWindowFit();
154 //! Start global panning operation
155 void activateGlobalPanning();
157 //! Clone the view window preserving a view point of the current view
160 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
184 //! Reset point of view
187 void windowActivated();
189 void windowDeactivated();
192 virtual void changeEvent(QEvent* theEvent);
194 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
196 virtual void showEvent(QShowEvent* theEvent);
198 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
205 void updateToolBar();
206 // void repaintToolBar();
216 bool processWindowControls(QObject *theObj, QEvent *theEvent);
217 bool processViewPort(QEvent *theEvent);
219 void vpMousePressEvent(QMouseEvent* theEvent);
220 void vpMouseReleaseEvent(QMouseEvent* theEvent);
221 void vpMouseMoveEvent(QMouseEvent* theEvent);
223 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
229 bool transformRequested() const;
230 bool setTransformRequested(OperationType);
232 // Transformation is selected and already started
233 bool transformInProcess() const
235 return myEventStarted;
237 void setTransformInProcess(bool bOn)
239 myEventStarted = bOn;
243 XGUI_Viewer* myViewer;
246 ViewerLabel* myGripWgt;
247 XGUI_ViewPort* myViewPort;
248 ViewerToolbar* myViewBar;
249 ViewerToolbar* myWindowBar;
250 QAction* myMinimizeBtn;
251 QAction* myMaximizeBtn;
261 WindowState myLastState;
268 XGUI::InteractionStyle myInteractionStyle;
269 OperationType myOperation;
270 XGUI::Mode2dType my2dMode;
273 bool myDrawRect; // set when a rect is used for selection or magnify
274 bool myEnableDrawMode;
275 bool myRotationPointSelection;
278 bool myEventStarted; // set when transformation is in process
284 XGUI::RotationPointType myCurrPointType;
285 XGUI::RotationPointType myPrevPointType;
287 gp_Pnt mySelectedPoint;
289 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
291 typedef QMap<OperationType, bool> MapOfTransformStatus;
292 MapOfTransformStatus myStatus;
297 //******************************************************
301 \brief Provides a toolbar widget with treansparent background over OCCT View window
303 class ViewerToolbar: public QToolBar
307 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
310 void onViewPortResized() { myResize = true; }
313 virtual void paintEvent(QPaintEvent* theEvent);
318 XGUI_ViewPort* myVPort;
322 //******************************************************
326 \brief Provides a Label widget with treansparent background over OCCT View window
328 class ViewerLabel: public QLabel
332 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
335 void onViewPortResized() { myResize = true; }
338 virtual void paintEvent(QPaintEvent* theEvent);
341 XGUI_ViewPort* myVPort;