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