1 // File: GLViewer_ViewPort.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 /***************************************************************************
7 ** Class: GLViewer_ViewPort
8 ** Descr: Visualisation canvas of QAD-based application
10 ** Created: UI team, 05.09.00
11 ****************************************************************************/
12 #ifndef GLVIEWER_VIEWPORT_H
13 #define GLVIEWER_VIEWPORT_H
22 #include <Aspect_Window.hxx>
27 class GLViewer_ViewSketcher;
28 class GLViewer_ViewTransformer;
31 #pragma warning( disable:4251 )
37 BS_Highlighting = 0x0001,
38 BS_Selection = 0x0002,
42 class GLVIEWER_EXPORT GLViewer_ViewPort: public QWidget//, public QAD_PopupServer
45 friend class GLViewer_ViewSketcher;
46 friend class GLViewer_ViewTransformer;
49 GLViewer_ViewPort( QWidget* parent );
53 void setSketchingEnabled( bool );
54 bool isSketchingEnabled() const;
55 void setTransformEnabled( bool );
56 bool isTransformEnabled() const;
58 virtual QColor backgroundColor() const;
59 virtual void setBackgroundColor( const QColor& );
61 void redrawPainters();
63 virtual void onUpdate();
65 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
68 enum ViewType { Type2D, Type3D };
69 void selectVisualId( ViewType );
71 virtual QPaintDevice* getPaintDevice() { return this; }
72 virtual void contextMenuEvent( QContextMenuEvent * e );
75 static void createCursors();
76 static void destroyCursors();
77 static QCursor* getHandCursor() { return handCursor; }
78 static void setHandCursor( const QCursor& newCursor );
79 static QCursor* getPanCursor() { return panCursor; }
80 static void setPanCursor( const QCursor& newCursor );
81 static QCursor* getPanglCursor() { return panglCursor; }
82 static void setPanglCursor( const QCursor& newCursor );
83 static QCursor* getZoomCursor() { return zoomCursor; }
84 static void setZoomCursor( const QCursor& newCursor );
87 static QCursor* getDefaultCursor() { return defCursor; }
88 static void setDefaultCursor( const QCursor& newCursor );
89 static QCursor* getRotCursor() { return rotCursor; }
90 static void setRotCursor( const QCursor& newCursor );
91 static QCursor* getSketchCursor() { return sketchCursor; }
92 static void setSketchCursor( const QCursor& newCursor );
96 virtual void paintEvent( QPaintEvent *);
97 virtual void mouseMoveEvent( QMouseEvent *);
98 virtual void mouseReleaseEvent( QMouseEvent *);
99 virtual void mousePressEvent( QMouseEvent *);
100 virtual void mouseDoubleClickEvent( QMouseEvent *);
101 virtual void keyPressEvent( QKeyEvent *);
102 virtual void keyReleaseEvent( QKeyEvent *);
103 virtual void wheelEvent( QWheelEvent *);
106 virtual void reset() = 0;
107 virtual void pan( int, int ) = 0;
108 virtual void setCenter( int, int ) = 0;
109 virtual void zoom( int, int, int, int ) = 0;
110 virtual void fitRect( const QRect& ) = 0;
111 virtual void fitSelect() = 0;
112 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
115 virtual void onCreatePopup() {}
116 virtual void onCreatePopup( QPopupMenu* );
117 virtual void onDestroyPopup( QPopupMenu* );
120 virtual void onChangeBgColor();
123 void vpKeyEvent( QKeyEvent* );
124 void vpMouseEvent( QMouseEvent* );
125 void vpWheelEvent( QWheelEvent* );
126 void vpDrawExternal( QPainter* );
127 void contextMenuRequested( QContextMenuEvent *e );
134 //Handle(Aspect_Window) myWindow;
135 bool myEnableSketching;
136 bool myEnableTransform;
137 bool myPaintersRedrawing; /* set to draw externally */
138 //QList<QAction> myPopupActions;
141 static int nCounter; /* objects counter */
142 static QCursor* defCursor;
143 static QCursor* panglCursor;
144 static QCursor* handCursor;
145 static QCursor* panCursor;
146 static QCursor* zoomCursor;
147 static QCursor* rotCursor;
148 static QCursor* sketchCursor;
152 #pragma warning ( default:4251 )