Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLSphereElement.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 "OGLSphereElement.h"
21 
22 #if _WIN32
23  #include <windows.h>
24 #endif //_WIN32
25 
26 #include <GL/gl.h>
27 
28 #include "OGLSphere.h"
29 
31 {
33  m_oCenter = OPoint3D(0.0, 0.0, 0.0);
34  m_fRadius = 2.0f;
35  m_bIs3D = false;
36 }
37 
39 {
41  {
42  delete m_pOGLSphereToDisplay;
43  }
44 }
45 
47 {
48  m_oColor = oColor;
49 }
50 
52 {
53  if (m_bVisible)
54  {
55  if (m_bIs3D)
56  {
57  // Nouvelle vue
58  glMatrixMode(GL_MODELVIEW);
59  glPushMatrix();
60  m_pOGLSphereToDisplay->drawSphere(m_oCenter, /*m_fRadius*/ 5.0f, m_oColor);
61  // Ancienne vue
62  glPopMatrix();
63  }
64  else
65  {
66  GLint viewport[4];
67  glGetIntegerv(GL_VIEWPORT, viewport);
68  unsigned int width = viewport[2];
69  unsigned int height = viewport[3];
70  // Nouvelle projection
71  glMatrixMode(GL_PROJECTION);
72  glPushMatrix();
73  glLoadIdentity();
74  glOrtho(0, width, 0.0, height, 0.0, 1.0);
75 
76  // Nouvelle vue
77  glMatrixMode(GL_MODELVIEW);
78  glPushMatrix();
79  glLoadIdentity();
80 
82 
83  // Ancienne projection
84  glMatrixMode(GL_PROJECTION);
85  glPopMatrix();
86 
87  // Ancienne vue
88  glMatrixMode(GL_MODELVIEW);
89  glPopMatrix();
90  }
91  }
92 
93  return 0;
94 }
Definition: color.h:31
bool m_bVisible
Definition: OGLElement.h:76
bool m_bIs3D
Definition: OGLElement.h:77
void setColor(const OColor &oColor)
virtual ~OGLSphereElement()
OGLSphere * m_pOGLSphereToDisplay
virtual int render()
void drawSphere(const OPoint3D &center, float raduis, const OColor &oColor) const
Definition: OGLSphere.cpp:35
The 3D point class.
Definition: 3d.h:487