1 #ifndef XGUI_ViewWindow_H
2 #define XGUI_ViewWindow_H
5 #include "XGUI_Constants.h"
15 #include <V3d_View.hxx>
16 #include <V3d_Viewer.hxx>
22 class XGUI_RectRubberBand;
26 \class XGUI_ViewWindow
28 \brief Implements a one view window of 3d viewer object.
29 It contains a view port object (drawing area) and toolbars for view camera and window management.
30 Also it managements events in view port
32 class XGUI_EXPORT XGUI_ViewWindow: public QFrame
36 //! Types of viewer operations
57 XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType);
59 virtual ~XGUI_ViewWindow();
61 //! Returns view port object
62 XGUI_ViewPort* viewPort() const
67 //! Retrurns current interaction style
68 XGUI::InteractionStyle interactionStyle() const
70 return myInteractionStyle;
73 //! Disable or enable given operation type
74 void setTransformEnabled(const OperationType, const bool);
76 //! Returns true if the given operation type is enabled
77 bool transformEnabled(const OperationType) const;
79 //! Returns View background object
80 Qtx::BackgroundData background() const;
82 //! Sets View background object
83 void setBackground(const Qtx::BackgroundData& theBackground);
85 //! Returns true if the current view window can be closed
86 bool closable() const { return myClosable; }
88 //! Sets the current view window closable or not
89 void setClosable( const bool isClosable ) { myClosable = isClosable; }
91 //! Enable/Disable drawing of ribbon line
92 void enableDrawMode(bool toEnable) { myEnableDrawMode = toEnable; }
94 //! Returns true if ribbon line drawing enabled
95 bool isDrawModeEnabled() const { return myEnableDrawMode; }
97 //! Updates drawing mode in the view window
98 void updateEnabledDrawMode();
101 //! Emited whien view transformation operation is started
102 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
104 //! Emited whien view transformation operation is finished
105 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
107 //void Show(QShowEvent *);
108 //void Hide(QHideEvent *);
109 //void maximized(XGUI_ViewWindow*, bool);
110 //void returnedTo3d();
112 //! Emited before the window closing
113 void tryClosing(XGUI_ViewWindow*);
115 //! Emited when window is closing
116 void closed( QMdiSubWindow* );
118 //! Emited on mouse press in view port
119 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
121 //! Emited on mouse release in view port
122 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
124 //! Emited on mouse double click in view port
125 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
127 //! Emited on mouse moving in view port
128 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
130 //! Emited on key press in view port
131 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
133 //! Emited on key release in view port
134 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
136 //! Emited on context menu request in view port
137 void contextMenuRequested(QContextMenuEvent *e);
139 //void viewModified(XGUI_ViewWindow*);
140 void viewCloned( QMdiSubWindow* theView );
143 //! Start zooming operation
146 //! Start rotation operation
147 void activateRotation();
149 //! Start panning operation
150 void activatePanning();
152 //! Start window fit operation
153 void activateWindowFit();
155 //! Start global panning operation
156 void activateGlobalPanning();
158 //! Clone the view window preserving a view point of the current view
161 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
185 //! Reset point of view
188 void windowActivated();
190 void windowDeactivated();
193 virtual void changeEvent(QEvent* theEvent);
195 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
197 virtual void showEvent(QShowEvent* theEvent);
199 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
206 void updateToolBar();
207 // void repaintToolBar();
217 bool processWindowControls(QObject *theObj, QEvent *theEvent);
218 bool processViewPort(QEvent *theEvent);
220 void vpMousePressEvent(QMouseEvent* theEvent);
221 void vpMouseReleaseEvent(QMouseEvent* theEvent);
222 void vpMouseMoveEvent(QMouseEvent* theEvent);
224 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
230 bool transformRequested() const;
231 bool setTransformRequested(OperationType);
233 // Transformation is selected and already started
234 bool transformInProcess() const
236 return myEventStarted;
238 void setTransformInProcess(bool bOn)
240 myEventStarted = bOn;
244 XGUI_Viewer* myViewer;
247 ViewerLabel* myGripWgt;
248 XGUI_ViewPort* myViewPort;
249 ViewerToolbar* myViewBar;
250 ViewerToolbar* myWindowBar;
251 QAction* myMinimizeBtn;
252 QAction* myMaximizeBtn;
262 WindowState myLastState;
269 XGUI::InteractionStyle myInteractionStyle;
270 OperationType myOperation;
271 XGUI::Mode2dType my2dMode;
274 bool myDrawRect; // set when a rect is used for selection or magnify
275 bool myEnableDrawMode;
276 bool myRotationPointSelection;
279 bool myEventStarted; // set when transformation is in process
285 XGUI::RotationPointType myCurrPointType;
286 XGUI::RotationPointType myPrevPointType;
288 gp_Pnt mySelectedPoint;
290 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
292 typedef QMap<OperationType, bool> MapOfTransformStatus;
293 MapOfTransformStatus myStatus;
298 //******************************************************
302 \brief Provides a toolbar widget with treansparent background over OCCT View window
304 class ViewerToolbar: public QToolBar
308 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
311 void onViewPortResized() { myResize = true; }
314 virtual void paintEvent(QPaintEvent* theEvent);
319 XGUI_ViewPort* myVPort;
323 //******************************************************
327 \brief Provides a Label widget with treansparent background over OCCT View window
329 class ViewerLabel: public QLabel
333 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
336 void onViewPortResized() { myResize = true; }
339 virtual void paintEvent(QPaintEvent* theEvent);
342 XGUI_ViewPort* myVPort;