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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
19 // Author : OPEN CASCADE
22 // File: GLViewer_ViewPort.h
23 // Created: November, 2004
25 /***************************************************************************
26 ** Class: GLViewer_ViewPort
27 ** Descr: Visualisation canvas of GLViewer
28 ** Created: UI team, 05.09.04
29 ****************************************************************************/
30 #ifndef GLVIEWER_VIEWPORT_H
31 #define GLVIEWER_VIEWPORT_H
40 #include <Aspect_Window.hxx>
45 class GLViewer_ViewSketcher;
46 class GLViewer_ViewTransformer;
49 #pragma warning( disable:4251 )
55 BS_Highlighting = 0x0001,
56 BS_Selection = 0x0002,
61 * Class GLViewer_ViewPort
62 * Visualisation canvas of GLViewer
64 class GLVIEWER_API GLViewer_ViewPort: public QWidget
67 friend class GLViewer_ViewSketcher;
68 friend class GLViewer_ViewTransformer;
71 GLViewer_ViewPort( QWidget* parent );
75 //! Activates/deactivates sketching
76 void setSketchingEnabled( bool );
77 //! Checks active status of sketcher
78 bool isSketchingEnabled() const;
79 //! Activates/deactivates transformer
80 void setTransformEnabled( bool );
81 //! Checks active status of transformer
82 bool isTransformEnabled() const;
84 //! Returns background color
85 virtual QColor backgroundColor() const;
86 //! Sets background color
87 virtual void setBackgroundColor( const QColor& );
89 //! Redraw external pa inters
90 void redrawPainters();
93 virtual void onUpdate();
95 //! Returns blocking status for current started operations
96 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
99 enum ViewType { Type2D, Type3D };
100 void selectVisualId( ViewType );
102 virtual QPaintDevice* getPaintDevice() { return this; }
103 virtual void contextMenuEvent( QContextMenuEvent * e );
106 static void createCursors();
107 static void destroyCursors();
108 static QCursor* getHandCursor() { return handCursor; }
109 static void setHandCursor( const QCursor& newCursor );
110 static QCursor* getPanCursor() { return panCursor; }
111 static void setPanCursor( const QCursor& newCursor );
112 static QCursor* getPanglCursor() { return panglCursor; }
113 static void setPanglCursor( const QCursor& newCursor );
114 static QCursor* getZoomCursor() { return zoomCursor; }
115 static void setZoomCursor( const QCursor& newCursor );
118 static QCursor* getDefaultCursor() { return defCursor; }
119 static void setDefaultCursor( const QCursor& newCursor );
120 static QCursor* getRotCursor() { return rotCursor; }
121 static void setRotCursor( const QCursor& newCursor );
122 static QCursor* getSketchCursor() { return sketchCursor; }
123 static void setSketchCursor( const QCursor& newCursor );
127 virtual void paintEvent( QPaintEvent *);
128 virtual void mouseMoveEvent( QMouseEvent *);
129 virtual void mouseReleaseEvent( QMouseEvent *);
130 virtual void mousePressEvent( QMouseEvent *);
131 virtual void mouseDoubleClickEvent( QMouseEvent *);
132 virtual void keyPressEvent( QKeyEvent *);
133 virtual void keyReleaseEvent( QKeyEvent *);
134 virtual void wheelEvent( QWheelEvent *);
137 virtual void reset() = 0;
138 virtual void pan( int, int ) = 0;
139 virtual void setCenter( int, int ) = 0;
140 virtual void zoom( int, int, int, int ) = 0;
141 virtual void fitRect( const QRect& ) = 0;
142 virtual void fitSelect() = 0;
143 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
146 virtual void onChangeBgColor();
149 void vpKeyEvent( QKeyEvent* );
150 void vpMouseEvent( QMouseEvent* );
151 void vpWheelEvent( QWheelEvent* );
152 void vpDrawExternal( QPainter* );
154 void contextMenuRequested( QContextMenuEvent* );
161 //Handle(Aspect_Window) myWindow;
162 bool myEnableSketching;
163 bool myEnableTransform;
164 bool myPaintersRedrawing; /* set to draw externally */
165 //QList<QAction> myPopupActions;
168 static int nCounter; /* objects counter */
169 static QCursor* defCursor;
170 static QCursor* panglCursor;
171 static QCursor* handCursor;
172 static QCursor* panCursor;
173 static QCursor* zoomCursor;
174 static QCursor* rotCursor;
175 static QCursor* sketchCursor;
179 #pragma warning ( default:4251 )