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_API 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"; }
54 virtual void contextMenuPopup( QPopupMenu* );
57 void setSelectionMode( SelectionMode );
58 SelectionMode getSelectionMode() const;
59 GLViewer_Selector* getSelector() const;
61 virtual void update( int = 0 );
63 void activateTransform( int );
64 void activateSketching( int );
66 GLViewer_ViewFrame* getActiveView() const;
69 void selectionChanged( SelectionChangeStatus );
72 virtual void onSketchingStarted();
73 virtual void onSketchingFinished();
74 virtual void onTransformationStarted();
75 virtual void onTransformationFinished();
76 virtual void onSelectionModeChanged();
78 virtual void unhilightDetected();
79 virtual bool eventFilter( QObject*, QEvent* );
81 /* virtual constructors */
82 virtual GLViewer_ViewTransformer* createTransformer( int );
83 virtual GLViewer_ViewSketcher* createSketcher( int );
84 virtual GLViewer_Selector* createSelector();
86 virtual void startOperations( QMouseEvent* ) {}
87 virtual bool updateOperations( QMouseEvent* ) { return false; }
88 virtual void finishOperations( QMouseEvent* ) {}
89 virtual void startOperations( QWheelEvent* ) {}
92 virtual void onKeyEvent( SUIT_ViewWindow*, QKeyEvent* );
93 virtual void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
94 virtual void onWheelEvent( SUIT_ViewWindow*, QWheelEvent* );
96 virtual void onSelectionCancel();
97 virtual void onSelectionDone( bool add, SelectionChangeStatus status );
99 virtual void onChangeBgColor();
102 void handleMouseMove( QMouseEvent* );
103 void handleMousePress( QMouseEvent* );
104 void handleMouseRelease( QMouseEvent* );
105 void handleWheel( QWheelEvent* );
108 GLViewer_Selector* mySelector; /* selector */
109 SelectionMode mySelMode; /* current selection mode */
110 GLViewer_ViewSketcher* mySketcher; /* sketch manipulator */
111 GLViewer_ViewTransformer* myTransformer; /* transform manipulator */
114 /****************************************************************
115 ** Class: GLViewer_ViewTransformer
117 *****************************************************************/
118 class GLVIEWER_API GLViewer_ViewTransformer : public QObject
121 GLViewer_ViewTransformer( GLViewer_Viewer*, int type );
122 ~GLViewer_ViewTransformer();
125 /*! Returns transformer type */
128 /*! Sets/returns acceleration key ( CTRL by default ) */
129 static int accelKey() { return acccelKey; }
130 static void setAccelKey( int k ) { acccelKey = k; }
132 /*! Sets/returns mouse button used for zooming ( MB1 by default ) */
133 static int zoomButton() { return zoomBtn; }
134 static void setZoomButton( int b ) { zoomBtn = b; }
136 /*! Sets/returns mouse button used for panning ( MB2 by default ) */
137 static int panButton() { return panBtn; }
138 static void setPanButton( int b ) { panBtn = b; }
140 /*! Sets/returns mouse button used for global pan ( MB1 by default ) */
141 static int panGlobalButton() { return panGlobalBtn; }
142 static void setPanGlobalButton( int b ) { panGlobalBtn = b; }
144 /*! Sets/returns mouse button used for fit area ( MB1 by default ) */
145 static int fitRectButton() { return fitRectBtn; }
146 static void setFitRectButton( int b ) { fitRectBtn = b; }
149 virtual bool eventFilter( QObject*, QEvent* );
152 enum TransformState { Debut, EnTrain, Fin };
153 virtual void onTransform( TransformState );
154 void initTransform( bool );
159 static int fitRectBtn;
160 static int panGlobalBtn;
162 static int acccelKey;
164 GLViewer_Viewer* myViewer;
166 QCursor mySavedCursor;
167 bool mySavedMouseTrack;
168 QPoint myStart, myCurr;
174 /****************************************************************
175 ** Class: GLViewer_ViewSketcher
177 *****************************************************************/
178 class GLVIEWER_API GLViewer_ViewSketcher : public QObject
181 GLViewer_ViewSketcher( GLViewer_Viewer*, int type );
182 ~GLViewer_ViewSketcher();
185 /*! Returns sketcher type */
186 int type() const { return myType; }
188 /*! Returns result of sketching */
189 void* data() const { return myData; }
191 /*! Returns current state of mouse/sys kbd buttons */
192 int buttonState() const { return myButtonState; }
194 /*! Sets/returns mouse button used for sketching ( MB1 by default ) */
195 static int sketchButton() { return sketchBtn; }
196 static void setSketchButton( int b ) { sketchBtn = b; }
198 virtual bool eventFilter( QObject*, QEvent* );
201 enum SketchState { Debut, EnTrain, Fin };
202 virtual void onSketch( SketchState );
205 static int sketchBtn;
206 GLViewer_Viewer* myViewer;
209 QCursor mySavedCursor;
210 QPoint myStart, myCurr;
215 #pragma warning ( default:4251 )