1 // File: GLViewer_Widget.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 /*! Class GLViewer_Widget
7 * Class for visualization OpenGL scene (widget) for GLViewer
9 #ifndef GLVIEWER_WIDGET_H
10 #define GLVIEWER_WIDGET_H
17 class GLViewer_ViewPort2d;
18 class GLViewer_CoordSystem;
20 class GLVIEWER_API GLViewer_Widget : public QGLWidget
26 /*! Parameters using for QOGLWidget as is
28 GLViewer_Widget( QWidget* theParent, const char* theName = 0 );
33 //! Returns parent GLViewer_ViewPort2d
34 /*! ViewPort2d because this class is not use for 3D Viewer */
35 GLViewer_ViewPort2d* getViewPort() const { return myViewPort; }
36 //! Returns width of OpenGl Window
37 GLint getWidth() const { return myWidth; }
38 //! Returns height of OpenGl Window
39 GLint getHeight() const { return myHeight; }
41 //! Returns scales on OpenGL scene along 3 directions
42 /*! in 2d scene zScale = 1.0 */
43 void getScale( GLfloat& xScale,
46 //! A function for installing the scales of OpenGL scene
47 void setScale( GLfloat xScale,
49 GLfloat zScaleGLfloat );
51 //! Returns offset parameters of Window in OpenGL global scene
52 void getPan( GLfloat& xPan, GLfloat& yPan, GLfloat& zPan );
53 //! A function for installing the offset parameters of Window in OpenGL global scene
54 void setPan( GLfloat xPan, GLfloat yPan, GLfloat zPan );
56 //! Returns rotation angle of Window in OpenGL global scene in degree
58 GLfloat getRotationAngle() const { return myRotationAnglePrev; }
59 //! A function for installing the rotation angle of Window in OpenGL global scene in degree
61 void setRotationAngle( GLfloat a ) { myRotationAnglePrev = a; }
63 //! Returns start point of curren rotation of Window in OpenGL global scene
64 void getRotationStart( GLfloat& rotationStartX,
65 GLfloat& rotationStartY,
66 GLfloat& rotationStartZ );
67 //! A function for installing the start point of curren rotation of Window in OpenGL global scene
68 void setRotationStart( GLfloat rotationStartX,
69 GLfloat rotationStartY,
70 GLfloat rotationStartZ );
71 //! Returns parameters of current rotation
72 void getRotation( GLfloat& rotationAngle,
73 GLfloat& rotationCenterX,
74 GLfloat& rotationCenterY,
75 GLfloat& rotationCenterZ );
76 //! A function for installing the parameters of current rotation
77 void setRotation( GLfloat, GLfloat, GLfloat, GLfloat );
79 //! A function load picture from file with name theFileName and post it in center of global OpenGL scene
80 void setBackground( QString theFileName );
82 //! A function add the tool tip with text theTTText on theTTRect rect to the widget window
83 void addToolTip( QString theTTText, QRect theTTRect );
84 //! A function remove tool tip form widget window
87 //! A function translate background of window in to PostScript file on disk
89 *\param hFile the name of PostScript file chosen by user
90 *\param aViewerCS the GLViewer_CoordSystem of window
91 *\param aPSCS the GLViewer_CoordSystem of PostScript page
93 virtual void translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
95 //! A function repaints OpenGL scene in export mode
96 /* Repaints all objects in only current view */
100 //! A function translate background of window in to EMF file on disk
105 *\param dc the name of HDC associated with file chosen by user
106 *\param aViewerCS the GLViewer_CoordSystem of window
107 *\param aEMFCS the GLViewer_CoordSystem of EMF page
109 virtual void translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
113 //! Auxiliary function. Returns rect of window background in viewer coordinate system
114 void getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
117 /* Redefined QT methods */
118 //! A function is called before first display of window (create OpenGL scene)
119 virtual void initializeGL();
120 //! A function is called in earch paint event of window
121 /* Calling by public method repaint() */
122 virtual void paintGL();
123 //! A function is called in earch resize event of window
124 virtual void resizeGL( int, int );
127 virtual void paintEvent( QPaintEvent* );
128 virtual void mouseMoveEvent( QMouseEvent* );
129 virtual void mousePressEvent( QMouseEvent* );
130 virtual void mouseReleaseEvent( QMouseEvent* );
132 /* Needs to redefine because Window must be updated highlight presentation when mouse enter window */
133 virtual void enterEvent( QEvent* );
134 /* Needs to redefine because Window must be updated highlight presentation when mouse leave window */
135 virtual void leaveEvent( QEvent* );
143 //! Scale along X direction
145 //! Scale along Y direction
147 //! Scale along Z direction
151 //! Window offset along X direction
153 //! Window offset along Y direction
155 //! Window offset along Z direction
159 GLfloat myRotationStartX;
160 GLfloat myRotationStartY;
161 GLfloat myRotationStartZ;
162 GLfloat myRotationAngle;
163 GLfloat myRotationCenterX;
164 GLfloat myRotationCenterY;
165 GLfloat myRotationCenterZ;
166 GLfloat myRotationAnglePrev;
169 GLViewer_ViewPort2d* myViewPort;
171 //! True if background is loaded
172 bool isLoadBackground;
173 //! File name of background image
174 QString myBackgroundFile;
175 //! Texture id of loaded background image
177 //! Width of background image
179 //! Height of background image
181 //! Size of background image
182 int myBackgroundSize;
186 //! Needs for export repaint
190 #endif // GLVIEWER_WIDGET_H