Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRayGraphic.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 
21 
22 #include "TYRayGraphic.h"
24 #include <QtOpenGL>
25 
26 bool TYRayGraphic::_gVisible = false;
27 
29 
31 
32 void TYRayGraphic::update(bool force /*=false*/)
33 {
35 }
36 
38 {
40  return boundingBox;
41 }
42 
44 {
45  switch (e.type)
46  {
47  case TYSOURCE:
48  _r = 1.0f;
49  _g = 1.0f;
50  _b = 0.0f; // jaune;
51  break;
52 
53  case TYDIFFRACTION:
54  _r = 0.2f;
55  _g = 0.55f;
56  _b = 0.91f; // bleu
57  break;
58 
59  case TYREFLEXION:
60  _r = 1.0f;
61  _g = 0.0f;
62  _b = 0.0f; // rouge
63  break;
64 
65  case TYREFLEXIONSOL:
66  _r = 1.0f;
67  _g = 0.5f;
68  _b = 0.0f; // orange
69 
70  case TYREFRACTION:
71  // Do nothing
72  // _r=0.0f; _g=0.84f; _b=0.35f; // vert
73  break;
74 
75  case TYRECEPTEUR:
76  _r = 1.0f;
77  _g = 0.43f;
78  _b = 0.71f; // rose
79  break;
80 
81  case TY_NO_TYPE:
82  // Do nothing ?
83  break;
84 
85  case TY_ALL_TYPE:
86  // Do nothing ?
87  break;
88  }
89 }
90 
92 {
93  TYRay* pRay = getElement();
94 
95  if (_visible)
96  {
97  // Dessine les evenements du rayon
98  glLineWidth(2.0);
99  glBegin(GL_LINE_STRIP);
100 
101  _lastRayEventType = 0;
103  for (unsigned int j = 0; j < pRay->getEvents().size(); j++)
104  {
105  acoustic_event* e = pRay->getEvents().at(j);
106 
107  if (j != 0)
108  {
109  // 2nd point du segment
110  OPoint3D pt(e->pos);
111  glVertex3f(pt._x, pt._y, pt._z);
112  }
113 
114  getRayEventColor(*e);
115  glColor3f(_r, _g, _b);
116  _lastRayEventType = e->type;
117  _lastRayEventPos = e->pos;
118 
119  // 1er point du segment
120  OPoint3D pt(e->pos);
121  glVertex3f(pt._x, pt._y, pt._z);
122  }
123 
124  glEnd();
125  }
126 }
Contexte de rendu utilisé par les fonctions d'affichage.
@ TYREFLEXION
Definition: acoustic_path.h:25
@ TYRECEPTEUR
Definition: acoustic_path.h:29
@ TYSOURCE
Definition: acoustic_path.h:28
@ TY_NO_TYPE
Definition: acoustic_path.h:23
@ TYREFLEXIONSOL
Definition: acoustic_path.h:26
@ TYREFRACTION
Definition: acoustic_path.h:27
@ TY_ALL_TYPE
Definition: acoustic_path.h:30
@ TYDIFFRACTION
Definition: acoustic_path.h:24
The box class.
Definition: 3d.h:1346
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
The 3D point class.
Definition: 3d.h:487
classe graphique pour un element de base
bool _visible
Inique si l'element est visible.
OBox boundingBox() const
virtual void update(bool force=false)
int _repeatRayEventCount
Definition: TYRayGraphic.h:83
void getRayEventColor(acoustic_event &e)
TYPoint _lastRayEventPos
Definition: TYRayGraphic.h:82
virtual void display(TYRenderContext &renderContext)
TYRayGraphic(TYRay *pElement)
virtual ~TYRayGraphic()
virtual void update(bool force=false)
virtual OBox computeBoundingBox() const
static bool _gVisible
Indique si toutes les instances sont visibles.
Definition: TYRayGraphic.h:75
int _lastRayEventType
Definition: TYRayGraphic.h:81
Classe decrivant un rayon acoustique gere par un lancer de rayon. Cette classe doit permettre la mode...
Definition: TYRay.h:35
This class store data and provide functions to manipulate event in the acoustic context.
Definition: acoustic_path.h:40
ACOUSTIC_EVENT_TYPES type
Event type.
Definition: acoustic_path.h:60
OPoint3D pos
Event position.
Definition: acoustic_path.h:53
virtual tab_acoustic_events & getEvents()
Get the events list of the ray.