Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLGrid.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  */
19 
20 #include "OGLGrid.h"
21 
22 #if _WIN32
23  #include <windows.h>
24 #endif //_WIN32
25 
26 #include <GL/gl.h>
27 
28 #include "Tympan/core/color.h"
30 #include "OGLLine.h"
31 
33 
35 
36 void OGLGrid::drawGrid(const float gridDimX, const float gridDimY, const float gridStep, const OColor& oColor,
37  bool bShowGridXY, bool showGridXZ, bool showGridZY) const
38 {
39  int k = 0;
40  int resX = int(gridDimX / gridStep);
41  int resY = int(gridDimY / gridStep);
42 
43  if (bShowGridXY)
44  {
45  for (k = -int(resX / 2); k <= int(resX / 2); k++)
46  {
47  OGLLine line1;
48  line1.drawLine(OPoint3D(gridStep * k, -gridDimY / 2, 0.0),
49  OPoint3D(gridStep * k, gridDimY / 2, 0.0), oColor, 1.0);
50  }
51 
52  for (k = -int(resY / 2); k <= int(resY / 2); k++)
53  {
54  OGLLine line2;
55  line2.drawLine(OPoint3D(-gridDimX / 2, gridStep * k, 0.0),
56  OPoint3D(gridDimX / 2, gridStep * k, 0.0), oColor, 1.0);
57  }
58  }
59 
60  if (showGridXZ)
61  {
62  for (k = -int(resX / 2); k <= int(resX / 2); k++)
63  {
64  OGLLine line1;
65  line1.drawLine(OPoint3D(gridStep * k, 0.0, -gridDimY / 2),
66  OPoint3D(gridStep * k, 0.0, gridDimY / 2), oColor, 1.0);
67  }
68 
69  for (k = -int(resY / 2); k <= int(resY / 2); k++)
70  {
71  OGLLine line2;
72  line2.drawLine(OPoint3D(-gridDimX / 2, 0.0, gridStep * k),
73  OPoint3D(gridDimX / 2, 0.0, gridStep * k), oColor, 1.0);
74  }
75  }
76 
77  if (showGridZY)
78  {
79  for (k = -int(resX / 2); k <= int(resX / 2); k++)
80  {
81  OGLLine line1;
82  line1.drawLine(OPoint3D(0.0, gridStep * k, -gridDimY / 2),
83  OPoint3D(0.0, gridStep * k, gridDimY / 2), oColor, 1.0);
84  }
85 
86  for (k = -int(resY / 2); k <= int(resY / 2); k++)
87  {
88  OGLLine line2;
89  line2.drawLine(OPoint3D(0.0, -gridDimX / 2, gridStep * k),
90  OPoint3D(0.0, gridDimX / 2, gridStep * k), oColor, 1.0);
91  }
92  }
93 }
All base classes related to 3D manipulation.
Definition: color.h:31
void drawGrid(const float gridDimX, const float gridDimY, const float gridStep, const OColor &oColor, bool bShowGridXY, bool showGridXZ, bool showGridZY) const
Definition: OGLGrid.cpp:36
virtual ~OGLGrid()
Definition: OGLGrid.cpp:34
OGLGrid()
Definition: OGLGrid.cpp:32
void drawLine(const OPoint3D &point1, const OPoint3D &point2, const OColor &oColor, float lineWidth) const
Definition: OGLLine.cpp:35
The 3D point class.
Definition: 3d.h:487