Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlEdge.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
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_GLEDGE_H
22 #define Tulip_GLEDGE_H
23 
24 #ifndef DOXYGEN_NOTFOR_DEVEL
25 
26 #include <tulip/PropertyTypes.h>
27 #include <tulip/Size.h>
28 #include <tulip/GlComplexeEntity.h>
29 #include <tulip/Matrix.h>
30 
31 namespace tlp {
32 
33 struct OcclusionTest;
34 class TextRenderer;
35 class GlLabel;
36 class EdgeExtremityGlyph;
37 
38 /**
39  * Class to represent an edge of a graph
40  */
41 class TLP_GL_SCOPE GlEdge : public GlComplexeEntity {
42 
43 public:
44 
45  /**
46  * Build an edge with the id : id
47  * id must be the id of the edge in graph
48  */
49  GlEdge(unsigned int id);
50 
51  /**
52  * Virtual function to accept GlSceneVisitor on this class
53  */
54  virtual void acceptVisitor(GlSceneVisitor *visitor);
55 
56  /**
57  * Return the edge bounding box
58  */
59  virtual BoundingBox getBoundingBox(const GlGraphInputData* data);
60 
61  /**
62  * Draw the edge with level of detail : lod and Camera : camera
63  */
64  virtual void draw(float lod,const GlGraphInputData *data,Camera* camera);
65 
66  /**
67  * Draw the label of the edge if drawEdgesLabel is true and if label selection is equal to drawSelect
68  * Use TextRenderer : renderer to draw the label
69  */
70  void drawLabel(bool drawSelect,OcclusionTest* test,const GlGraphInputData* data, float lod);
71 
72  /**
73  * Draw the label of the edge if drawEdgesLabel is true
74  * Use TextRenderer : renderer to draw the label
75  */
76  void drawLabel(OcclusionTest* test,const GlGraphInputData* data);
77 
78  /**
79  * Draw the label of the edge if drawEdgesLabel is true
80  * Use TextRenderer : renderer to draw the label
81  */
82  void drawLabel(OcclusionTest* test,const GlGraphInputData* data, float lod, Camera *camera=NULL);
83 
84  /**
85  * This function is used by the engine to get line coordinates of the edge
86  */
87  void getVertices(const GlGraphInputData *data,std::vector<Coord> &linesCoordsArray);
88 
89  /**
90  * This function is used by the engine to get line colors of the edge
91  */
92  void getColors(const GlGraphInputData *data,const Coord *vertices,unsigned int numberOfVertices,std::vector<Color> &linesColorsArray);
93  /**
94  * This function is used by the engine to get line colors of the edge
95  */
96  void getColors(const GlGraphInputData *data,const std::vector<Coord> &vertices,std::vector<Color> &linesColorsArray);
97 
98  /**
99  * Compute the edge size
100  */
101  void getEdgeSize(const GlGraphInputData *data,edge e,const Size &srcSize, const Size &tgtSize,const float maxSrcSize,const float maxTgtSize,Size &edgeSize);
102 
103  /**
104  * Compute edge anchor
105  */
106  void getEdgeAnchor(const GlGraphInputData *data,const node &source,const node &target,const LineType::RealType &bends,const Coord &srcCoord,const Coord &tgtCoord,const Size &srcSize,const Size &tgtSize, Coord &srcAnchor, Coord &tgtAnchor);
107 
108  unsigned int id;
109 
110 private :
111 
112  static GlLabel *label;
113 
114  /**
115  * Draw the Edge : this function is used by draw function
116  */
117  void drawEdge(const Coord &srcNodePos, const Coord &tgtNodePos,
118  const Coord &startPoint, const Coord &endPoint, const LineType::RealType &bends,
119  const Color &startColor, const Color &endColor, const Coord &lookDir, bool colorInterpolate, const Color &borderColor,
120  const Size &size, int shape, bool edge3D, float lod,const std::string &textureName, const float outlineWidth);
121 
122  /**
123  * Function used to compute bounding box for edge extremity.
124  */
125  BoundingBox eeGlyphBoundingBox(const Coord& anchor, const Coord& tgt, float glyphNrm,
126  const Matrix<float, 4>& transformation, const Matrix<float, 4>& size);
127 
128  /**
129  * Compute the edge colors and store these colors in srcCol and tgtCol
130  * \param data : input data used to compute edge colors
131  */
132  void getEdgeColor(const GlGraphInputData *data,const edge &e,const node &source,const node &target, bool selected,Color &srcCol, Color &tgtCol);
133 
134 
135 
136  /**
137  * Compute width lod of edge
138  * This lod is used to know if the edge is render in polygon mode or line mode
139  */
140  float getEdgeWidthLod(const Coord &edgeCoord,const Size &edgeSize,Camera *camera);
141 
142  /**
143  * Thgis function is used to render edge arrows
144  */
145  void displayArrowAndAdjustAnchor(const GlGraphInputData *data,const edge &e,const node &source,const Size &sizeRatio,float edgeSize,const Color &color,float maxSize,bool selected,float selectionOutlineSize,
146  int tgtEdgeGlyph,size_t numberOfBends,const Coord &anchor,const Coord &tgtCoord,
147  const Coord &srcAnchor,const Coord &tgtAnchor,Coord &lineAnchor, EdgeExtremityGlyph* srcEdgeGlyph = NULL, Camera *camera = NULL);
148 
149 };
150 
151 }
152 
153 #endif // DOXYGEN_NOTFOR_DEVEL
154 
155 #endif // Tulip_GLEDGE_H
156 ///@endcond