Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYOpenGLRenderer.h
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 
27 #ifndef __TY_OPENGL_RENDERER__
28 #define __TY_OPENGL_RENDERER__
29 
32 
34 
36 
41 #include <qmatrix4x4.h>
42 
43 class TYGeometryNode;
49 {
50 public:
55  {
63  };
64 
69 
74 
79  void operator=(const TYOpenGLRenderer&) = delete;
80 
84  void initializeGL();
85 
89  void init();
90 
94  void setRenderMode(RenderMode mode);
95 
103  void invalidateScene(void);
112  void updateDisplayListOverlay(TYRenderContext& renderContext, TYGeometryNode* pElement,
113  TYGeometryNode* pDansCeRepere);
114 
122  void OpenGLRender(TYRenderContext& renderContext, int x = 0, int y = 0);
123 
127  void drawElement(TYRenderContext& renderContext) const;
128 
134  void addOGLElement(OGLElement* pOGLElement);
135 
136  void addLight(OGLLightElement* pOGLElementLight);
137  void removeLights();
138  std::vector<OGLLightElement*> getLights();
139 
140  void setBackground(double* bgColor)
141  {
142  _pBackgroundColor[0] = bgColor[0];
143  _pBackgroundColor[1] = bgColor[1];
144  _pBackgroundColor[2] = bgColor[2];
145  };
146 
152  void removeOGLElement(OGLElement* pOGLElement);
153 
154  void setRenderType(int renderType)
155  {
156  m_renderType = renderType;
157  };
158 
159  void addSelectedElement(TYElement* pElement);
160  void removeSelectedElement(TYElement* pElement);
162 
163 protected:
165  GLuint _displayList;
170 
171  std::vector<OGLElement*> _tabOGLElement;
172 
174  std::vector<TYElement*> _tabSelectedElements;
175 
177  std::vector<OGLLightElement*> _tabLights;
178 
181 
183 
184 private:
188  void _renderScene(TYRenderContext& renderContext) const;
189 
190  // Tell if the scene render cache must be rebuilt
192 
193  void addBoundingBoxMeshInstances(std::vector<OGLMeshInstance>& meshInstances, TYElementGraphic* element);
194  void collectMeshInstances(TYElementGraphic* elementGraphic, std::vector<OGLMeshInstance>& meshInstances,
195  TYRenderContext* renderContext);
196 
197  void drawMeshInstances(TYRenderContext& renderContext,
198  const std::vector<OGLMeshInstance>& meshInstances) const;
203 };
204 
205 #endif // __TY_OPENGL_RENDERER__
All base classes related to 3D manipulation.
Representation graphique d'un element de base (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
classe graphique pour un element de base
Realise le rendu VTK et le rendu OpenGL.
std::vector< TYElement * > _tabSelectedElements
Elements selectionnes.
void _renderScene(TYRenderContext &renderContext) const
0 --> render all, 1 --> render 2D, 2 --> render 3D
void removeSelectedElement(TYElement *pElement)
void addLight(OGLLightElement *pOGLElementLight)
void addOGLElement(OGLElement *pOGLElement)
void invalidateScene(void)
void removeOGLElement(OGLElement *pOGLElement)
std::vector< OGLLightElement * > _tabLights
Liste des lumieres dans la scene 3D.
void collectMeshInstances(TYElementGraphic *elementGraphic, std::vector< OGLMeshInstance > &meshInstances, TYRenderContext *renderContext)
QMatrix4x4 _boundingBoxScaleMatrix
GLuint _displayList
Display liste globale.
void addBoundingBoxMeshInstances(std::vector< OGLMeshInstance > &meshInstances, TYElementGraphic *element)
void setBackground(double *bgColor)
RenderMode _renderMode
Mode de rendu.
OGLCamera * _pActiveCamera
void updateDisplayListOverlay(TYRenderContext &renderContext, TYGeometryNode *pElement, TYGeometryNode *pDansCeRepere)
std::vector< OGLElement * > _tabOGLElement
void setRenderMode(RenderMode mode)
double * _pBackgroundColor
TYOpenGLRenderer(const TYOpenGLRenderer &)=delete
void setRenderType(int renderType)
std::vector< OGLLightElement * > getLights()
void drawMeshInstances(TYRenderContext &renderContext, const std::vector< OGLMeshInstance > &meshInstances) const
GLuint _displayListOverlay
Display liste pour les deplacements.
void drawElement(TYRenderContext &renderContext) const
RenderMode getRenderMode()
void operator=(const TYOpenGLRenderer &)=delete
void OpenGLRender(TYRenderContext &renderContext, int x=0, int y=0)
void addSelectedElement(TYElement *pElement)