Tulip  4.0.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlGraphRenderer.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
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/GlGraphRenderingParameters.h>
24 #include <tulip/GlGraphInputData.h>
25 #include <tulip/GlScene.h>
26 
27 namespace tlp {
28 
29 class Graph;
30 
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  /**
44  * @brief Constructor
45  * \param inputData : GlGraphInputData used by renderer to display the graph (in input data you 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):inputData(inputData),graphModified(true),selectionDrawActivate(false),selectionIdMap(NULL),selectionCurrentId(NULL) {
49  }
50 
51  /**
52  * @brief Destructor
53  */
54  virtual ~GlGraphRenderer() {}
55 
56  /**
57  * @brief This function is call by GlGraphComposite to draw the graph
58  *
59  * If you reimplement this function you have to render nodes/edges. It's the most important 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, int h, std::vector<SelectedEntity>& selectedEntities) = 0;
76 
77  /**
78  * @brief You can use this funtion if you want to inject a visitor on the graph
79  */
80  virtual void visitGraph(GlSceneVisitor *visitor,bool visitHiddenEntities=false);
81 
82  /**
83  * @brief This function set if the content of the graph is modified
84  */
85  void setGraphModified(bool graphModified) {
86  this->graphModified=graphModified;
87  }
88 
89 protected:
90 
91  void visitNodes(Graph *graph,GlSceneVisitor *visitor,bool visitHiddenEntities=false);
92  void visitEdges(Graph *graph,GlSceneVisitor *visitor,bool visitHiddenEntities=false);
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