Tulip  5.6.0
Large graphs analysis and drawing
GlGraphRenderer.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef Tulip_GLGRAPHRENDERER_H
21 #define Tulip_GLGRAPHRENDERER_H
22 
23 #include <unordered_map>
24 
25 #include <tulip/GlScene.h>
26 #include <tulip/tulipconf.h>
27 
28 namespace tlp {
29 
30 class Graph;
31 class GlGraphInputData;
32 class Camera;
33 
34 /**
35  * @ingroup OpenGL
36  * @brief Class used by GlGraphComposite to render the graph in OpenGL
37  *
38  * To create a graph renderer, you have to implement two functions : draw() and selectEntities()
39  * @see GlGraphComposite
40  */
41 class TLP_GL_SCOPE GlGraphRenderer {
42 
43 public:
44  /**
45  * @brief Constructor
46  * \param inputData : GlGraphInputData used by renderer to display the graph (in input data you
47  * have pointers on properties used to render nodes/edges
48  * \param parameters : GlGraphRenderingParameters used by renderer to display the graph
49  */
50  GlGraphRenderer(const GlGraphInputData *inputData);
51 
52  /**
53  * @brief Destructor
54  */
55  virtual ~GlGraphRenderer() {}
56 
57  /**
58  * @brief This function is call by GlGraphComposite to draw the graph
59  *
60  * If you reimplement this function you have to render nodes/edges. It's the most important
61  * function of GlGraphRenderer
62  *
63  * \param lod : lod used to this Rendering
64  * \param camera : camera used to this rendering
65  */
66  virtual void draw(float lod, Camera *camera) = 0;
67 
68  /**
69  * @brief This function is call by GlGraphComposite to selected entities into the graph
70  * \param type : type of selected entities
71  * \param x : x of the selected zone
72  * \param y : y of the selected zone
73  * \param w : width of the selected zone
74  * \param h : height of the selected zone
75  * \param selectedEntities : you have to put selected entities into this vector
76  */
77  virtual void selectEntities(Camera *camera, RenderingEntitiesFlag type, int x, int y, int w,
78  int h, std::vector<SelectedEntity> &selectedEntities) = 0;
79 
80  /**
81  * @brief You can use this function if you want to inject a visitor on the graph
82  */
83  virtual void visitGraph(GlSceneVisitor *visitor, bool visitHiddenEntities = false);
84 
85  /**
86  * @brief This function set if the content of the graph is modified
87  */
88  void setGraphModified(bool graphModified) {
89  this->graphModified = graphModified;
90  }
91 
92 protected:
93  void visitNodes(Graph *graph, GlSceneVisitor *visitor);
94  void visitEdges(Graph *graph, GlSceneVisitor *visitor);
95 
96  const GlGraphInputData *inputData;
97 
98  bool graphModified;
99 
100  bool selectionDrawActivate;
101  RenderingEntitiesFlag selectionType;
102  std::unordered_map<unsigned int, SelectedEntity> *selectionIdMap;
103  unsigned int *selectionCurrentId;
104 };
105 } // namespace tlp
106 
107 #endif
tlp::Graph
Definition: Graph.h:234
tlp::GlGraphRenderer
Class used by GlGraphComposite to render the graph in OpenGL.
Definition: GlGraphRenderer.h:41
tlp::GlGraphRenderer::setGraphModified
void setGraphModified(bool graphModified)
This function set if the content of the graph is modified.
Definition: GlGraphRenderer.h:88
tlp::GlGraphRenderer::~GlGraphRenderer
virtual ~GlGraphRenderer()
Destructor.
Definition: GlGraphRenderer.h:55
tlp
Definition: AbstractProperty.h:34
tlp::Camera
Tulip OpenGL camera object.
Definition: Camera.h:47