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;
22 class XGUI_ViewWindow : public QFrame
26 enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
27 PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
28 FRONTVIEW, BACKVIEW, TOPVIEW, BOTTOMVIEW, LEFTVIEW, RIGHTVIEW,
29 CLOCKWISEVIEW, ANTICLOCKWISEVIEW };
31 XGUI_ViewWindow(XGUI_Viewer* theViewer,
32 V3d_TypeOfView theType);
34 virtual ~XGUI_ViewWindow();
36 XGUI_ViewPort* viewPort() const { return myViewPort; }
39 XGUI::InteractionStyle interactionStyle() const { return myInteractionStyle; }
41 void setTransformEnabled( const OperationType, const bool );
42 bool transformEnabled( const OperationType ) const;
44 XGUI_ViewBackground background() const;
45 void setBackground( const XGUI_ViewBackground& theBackground );
48 void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
49 void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
50 //void viewCloned( XGUI_ViewWindow* );
52 void Show( QShowEvent * );
53 void Hide( QHideEvent * );
54 void maximized( XGUI_ViewWindow*, bool );
58 void tryClosing( XGUI_ViewWindow* );
59 void closing( XGUI_ViewWindow* );
60 void mousePressed( XGUI_ViewWindow*, QMouseEvent* );
61 void mouseReleased( XGUI_ViewWindow*, QMouseEvent* );
62 void mouseDoubleClicked( XGUI_ViewWindow*, QMouseEvent* );
63 void mouseMoving( XGUI_ViewWindow*, QMouseEvent* );
64 void wheeling( XGUI_ViewWindow*, QWheelEvent* );
65 void keyPressed( XGUI_ViewWindow*, QKeyEvent* );
66 void keyReleased( XGUI_ViewWindow*, QKeyEvent* );
67 void contextMenuRequested( QContextMenuEvent *e );
68 void viewModified( XGUI_ViewWindow* );
72 void activateRotation();
73 void activatePanning();
76 virtual void resizeEvent(QResizeEvent* theEvent);
78 virtual void changeEvent(QEvent* theEvent);
80 virtual void enterEvent(QEvent* theEvent);
81 virtual void leaveEvent(QEvent* theEvent);
83 virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
91 enum WindowState { MinimizedState, MaximizedState, NormalState };
93 bool processWindowControls(QObject *theObj, QEvent *theEvent);
94 bool processViewPort(QEvent *theEvent);
96 void vpMousePressEvent(QMouseEvent* theEvent);
97 void vpMouseReleaseEvent(QMouseEvent* theEvent);
98 void vpMouseMoveEvent(QMouseEvent* theEvent);
100 OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
106 bool transformRequested() const;
107 bool setTransformRequested ( OperationType );
109 // Transformation is selected and already started
110 bool transformInProcess() const { return myEventStarted; }
111 void setTransformInProcess( bool bOn ) { myEventStarted = bOn; }
114 XGUI_Viewer* myViewer;
117 ViewerLabel* myGripWgt;
118 XGUI_ViewPort* myViewPort;
119 ViewerToolbar* myViewBar;
120 ViewerToolbar* myWindowBar;
121 QAction* myMinimizeBtn;
122 QAction* myMaximizeBtn;
132 WindowState myLastState;
139 XGUI::InteractionStyle myInteractionStyle;
140 OperationType myOperation;
141 XGUI::Mode2dType my2dMode;
144 bool myDrawRect; // set when a rect is used for selection or magnify
145 bool myEnableDrawMode;
146 bool myRotationPointSelection;
149 bool myEventStarted; // set when transformation is in process
153 XGUI::RotationPointType myCurrPointType;
154 XGUI::RotationPointType myPrevPointType;
156 gp_Pnt mySelectedPoint;
158 XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
160 typedef QMap<OperationType, bool> MapOfTransformStatus;
161 MapOfTransformStatus myStatus;
167 //******************************************************
168 class ViewerToolbar : public QToolBar
172 ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort) :
173 QToolBar(theParent), myVPort(thePort) {}
176 virtual void paintEvent( QPaintEvent* theEvent);
179 XGUI_ViewPort* myVPort;
182 //******************************************************
183 class ViewerLabel : public QLabel
187 ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort) :
188 QLabel(theParent), myVPort(thePort) {}
191 virtual void paintEvent( QPaintEvent* theEvent);
194 XGUI_ViewPort* myVPort;