Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLScalarBarElement.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 "OGLScalarBarElement.h"
21 
22 #if _WIN32
23  #include <windows.h>
24 #endif //_WIN32
25 
26 #include <GL/gl.h>
27 
28 #include "OGLRectangle.h"
29 #include "OGLFont.h"
30 
32 {
36  m_oPosition = QVector3D(0.0, 0.0, 0.0);
37  m_stdText0 = "";
38  m_stdText1 = "";
39  m_stdText2 = "";
40  m_fWidth = 1;
41  m_fHeight = 1;
42  m_bIs3D = false;
43 }
44 
46 {
48  {
50  }
52  {
54  }
56  {
57  delete m_pOGLFont0ToDisplay;
58  }
59 }
60 
62 {
63  m_oPosA.setX(m_oPosition.x() - (m_fWidth / 2));
64  m_oPosA.setY(m_oPosition.y() - (m_fHeight / 2));
65  m_oPosA.setZ(m_oPosition.z());
66  m_oPosB.setX(m_oPosition.x());
67  m_oPosB.setY(m_oPosition.y() - (m_fHeight / 2));
68  m_oPosB.setZ(m_oPosition.z());
69  m_oPosC.setX(m_oPosition.x() + (m_fWidth / 2));
70  m_oPosC.setY(m_oPosition.y() - (m_fHeight / 2));
71  m_oPosC.setZ(m_oPosition.z());
72  m_oPosD.setX(m_oPosition.x() + (m_fWidth / 2));
73  m_oPosD.setY(m_oPosition.y() + (m_fHeight / 2));
74  m_oPosD.setZ(m_oPosition.z());
75  m_oPosE.setX(m_oPosition.x());
76  m_oPosE.setY(m_oPosition.y() + (m_fHeight / 2));
77  m_oPosE.setZ(m_oPosition.z());
78  m_oPosF.setX(m_oPosition.x() - (m_fWidth / 2));
79  m_oPosF.setY(m_oPosition.y() + (m_fHeight / 2));
80  m_oPosF.setZ(m_oPosition.z());
81 }
82 
84 {
85  if (m_bVisible)
86  {
87  // ScalarBarElement must always be displayed in GL_FILL mode
88  GLdouble polygonMode[2];
89  glGetDoublev(GL_POLYGON_MODE, polygonMode);
90  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
91 
92  if (m_bIs3D)
93  {
94  // Nouvelle vue
95  glMatrixMode(GL_MODELVIEW);
96  glPushMatrix();
98  true);
100  true);
101  if (m_pOGLFont0ToDisplay->load(m_qsFontPath.toStdString().c_str()))
102  {
107  }
108  // Ancienne vue
109  glPopMatrix();
110  }
111  else
112  {
113  GLint viewport[4];
114  glGetIntegerv(GL_VIEWPORT, viewport);
115  unsigned int width = viewport[2];
116  unsigned int height = viewport[3];
117 
118  // Nouvelle projection
119  glMatrixMode(GL_PROJECTION);
120  glPushMatrix();
121  glLoadIdentity();
122  glOrtho(0, width, 0.0, height, 0.0, 1.0);
123 
124  // Nouvelle vue
125  glMatrixMode(GL_MODELVIEW);
126  glPushMatrix();
127  glLoadIdentity();
128 
130  true);
132  true);
133  if (m_pOGLFont0ToDisplay->load(m_qsFontPath.toStdString().c_str()))
134  {
139  }
140 
141  // Ancienne projection
142  glMatrixMode(GL_PROJECTION);
143  glPopMatrix();
144 
145  // Ancienne vue
146  glMatrixMode(GL_MODELVIEW);
147  glPopMatrix();
148  }
149 
150  // Restore polygons display mode
151  glPolygonMode(GL_FRONT_AND_BACK, polygonMode[0]);
152  }
153 
154  return 0;
155 }
static const OColor BLACK
Definition: color.h:86
static const OColor WHITE
Definition: color.h:93
bool m_bVisible
Definition: OGLElement.h:76
bool m_bIs3D
Definition: OGLElement.h:77
bool load(const char *filename)
Definition: OGLFont.cpp:30
void drawText(const std::string &msg, const OColor &color, double x, double y) const
Definition: OGLFont.cpp:64
void drawRectangle(const QVector3D &point0, const QVector3D &point1, const QVector3D &point2, const QVector3D &point3, const OColor &oColor, bool bFalse=false) const
OGLRectangle * m_pOGLRectangleRightToDisplay
OGLRectangle * m_pOGLRectangleLeftToDisplay
virtual void bind()
Definition: OGLTexture.cpp:32