Code_TYMPAN  4.2.0
Industrial site acoustic simulation
TYGeometryNodeGraphic.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 
21 #include <QtOpenGL> // this MUST be included before GL/*.h
22 #include <GL/gl.h>
23 #include <GL/glu.h>
24 
25 #include "TYGeometryNodeGraphic.h"
26 
28  TYElementGraphic(pElement)
29 {
30 }
31 
32 
34 {
35 }
36 
37 void TYGeometryNodeGraphic::update(bool force /*=false*/)
38 {
39  // On affecte le meme etat au GeoNode que l'element pour savoir s'il est actif dans le calcul courant
40  getElement()->setInCurrentCalcul(getElement()->getElement()->isInCurrentCalcul());
41 
43 }
44 
46 {
47  glPushMatrix();
48 
49  GLdouble m[4][4];
50  OMatrix matrix = getElement()->getMatrix();
51  for (int j = 0; j < 4; j++)
52  {
53  for (int k = 0; k < 4; k++)
54  {
55  m[j][k] = matrix._m[k][j];
56  }
57  }
58  glMultMatrixd((GLdouble*)m);
59 }
61 {
62  TYListPtrGeoNode GeoNodeParents;
63  TYGeometryNode* pThisGeoNode = ((TYGeometryNode*)getElement());
64  pThisGeoNode->GetGeoNodeParentList(GeoNodeParents);
65  TYListPtrGeoNode::iterator ite = GeoNodeParents.end();
66  if (!GeoNodeParents.empty())
67  {
68  ite--; //end n'est jamais valide
69  }
70  int i;
71  int nbPushMatrix = 0;
72  bool bPushMatrix = false;
73  for (i = 0; i < GeoNodeParents.size() && (*ite) != pThisGeoNode; i++)
74  {
75  if (pDansCeRepere == NULL) //NULL = site pere (repere du TYSite le plus haut)
76  {
77  bPushMatrix = true;
78  }
79  if (bPushMatrix)
80  {
81  //PushMatrix
82  TYGeometryNode* pCurrentTYGeometryNode = (TYGeometryNode*)(*ite);
83  TYElementGraphic* pCurrentTYElementGraphic = (TYElementGraphic*)pCurrentTYGeometryNode->getGraphicObject();
84  TYGeometryNodeGraphic* pCurrentTYGeometryNodeGraphic = (TYGeometryNodeGraphic*)pCurrentTYElementGraphic;
85  pCurrentTYGeometryNodeGraphic->pushMatrix();
86  nbPushMatrix++;
87  }
88  if ((*ite) == pDansCeRepere) //NULL = root
89  {
90  bPushMatrix = true;
91  }
92 
93  if (ite != GeoNodeParents.begin())
94  {
95  ite--;
96  }
97  }
98  display(mode);
99  //PopMatrix
100  for (i = 0; i < nbPushMatrix; i++)
101  {
102  glPopMatrix();
103  }
104 }
105 
106 void TYGeometryNodeGraphic::getChilds(TYListPtrTYElementGraphic& childs, bool recursif /*=true*/)
107 {
108  TYElementGraphic* pTYElementGraphic = (TYElementGraphic*)getElement()->getElement()->getGraphicObject();
109  childs.push_back(pTYElementGraphic);
110  if (recursif)
111  {
112  pTYElementGraphic->getChilds(childs, recursif);
113  }
114 }
115 
117 {
118  OBox reset;
119  _boundingBox = reset;
120  ((TYElementGraphic*)getElement()->getElement()->getGraphicObject())->computeBoundingBox();
121  _boundingBox.Enlarge(((TYElementGraphic*)getElement()->getElement()->getGraphicObject())->GetBox());
122 }
123 
124 
125 void TYGeometryNodeGraphic::display(GLenum mode)//= GL_RENDER
126 {
127  pushMatrix();
128 
129  LPTYElementGraphic pGraphicObject = getElement()->getElement()->getGraphicObject();
130 
131  pGraphicObject->display(mode);
132 
133  glPopMatrix();
134 }
void GetGeoNodeParentList(TYListPtrGeoNode &GetGeoNodeParents)
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
TYGeometryNodeGraphic(TYGeometryNode *pElement)
classe graphique pour un GeometryNode
The box class.
Definition: 3d.h:1292
Representation graphique d&#39;un GeometryNode (fichier header)
virtual void update(bool force=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
std::list< TYGeometryNode * > TYListPtrGeoNode
Liste ordonnee de pointeurs de TYElement.
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1531
virtual void update(bool force=false)
The 4x4 matrix class.
Definition: 3d.h:625
classe graphique pour un element de base
void displayPushingParentMatrix(GLenum mode, TYGeometryNode *pDansCeRepere)
virtual void display(GLenum mode=GL_RENDER)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void display(GLenum mode=GL_RENDER)
double _m[4][4]
The 4x4 matrix array.
Definition: 3d.h:923