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;
23 class XGUI_ViewWindow : public QFrame
27 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
28 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
29 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
30 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
32 XGUI_ViewWindow(XGUI_Viewer* theViewer,
33 V3d_TypeOfView theType);
35 virtual ~XGUI_ViewWindow();
37 XGUI_ViewPort* viewPort() const { return myViewPort; }
40 XGUI::InteractionStyle interactionStyle() const { return myInteractionStyle; }
42 void setTransformEnabled( const OperationType, const bool );
43 bool transformEnabled( const OperationType ) const;
45 XGUI_ViewBackground background() const;
46 void setBackground( const XGUI_ViewBackground& theBackground );
48 bool closable() const { return myClosable; }
49 void setClosable( const bool isClosable ) { myClosable = isClosable; }
52 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
53 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
55 void Show( QShowEvent * );
56 void Hide( QHideEvent * );
57 void maximized( XGUI_ViewWindow*, bool );
61 void tryClosing( XGUI_ViewWindow* );
62 void closed( QMdiSubWindow* );
63 void mousePressed( XGUI_ViewWindow*, QMouseEvent* );
64 void mouseReleased( XGUI_ViewWindow*, QMouseEvent* );
65 void mouseDoubleClicked( XGUI_ViewWindow*, QMouseEvent* );
66 void mouseMoving( XGUI_ViewWindow*, QMouseEvent* );
67 void keyPressed( XGUI_ViewWindow*, QKeyEvent* );
68 void keyReleased( XGUI_ViewWindow*, QKeyEvent* );
69 void contextMenuRequested( QContextMenuEvent *e );
71 void viewModified( XGUI_ViewWindow* );
72 void viewCloned( QMdiSubWindow* theView );
76 void activateRotation();
77 void activatePanning();
78 void activateWindowFit();
79 void activateGlobalPanning();
93 virtual void resizeEvent(QResizeEvent* theEvent);
95 virtual void changeEvent(QEvent* theEvent);
97 virtual void enterEvent(QEvent* theEvent);
98 virtual void leaveEvent(QEvent* theEvent);
100 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
108 enum WindowState { MinimizedState, MaximizedState, NormalState };
110 bool processWindowControls(QObject *theObj, QEvent *theEvent);
111 bool processViewPort(QEvent *theEvent);
113 void vpMousePressEvent(QMouseEvent* theEvent);
114 void vpMouseReleaseEvent(QMouseEvent* theEvent);
115 void vpMouseMoveEvent(QMouseEvent* theEvent);
117 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
123 bool transformRequested() const;
124 bool setTransformRequested ( OperationType );
126 // Transformation is selected and already started
127 bool transformInProcess() const { return myEventStarted; }
128 void setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
131 XGUI_Viewer* myViewer;
134 ViewerLabel* myGripWgt;
135 XGUI_ViewPort* myViewPort;
136 ViewerToolbar* myViewBar;
137 ViewerToolbar* myWindowBar;
138 QAction* myMinimizeBtn;
139 QAction* myMaximizeBtn;
149 WindowState myLastState;
156 XGUI::InteractionStyle myInteractionStyle;
157 OperationType myOperation;
158 XGUI::Mode2dType my2dMode;
161 bool myDrawRect; // set when a rect is used for selection or magnify
162 bool myEnableDrawMode;
163 bool myRotationPointSelection;
166 bool myEventStarted; // set when transformation is in process
171 XGUI::RotationPointType myCurrPointType;
172 XGUI::RotationPointType myPrevPointType;
174 gp_Pnt mySelectedPoint;
176 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
178 typedef QMap<OperationType, bool> MapOfTransformStatus;
179 MapOfTransformStatus myStatus;
185 //******************************************************
186 class ViewerToolbar : public QToolBar
190 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort) :
191 QToolBar(theParent), myVPort(thePort) {}
194 virtual void paintEvent( QPaintEvent* theEvent);
197 XGUI_ViewPort* myVPort;
200 //******************************************************
201 class ViewerLabel : public QLabel
205 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort) :
206 QLabel(theParent), myVPort(thePort) {}
209 virtual void paintEvent( QPaintEvent* theEvent);
212 XGUI_ViewPort* myVPort;