1 // File: GLViewer_Viewer.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 /***************************************************************************
7 ** Class: GLViewer_Viewer
8 ** Descr: Viewer for QAD-based application
10 ** Created: UI team, 05.09.00
11 ****************************************************************************/
12 #ifndef GLVIEWER_VIEWER_H
13 #define GLVIEWER_VIEWER_H
15 #include "GLViewer_Defs.h"
16 #include "GLViewer_ViewFrame.h"
17 #include <SUIT_ViewModel.h>
24 class GLViewer_Selector;
25 class GLViewer_ViewSketcher;
26 class GLViewer_ViewTransformer;
29 class SUIT_ViewWindow;
32 #pragma warning( disable:4251 )
35 class GLVIEWER_EXPORT GLViewer_Viewer: public SUIT_ViewModel
40 enum SelectionMode { NoSelection, Single, Multiple };
41 enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
42 Zoom, PanGlobal, Pan, Rotate, UserTransform = 100 };
43 enum SketchingType { NoSketching, Rect, UserSketching = 100 };
46 GLViewer_Viewer( const QString& title );
50 virtual void setViewManager( SUIT_ViewManager* theViewManager );
51 virtual QString getType() const { return Type(); }
52 static QString Type() { return "GLViewer_ViewModel"; }
55 void setSelectionMode( SelectionMode );
56 SelectionMode getSelectionMode() const;
57 GLViewer_Selector* getSelector() const;
59 virtual void update( int = 0 );
61 void activateTransform( int );
62 void activateSketching( int );
64 GLViewer_ViewFrame* getActiveView() const;
67 void selectionChanged( SelectionChangeStatus );
70 virtual void onSketchingStarted();
71 virtual void onSketchingFinished();
72 virtual void onTransformationStarted();
73 virtual void onTransformationFinished();
74 virtual void onSelectionModeChanged();
76 virtual void unhilightDetected();
77 virtual bool eventFilter( QObject*, QEvent* );
79 /* virtual constructors */
80 virtual GLViewer_ViewTransformer* createTransformer( int );
81 virtual GLViewer_ViewSketcher* createSketcher( int );
82 virtual GLViewer_Selector* createSelector();
84 virtual void startOperations( QMouseEvent* ) {}
85 virtual bool updateOperations( QMouseEvent* ) { return false; }
86 virtual void finishOperations( QMouseEvent* ) {}
87 virtual void startOperations( QWheelEvent* ) {}
90 virtual void onKeyEvent( SUIT_ViewWindow*, QKeyEvent* );
91 virtual void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
92 virtual void onWheelEvent( SUIT_ViewWindow*, QWheelEvent* );
94 virtual void onSelectionCancel();
95 virtual void onSelectionDone( bool add, SelectionChangeStatus status );
98 void handleMouseMove( QMouseEvent* );
99 void handleMousePress( QMouseEvent* );
100 void handleMouseRelease( QMouseEvent* );
101 void handleWheel( QWheelEvent* );
104 GLViewer_Selector* mySelector; /* selector */
105 SelectionMode mySelMode; /* current selection mode */
106 GLViewer_ViewSketcher* mySketcher; /* sketch manipulator */
107 GLViewer_ViewTransformer* myTransformer; /* transform manipulator */
110 /****************************************************************
111 ** Class: GLViewer_ViewTransformer
113 *****************************************************************/
114 class GLVIEWER_EXPORT GLViewer_ViewTransformer : public QObject
117 GLViewer_ViewTransformer( GLViewer_Viewer*, int type );
118 ~GLViewer_ViewTransformer();
121 /*! Returns transformer type */
124 /*! Sets/returns acceleration key ( CTRL by default ) */
125 static int accelKey() { return acccelKey; }
126 static void setAccelKey( int k ) { acccelKey = k; }
128 /*! Sets/returns mouse button used for zooming ( MB1 by default ) */
129 static int zoomButton() { return zoomBtn; }
130 static void setZoomButton( int b ) { zoomBtn = b; }
132 /*! Sets/returns mouse button used for panning ( MB2 by default ) */
133 static int panButton() { return panBtn; }
134 static void setPanButton( int b ) { panBtn = b; }
136 /*! Sets/returns mouse button used for global pan ( MB1 by default ) */
137 static int panGlobalButton() { return panGlobalBtn; }
138 static void setPanGlobalButton( int b ) { panGlobalBtn = b; }
140 /*! Sets/returns mouse button used for fit area ( MB1 by default ) */
141 static int fitRectButton() { return fitRectBtn; }
142 static void setFitRectButton( int b ) { fitRectBtn = b; }
145 virtual bool eventFilter( QObject*, QEvent* );
148 enum TransformState { Debut, EnTrain, Fin };
149 virtual void onTransform( TransformState );
150 void initTransform( bool );
155 static int fitRectBtn;
156 static int panGlobalBtn;
158 static int acccelKey;
160 GLViewer_Viewer* myViewer;
162 QCursor mySavedCursor;
163 bool mySavedMouseTrack;
164 QPoint myStart, myCurr;
170 /****************************************************************
171 ** Class: GLViewer_ViewSketcher
173 *****************************************************************/
174 class GLVIEWER_EXPORT GLViewer_ViewSketcher : public QObject
177 GLViewer_ViewSketcher( GLViewer_Viewer*, int type );
178 ~GLViewer_ViewSketcher();
181 /*! Returns sketcher type */
182 int type() const { return myType; }
184 /*! Returns result of sketching */
185 void* data() const { return myData; }
187 /*! Returns current state of mouse/sys kbd buttons */
188 int buttonState() const { return myButtonState; }
190 /*! Sets/returns mouse button used for sketching ( MB1 by default ) */
191 static int sketchButton() { return sketchBtn; }
192 static void setSketchButton( int b ) { sketchBtn = b; }
194 virtual bool eventFilter( QObject*, QEvent* );
197 enum SketchState { Debut, EnTrain, Fin };
198 virtual void onSketch( SketchState );
201 static int sketchBtn;
202 GLViewer_Viewer* myViewer;
205 QCursor mySavedCursor;
206 QPoint myStart, myCurr;
211 #pragma warning ( default:4251 )