Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYPolyLineGraphic.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 
23 #include "TYPolyLineGraphic.h"
24 
27 
28 TYPolyLineGraphic::TYPolyLineGraphic(bool closed /*=false*/) : TYElementGraphic(NULL), width(default_width_px)
29 {
30  _closed = closed;
31 }
32 
34 
35 void TYPolyLineGraphic::update(bool force /*=false*/)
36 {
38 }
39 
41 {
42  OBox reset;
43  _boundingBox = reset;
44 
45  size_t nbPts = _tabPts.size();
46  for (size_t i = 0; i < nbPts; i++)
47  {
48  TYPoint pt(_tabPts[i % (_tabPts.size())]);
49  _boundingBox.Enlarge((float)(pt._x), (float)(pt._y), (float)(pt._z));
50  }
51 }
52 
53 void TYPolyLineGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
54 {
55  size_t nbPts = _tabPts.size();
56  float colorTYPolyLineGraphic[4];
57  glGetFloatv(GL_CURRENT_COLOR, colorTYPolyLineGraphic);
58 
59  if (_highlight)
60  {
61  if (_bFirstDisp)
62  {
64  _bFirstDisp = false;
65  }
67  if (mode == GL_COMPILE)
68  {
69  drawName(pModelerElement);
70  }
71  glColor3f(colorTYPolyLineGraphic[0], colorTYPolyLineGraphic[1], colorTYPolyLineGraphic[2]);
72  }
73 
74  if (_visible)
75  {
76  GLenum line_mode = 0;
77 
78  if (_closed)
79  {
80  line_mode = GL_LINE_LOOP;
81  }
82  else
83  {
84  line_mode = GL_LINE_STRIP;
85  }
86 
87  glLineWidth(width);
88 
89  glBegin(line_mode);
90 
91  for (size_t i = 0; i < nbPts; i++)
92  {
93  TYPoint pt(_tabPts[i % (_tabPts.size())]);
94  glVertex3f(pt._x, pt._y, pt._z);
95  }
96 
97  glEnd();
98  glColor3f(colorTYPolyLineGraphic[0], colorTYPolyLineGraphic[1], colorTYPolyLineGraphic[2]);
99  // Calcul du volume englobant pour le fit:
101  }
102 }
Representation graphique d'une polyligne (fichier header)
The box class.
Definition: 3d.h:1294
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1614
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
classe graphique pour un element de base
void drawName(TYElement *pModelerElement=nullptr)
static OBox _globalBoundingBox
bool _visible
Inique si l'element est visible.
bool _highlight
Indique si le highlight est active pour cet element.
virtual void update(bool force=false)
TYPolyLineGraphic(bool closed=false)
GLfloat width
Line width - cf OpenGL doc for exact meaning.
virtual void update(bool force=false)
virtual void computeBoundingBox()
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)