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
91 //! Sets the current view window closable or not
92 void setClosable(const bool isClosable)
94 myClosable = isClosable;
97 //! Enable/Disable drawing of ribbon line
98 void enableDrawMode(bool toEnable)
100 myEnableDrawMode = toEnable;
103 //! Returns true if ribbon line drawing enabled
104 bool isDrawModeEnabled() const
106 return myEnableDrawMode;
109 //! Updates drawing mode in the view window
110 void updateEnabledDrawMode();
113 //! Emited whien view transformation operation is started
114 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
116 //! Emited whien view transformation operation is finished
117 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
119 //void Show(QShowEvent *);
120 //void Hide(QHideEvent *);
121 //void maximized(XGUI_ViewWindow*, bool);
122 //void returnedTo3d();
124 //! Emited before the window closing
125 void tryClosing(XGUI_ViewWindow*);
127 //! Emited when window is closing
128 void closed(QMdiSubWindow*);
130 //! Emited on mouse press in view port
131 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
133 //! Emited on mouse release in view port
134 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
136 //! Emited on mouse double click in view port
137 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
139 //! Emited on mouse moving in view port
140 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
142 //! Emited on key press in view port
143 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
145 //! Emited on key release in view port
146 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
148 //! Emited on context menu request in view port
149 void contextMenuRequested(QContextMenuEvent *e);
151 //void viewModified(XGUI_ViewWindow*);
152 void viewCloned(QMdiSubWindow* theView);
155 //! Start zooming operation
158 //! Start rotation operation
159 void activateRotation();
161 //! Start panning operation
162 void activatePanning();
164 //! Start window fit operation
165 void activateWindowFit();
167 //! Start global panning operation
168 void activateGlobalPanning();
170 //! Clone the view window preserving a view point of the current view
173 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
197 //! Reset point of view
200 void windowActivated();
202 void windowDeactivated();
205 virtual void changeEvent(QEvent* theEvent);
207 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
209 virtual void showEvent(QShowEvent* theEvent);
211 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
218 void updateToolBar();
219 // void repaintToolBar();
229 bool processWindowControls(QObject *theObj, QEvent *theEvent);
230 bool processViewPort(QEvent *theEvent);
232 void vpMousePressEvent(QMouseEvent* theEvent);
233 void vpMouseReleaseEvent(QMouseEvent* theEvent);
234 void vpMouseMoveEvent(QMouseEvent* theEvent);
236 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
242 bool transformRequested() const;
243 bool setTransformRequested(OperationType);
245 // Transformation is selected and already started
246 bool transformInProcess() const
248 return myEventStarted;
250 void setTransformInProcess(bool bOn)
252 myEventStarted = bOn;
256 XGUI_Viewer* myViewer;
259 ViewerLabel* myGripWgt;
260 XGUI_ViewPort* myViewPort;
261 ViewerToolbar* myViewBar;
262 ViewerToolbar* myWindowBar;
263 QAction* myMinimizeBtn;
264 QAction* myMaximizeBtn;
274 WindowState myLastState;
281 XGUI::InteractionStyle myInteractionStyle;
282 OperationType myOperation;
283 XGUI::Mode2dType my2dMode;
286 bool myDrawRect; // set when a rect is used for selection or magnify
287 bool myEnableDrawMode;
288 bool myRotationPointSelection;
291 bool myEventStarted; // set when transformation is in process
297 XGUI::RotationPointType myCurrPointType;
298 XGUI::RotationPointType myPrevPointType;
300 gp_Pnt mySelectedPoint;
302 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
304 typedef QMap<OperationType, bool> MapOfTransformStatus;
305 MapOfTransformStatus myStatus;
310 //******************************************************
314 \brief Provides a toolbar widget with treansparent background over OCCT View window
316 class ViewerToolbar : public QToolBar
320 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
323 void onViewPortResized()
329 virtual void paintEvent(QPaintEvent* theEvent);
332 XGUI_ViewPort* myVPort;
336 //******************************************************
340 \brief Provides a Label widget with treansparent background over OCCT View window
342 class ViewerLabel : public QLabel
346 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
349 void onViewPortResized()
355 virtual void paintEvent(QPaintEvent* theEvent);
358 XGUI_ViewPort* myVPort;