Salome HOME
Update comments
[modules/gui.git] / src / GLViewer / GLViewer_Grid.h
1 // File:      GLViewer_Grid.h
2 // Created:   November, 2004
3 // Author:    OCC team
4 // Copyright (C) CEA 2004
5
6 #ifndef GLVIEWER_GRID_H
7 #define GLVIEWER_GRID_H
8
9 #ifdef WNT
10 #include "windows.h"
11 #endif
12
13 #include "GLViewer.h"
14
15 #include <GL/gl.h>
16 #include <GL/glu.h>
17
18 #ifdef WNT
19 #pragma warning( disable:4251 )
20 #endif
21
22 /*! Class GLViewer_Grid
23   2D rectangular grid for GLViewer
24   Grid is adapt cells for current view
25 */
26
27 class GLVIEWER_API GLViewer_Grid 
28 {
29 public:
30   //! A default constructor
31   GLViewer_Grid();
32   //! A constructor
33   /*
34   * \param  width and \param height - width and height of grid 
35   * \param winW and \param winH     - width and height of window 
36   * \param xSize and \param ySize   - steps along x and y direction
37   * \param xPan and \param yPan     - offsets along x and y direction
38   * \param xScale and \param yScal  - scale factors along x and y direction
39   */
40   GLViewer_Grid( GLfloat width, GLfloat height,
41                  GLfloat winW, GLfloat winH,
42                  GLfloat xSize, GLfloat ySize,
43                  GLfloat xPan, GLfloat yPan,
44                  GLfloat xScale, GLfloat yScale );
45   ~GLViewer_Grid();
46
47   //! Draws grid
48   void                   draw();
49
50   //! Sets color of grid in RGB format
51   void                   setGridColor( GLfloat r, GLfloat g, GLfloat b );
52   //! Sets color of grid axes in RGB format
53   void                   setAxisColor( GLfloat r, GLfloat g, GLfloat b );
54   void                   setGridWidth( float );
55   //! Sets Radius of center point( begin coords )
56   void                   setCenterRadius( int );
57
58   //! Sets steps along x and y directions
59   void                   setSize( float xs, float ys );
60   //! Sets offset along x and y direction
61   void                   setPan( float xp, float yp );
62   //! Sets common scale factor along x and y direction
63   bool                   setZoom( float zoom );
64   //! Recomputes grid in new size and scale of view
65   void                   setResize( float winW, float winH, float Zoom );
66
67   void                   getSize( float&, float& ) const;
68   void                   getPan( float&, float& ) const;
69   void                   getScale( float&, float& ) const;
70
71   //! Sets step of scale
72   void                   setScaleFactor( int );
73   int                    getScaleFactor();
74
75 protected:
76   //! Initialize grid display list
77   bool                   initList();
78
79   GLuint                 myGridList;
80   GLfloat                myGridColor[3];
81   GLfloat                myAxisColor[3];
82   GLfloat                myGridHeight;
83   GLfloat                myGridWidth;
84   GLfloat                myWinW;
85   GLfloat                myWinH;
86   GLfloat                myXSize;
87   GLfloat                myYSize;
88   GLfloat                myXPan;
89   GLfloat                myYPan;
90   GLfloat                myXScale;
91   GLfloat                myYScale;
92   GLfloat                myLineWidth;
93   GLfloat                myCenterWidth;
94   GLint                  myCenterRadius;
95   GLint                  myScaleFactor;
96   GLboolean              myIsUpdate;
97 };
98
99 #ifdef WNT
100 #pragma warning ( default:4251 )
101 #endif
102
103 #endif