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