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();
204 bool processWindowControls(QObject *theObj, QEvent *theEvent);
205 bool processViewPort(QEvent *theEvent);
207 void vpMousePressEvent(QMouseEvent* theEvent);
208 void vpMouseReleaseEvent(QMouseEvent* theEvent);
209 void vpMouseMoveEvent(QMouseEvent* theEvent);
211 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
217 bool transformRequested() const;
218 bool setTransformRequested(OperationType);
220 // Transformation is selected and already started
221 bool transformInProcess() const
223 return myEventStarted;
225 void setTransformInProcess(bool bOn)
227 myEventStarted = bOn;
231 XGUI_Viewer* myViewer;
234 ViewerLabel* myGripWgt;
235 XGUI_ViewPort* myViewPort;
236 ViewerToolbar* myViewBar;
237 ViewerToolbar* myWindowBar;
238 QAction* myMinimizeBtn;
239 QAction* myMaximizeBtn;
249 WindowState myLastState;
256 XGUI::InteractionStyle myInteractionStyle;
257 OperationType myOperation;
258 XGUI::Mode2dType my2dMode;
261 bool myDrawRect; // set when a rect is used for selection or magnify
262 bool myEnableDrawMode;
263 bool myRotationPointSelection;
266 bool myEventStarted; // set when transformation is in process
271 XGUI::RotationPointType myCurrPointType;
272 XGUI::RotationPointType myPrevPointType;
274 gp_Pnt mySelectedPoint;
276 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
278 typedef QMap<OperationType, bool> MapOfTransformStatus;
279 MapOfTransformStatus myStatus;
284 //******************************************************
288 \brief Provides a toolbar widget with treansparent background over OCCT View window
290 class ViewerToolbar: public QToolBar
294 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
295 : QToolBar(theParent), myVPort(thePort)
297 setBackgroundRole(QPalette::NoRole);
298 setAttribute(Qt::WA_NoSystemBackground);
299 setAttribute(Qt::WA_PaintOnScreen);
302 void repaintBackground();
305 virtual void paintEvent(QPaintEvent* theEvent);
308 XGUI_ViewPort* myVPort;
311 //******************************************************
315 \brief Provides a Label widget with treansparent background over OCCT View window
317 class ViewerLabel: public QLabel
321 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
322 : QLabel(theParent), myVPort(thePort)
324 setAttribute(Qt::WA_NoSystemBackground);
327 void repaintBackground();
330 virtual void paintEvent(QPaintEvent* theEvent);
333 XGUI_ViewPort* myVPort;