Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLScalarBarElement.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 "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"
31 
33 {
37  m_oPosition = OPoint3D(0.0, 0.0, 0.0);
38  m_stdText0 = "";
39  m_stdText1 = "";
40  m_stdText2 = "";
41  m_fWidth = 1;
42  m_fHeight = 1;
43  m_bIs3D = false;
44 }
45 
47 {
49  {
51  }
53  {
55  }
57  {
58  delete m_pOGLFont0ToDisplay;
59  }
60 }
61 
63 {
64  m_oPosA._x = m_oPosition._x - (m_fWidth / 2);
65  m_oPosA._y = m_oPosition._y - (m_fHeight / 2);
68  m_oPosB._y = m_oPosition._y - (m_fHeight / 2);
70  m_oPosC._x = m_oPosition._x + (m_fWidth / 2);
71  m_oPosC._y = m_oPosition._y - (m_fHeight / 2);
73  m_oPosD._x = m_oPosition._x + (m_fWidth / 2);
74  m_oPosD._y = m_oPosition._y + (m_fHeight / 2);
77  m_oPosE._y = m_oPosition._y + (m_fHeight / 2);
79  m_oPosF._x = m_oPosition._x - (m_fWidth / 2);
80  m_oPosF._y = m_oPosition._y + (m_fHeight / 2);
82 }
83 
85 {
86  if (m_bVisible)
87  {
88  // ScalarBarElement must always be displayed in GL_FILL mode
89  GLdouble polygonMode[2];
90  glGetDoublev(GL_POLYGON_MODE, polygonMode);
91  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
92 
93  if (m_bIs3D)
94  {
95  // Nouvelle vue
96  glMatrixMode(GL_MODELVIEW);
97  glPushMatrix();
99  true);
101  true);
102  if (m_pOGLFont0ToDisplay->load(m_qsFontPath.toStdString().c_str()))
103  {
108  }
109  // Ancienne vue
110  glPopMatrix();
111  }
112  else
113  {
114  // Nouvelle projection
115  glMatrixMode(GL_PROJECTION);
116  glPushMatrix();
117  glLoadIdentity();
118  unsigned int width = OSizeManager::get()->getWidth();
119  unsigned int height = OSizeManager::get()->getHeight();
120  glOrtho(0, width, 0.0, height, 0.0, 1.0);
121 
122  // Nouvelle vue
123  glMatrixMode(GL_MODELVIEW);
124  glPushMatrix();
125  glLoadIdentity();
126 
128  true);
130  true);
131  if (m_pOGLFont0ToDisplay->load(m_qsFontPath.toStdString().c_str()))
132  {
137  }
138 
139  // Ancienne projection
140  glMatrixMode(GL_PROJECTION);
141  glPopMatrix();
142 
143  // Ancienne vue
144  glMatrixMode(GL_MODELVIEW);
145  glPopMatrix();
146  }
147 
148  // Restore polygons display mode
149  glPolygonMode(GL_FRONT_AND_BACK, polygonMode[0]);
150  }
151 
152  return 0;
153 }
static const OColor BLACK
Definition: color.h:86
static const OColor WHITE
Definition: color.h:93
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
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:68
void drawRectangle(const OPoint3D &point0, const OPoint3D &point1, const OPoint3D &point2, const OPoint3D &point3, const OColor &oColor, bool bFalse=false) const
OGLRectangle * m_pOGLRectangleRightToDisplay
OGLRectangle * m_pOGLRectangleLeftToDisplay
virtual void bind()
Definition: OGLTexture.cpp:32
The 3D point class.
Definition: 3d.h:487
static LPOSizeManager get()