1 #ifndef XGUI_ViewWindow_H
2 #define XGUI_ViewWindow_H
4 #include "XGUI_Constants.h"
5 #include "XGUI_ViewBackground.h"
13 #include <V3d_View.hxx>
14 #include <V3d_Viewer.hxx>
20 class XGUI_RectRubberBand;
24 \class XGUI_ViewWindow
26 \brief Implements a one view window of 3d viewer object.
27 It contains a view port object (drawing area) and toolbars for view camera and window management.
28 Also it managements events in view port
30 class XGUI_ViewWindow: public QFrame
34 //! Types of viewer operations
55 XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType);
57 virtual ~XGUI_ViewWindow();
59 //! Returns view port object
60 XGUI_ViewPort* viewPort() const
65 //! Retrurns current interaction style
66 XGUI::InteractionStyle interactionStyle() const
68 return myInteractionStyle;
71 //! Disable or enable given operation type
72 void setTransformEnabled(const OperationType, const bool);
74 //! Returns true if the given operation type is enabled
75 bool transformEnabled(const OperationType) const;
77 //! Returns View background object
78 XGUI_ViewBackground background() const;
80 //! Sets View background object
81 void setBackground(const XGUI_ViewBackground& theBackground);
83 //! Returns true if the current view window can be closed
84 bool closable() const { return myClosable; }
86 //! Sets the current view window closable or not
87 void setClosable( const bool isClosable ) { myClosable = isClosable; }
90 //! Emited whien view transformation operation is started
91 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
93 //! Emited whien view transformation operation is finished
94 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
96 //void Show(QShowEvent *);
97 //void Hide(QHideEvent *);
98 //void maximized(XGUI_ViewWindow*, bool);
99 //void returnedTo3d();
101 //! Emited before the window closing
102 void tryClosing(XGUI_ViewWindow*);
104 //! Emited when window is closing
105 void closed( QMdiSubWindow* );
107 //! Emited on mouse press in view port
108 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
110 //! Emited on mouse release in view port
111 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
113 //! Emited on mouse double click in view port
114 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
116 //! Emited on mouse moving in view port
117 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
119 //! Emited on key press in view port
120 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
122 //! Emited on key release in view port
123 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
125 //! Emited on context menu request in view port
126 void contextMenuRequested(QContextMenuEvent *e);
128 //void viewModified(XGUI_ViewWindow*);
129 void viewCloned( QMdiSubWindow* theView );
132 //! Start zooming operation
135 //! Start rotation operation
136 void activateRotation();
138 //! Start panning operation
139 void activatePanning();
141 //! Start window fit operation
142 void activateWindowFit();
144 //! Start global panning operation
145 void activateGlobalPanning();
147 //! Clone the view window preserving a view point of the current view
150 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
174 //! Reset point of view
179 virtual void resizeEvent(QResizeEvent* theEvent);
181 virtual void changeEvent(QEvent* theEvent);
183 virtual void enterEvent(QEvent* theEvent);
184 virtual void leaveEvent(QEvent* theEvent);
186 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
193 void updateToolBar();
194 // void repaintToolBar();
199 MinimizedState, MaximizedState, NormalState
202 bool processWindowControls(QObject *theObj, QEvent *theEvent);
203 bool processViewPort(QEvent *theEvent);
205 void vpMousePressEvent(QMouseEvent* theEvent);
206 void vpMouseReleaseEvent(QMouseEvent* theEvent);
207 void vpMouseMoveEvent(QMouseEvent* theEvent);
209 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
215 bool transformRequested() const;
216 bool setTransformRequested(OperationType);
218 // Transformation is selected and already started
219 bool transformInProcess() const
221 return myEventStarted;
223 void setTransformInProcess(bool bOn)
225 myEventStarted = bOn;
229 XGUI_Viewer* myViewer;
232 ViewerLabel* myGripWgt;
233 XGUI_ViewPort* myViewPort;
234 ViewerToolbar* myViewBar;
235 ViewerToolbar* myWindowBar;
236 QAction* myMinimizeBtn;
237 QAction* myMaximizeBtn;
247 WindowState myLastState;
254 XGUI::InteractionStyle myInteractionStyle;
255 OperationType myOperation;
256 XGUI::Mode2dType my2dMode;
259 bool myDrawRect; // set when a rect is used for selection or magnify
260 bool myEnableDrawMode;
261 bool myRotationPointSelection;
264 bool myEventStarted; // set when transformation is in process
269 XGUI::RotationPointType myCurrPointType;
270 XGUI::RotationPointType myPrevPointType;
272 gp_Pnt mySelectedPoint;
274 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
276 typedef QMap<OperationType, bool> MapOfTransformStatus;
277 MapOfTransformStatus myStatus;
282 //******************************************************
286 \brief Provides a toolbar widget with treansparent background over OCCT View window
288 class ViewerToolbar: public QToolBar
292 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
293 : QToolBar(theParent), myVPort(thePort)
295 setBackgroundRole(QPalette::NoRole);
296 setAttribute(Qt::WA_NoSystemBackground);
297 setAttribute(Qt::WA_PaintOnScreen);
300 void repaintBackground();
303 virtual void paintEvent(QPaintEvent* theEvent);
306 XGUI_ViewPort* myVPort;
309 //******************************************************
313 \brief Provides a Label widget with treansparent background over OCCT View window
315 class ViewerLabel: public QLabel
319 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
320 : QLabel(theParent), myVPort(thePort)
322 setAttribute(Qt::WA_NoSystemBackground);
325 void repaintBackground();
328 virtual void paintEvent(QPaintEvent* theEvent);
331 XGUI_ViewPort* myVPort;