Version: 9.16.0
GLViewer_Widget.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_Widget.h
25// Created: November, 2004
26//
27#ifndef GLVIEWER_WIDGET_H
28#define GLVIEWER_WIDGET_H
29
30#include "GLViewer.h"
31
32#include <QtOpenGL>
33
34class QFile;
35
38
44{
45 Q_OBJECT
46
47public:
49
51 GLViewer_Widget( QWidget* theParent, const char* theName = 0 );
52
55
57
58 GLViewer_ViewPort2d* getViewPort() const { return myViewPort; }
60 GLint getWidth() const { return myWidth; }
62 GLint getHeight() const { return myHeight; }
63
65
66 void getScale( GLfloat& xScale,
67 GLfloat& yScale,
68 GLfloat& zScale );
70 void setScale( GLfloat xScale,
71 GLfloat yScale,
72 GLfloat zScaleGLfloat );
73
75 void getPan( GLfloat& xPan, GLfloat& yPan, GLfloat& zPan );
77 void setPan( GLfloat xPan, GLfloat yPan, GLfloat zPan );
78
80
81 GLfloat getRotationAngle() const { return myRotationAnglePrev; }
83
84 void setRotationAngle( GLfloat a ) { myRotationAnglePrev = a; }
85
87 void getRotationStart( GLfloat& rotationStartX,
88 GLfloat& rotationStartY,
89 GLfloat& rotationStartZ );
91 void setRotationStart( GLfloat rotationStartX,
92 GLfloat rotationStartY,
93 GLfloat rotationStartZ );
95 void getRotation( GLfloat& rotationAngle,
96 GLfloat& rotationCenterX,
97 GLfloat& rotationCenterY,
98 GLfloat& rotationCenterZ );
100 void setRotation( GLfloat, GLfloat, GLfloat, GLfloat );
101
103 void setBackground( QString theFileName );
104
106 void addToolTip( QString theTTText, QRect theTTRect );
108 void removeToolTip();
109
111
116 virtual void translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
117
119 /* Repaints all objects in only current view */
120 void exportRepaint();
121
122#ifdef WIN32
125
132 virtual void translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
133#endif
134
135private:
137 void getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
138
139protected:
140 /* Redefined QT methods */
142 virtual void initializeGL();
144 /* Calling by public method repaint() */
145 virtual void paintGL();
147 virtual void resizeGL( int, int );
148
149
150 virtual void paintEvent( QPaintEvent* );
151 virtual void mouseMoveEvent( QMouseEvent* );
152 virtual void mousePressEvent( QMouseEvent* );
153 virtual void mouseReleaseEvent( QMouseEvent* );
154
155 /* Needs to redefine because Window must be updated highlight presentation when mouse enter window */
156 virtual void enterEvent( QEvent* );
157 /* Needs to redefine because Window must be updated highlight presentation when mouse leave window */
158 virtual void leaveEvent( QEvent* );
159
160 virtual bool event ( QEvent* );
161
162private:
164 GLint myWidth;
166 GLint myHeight;
167
169 GLfloat myXScale;
171 GLfloat myYScale;
173 /* equals 1 in 2D */
174 GLfloat myZScale;
175
177 GLfloat myXPan;
179 GLfloat myYPan;
181 /* equals 0 in 2D */
182 GLfloat myZPan;
183
192
193 GLboolean myStart;
195
201 GLuint texName;
203 int myIW;
205 int myIH;
208
210
213};
214
215#endif // GLVIEWER_WIDGET_H
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
Class implementing mathematical model of 2D coordinate system.
Definition: GLViewer_CoordSystem.h:45
Definition: GLViewer_ViewPort2d.h:69
Definition: GLViewer_Widget.h:44
GLfloat myRotationStartY
Definition: GLViewer_Widget.h:185
GLfloat myRotationAnglePrev
Definition: GLViewer_Widget.h:191
int myBackgroundSize
Size of background image.
Definition: GLViewer_Widget.h:207
QRect myToolTipRect
Definition: GLViewer_Widget.h:209
GLint getHeight() const
Returns height of OpenGl Window.
Definition: GLViewer_Widget.h:62
GLint getWidth() const
Returns width of OpenGl Window.
Definition: GLViewer_Widget.h:60
GLfloat myRotationCenterZ
Definition: GLViewer_Widget.h:190
QString myBackgroundFile
File name of background image.
Definition: GLViewer_Widget.h:199
GLfloat getRotationAngle() const
Returns rotation angle of Window in OpenGL global scene in degree.
Definition: GLViewer_Widget.h:81
GLboolean myStart
Definition: GLViewer_Widget.h:193
bool isExportMode
Needs for export repaint.
Definition: GLViewer_Widget.h:212
GLfloat myRotationAngle
Definition: GLViewer_Widget.h:187
GLint myWidth
width of window
Definition: GLViewer_Widget.h:164
void setRotationAngle(GLfloat a)
A function for installing the rotation angle of Window in OpenGL global scene in degree.
Definition: GLViewer_Widget.h:84
GLfloat myYScale
Scale along Y direction.
Definition: GLViewer_Widget.h:171
GLViewer_ViewPort2d * myViewPort
Definition: GLViewer_Widget.h:194
bool isLoadBackground
True if background is loaded.
Definition: GLViewer_Widget.h:197
GLfloat myRotationCenterY
Definition: GLViewer_Widget.h:189
GLuint texName
Texture id of loaded background image.
Definition: GLViewer_Widget.h:201
GLfloat myRotationStartZ
Definition: GLViewer_Widget.h:186
int myIW
Width of background image.
Definition: GLViewer_Widget.h:203
GLfloat myZPan
Window offset along Z direction.
Definition: GLViewer_Widget.h:182
GLfloat myXPan
Window offset along X direction.
Definition: GLViewer_Widget.h:177
GLfloat myRotationCenterX
Definition: GLViewer_Widget.h:188
int myIH
Height of background image.
Definition: GLViewer_Widget.h:205
GLint myHeight
height of window
Definition: GLViewer_Widget.h:166
GLfloat myRotationStartX
Definition: GLViewer_Widget.h:184
GLfloat myYPan
Window offset along Y direction.
Definition: GLViewer_Widget.h:179
GLfloat myZScale
Scale along Z direction.
Definition: GLViewer_Widget.h:174
GLViewer_ViewPort2d * getViewPort() const
Returns parent GLViewer_ViewPort2d.
Definition: GLViewer_Widget.h:58
GLfloat myXScale
Scale along X direction.
Definition: GLViewer_Widget.h:169