Tulip  4.0.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 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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef Tulip_GLEDGE_H
22 #define Tulip_GLEDGE_H
23 
24 #ifndef DOXYGEN_NOTFOR_DEVEL
25 #include <tulip/OpenGlConfigManager.h>
26 
27 #include <tulip/PropertyTypes.h>
28 
29 #include <tulip/GlComplexeEntity.h>
30 #include <tulip/EdgeExtremityGlyph.h>
31 
32 namespace tlp {
33 
34 struct OcclusionTest;
35 class TextRenderer;
36 class GlLabel;
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  * This function must be called before each graph rendering
105  * This function clears previously compute edgeWidthLod
106  */
107  static void clearEdgeWidthLodSystem() {
108  haveToComputeEdgeWidthBaseLod=true;
109  }
110 
111  unsigned int id;
112 
113 private :
114 
115  static GlLabel *label;
116  static bool haveToComputeEdgeWidthBaseLod;
117  static bool orthoProjection;
118  static float edgeWidthBaseLod;
119 
120  /**
121  * Draw the Edge : this function is used by draw function
122  */
123  void drawEdge(const Coord &srcNodePos, const Coord &tgtNodePos,
124  const Coord &startPoint, const Coord &endPoint, const LineType::RealType &bends,
125  const Color &startColor, const Color &endColor, const Coord &lookDir, bool colorInterpolate, const Color &borderColor,
126  const Size &size, int shape, bool edge3D, float lod,const std::string &textureName, const float outlineWidth);
127 
128  /**
129  * Function used to compute bounding box for edge extremity.
130  */
131  BoundingBox eeGlyphBoundingBox(const Coord& anchor, const Coord& tgt, float glyphNrm,
132  const Matrix<float, 4>& transformation, const Matrix<float, 4>& size);
133 
134  /**
135  * Compute the edge colors and store these colors in srcCol and tgtCol
136  * \param data : input data used to compute edge colors
137  */
138  void getEdgeColor(const GlGraphInputData *data,const edge &e,const node &source,const node &target, bool selected,Color &srcCol, Color &tgtCol);
139 
140 
141 
142  /**
143  * Compute width lod of edge
144  * This lod is used to know if the edge is render in polygon mode or line mode
145  */
146  float getEdgeWidthLod(const Coord &edgeCoord,const Size &edgeSize,Camera *camera);
147 
148  /**
149  * Compute edge anchor
150  */
151  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);
152 
153  /**
154  * Thgis function is used to render edge arrows
155  */
156  void displayArrow(const GlGraphInputData *data,const edge &e,const node &source,const Size &sizeRatio,float edgeSize,const Color &color,float maxSize,bool selected,float selectionOutlineSize,
157  int srcEdgeGlyph,int tgtEdgeGlyph,size_t numberOfBends,const Coord &anchor,const Coord &tgtCoord,
158  const Coord &srcAnchor,const Coord &tgtAnchor,Coord &lineAnchor);
159 
160 };
161 
162 }
163 
164 #endif // DOXYGEN_NOTFOR_DEVEL
165 
166 #endif // Tulip_GLEDGE_H
167 ///@endcond