Salome HOME
Revert "Synchronize adm files"
[modules/gui.git] / src / GLViewer / GLViewer_Grid.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  Author : OPEN CASCADE
24 // File:      GLViewer_Grid.h
25 // Created:   November, 2004
26 //
27 #ifndef GLVIEWER_GRID_H
28 #define GLVIEWER_GRID_H
29
30 #ifdef WIN32
31 #include "windows.h"
32 #endif
33
34 #include "GLViewer.h"
35
36 #include <GL/gl.h>
37 #include <GL/glu.h>
38
39 #ifdef WIN32
40 #pragma warning( disable:4251 )
41 #endif
42
43 /*! Class GLViewer_Grid
44   2D rectangular grid for GLViewer
45   Grid is adapt cells for current view
46 */
47
48 class GLVIEWER_API GLViewer_Grid 
49 {
50 public:
51   //! A default constructor
52   GLViewer_Grid();
53   //! A constructor
54   /*
55   * \param  width and \param height - width and height of grid 
56   * \param winW and \param winH     - width and height of window 
57   * \param xSize and \param ySize   - steps along x and y direction
58   * \param xPan and \param yPan     - offsets along x and y direction
59   * \param xScale and \param yScal  - scale factors along x and y direction
60   */
61   GLViewer_Grid( GLfloat width, GLfloat height,
62                  GLfloat winW, GLfloat winH,
63                  GLfloat xSize, GLfloat ySize,
64                  GLfloat xPan, GLfloat yPan,
65                  GLfloat xScale, GLfloat yScale );
66   ~GLViewer_Grid();
67
68   //! Draws grid
69   void                   draw();
70
71   //! Sets color of grid in RGB format
72   void                   setGridColor( GLfloat r, GLfloat g, GLfloat b );
73   //! Sets color of grid axes in RGB format
74   void                   setAxisColor( GLfloat r, GLfloat g, GLfloat b );
75   void                   setGridWidth( float );
76   //! Sets Radius of center point( begin coords )
77   void                   setCenterRadius( int );
78
79   //! Sets steps along x and y directions
80   void                   setSize( float xs, float ys );
81   //! Sets offset along x and y direction
82   void                   setPan( float xp, float yp );
83   //! Sets common scale factor along x and y direction
84   bool                   setZoom( float zoom );
85   //! Recomputes grid in new size and scale of view
86   void                   setResize( float winW, float winH, float Zoom );
87
88   void                   getSize( float&, float& ) const;
89   void                   getPan( float&, float& ) const;
90   void                   getScale( float&, float& ) const;
91
92   //! Sets step of scale
93   void                   setScaleFactor( int );
94   int                    getScaleFactor();
95
96 protected:
97   //! Initialize grid display list
98   bool                   initList();
99
100   GLuint                 myGridList;
101   GLfloat                myGridColor[3];
102   GLfloat                myAxisColor[3];
103   GLfloat                myGridHeight;
104   GLfloat                myGridWidth;
105   GLfloat                myWinW;
106   GLfloat                myWinH;
107   GLfloat                myXSize;
108   GLfloat                myYSize;
109   GLfloat                myXPan;
110   GLfloat                myYPan;
111   GLfloat                myXScale;
112   GLfloat                myYScale;
113   GLfloat                myLineWidth;
114   GLfloat                myCenterWidth;
115   GLint                  myCenterRadius;
116   GLint                  myScaleFactor;
117   GLboolean              myIsUpdate;
118 };
119
120 #ifdef WIN32
121 #pragma warning ( default:4251 )
122 #endif
123
124 #endif