Salome HOME
new files added
[modules/gui.git] / src / GLViewer / GLViewer_Widget.h
1 // File:      GLViewer_Widget.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 /***************************************************************************
7 **  Class:   GLViewer_Widget
8 **  Descr:   OpenGL Widget for GLViewer
9 **  Module:  GLViewer
10 **  Created: UI team, 27.03.03
11 ****************************************************************************/
12 #ifndef GLVIEWER_WIDGET_H
13 #define GLVIEWER_WIDGET_H
14
15 #include "GLViewer.h"
16
17 #include <qgl.h>
18 #include <qfile.h>
19
20 class GLViewer_ViewPort2d;
21 class GLViewer_CoordSystem;
22
23 class GLVIEWER_API GLViewer_Widget : public QGLWidget
24 {
25   Q_OBJECT
26
27 public:
28     GLViewer_Widget( QWidget*, const char* = 0 );
29     ~GLViewer_Widget();
30
31     GLViewer_ViewPort2d*   getViewPort() const { return myViewPort; }
32     GLint                  getWidth() const { return myWidth; }
33     GLint                  getHeight() const { return myHeight; }
34
35     void                   getScale( GLfloat&, GLfloat&, GLfloat& );
36     void                   setScale( GLfloat, GLfloat, GLfloat );
37
38     void                   getPan( GLfloat&, GLfloat&, GLfloat& );
39     void                   setPan( GLfloat, GLfloat, GLfloat );
40
41     GLfloat                getRotationAngle() const { return myRotationAnglePrev; }
42     void                   setRotationAngle( GLfloat a ) { myRotationAnglePrev = a; }
43     void                   getRotationStart( GLfloat&, GLfloat&, GLfloat& );
44     void                   setRotationStart( GLfloat, GLfloat, GLfloat );
45     void                   getRotation( GLfloat&, GLfloat&, GLfloat&, GLfloat& );
46     void                   setRotation( GLfloat, GLfloat, GLfloat, GLfloat );
47     void                   setBackground( QString );
48
49     void                   addToolTip( QString, QRect );
50     void                   removeToolTip();
51
52     void                   copyBuffers();
53     virtual void           translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
54
55     void                   exportRepaint();
56
57 #ifdef WIN32
58     virtual void           translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
59 #endif
60
61 private:
62     void                   getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
63
64 protected:
65     virtual void           initializeGL();
66     virtual void           paintGL();
67     virtual void           resizeGL( int, int );
68
69     virtual void           paintEvent( QPaintEvent* );
70     virtual void           mouseMoveEvent( QMouseEvent* );
71     virtual void           mousePressEvent( QMouseEvent* );
72     virtual void           mouseReleaseEvent( QMouseEvent* );
73     virtual void           enterEvent( QEvent* );
74     virtual void           leaveEvent( QEvent* );
75
76 private:
77     GLint                  myWidth;
78     GLint                  myHeight;
79
80     GLfloat                myXScale;
81     GLfloat                myYScale;
82     GLfloat                myZScale;
83
84     GLfloat                myXPan;
85     GLfloat                myYPan;
86     GLfloat                myZPan;
87
88     GLfloat                myRotationStartX;
89     GLfloat                myRotationStartY;
90     GLfloat                myRotationStartZ;
91     GLfloat                myRotationAngle;
92     GLfloat                myRotationCenterX;
93     GLfloat                myRotationCenterY;
94     GLfloat                myRotationCenterZ;
95     GLfloat                myRotationAnglePrev;
96
97     GLboolean              myStart;
98     GLViewer_ViewPort2d*   myViewPort;
99
100     //new code
101     bool                   isLoadBackground;
102     QString                myBackgroundFile;
103     GLuint                 texName;
104     int                    myIW;
105     int                    myIH;
106     int                    myBackgroundSize;
107
108     //GLubyte***             pixels;
109     QRect                  myToolTipRect;
110
111     //for export repaint
112     bool                   isExportMode;
113 };
114
115 #endif // GLVIEWER_WIDGET_H