Tulip  5.2.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 <tulip/GlScene.h>
24 #include <tulip/tulipconf.h>
25 
26 namespace tlp {
27 
28 class Graph;
29 class GlGraphInputData;
30 class Camera;
31 
32 /**
33  * @ingroup OpenGL
34  * @brief Class used by GlGraphComposite to render the graph in OpenGL
35  *
36  * To create a graph renderer, you have to implement two functions : draw() and selectEntities()
37  * @see GlGraphComposite
38  */
39 class TLP_GL_SCOPE GlGraphRenderer {
40 
41 public:
42  /**
43  * @brief Constructor
44  * \param inputData : GlGraphInputData used by renderer to display the graph (in input data you
45  * have pointers on properties used to render nodes/edges
46  * \param parameters : GlGraphRenderingParameters used by renderer to display the graph
47  */
48  GlGraphRenderer(const GlGraphInputData *inputData);
49 
50  /**
51  * @brief Destructor
52  */
53  virtual ~GlGraphRenderer() {}
54 
55  /**
56  * @brief This function is call by GlGraphComposite to draw the graph
57  *
58  * If you reimplement this function you have to render nodes/edges. It's the most important
59  * function of GlGraphRenderer
60  *
61  * \param lod : lod used to this Rendering
62  * \param camera : camera used to this rendering
63  */
64  virtual void draw(float lod, Camera *camera) = 0;
65 
66  /**
67  * @brief This function is call by GlGraphComposite to selected entities into the graph
68  * \param type : type of selected entities
69  * \param x : x of the selected zone
70  * \param y : y of the selected zone
71  * \param w : width of the selected zone
72  * \param h : height of the selected zone
73  * \param selectedEntities : you have to put selected entities into this vector
74  */
75  virtual void selectEntities(Camera *camera, RenderingEntitiesFlag type, int x, int y, int w,
76  int h, std::vector<SelectedEntity> &selectedEntities) = 0;
77 
78  /**
79  * @brief You can use this funtion if you want to inject a visitor on the graph
80  */
81  virtual void visitGraph(GlSceneVisitor *visitor, bool visitHiddenEntities = false);
82 
83  /**
84  * @brief This function set if the content of the graph is modified
85  */
86  void setGraphModified(bool graphModified) {
87  this->graphModified = graphModified;
88  }
89 
90 protected:
91  void visitNodes(Graph *graph, GlSceneVisitor *visitor);
92  void visitEdges(Graph *graph, GlSceneVisitor *visitor);
93 
94  const GlGraphInputData *inputData;
95 
96  bool graphModified;
97 
98  bool selectionDrawActivate;
99  RenderingEntitiesFlag selectionType;
100  std::map<unsigned int, SelectedEntity> *selectionIdMap;
101  unsigned int *selectionCurrentId;
102 };
103 }
104 
105 #endif
virtual ~GlGraphRenderer()
Destructor.
void setGraphModified(bool graphModified)
This function set if the content of the graph is modified.
Tulip OpenGL camera object.
Definition: Camera.h:47
Class used by GlGraphComposite to render the graph in OpenGL.