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);
203 void updateToolBar();
204 // void repaintToolBar();
214 bool processWindowControls(QObject *theObj, QEvent *theEvent);
215 bool processViewPort(QEvent *theEvent);
217 void vpMousePressEvent(QMouseEvent* theEvent);
218 void vpMouseReleaseEvent(QMouseEvent* theEvent);
219 void vpMouseMoveEvent(QMouseEvent* theEvent);
221 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
227 bool transformRequested() const;
228 bool setTransformRequested(OperationType);
230 // Transformation is selected and already started
231 bool transformInProcess() const
233 return myEventStarted;
235 void setTransformInProcess(bool bOn)
237 myEventStarted = bOn;
241 XGUI_Viewer* myViewer;
244 ViewerLabel* myGripWgt;
245 XGUI_ViewPort* myViewPort;
246 ViewerToolbar* myViewBar;
247 ViewerToolbar* myWindowBar;
248 QAction* myMinimizeBtn;
249 QAction* myMaximizeBtn;
259 WindowState myLastState;
266 XGUI::InteractionStyle myInteractionStyle;
267 OperationType myOperation;
268 XGUI::Mode2dType my2dMode;
271 bool myDrawRect; // set when a rect is used for selection or magnify
272 bool myEnableDrawMode;
273 bool myRotationPointSelection;
276 bool myEventStarted; // set when transformation is in process
282 XGUI::RotationPointType myCurrPointType;
283 XGUI::RotationPointType myPrevPointType;
285 gp_Pnt mySelectedPoint;
287 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
289 typedef QMap<OperationType, bool> MapOfTransformStatus;
290 MapOfTransformStatus myStatus;
295 //******************************************************
299 \brief Provides a toolbar widget with treansparent background over OCCT View window
301 class ViewerToolbar: public QToolBar
305 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
308 void onViewPortResized() { myResize = true; }
311 virtual void paintEvent(QPaintEvent* theEvent);
316 XGUI_ViewPort* myVPort;
320 //******************************************************
324 \brief Provides a Label widget with treansparent background over OCCT View window
326 class ViewerLabel: public QLabel
330 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
333 void onViewPortResized() { myResize = true; }
336 virtual void paintEvent(QPaintEvent* theEvent);
339 XGUI_ViewPort* myVPort;