Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPanelGraphic.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 
27 
28 #include "TYPanelGraphic.h"
29 
30 #define IMG(id) OLocalizator::getPicture("TYPanelGraphic", (id))
31 
33 {
34  _font = new OGLFont();
35 
36  // Position
37  _posX = 0.0;
38  _posY = 0.0;
39 
40  // Taille du panel
41  _width = 100.0;
42  _height = 100.0;
43 
46 }
47 
49 
50 void TYPanelGraphic::update(bool force /*=false*/)
51 {
53 }
54 
55 void TYPanelGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
56 {
57  LPTYPanel pPanel = getElement();
58 
59  if (pPanel == NULL)
60  {
61  return;
62  }
63 
64  if (_visible)
65  {
66  // On sauvegarde le mode d'affichage des polygones
67  GLdouble polygonMode[2];
68  glGetDoublev(GL_POLYGON_MODE, polygonMode);
69 
70  // Mode GL_FILL
71  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
72 
73  // Nouvelle projection
74  glMatrixMode(GL_PROJECTION);
75  glPushMatrix();
76  glLoadIdentity();
77  glOrtho(0, OSizeManager::get()->getWidth(), 0.0, OSizeManager::get()->getHeight(), 0.0, 1.0);
78 
79  // Nouvelle vue
80  glMatrixMode(GL_MODELVIEW);
81  glPushMatrix();
82  glLoadIdentity();
83 
84  // Eloignement du curseur
85  int offset = 5;
86 
87  int x = _posX + offset;
88  int y = _posY - offset;
89  int dx = _width;
90  int dy = _height;
91 
92  // Dessin du panel
93  glColor3fv(_backColor);
94  glBegin(GL_QUADS);
95  glVertex2i(x, y);
96  glVertex2i(x, y - dy);
97  glVertex2i(x + dx, y - dy);
98  glVertex2i(x + dx, y);
99  glEnd();
100 
101  // On charge la texture des polices pour la valeur min
102  _font->load(IMG("id_font").toLatin1().data());
103  _font->bind();
104 
105  // On affiche la position
106  // Delta en x : 3
107  // Delta en y : -3
108  dx = 3 + offset;
109  dy = -3 - offset;
110  x = _posX + dx;
111  y = _posY + dy;
112  _font->drawText(getElement()->getFirstPos() + " " + getElement()->getSecondPos(), OColor::BLACK, x,
113  y);
114 
115  // On affiche la valeur
116  // Delta en x : 3
117  // Delta en y : -23
118  dx = 3 + offset;
119  dy = -23 - offset;
120  x = _posX + dx;
121  y = _posY + dy;
122  _font->drawText(getElement()->getValue(), OColor::BLACK, x, y);
123 
124  // Ancienne projection
125  glMatrixMode(GL_PROJECTION);
126  glPopMatrix();
127 
128  // Ancienne vue
129  glMatrixMode(GL_MODELVIEW);
130  glPopMatrix();
131 
132  // On restaure le mode d'affichage des polygones
133  glPolygonMode(GL_FRONT_AND_BACK, polygonMode[0]);
134  }
135 }
#define IMG(id)
Representation graphique d'un panel d'informations (fichier header)
static const OColor BLACK
Definition: color.h:86
static const OColor YELLOW
Definition: color.h:92
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
virtual void bind()
Definition: OGLTexture.cpp:32
static LPOSizeManager get()
classe graphique pour un element de base
bool _visible
Inique si l'element est visible.
virtual void update(bool force=false)
TYPanelGraphic(TYPanel *pElement)
virtual void update(bool force=false)
double getHeight() const
virtual ~TYPanelGraphic()
double getWidth() const
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
Classe de definition d'un panel d'information.
Definition: TYPanel.h:34