1 // Copyright (C) 2005 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : OPEN CASCADE
22 // File: GLViewer_ViewPort.h
23 // Created: November, 2004
25 #ifndef GLVIEWER_VIEWPORT_H
26 #define GLVIEWER_VIEWPORT_H
35 #include <Aspect_Window.hxx>
40 class GLViewer_ViewSketcher;
41 class GLViewer_ViewTransformer;
44 #pragma warning( disable:4251 )
50 BS_Highlighting = 0x0001,
51 BS_Selection = 0x0002,
56 \class GLViewer_ViewPort
57 Visualisation canvas of GLViewer
59 class GLVIEWER_API GLViewer_ViewPort: public QWidget
62 friend class GLViewer_ViewSketcher;
63 friend class GLViewer_ViewTransformer;
66 GLViewer_ViewPort( QWidget* parent );
70 //! Activates/deactivates sketching
71 void setSketchingEnabled( bool );
72 //! Checks active status of sketcher
73 bool isSketchingEnabled() const;
74 //! Activates/deactivates transformer
75 void setTransformEnabled( bool );
76 //! Checks active status of transformer
77 bool isTransformEnabled() const;
79 //! Returns background color
80 virtual QColor backgroundColor() const;
81 //! Sets background color
82 virtual void setBackgroundColor( const QColor& );
84 //! Redraw external pa inters
85 void redrawPainters();
88 virtual void onUpdate();
90 //! Returns blocking status for current started operations
91 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
94 enum ViewType { Type2D, Type3D };
95 void selectVisualId( ViewType );
97 virtual QPaintDevice* getPaintDevice() { return this; }
98 virtual void contextMenuEvent( QContextMenuEvent * e );
101 static void createCursors();
102 static void destroyCursors();
103 static QCursor* getHandCursor() { return handCursor; }
104 static void setHandCursor( const QCursor& newCursor );
105 static QCursor* getPanCursor() { return panCursor; }
106 static void setPanCursor( const QCursor& newCursor );
107 static QCursor* getPanglCursor() { return panglCursor; }
108 static void setPanglCursor( const QCursor& newCursor );
109 static QCursor* getZoomCursor() { return zoomCursor; }
110 static void setZoomCursor( const QCursor& newCursor );
113 static QCursor* getDefaultCursor() { return defCursor; }
114 static void setDefaultCursor( const QCursor& newCursor );
115 static QCursor* getRotCursor() { return rotCursor; }
116 static void setRotCursor( const QCursor& newCursor );
117 static QCursor* getSketchCursor() { return sketchCursor; }
118 static void setSketchCursor( const QCursor& newCursor );
122 virtual void paintEvent( QPaintEvent *);
123 virtual void mouseMoveEvent( QMouseEvent *);
124 virtual void mouseReleaseEvent( QMouseEvent *);
125 virtual void mousePressEvent( QMouseEvent *);
126 virtual void mouseDoubleClickEvent( QMouseEvent *);
127 virtual void keyPressEvent( QKeyEvent *);
128 virtual void keyReleaseEvent( QKeyEvent *);
129 virtual void wheelEvent( QWheelEvent *);
132 virtual void reset() = 0;
133 virtual void pan( int, int ) = 0;
134 virtual void setCenter( int, int ) = 0;
135 virtual void zoom( int, int, int, int ) = 0;
136 virtual void fitRect( const QRect& ) = 0;
137 virtual void fitSelect() = 0;
138 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
141 virtual void onChangeBgColor();
144 void vpKeyEvent( QKeyEvent* );
145 void vpMouseEvent( QMouseEvent* );
146 void vpWheelEvent( QWheelEvent* );
147 void vpDrawExternal( QPainter* );
149 void contextMenuRequested( QContextMenuEvent* );
156 //Handle(Aspect_Window) myWindow;
157 bool myEnableSketching;
158 bool myEnableTransform;
159 bool myPaintersRedrawing; /* set to draw externally */
160 //QList<QAction> myPopupActions;
163 static int nCounter; /* objects counter */
164 static QCursor* defCursor;
165 static QCursor* panglCursor;
166 static QCursor* handCursor;
167 static QCursor* panCursor;
168 static QCursor* zoomCursor;
169 static QCursor* rotCursor;
170 static QCursor* sketchCursor;
174 #pragma warning ( default:4251 )