Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLGridElement.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 "OGLGridElement.h"
21 
22 #if _WIN32
23  #include <windows.h>
24 #endif //_WIN32
25 
26 #include <GL/gl.h>
27 
28 #include "OGLGrid.h"
29 
31 {
33  m_fGridDimX = .0;
34  m_fGridDimY = .0;
35  m_fGridStep = .0;
36  m_bIs3D = false;
37  m_bShowGridXY = false;
38  m_bShowGridXZ = false;
39  m_bShowGridZY = false;
40 }
41 
43 {
45  {
46  delete m_pOGLGridToDisplay;
47  }
48 }
49 
50 void OGLGridElement::setColor(const OColor& oColor)
51 {
52  m_oColor = oColor;
53 }
54 
56 {
57  if (m_bVisible)
58  {
59  if (m_bIs3D)
60  {
61  // Nouvelle vue
62  glMatrixMode(GL_MODELVIEW);
63  glPushMatrix();
66  // Ancienne vue
67  glPopMatrix();
68  }
69  else
70  {
71  GLint viewport[4];
72  glGetIntegerv(GL_VIEWPORT, viewport);
73  unsigned int width = viewport[2];
74  unsigned int height = viewport[3];
75  // Nouvelle projection
76  glMatrixMode(GL_PROJECTION);
77  glPushMatrix();
78  glLoadIdentity();
79  glOrtho(0, width, 0.0, height, 0.0, 1.0);
80 
81  // Nouvelle vue
82  glMatrixMode(GL_MODELVIEW);
83  glPushMatrix();
84  glLoadIdentity();
85 
88 
89  // Ancienne projection
90  glMatrixMode(GL_PROJECTION);
91  glPopMatrix();
92 
93  // Ancienne vue
94  glMatrixMode(GL_MODELVIEW);
95  glPopMatrix();
96  }
97  }
98 
99  return 0;
100 }
Definition: color.h:36
bool m_bVisible
Definition: OGLElement.h:76
bool m_bIs3D
Definition: OGLElement.h:77
virtual ~OGLGridElement()
virtual int render()
void setColor(const OColor &oColor)
OGLGrid * m_pOGLGridToDisplay
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