Back to index

salome-gui  6.5.0
GLViewer_Widget.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  Author : OPEN CASCADE
00024 // File:      GLViewer_Widget.h
00025 // Created:   November, 2004
00026 //
00027 #ifndef GLVIEWER_WIDGET_H
00028 #define GLVIEWER_WIDGET_H
00029 
00030 #include "GLViewer.h"
00031 
00032 #include <QtOpenGL>
00033 
00034 class QFile;
00035 
00036 class GLViewer_ViewPort2d;
00037 class GLViewer_CoordSystem;
00038 
00043 class GLVIEWER_API GLViewer_Widget : public QGLWidget
00044 {
00045   Q_OBJECT
00046 
00047 public:
00049 
00051   GLViewer_Widget( QWidget* theParent, const char* theName = 0 );
00052  
00054   ~GLViewer_Widget();
00055 
00057 
00058   GLViewer_ViewPort2d*   getViewPort() const { return myViewPort; }
00060   GLint                  getWidth() const { return myWidth; }
00062   GLint                  getHeight() const { return myHeight; }
00063   
00065 
00066   void                   getScale( GLfloat& xScale,
00067                                    GLfloat& yScale,
00068                                    GLfloat& zScale );
00070   void                   setScale( GLfloat xScale,
00071                                    GLfloat yScale,
00072                                    GLfloat zScaleGLfloat );
00073   
00075   void                   getPan( GLfloat& xPan, GLfloat& yPan, GLfloat& zPan );
00077   void                   setPan( GLfloat xPan, GLfloat yPan, GLfloat zPan );
00078   
00080 
00081   GLfloat                getRotationAngle() const { return myRotationAnglePrev; }
00083 
00084   void                   setRotationAngle( GLfloat a ) { myRotationAnglePrev = a; }
00085 
00087   void                   getRotationStart( GLfloat& rotationStartX,
00088                                            GLfloat& rotationStartY,
00089                                            GLfloat& rotationStartZ );
00091   void                   setRotationStart( GLfloat rotationStartX,
00092                                            GLfloat rotationStartY,
00093                                            GLfloat rotationStartZ );
00095   void                   getRotation( GLfloat& rotationAngle,
00096                                       GLfloat& rotationCenterX,
00097                                       GLfloat& rotationCenterY,
00098                                       GLfloat& rotationCenterZ );
00100   void                   setRotation( GLfloat, GLfloat, GLfloat, GLfloat );
00101 
00103   void                   setBackground( QString theFileName );
00104   
00106   void                   addToolTip( QString theTTText, QRect theTTRect );
00108   void                   removeToolTip();
00109   
00111 
00116   virtual void           translateBackgroundToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS );
00117   
00119   /* Repaints all objects in only current view */
00120   void                   exportRepaint();
00121 
00122 #ifdef WIN32
00123 
00124 
00125 
00132   virtual void           translateBackgroundToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS );
00133 #endif
00134 
00135 private:
00137   void                   getBackgroundRectInViewerCS( double& left, double& top, double& right, double& bottom );
00138   
00139 protected:
00140   /* Redefined QT methods */
00142   virtual void           initializeGL();
00144   /* Calling by public method repaint() */
00145   virtual void           paintGL();
00147   virtual void           resizeGL( int, int );
00148   
00149   
00150   virtual void           paintEvent( QPaintEvent* );
00151   virtual void           mouseMoveEvent( QMouseEvent* );
00152   virtual void           mousePressEvent( QMouseEvent* );
00153   virtual void           mouseReleaseEvent( QMouseEvent* );
00154 
00155   /* Needs to redefine because Window must be updated highlight presentation when mouse enter window */
00156   virtual void           enterEvent( QEvent* );
00157   /* Needs to redefine because Window must be updated highlight presentation when mouse leave window */
00158   virtual void           leaveEvent( QEvent* );
00159 
00160   virtual bool           event ( QEvent* );
00161   
00162 private:
00164   GLint                  myWidth;
00166   GLint                  myHeight;
00167   
00169   GLfloat                myXScale;
00171   GLfloat                myYScale;
00173   /* equals 1 in 2D */
00174   GLfloat                myZScale;
00175 
00177   GLfloat                myXPan;
00179   GLfloat                myYPan;
00181   /* equals 0 in 2D */
00182   GLfloat                myZPan;
00183 
00184   GLfloat                myRotationStartX;
00185   GLfloat                myRotationStartY;
00186   GLfloat                myRotationStartZ;
00187   GLfloat                myRotationAngle;
00188   GLfloat                myRotationCenterX;
00189   GLfloat                myRotationCenterY;
00190   GLfloat                myRotationCenterZ;
00191   GLfloat                myRotationAnglePrev;
00192   
00193   GLboolean              myStart;
00194   GLViewer_ViewPort2d*   myViewPort;
00195   
00197   bool                   isLoadBackground;
00199   QString                myBackgroundFile;
00201   GLuint                 texName;
00203   int                    myIW;
00205   int                    myIH;
00207   int                    myBackgroundSize;
00208 
00209   QRect                  myToolTipRect;
00210 
00212   bool                   isExportMode;
00213 };
00214 
00215 #endif // GLVIEWER_WIDGET_H