1 // Copyright (C) 2007-2023 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, or (at your option) any later version.
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
23 // Author : OPEN CASCADE
24 // File: GLViewer_ViewPort.h
25 // Created: November, 2004
27 #ifndef GLVIEWER_VIEWPORT_H
28 #define GLVIEWER_VIEWPORT_H
37 //#include <Aspect_Window.hxx>
42 class GLViewer_ViewSketcher;
43 class GLViewer_ViewTransformer;
46 #pragma warning( disable:4251 )
52 BS_Highlighting = 0x0001,
53 BS_Selection = 0x0002,
58 \class GLViewer_ViewPort
59 Visualisation canvas of GLViewer
61 class GLVIEWER_API GLViewer_ViewPort: public QWidget
64 friend class GLViewer_ViewSketcher;
65 friend class GLViewer_ViewTransformer;
68 GLViewer_ViewPort( QWidget* parent );
72 //! Activates/deactivates sketching
73 void setSketchingEnabled( bool );
74 //! Checks active status of sketcher
75 bool isSketchingEnabled() const;
76 //! Activates/deactivates transformer
77 void setTransformEnabled( bool );
78 //! Checks active status of transformer
79 bool isTransformEnabled() const;
81 //! Returns background color
82 virtual QColor backgroundColor() const;
83 //! Sets background color
84 virtual void setBackgroundColor( const QColor& );
86 //! Redraw external pa inters
87 void redrawPainters();
90 virtual void onUpdate();
92 //! Returns blocking status for current started operations
93 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
96 enum ViewType { Type2D, Type3D };
97 void selectVisualId( ViewType );
99 virtual QPaintDevice* getPaintDevice() { return this; }
100 virtual void contextMenuEvent( QContextMenuEvent * e );
103 static void createCursors();
104 static void destroyCursors();
105 static QCursor* getHandCursor() { return handCursor; }
106 static void setHandCursor( const QCursor& newCursor );
107 static QCursor* getPanCursor() { return panCursor; }
108 static void setPanCursor( const QCursor& newCursor );
109 static QCursor* getPanglCursor() { return panglCursor; }
110 static void setPanglCursor( const QCursor& newCursor );
111 static QCursor* getZoomCursor() { return zoomCursor; }
112 static void setZoomCursor( const QCursor& newCursor );
115 static QCursor* getDefaultCursor() { return defCursor; }
116 static void setDefaultCursor( const QCursor& newCursor );
117 static QCursor* getRotCursor() { return rotCursor; }
118 static void setRotCursor( const QCursor& newCursor );
119 static QCursor* getSketchCursor() { return sketchCursor; }
120 static void setSketchCursor( const QCursor& newCursor );
124 virtual void paintEvent( QPaintEvent *);
125 virtual void mouseMoveEvent( QMouseEvent *);
126 virtual void mouseReleaseEvent( QMouseEvent *);
127 virtual void mousePressEvent( QMouseEvent *);
128 virtual void mouseDoubleClickEvent( QMouseEvent *);
129 virtual void keyPressEvent( QKeyEvent *);
130 virtual void keyReleaseEvent( QKeyEvent *);
131 virtual void wheelEvent( QWheelEvent *);
134 virtual void reset() = 0;
135 virtual void pan( int, int ) = 0;
136 virtual void setCenter( int, int ) = 0;
137 virtual void zoom( int, int, int, int ) = 0;
138 virtual void fitRect( const QRect& ) = 0;
139 virtual void fitSelect() = 0;
140 virtual void fitAll( bool keepScale = false, bool withZ = true ) = 0;
143 virtual void onChangeBgColor();
146 void vpKeyEvent( QKeyEvent* );
147 void vpMouseEvent( QMouseEvent* );
148 void vpWheelEvent( QWheelEvent* );
149 void vpDrawExternal( QPainter* );
151 void contextMenuRequested( QContextMenuEvent* );
158 //Handle(Aspect_Window) myWindow;
159 bool myEnableSketching;
160 bool myEnableTransform;
161 bool myPaintersRedrawing; /* set to draw externally */
162 //QList<QAction> myPopupActions;
165 static int nCounter; /* objects counter */
166 static QCursor* defCursor;
167 static QCursor* panglCursor;
168 static QCursor* handCursor;
169 static QCursor* panCursor;
170 static QCursor* zoomCursor;
171 static QCursor* rotCursor;
172 static QCursor* sketchCursor;
176 #pragma warning ( default:4251 )