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; }
91 //! Emited whien view transformation operation is started
92 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
94 //! Emited whien view transformation operation is finished
95 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
97 //void Show(QShowEvent *);
98 //void Hide(QHideEvent *);
99 //void maximized(XGUI_ViewWindow*, bool);
100 //void returnedTo3d();
102 //! Emited before the window closing
103 void tryClosing(XGUI_ViewWindow*);
105 //! Emited when window is closing
106 void closed( QMdiSubWindow* );
108 //! Emited on mouse press in view port
109 void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
111 //! Emited on mouse release in view port
112 void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
114 //! Emited on mouse double click in view port
115 void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
117 //! Emited on mouse moving in view port
118 void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
120 //! Emited on key press in view port
121 void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
123 //! Emited on key release in view port
124 void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
126 //! Emited on context menu request in view port
127 void contextMenuRequested(QContextMenuEvent *e);
129 //void viewModified(XGUI_ViewWindow*);
130 void viewCloned( QMdiSubWindow* theView );
133 //! Start zooming operation
136 //! Start rotation operation
137 void activateRotation();
139 //! Start panning operation
140 void activatePanning();
142 //! Start window fit operation
143 void activateWindowFit();
145 //! Start global panning operation
146 void activateGlobalPanning();
148 //! Clone the view window preserving a view point of the current view
151 //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
175 //! Reset point of view
178 void windowActivated();
180 void windowDeactivated();
183 virtual void resizeEvent(QResizeEvent* theEvent);
185 virtual void changeEvent(QEvent* theEvent);
187 //virtual void enterEvent(QEvent* theEvent);
188 //virtual void leaveEvent(QEvent* theEvent);
190 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
197 void updateToolBar();
198 // void repaintToolBar();
208 bool processWindowControls(QObject *theObj, QEvent *theEvent);
209 bool processViewPort(QEvent *theEvent);
211 void vpMousePressEvent(QMouseEvent* theEvent);
212 void vpMouseReleaseEvent(QMouseEvent* theEvent);
213 void vpMouseMoveEvent(QMouseEvent* theEvent);
215 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
221 bool transformRequested() const;
222 bool setTransformRequested(OperationType);
224 // Transformation is selected and already started
225 bool transformInProcess() const
227 return myEventStarted;
229 void setTransformInProcess(bool bOn)
231 myEventStarted = bOn;
235 XGUI_Viewer* myViewer;
238 ViewerLabel* myGripWgt;
239 XGUI_ViewPort* myViewPort;
240 ViewerToolbar* myViewBar;
241 ViewerToolbar* myWindowBar;
242 QAction* myMinimizeBtn;
243 QAction* myMaximizeBtn;
253 WindowState myLastState;
260 XGUI::InteractionStyle myInteractionStyle;
261 OperationType myOperation;
262 XGUI::Mode2dType my2dMode;
265 bool myDrawRect; // set when a rect is used for selection or magnify
266 bool myEnableDrawMode;
267 bool myRotationPointSelection;
270 bool myEventStarted; // set when transformation is in process
275 XGUI::RotationPointType myCurrPointType;
276 XGUI::RotationPointType myPrevPointType;
278 gp_Pnt mySelectedPoint;
280 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
282 typedef QMap<OperationType, bool> MapOfTransformStatus;
283 MapOfTransformStatus myStatus;
288 //******************************************************
292 \brief Provides a toolbar widget with treansparent background over OCCT View window
294 class ViewerToolbar: public QToolBar
298 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
299 : QToolBar(theParent), myVPort(thePort)
301 setBackgroundRole(QPalette::NoRole);
302 setAttribute(Qt::WA_NoSystemBackground);
303 setAttribute(Qt::WA_PaintOnScreen);
307 virtual void paintEvent(QPaintEvent* theEvent);
310 XGUI_ViewPort* myVPort;
313 //******************************************************
317 \brief Provides a Label widget with treansparent background over OCCT View window
319 class ViewerLabel: public QLabel
323 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
324 : QLabel(theParent), myVPort(thePort)
326 setAttribute(Qt::WA_NoSystemBackground);
329 void repaintBackground();
332 virtual void paintEvent(QPaintEvent* theEvent);
335 XGUI_ViewPort* myVPort;