Version: 9.16.0
GLViewer_ViewPort.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// Author : OPEN CASCADE
24// File: GLViewer_ViewPort.h
25// Created: November, 2004
26//
27#ifndef GLVIEWER_VIEWPORT_H
28#define GLVIEWER_VIEWPORT_H
29
30#include "GLViewer.h"
31
32//#include <QList>
33#include <QColor>
34//#include <QAction>
35#include <QWidget>
36
37//#include <Aspect_Window.hxx>
38
39class QRect;
40class QCursor;
41class QPainter;
44
45#ifdef WIN32
46#pragma warning( disable:4251 )
47#endif
48
50{
51 BS_NoBlock = 0x0000,
53 BS_Selection = 0x0002,
54 BS_Dragging = 0x0004
55};
56
62{
63 Q_OBJECT
66
67public:
68 GLViewer_ViewPort( QWidget* parent );
70
71public:
73 void setSketchingEnabled( bool );
75 bool isSketchingEnabled() const;
77 void setTransformEnabled( bool );
79 bool isTransformEnabled() const;
80
82 virtual QColor backgroundColor() const;
84 virtual void setBackgroundColor( const QColor& );
85
87 void redrawPainters();
88
90 virtual void onUpdate();
91
93 virtual BlockStatus currentBlock(){ return BS_NoBlock; }
94
95protected:
96 enum ViewType { Type2D, Type3D };
97 void selectVisualId( ViewType );
98
99 virtual QPaintDevice* getPaintDevice() { return this; }
100 virtual void contextMenuEvent( QContextMenuEvent * e );
101
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 );
113
114public://ouv
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 );
121
122protected:
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 *);
132
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;
141
142protected slots:
143 virtual void onChangeBgColor();
144
145signals:
146 void vpKeyEvent( QKeyEvent* );
147 void vpMouseEvent( QMouseEvent* );
148 void vpWheelEvent( QWheelEvent* );
149 void vpDrawExternal( QPainter* );
150
151 void contextMenuRequested( QContextMenuEvent* );
152
153private:
154 void initialize();
155 void cleanup();
156
157protected:
158 //Handle(Aspect_Window) myWindow;
161 bool myPaintersRedrawing; /* set to draw externally */
162 //QList<QAction> myPopupActions;
163
164private:
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;
173};
174
175#ifdef WIN32
176#pragma warning ( default:4251 )
177#endif
178
179#endif
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
BlockStatus
Definition: GLViewer_ViewPort.h:50
@ BS_Highlighting
Definition: GLViewer_ViewPort.h:52
@ BS_NoBlock
Definition: GLViewer_ViewPort.h:51
@ BS_Dragging
Definition: GLViewer_ViewPort.h:54
@ BS_Selection
Definition: GLViewer_ViewPort.h:53
Definition: GLViewer_ViewPort.h:62
virtual BlockStatus currentBlock()
Returns blocking status for current started operations.
Definition: GLViewer_ViewPort.h:93
virtual void fitAll(bool keepScale=false, bool withZ=true)=0
virtual void fitSelect()=0
static QCursor * rotCursor
Definition: GLViewer_ViewPort.h:171
static QCursor * sketchCursor
Definition: GLViewer_ViewPort.h:172
virtual void fitRect(const QRect &)=0
static QCursor * handCursor
Definition: GLViewer_ViewPort.h:168
virtual void reset()=0
TO BE REDEFINED.
bool myPaintersRedrawing
Definition: GLViewer_ViewPort.h:161
static QCursor * getRotCursor()
Definition: GLViewer_ViewPort.h:117
virtual void zoom(int, int, int, int)=0
virtual void setCenter(int, int)=0
static QCursor * getZoomCursor()
Definition: GLViewer_ViewPort.h:111
static QCursor * getDefaultCursor()
Definition: GLViewer_ViewPort.h:115
static QCursor * panCursor
Definition: GLViewer_ViewPort.h:169
ViewType
Definition: GLViewer_ViewPort.h:96
@ Type2D
Definition: GLViewer_ViewPort.h:96
void vpKeyEvent(QKeyEvent *)
static QCursor * zoomCursor
Definition: GLViewer_ViewPort.h:170
virtual QPaintDevice * getPaintDevice()
Definition: GLViewer_ViewPort.h:99
bool myEnableTransform
Definition: GLViewer_ViewPort.h:160
void vpDrawExternal(QPainter *)
static QCursor * defCursor
Definition: GLViewer_ViewPort.h:166
static QCursor * getHandCursor()
Definition: GLViewer_ViewPort.h:105
void vpWheelEvent(QWheelEvent *)
void contextMenuRequested(QContextMenuEvent *)
void vpMouseEvent(QMouseEvent *)
static QCursor * getSketchCursor()
Definition: GLViewer_ViewPort.h:119
static QCursor * getPanCursor()
Definition: GLViewer_ViewPort.h:107
static QCursor * getPanglCursor()
Definition: GLViewer_ViewPort.h:109
virtual void pan(int, int)=0
static int nCounter
Definition: GLViewer_ViewPort.h:165
bool myEnableSketching
Definition: GLViewer_ViewPort.h:159
static QCursor * panglCursor
Definition: GLViewer_ViewPort.h:167
Definition: GLViewer_Viewer.h:199
Definition: GLViewer_Viewer.h:139