Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces 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/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  /**
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);
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 function of GlGraphRenderer
59  *
60  * \param lod : lod used to this Rendering
61  * \param camera : camera used to this rendering
62  */
63  virtual void draw(float lod,Camera* camera) = 0;
64 
65  /**
66  * @brief This function is call by GlGraphComposite to selected entities into the graph
67  * \param type : type of selected entities
68  * \param x : x of the selected zone
69  * \param y : y of the selected zone
70  * \param w : width of the selected zone
71  * \param h : height of the selected zone
72  * \param selectedEntities : you have to put selected entities into this vector
73  */
74  virtual void selectEntities(Camera *camera,RenderingEntitiesFlag type,int x, int y, int w, int h, std::vector<SelectedEntity>& selectedEntities) = 0;
75 
76  /**
77  * @brief You can use this funtion if you want to inject a visitor on the graph
78  */
79  virtual void visitGraph(GlSceneVisitor *visitor,bool visitHiddenEntities=false);
80 
81  /**
82  * @brief This function set if the content of the graph is modified
83  */
84  void setGraphModified(bool graphModified) {
85  this->graphModified=graphModified;
86  }
87 
88 protected:
89 
90  void visitNodes(Graph *graph,GlSceneVisitor *visitor,bool visitHiddenEntities=false);
91  void visitEdges(Graph *graph,GlSceneVisitor *visitor,bool visitHiddenEntities=false);
92 
93  const GlGraphInputData* inputData;
94 
95  bool graphModified;
96 
97  bool selectionDrawActivate;
98  RenderingEntitiesFlag selectionType;
99  std::map<unsigned int, SelectedEntity> *selectionIdMap;
100  unsigned int *selectionCurrentId;
101 };
102 }
103 
104 #endif