Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYEtageGraphic.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 "TYEtageGraphic.h"
24 
26 {
27  TYMurElement dummy;
28  _pPolyLineGraphic = new TYPolyLineGraphic(); // az++
29  _pPolyLineGraphic->setElement(pElement);
30 }
31 
33 {
34  delete _pPolyLineGraphic;
35 }
36 
37 void TYEtageGraphic::update(bool force /*=false*/)
38 {
40 }
41 
42 void TYEtageGraphic::getChilds(TYListPtrTYElementGraphic& childs, bool recursif /*=true*/)
43 {
44  TYListPtrTYElementGraphic Localchilds;
45  int i = 0;
46  for (i = 0; i < getElement()->getTabMachine().size(); i++)
47  {
48  Localchilds.push_back(getElement()->getTabMachine()[i]->getGraphicObject().getRealPointer());
49  }
50  // Sources
51  for (i = 0; i < getElement()->getTabSources().size(); i++)
52  {
53  Localchilds.push_back(getElement()->getTabSources()[i]->getGraphicObject().getRealPointer());
54  }
55 
56  // Murs
57  for (i = 0; i < getElement()->getTabMur().size(); i++)
58  {
59  Localchilds.push_back(getElement()->getTabMur()[i]->getGraphicObject().getRealPointer());
60  }
61  if (!getElement()->getClosed())
62  {
63  Localchilds.push_back(_pPolyLineGraphic);
64  }
65  else
66  {
67  Localchilds.push_back(getElement()->getSol()->getGraphicObject().getRealPointer());
68  Localchilds.push_back(getElement()->getPlafond()->getGraphicObject().getRealPointer());
69  }
70 
71  TYListPtrTYElementGraphic::iterator ite = Localchilds.begin();
72  for (i = 0; i < Localchilds.size(); i++)
73  {
74  TYElementGraphic* pTYElementGraphic = (TYElementGraphic*)(*ite);
75  childs.push_back(pTYElementGraphic);
76  if (recursif)
77  {
78  pTYElementGraphic->getChilds(childs, recursif);
79  }
80  ite++;
81  }
82 }
83 
85 {
86  OBox reset;
87  _boundingBox = reset;
88 
89  int i = 0;
90  for (i = 0; i < getElement()->getTabMachine().size(); i++)
91  {
92  getElement()->getTabMachine()[i]->getGraphicObject()->computeBoundingBox();
93  _boundingBox.Enlarge(getElement()->getTabMachine()[i]->getGraphicObject()->GetBox());
94  }
95 
96  // Sources
97  for (i = 0; i < getElement()->getTabSources().size(); i++)
98  {
99  getElement()->getTabSources()[i]->getGraphicObject()->computeBoundingBox();
100  _boundingBox.Enlarge(getElement()->getTabSources()[i]->getGraphicObject()->GetBox());
101  }
102 
103  // Murs
104  for (i = 0; i < getElement()->getTabMur().size(); i++)
105  {
106  getElement()->getTabMur()[i]->getGraphicObject()->computeBoundingBox();
107  _boundingBox.Enlarge(getElement()->getTabMur()[i]->getGraphicObject()->GetBox());
108  }
109 
110  // Sol et plafond
112  if (!getElement()->getClosed())
113  {
114  pPolyLineGraphic->computeBoundingBox();
115  _boundingBox.Enlarge(pPolyLineGraphic->GetBox());
116  }
117  else
118  {
119  getElement()->getSol()->getGraphicObject()->computeBoundingBox();
120  getElement()->getPlafond()->getGraphicObject()->computeBoundingBox();
121  _boundingBox.Enlarge(getElement()->getSol()->getGraphicObject()->GetBox());
122  _boundingBox.Enlarge(getElement()->getPlafond()->getGraphicObject()->GetBox());
123  }
124 }
125 
126 void TYEtageGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
127 {
128  int i = 0;
129 
130  for (i = 0; i < getElement()->getTabMachine().size(); i++)
131  {
132  // Met l'attribut inCurrentCalcul a trou pour rendre la machine visible
133  getElement()->getTabMachine()[i]->getElement()->setInCurrentCalcul(true);
134  getElement()->getTabMachine()[i]->getGraphicObject()->display(pModelerElement, mode);
135  }
136 
137  // Sources
138  for (i = 0; i < getElement()->getTabSources().size(); i++)
139  {
140  // Met l'attribut inCurrentCalcul a trou pour rendre la source visible
141  getElement()->getTabSources()[i]->getElement()->setInCurrentCalcul(true);
142  getElement()->getTabSources()[i]->getGraphicObject()->display(pModelerElement, mode);
143  }
144 
145  // Murs
146  for (i = 0; i < getElement()->getTabMur().size(); i++)
147  {
148  getElement()->getTabMur()[i]->getGraphicObject()->display(pModelerElement, mode);
149  }
150 
151  // Sol et plafond
153  if (!getElement()->getClosed())
154  {
155  pPolyLineGraphic->setTabPoint(getElement()->sommets());
156  pPolyLineGraphic->display(pModelerElement, mode);
157  }
158  else
159  {
160  getElement()->getSol()->getGraphicObject()->display(pModelerElement, mode);
162  {
163  getElement()->getPlafond()->getGraphicObject()->display(pModelerElement, mode);
164  }
165  }
166 }
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
Representation graphique d'un etage (fichier header)
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
classe graphique pour un element de base
virtual void update(bool force=false)
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setElement(TYElement *pElt)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
TYEtageGraphic(TYEtage *pElement)
virtual void update(bool force=false)
virtual ~TYEtageGraphic()
TYElementGraphic * _pPolyLineGraphic
virtual void computeBoundingBox()
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
classe graphique pour representer une polyligne a partir d'un tableau de points.
void setTabPoint(const TYTabPoint &tabPts)
virtual void computeBoundingBox()
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)