Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLGrid.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) 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.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 /*
17  *
18  */
19 
20 #include "OGLGrid.h"
21 #include <qvector3d.h>
22 
23 #include "Tympan/core/color.h"
24 #include "OGLLine.h"
25 
27 
29 
30 void OGLGrid::drawGrid(const float gridDimX, const float gridDimY, const float gridStep, const OColor& oColor,
31  bool bShowGridXY, bool showGridXZ, bool showGridZY) const
32 {
33  int k = 0;
34  int resX = int(gridDimX / gridStep);
35  int resY = int(gridDimY / gridStep);
36 
37  if (bShowGridXY)
38  {
39  for (k = -int(resX / 2); k <= int(resX / 2); k++)
40  {
41  OGLLine line1;
42  line1.drawLine(QVector3D(gridStep * k, -gridDimY / 2, 0.0),
43  QVector3D(gridStep * k, gridDimY / 2, 0.0), oColor, 1.0);
44  }
45 
46  for (k = -int(resY / 2); k <= int(resY / 2); k++)
47  {
48  OGLLine line2;
49  line2.drawLine(QVector3D(-gridDimX / 2, gridStep * k, 0.0),
50  QVector3D(gridDimX / 2, gridStep * k, 0.0), oColor, 1.0);
51  }
52  }
53 
54  if (showGridXZ)
55  {
56  for (k = -int(resX / 2); k <= int(resX / 2); k++)
57  {
58  OGLLine line1;
59  line1.drawLine(QVector3D(gridStep * k, 0.0, -gridDimY / 2),
60  QVector3D(gridStep * k, 0.0, gridDimY / 2), oColor, 1.0);
61  }
62 
63  for (k = -int(resY / 2); k <= int(resY / 2); k++)
64  {
65  OGLLine line2;
66  line2.drawLine(QVector3D(-gridDimX / 2, 0.0, gridStep * k),
67  QVector3D(gridDimX / 2, 0.0, gridStep * k), oColor, 1.0);
68  }
69  }
70 
71  if (showGridZY)
72  {
73  for (k = -int(resX / 2); k <= int(resX / 2); k++)
74  {
75  OGLLine line1;
76  line1.drawLine(QVector3D(0.0, gridStep * k, -gridDimY / 2),
77  QVector3D(0.0, gridStep * k, gridDimY / 2), oColor, 1.0);
78  }
79 
80  for (k = -int(resY / 2); k <= int(resY / 2); k++)
81  {
82  OGLLine line2;
83  line2.drawLine(QVector3D(0.0, -gridDimX / 2, gridStep * k),
84  QVector3D(0.0, gridDimX / 2, gridStep * k), oColor, 1.0);
85  }
86  }
87 }
Definition: color.h:36
void drawGrid(const float gridDimX, const float gridDimY, const float gridStep, const OColor &oColor, bool bShowGridXY, bool showGridXZ, bool showGridZY) const
Definition: OGLGrid.cpp:30
virtual ~OGLGrid()
Definition: OGLGrid.cpp:28
OGLGrid()
Definition: OGLGrid.cpp:26
void drawLine(const QVector3D &point1, const QVector3D &point2, const OColor &oColor, float lineWidth) const
Definition: OGLLine.cpp:35