Tulip  5.1.0
Large graphs analysis and drawing
GlNode.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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef Tulip_GLNODE_H
22 #define Tulip_GLNODE_H
23 
24 #ifndef DOXYGEN_NOTFOR_DEVEL
25 
26 #include <tulip/Color.h>
27 #include <tulip/Coord.h>
28 #include <tulip/Size.h>
29 #include <tulip/GlComplexeEntity.h>
30 
31 #include <vector>
32 
33 namespace tlp {
34 
35 struct OcclusionTest;
36 class TextRenderer;
37 class GlSceneVisitor;
38 class GlLabel;
39 class GlBox;
40 
41 /**
42  * Class to represent a node of a graph
43  */
44 class TLP_GL_SCOPE GlNode : public GlComplexeEntity {
45 
46 public:
47 
48  /**
49  * Default constructor with id
50  * id must be the id of the node in graph
51  */
52  GlNode(unsigned int id);
53 
54  /**
55  * Virtual function to accept GlSceneVisitor on this class
56  */
57  virtual void acceptVisitor(GlSceneVisitor *visitor);
58 
59  /**
60  * Return the node bounding box
61  */
62  virtual BoundingBox getBoundingBox(const GlGraphInputData* data);
63 
64  /**
65  * Draw the node with level of detail : lod and Camera : camera
66  */
67  virtual void draw(float lod,const GlGraphInputData *data,Camera* camera);
68 
69  /**
70  * Draw the label of the node if drawNodesLabel is true and if label selection is equal to drawSelect
71  * Use TextRenderer : renderer to draw the label
72  */
73  virtual void drawLabel(bool drawSelect,OcclusionTest* test,const GlGraphInputData* data,float lod);
74 
75  /**
76  * Draw the label of the node if drawEdgesLabel is true
77  * Use TextRenderer : renderer to draw the label
78  */
79  virtual void drawLabel(OcclusionTest* test,const GlGraphInputData* data);
80 
81  /**
82  * Draw the label of the node if drawEdgesLabel is true
83  * Use TextRenderer : renderer to draw the label
84  */
85  virtual void drawLabel(OcclusionTest* test,const GlGraphInputData* data,float lod,Camera *camera=NULL);
86 
87  unsigned int id;
88 
89  /**
90  * This function is used by the engine to get point coordinate and color of the node
91  */
92  void getPointAndColor(GlGraphInputData *inputData,std::vector<Coord> &pointsCoordsArray,std::vector<Color> &pointsColorsArray);
93 
94  /**
95  * This function is used by the engine to get color of the node
96  */
97  void getColor(GlGraphInputData *inputData,std::vector<Color> &pointsColorsArray);
98 
99 protected :
100  unsigned int oldId;
101 
102  // initialize the data member below
103  void init(const GlGraphInputData* data);
104 
105  tlp::Coord coord;
106  int glyph;
107  tlp::Size size;
108  float rot;
109  bool selected;
110 
111  static GlLabel *label;
112  static GlBox* selectionBox;
113 };
114 
115 }
116 
117 #endif // DOXYGEN_NOTFOR_DEVEL
118 
119 #endif // Tulip_GLNODE_H
120 ///@endcond