1 // File: GLViewer_ViewPort.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 /***************************************************************************
7 ** Class: GLViewer_ViewPort
8 ** Descr: Visualisation canvas of GLViewer
9 ** Created: UI team, 05.09.04
10 ****************************************************************************/
11 #ifndef GLVIEWER_VIEWPORT_H
12 #define GLVIEWER_VIEWPORT_H
21 #include <Aspect_Window.hxx>
26 class GLViewer_ViewSketcher;
27 class GLViewer_ViewTransformer;
30 #pragma warning( disable:4251 )
36 BS_Highlighting = 0x0001,
37 BS_Selection = 0x0002,
42 * Class GLViewer_ViewPort
43 * Visualisation canvas of GLViewer
45 class GLVIEWER_API GLViewer_ViewPort: public QWidget
48 friend class GLViewer_ViewSketcher;
49 friend class GLViewer_ViewTransformer;
52 GLViewer_ViewPort( QWidget* parent );
56 //! Activates/deactivates sketching
57 void setSketchingEnabled( bool );
58 //! Checks active status of sketcher
59 bool isSketchingEnabled() const;
60 //! Activates/deactivates transformer
61 void setTransformEnabled( bool );
62 //! Checks active status of transformer
63 bool isTransformEnabled() const;
65 //! Returns background color
66 virtual QColor backgroundColor() const;
67 //! Sets background color
68 virtual void setBackgroundColor( const QColor& );
70 //! Redraw external pa inters
71 void redrawPainters();
74 virtual void onUpdate();
76 //! Returns blocking status for current started operations
77 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
80 enum ViewType { Type2D, Type3D };
81 void selectVisualId( ViewType );
83 virtual QPaintDevice* getPaintDevice() { return this; }
84 virtual void contextMenuEvent( QContextMenuEvent * e );
87 static void createCursors();
88 static void destroyCursors();
89 static QCursor* getHandCursor() { return handCursor; }
90 static void setHandCursor( const QCursor& newCursor );
91 static QCursor* getPanCursor() { return panCursor; }
92 static void setPanCursor( const QCursor& newCursor );
93 static QCursor* getPanglCursor() { return panglCursor; }
94 static void setPanglCursor( const QCursor& newCursor );
95 static QCursor* getZoomCursor() { return zoomCursor; }
96 static void setZoomCursor( const QCursor& newCursor );
99 static QCursor* getDefaultCursor() { return defCursor; }
100 static void setDefaultCursor( const QCursor& newCursor );
101 static QCursor* getRotCursor() { return rotCursor; }
102 static void setRotCursor( const QCursor& newCursor );
103 static QCursor* getSketchCursor() { return sketchCursor; }
104 static void setSketchCursor( const QCursor& newCursor );
108 virtual void paintEvent( QPaintEvent *);
109 virtual void mouseMoveEvent( QMouseEvent *);
110 virtual void mouseReleaseEvent( QMouseEvent *);
111 virtual void mousePressEvent( QMouseEvent *);
112 virtual void mouseDoubleClickEvent( QMouseEvent *);
113 virtual void keyPressEvent( QKeyEvent *);
114 virtual void keyReleaseEvent( QKeyEvent *);
115 virtual void wheelEvent( QWheelEvent *);
118 virtual void reset() = 0;
119 virtual void pan( int, int ) = 0;
120 virtual void setCenter( int, int ) = 0;
121 virtual void zoom( int, int, int, int ) = 0;
122 virtual void fitRect( const QRect& ) = 0;
123 virtual void fitSelect() = 0;
124 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
127 virtual void onChangeBgColor();
130 void vpKeyEvent( QKeyEvent* );
131 void vpMouseEvent( QMouseEvent* );
132 void vpWheelEvent( QWheelEvent* );
133 void vpDrawExternal( QPainter* );
135 void contextMenuRequested( QContextMenuEvent* );
142 //Handle(Aspect_Window) myWindow;
143 bool myEnableSketching;
144 bool myEnableTransform;
145 bool myPaintersRedrawing; /* set to draw externally */
146 //QList<QAction> myPopupActions;
149 static int nCounter; /* objects counter */
150 static QCursor* defCursor;
151 static QCursor* panglCursor;
152 static QCursor* handCursor;
153 static QCursor* panCursor;
154 static QCursor* zoomCursor;
155 static QCursor* rotCursor;
156 static QCursor* sketchCursor;
160 #pragma warning ( default:4251 )