Code_TYMPAN
4.4.0
Industrial site acoustic simulation
Tympan
gui
gl
TYPolyLineGraphic.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
23
#include "
gui/gl/TYRenderContext.h
"
24
#include <QtOpenGL>
25
26
#include "
TYPolyLineGraphic.h
"
27
#include "
Tympan/models/business/geometry/TYRectangle.h
"
28
29
TYPolyLineGraphic::TYPolyLineGraphic
(
bool
closed
/*=false*/
) :
TYElementGraphic
(NULL), width(default_width_px)
30
{
31
_closed
= closed;
32
}
33
34
TYPolyLineGraphic::~TYPolyLineGraphic
() {}
35
36
void
TYPolyLineGraphic::update
(
bool
force
/*=false*/
)
37
{
38
TYElementGraphic::update
(force);
39
}
40
41
OBox
TYPolyLineGraphic::computeBoundingBox
()
const
42
{
43
OBox
boundingBox
;
44
size_t
nbPts =
_tabPts
.size();
45
if
(nbPts > 0)
46
{
47
TYPoint
pt{
_tabPts
[0 % nbPts]};
48
boundingBox
=
OBox
{pt, pt};
49
for
(
size_t
i = 1; i < nbPts; i++)
50
{
51
pt =
TYPoint
{
_tabPts
[i % nbPts]};
52
boundingBox
.
Enlarge
((
float
)(pt._x), (
float
)(pt._y), (
float
)(pt._z));
53
}
54
}
55
return
boundingBox
;
56
}
57
void
TYPolyLineGraphic::display
(
TYRenderContext
& renderContext)
58
{
59
size_t
nbPts =
_tabPts
.size();
60
float
colorTYPolyLineGraphic[4];
61
glGetFloatv(GL_CURRENT_COLOR, colorTYPolyLineGraphic);
62
63
if
(
_highlight
)
64
{
65
if
(renderContext.
pass
==
TYRenderPass::Overlay
)
66
{
67
drawName
(renderContext);
68
}
69
glColor3f(colorTYPolyLineGraphic[0], colorTYPolyLineGraphic[1], colorTYPolyLineGraphic[2]);
70
}
71
72
if
(
_visible
)
73
{
74
GLenum line_mode = 0;
75
76
if
(
_closed
)
77
{
78
line_mode = GL_LINE_LOOP;
79
}
80
else
81
{
82
line_mode = GL_LINE_STRIP;
83
}
84
85
glLineWidth(
width
);
86
87
glBegin(line_mode);
88
89
for
(
size_t
i = 0; i < nbPts; i++)
90
{
91
TYPoint
pt(
_tabPts
[i % (
_tabPts
.size())]);
92
glVertex3f(pt.
_x
, pt.
_y
, pt.
_z
);
93
}
94
95
glEnd();
96
glColor3f(colorTYPolyLineGraphic[0], colorTYPolyLineGraphic[1], colorTYPolyLineGraphic[2]);
97
}
98
}
TYPolyLineGraphic.h
Representation graphique d'une polyligne (fichier header)
TYRectangle.h
TYRenderContext.h
Contexte de rendu utilisé par les fonctions d'affichage.
TYRenderPass::Overlay
@ Overlay
The current render pass is for overlay elements.
OBox
The box class.
Definition:
3d.h:1346
OBox::Enlarge
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition:
3d.cpp:1614
OCoord3D::_y
double _y
y coordinate of OCoord3D
Definition:
3d.h:283
OCoord3D::_z
double _z
z coordinate of OCoord3D
Definition:
3d.h:284
OCoord3D::_x
double _x
x coordinate of OCoord3D
Definition:
3d.h:282
TYElementGraphic
classe graphique pour un element de base
Definition:
TYElementGraphic.h:63
TYElementGraphic::drawName
void drawName(TYRenderContext &renderContext)
Definition:
TYElementGraphic.cpp:138
TYElementGraphic::_visible
bool _visible
Inique si l'element est visible.
Definition:
TYElementGraphic.h:270
TYElementGraphic::boundingBox
OBox boundingBox() const
Definition:
TYElementGraphic.cpp:227
TYElementGraphic::_highlight
bool _highlight
Indique si le highlight est active pour cet element.
Definition:
TYElementGraphic.h:264
TYElementGraphic::update
virtual void update(bool force=false)
Definition:
TYElementGraphic.cpp:83
TYPoint
Definition:
TYPoint.h:31
TYPolyLineGraphic::TYPolyLineGraphic
TYPolyLineGraphic(bool closed=false)
Definition:
TYPolyLineGraphic.cpp:29
TYPolyLineGraphic::update
virtual void update(bool force=false)
Definition:
TYPolyLineGraphic.cpp:36
TYPolyLineGraphic::~TYPolyLineGraphic
virtual ~TYPolyLineGraphic()
Definition:
TYPolyLineGraphic.cpp:34
TYPolyLineGraphic::_tabPts
TYTabPoint _tabPts
Definition:
TYPolyLineGraphic.h:100
TYPolyLineGraphic::_closed
bool _closed
Definition:
TYPolyLineGraphic.h:101
TYPolyLineGraphic::computeBoundingBox
virtual OBox computeBoundingBox() const
Definition:
TYPolyLineGraphic.cpp:41
TYPolyLineGraphic::display
virtual void display(TYRenderContext &renderContext)
Definition:
TYPolyLineGraphic.cpp:57
TYPolyLineGraphic::width
float width
Line width - cf OpenGL doc for exact meaning.
Definition:
TYPolyLineGraphic.h:103
TYRenderContext
Definition:
TYRenderContext.h:45
TYRenderContext::pass
const TYRenderPass pass
Definition:
TYRenderContext.h:53
Generated on Thu Jan 29 2026 14:35:53 for Code_TYMPAN by
1.9.1