Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GLViewer_Widget.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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 
34 class QFile;
35 
38 
44 {
45  Q_OBJECT
46 
47 public:
49 
51  GLViewer_Widget( QWidget* theParent, const char* theName = 0 );
52 
54  ~GLViewer_Widget();
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
123 
124 
125 
132  virtual void translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
133 #endif
134 
135 private:
137  void getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
138 
139 protected:
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 
162 private:
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