1 #ifndef XGUI_ViewWindow_H
2 #define XGUI_ViewWindow_H
5 #include "XGUI_Constants.h"
7 #include <ModuleBase_IViewWindow.h>
17 //#include <V3d_View.hxx>
18 //#include <V3d_Viewer.hxx>
24 class XGUI_RectRubberBand;
28 \class XGUI_ViewWindow
30 \brief Implements a one view window of 3d viewer object.
31 It contains a view port object (drawing area) and toolbars for view camera and window management.
32 Also it managements events in view port
34 class XGUI_EXPORT XGUI_ViewWindow : public QFrame, public ModuleBase_IViewWindow
38 //! Types of viewer operations
59 XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType);
61 virtual ~XGUI_ViewWindow();
63 //! Returns view port object
64 XGUI_ViewPort* viewPort() const
69 //! Retrurns current interaction style
70 XGUI::InteractionStyle interactionStyle() const
72 return myInteractionStyle;
75 //! Disable or enable given operation type
76 void setTransformEnabled(const OperationType, const bool);
78 //! Returns true if the given operation type is enabled
79 bool transformEnabled(const OperationType) const;
81 //! Returns View background object
82 Qtx::BackgroundData background() const;
84 //! Sets View background object
85 void setBackground(const Qtx::BackgroundData& theBackground);
87 //! Returns true if the current view window can be closed
93 //! Sets the current view window closable or not
94 void setClosable(const bool isClosable)
96 myClosable = isClosable;
99 //! Enable/Disable drawing of ribbon line
100 void enableDrawMode(bool toEnable)
102 myEnableDrawMode = toEnable;
105 //! Returns true if ribbon line drawing enabled
106 bool isDrawModeEnabled() const
108 return myEnableDrawMode;
111 //! Updates drawing mode in the view window
112 void updateEnabledDrawMode();
114 /// Returns OCCT object which contains 3d view object
115 virtual Handle(V3d_View) v3dView() const;
118 //! Emited whien view transformation operation is started
119 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
121 //! Emited whien view transformation operation is finished
122 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
124 //void Show(QShowEvent *);
125 //void Hide(QHideEvent *);
126 //void maximized(XGUI_ViewWindow*, bool);
127 //void returnedTo3d();
129 //! Emited before the window closing
130 void tryClosing(XGUI_ViewWindow*);
132 //! Emited when window is closing
133 void closed(QMdiSubWindow*);
135 //! Emited on mouse press in view port
136 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
138 //! Emited on mouse release in view port
139 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
141 //! Emited on mouse double click in view port
142 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
144 //! Emited on mouse moving in view port
145 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
147 //! Emited on key press in view port
148 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
150 //! Emited on key release in view port
151 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
153 //! Emited on context menu request in view port
154 void contextMenuRequested(QContextMenuEvent *e);
156 //void viewModified(XGUI_ViewWindow*);
157 void viewCloned(QMdiSubWindow* theView);
160 //! Start zooming operation
163 //! Start rotation operation
164 void activateRotation();
166 //! Start panning operation
167 void activatePanning();
169 //! Start window fit operation
170 void activateWindowFit();
172 //! Start global panning operation
173 void activateGlobalPanning();
175 //! Clone the view window preserving a view point of the current view
178 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
202 //! Reset point of view
205 void windowActivated();
207 void windowDeactivated();
210 virtual void changeEvent(QEvent* theEvent);
212 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
214 virtual void showEvent(QShowEvent* theEvent);
216 virtual void contextMenuEvent(QContextMenuEvent* theEvent);
223 void updateToolBar();
224 // void repaintToolBar();
234 bool processWindowControls(QObject *theObj, QEvent *theEvent);
235 bool processViewPort(QEvent *theEvent);
237 void vpMousePressEvent(QMouseEvent* theEvent);
238 void vpMouseReleaseEvent(QMouseEvent* theEvent);
239 void vpMouseMoveEvent(QMouseEvent* theEvent);
241 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
247 bool transformRequested() const;
248 bool setTransformRequested(OperationType);
250 // Transformation is selected and already started
251 bool transformInProcess() const
253 return myEventStarted;
255 void setTransformInProcess(bool bOn)
257 myEventStarted = bOn;
261 XGUI_Viewer* myViewer;
264 ViewerLabel* myGripWgt;
265 XGUI_ViewPort* myViewPort;
266 ViewerToolbar* myViewBar;
267 ViewerToolbar* myWindowBar;
268 QAction* myMinimizeBtn;
269 QAction* myMaximizeBtn;
279 WindowState myLastState;
286 XGUI::InteractionStyle myInteractionStyle;
287 OperationType myOperation;
288 XGUI::Mode2dType my2dMode;
291 bool myDrawRect; // set when a rect is used for selection or magnify
292 bool myEnableDrawMode;
293 bool myRotationPointSelection;
296 bool myEventStarted; // set when transformation is in process
302 XGUI::RotationPointType myCurrPointType;
303 XGUI::RotationPointType myPrevPointType;
305 gp_Pnt mySelectedPoint;
307 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
309 typedef QMap<OperationType, bool> MapOfTransformStatus;
310 MapOfTransformStatus myStatus;
315 //******************************************************
319 \brief Provides a toolbar widget with treansparent background over OCCT View window
321 class ViewerToolbar : public QToolBar
325 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
328 void onViewPortResized()
334 virtual void paintEvent(QPaintEvent* theEvent);
337 XGUI_ViewPort* myVPort;
341 //******************************************************
345 \brief Provides a Label widget with treansparent background over OCCT View window
347 class ViewerLabel : public QLabel
351 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
354 void onViewPortResized()
360 virtual void paintEvent(QPaintEvent* theEvent);
363 XGUI_ViewPort* myVPort;