Back to index

salome-gui  6.5.0
GLViewer_Grid.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_Grid.h
00025 // Created:   November, 2004
00026 //
00027 #ifndef GLVIEWER_GRID_H
00028 #define GLVIEWER_GRID_H
00029 
00030 #ifdef WIN32
00031 #include "windows.h"
00032 #endif
00033 
00034 #include "GLViewer.h"
00035 
00036 #include <GL/gl.h>
00037 #include <GL/glu.h>
00038 
00039 #ifdef WIN32
00040 #pragma warning( disable:4251 )
00041 #endif
00042 
00048 class GLVIEWER_API GLViewer_Grid 
00049 {
00050 public:
00052   GLViewer_Grid();
00054   /*
00055   * \param  width and \param height - width and height of grid 
00056   * \param winW and \param winH     - width and height of window 
00057   * \param xSize and \param ySize   - steps along x and y direction
00058   * \param xPan and \param yPan     - offsets along x and y direction
00059   * \param xScale and \param yScal  - scale factors along x and y direction
00060   */
00061   GLViewer_Grid( GLfloat width, GLfloat height,
00062                  GLfloat winW, GLfloat winH,
00063                  GLfloat xSize, GLfloat ySize,
00064                  GLfloat xPan, GLfloat yPan,
00065                  GLfloat xScale, GLfloat yScale );
00066   ~GLViewer_Grid();
00067 
00069   void                   draw();
00070 
00072   void                   setGridColor( GLfloat r, GLfloat g, GLfloat b );
00074   void                   setAxisColor( GLfloat r, GLfloat g, GLfloat b );
00075   void                   setGridWidth( float );
00077   void                   setCenterRadius( int );
00078 
00080   void                   setSize( float xs, float ys );
00082   void                   setPan( float xp, float yp );
00084   bool                   setZoom( float zoom );
00086   void                   setResize( float winW, float winH, float Zoom );
00087 
00088   void                   getSize( float&, float& ) const;
00089   void                   getPan( float&, float& ) const;
00090   void                   getScale( float&, float& ) const;
00091 
00093   void                   setScaleFactor( int );
00094   int                    getScaleFactor();
00095 
00096 protected:
00098   bool                   initList();
00099 
00100   GLuint                 myGridList;
00101   GLfloat                myGridColor[3];
00102   GLfloat                myAxisColor[3];
00103   GLfloat                myGridHeight;
00104   GLfloat                myGridWidth;
00105   GLfloat                myWinW;
00106   GLfloat                myWinH;
00107   GLfloat                myXSize;
00108   GLfloat                myYSize;
00109   GLfloat                myXPan;
00110   GLfloat                myYPan;
00111   GLfloat                myXScale;
00112   GLfloat                myYScale;
00113   GLfloat                myLineWidth;
00114   GLfloat                myCenterWidth;
00115   GLint                  myCenterRadius;
00116   GLint                  myScaleFactor;
00117   GLboolean              myIsUpdate;
00118 };
00119 
00120 #ifdef WIN32
00121 #pragma warning ( default:4251 )
00122 #endif
00123 
00124 #endif