src/GLViewer/GLViewer_Grid.h

Go to the documentation of this file.
00001 //  Copyright (C) 2005 OPEN CASCADE
00002 //
00003 //  This library is free software; you can redistribute it and/or
00004 //  modify it under the terms of the GNU Lesser General Public
00005 //  License as published by the Free Software Foundation; either
00006 //  version 2.1 of the License.
00007 //
00008 //  This library is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 //  Lesser General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU Lesser General Public
00014 //  License along with this library; if not, write to the Free Software
00015 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 //  Author : OPEN CASCADE
00020 //
00021 
00022 // File:      GLViewer_Grid.h
00023 // Created:   November, 2004
00024 
00025 #ifndef GLVIEWER_GRID_H
00026 #define GLVIEWER_GRID_H
00027 
00028 #ifdef WNT
00029 #include "windows.h"
00030 #endif
00031 
00032 #include "GLViewer.h"
00033 
00034 #include <GL/gl.h>
00035 #include <GL/glu.h>
00036 
00037 #ifdef WNT
00038 #pragma warning( disable:4251 )
00039 #endif
00040 
00046 class GLVIEWER_API GLViewer_Grid 
00047 {
00048 public:
00050   GLViewer_Grid();
00052   /*
00053   * \param  width and \param height - width and height of grid 
00054   * \param winW and \param winH     - width and height of window 
00055   * \param xSize and \param ySize   - steps along x and y direction
00056   * \param xPan and \param yPan     - offsets along x and y direction
00057   * \param xScale and \param yScal  - scale factors along x and y direction
00058   */
00059   GLViewer_Grid( GLfloat width, GLfloat height,
00060            GLfloat winW, GLfloat winH,
00061            GLfloat xSize, GLfloat ySize,
00062            GLfloat xPan, GLfloat yPan,
00063            GLfloat xScale, GLfloat yScale );
00064   ~GLViewer_Grid();
00065 
00067   void                   draw();
00068 
00070   void                   setGridColor( GLfloat r, GLfloat g, GLfloat b );
00072   void                   setAxisColor( GLfloat r, GLfloat g, GLfloat b );
00073   void                   setGridWidth( float );
00075   void                   setCenterRadius( int );
00076 
00078   void                   setSize( float xs, float ys );
00080   void                   setPan( float xp, float yp );
00082   bool                   setZoom( float zoom );
00084   void                   setResize( float winW, float winH, float Zoom );
00085 
00086   void                   getSize( float&, float& ) const;
00087   void                   getPan( float&, float& ) const;
00088   void                   getScale( float&, float& ) const;
00089 
00091   void                   setScaleFactor( int );
00092   int                    getScaleFactor();
00093 
00094 protected:
00096   bool                   initList();
00097 
00098   GLuint                 myGridList;
00099   GLfloat                myGridColor[3];
00100   GLfloat                myAxisColor[3];
00101   GLfloat                myGridHeight;
00102   GLfloat                myGridWidth;
00103   GLfloat                myWinW;
00104   GLfloat                myWinH;
00105   GLfloat                myXSize;
00106   GLfloat                myYSize;
00107   GLfloat                myXPan;
00108   GLfloat                myYPan;
00109   GLfloat                myXScale;
00110   GLfloat                myYScale;
00111   GLfloat                myLineWidth;
00112   GLfloat                myCenterWidth;
00113   GLint                  myCenterRadius;
00114   GLint                  myScaleFactor;
00115   GLboolean              myIsUpdate;
00116 };
00117 
00118 #ifdef WNT
00119 #pragma warning ( default:4251 )
00120 #endif
00121 
00122 #endif