![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef Tulip_GLEDGE_H 00022 #define Tulip_GLEDGE_H 00023 00024 #ifndef DOXYGEN_NOTFOR_DEVEL 00025 00026 #include <tulip/PropertyTypes.h> 00027 #include <tulip/Size.h> 00028 #include <tulip/GlComplexeEntity.h> 00029 #include <tulip/Matrix.h> 00030 00031 namespace tlp { 00032 00033 struct OcclusionTest; 00034 class TextRenderer; 00035 class GlLabel; 00036 class EdgeExtremityGlyph; 00037 00038 /** 00039 * Class to represent an edge of a graph 00040 */ 00041 class TLP_GL_SCOPE GlEdge : public GlComplexeEntity { 00042 00043 public: 00044 00045 /** 00046 * Build an edge with the id : id 00047 * id must be the id of the edge in graph 00048 */ 00049 GlEdge(unsigned int id); 00050 00051 /** 00052 * Virtual function to accept GlSceneVisitor on this class 00053 */ 00054 virtual void acceptVisitor(GlSceneVisitor *visitor); 00055 00056 /** 00057 * Return the edge bounding box 00058 */ 00059 virtual BoundingBox getBoundingBox(const GlGraphInputData* data); 00060 00061 /** 00062 * Draw the edge with level of detail : lod and Camera : camera 00063 */ 00064 virtual void draw(float lod,const GlGraphInputData *data,Camera* camera); 00065 00066 /** 00067 * Draw the label of the edge if drawEdgesLabel is true and if label selection is equal to drawSelect 00068 * Use TextRenderer : renderer to draw the label 00069 */ 00070 void drawLabel(bool drawSelect,OcclusionTest* test,const GlGraphInputData* data, float lod); 00071 00072 /** 00073 * Draw the label of the edge if drawEdgesLabel is true 00074 * Use TextRenderer : renderer to draw the label 00075 */ 00076 void drawLabel(OcclusionTest* test,const GlGraphInputData* data); 00077 00078 /** 00079 * Draw the label of the edge if drawEdgesLabel is true 00080 * Use TextRenderer : renderer to draw the label 00081 */ 00082 void drawLabel(OcclusionTest* test,const GlGraphInputData* data, float lod, Camera *camera=NULL); 00083 00084 /** 00085 * This function is used by the engine to get line coordinates of the edge 00086 */ 00087 void getVertices(const GlGraphInputData *data,std::vector<Coord> &linesCoordsArray); 00088 00089 /** 00090 * This function is used by the engine to get line colors of the edge 00091 */ 00092 void getColors(const GlGraphInputData *data,const Coord *vertices,unsigned int numberOfVertices,std::vector<Color> &linesColorsArray); 00093 /** 00094 * This function is used by the engine to get line colors of the edge 00095 */ 00096 void getColors(const GlGraphInputData *data,const std::vector<Coord> &vertices,std::vector<Color> &linesColorsArray); 00097 00098 /** 00099 * Compute the edge size 00100 */ 00101 void getEdgeSize(const GlGraphInputData *data,edge e,const Size &srcSize, const Size &tgtSize,const float maxSrcSize,const float maxTgtSize,Size &edgeSize); 00102 00103 /** 00104 * Compute edge anchor 00105 */ 00106 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); 00107 00108 unsigned int id; 00109 00110 private : 00111 00112 static GlLabel *label; 00113 00114 /** 00115 * Draw the Edge : this function is used by draw function 00116 */ 00117 void drawEdge(const Coord &srcNodePos, const Coord &tgtNodePos, 00118 const Coord &startPoint, const Coord &endPoint, const LineType::RealType &bends, 00119 const Color &startColor, const Color &endColor, const Coord &lookDir, bool colorInterpolate, const Color &borderColor, 00120 const Size &size, int shape, bool edge3D, float lod,const std::string &textureName, const float outlineWidth); 00121 00122 /** 00123 * Function used to compute bounding box for edge extremity. 00124 */ 00125 BoundingBox eeGlyphBoundingBox(const Coord& anchor, const Coord& tgt, float glyphNrm, 00126 const Matrix<float, 4>& transformation, const Matrix<float, 4>& size); 00127 00128 /** 00129 * Compute the edge colors and store these colors in srcCol and tgtCol 00130 * \param data : input data used to compute edge colors 00131 */ 00132 void getEdgeColor(const GlGraphInputData *data,const edge &e,const node &source,const node &target, bool selected,Color &srcCol, Color &tgtCol); 00133 00134 00135 00136 /** 00137 * Compute width lod of edge 00138 * This lod is used to know if the edge is render in polygon mode or line mode 00139 */ 00140 float getEdgeWidthLod(const Coord &edgeCoord,const Size &edgeSize,Camera *camera); 00141 00142 /** 00143 * Thgis function is used to render edge arrows 00144 */ 00145 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, 00146 int tgtEdgeGlyph,size_t numberOfBends,const Coord &anchor,const Coord &tgtCoord, 00147 const Coord &srcAnchor,const Coord &tgtAnchor,Coord &lineAnchor, EdgeExtremityGlyph* srcEdgeGlyph = NULL, Camera *camera = NULL); 00148 00149 }; 00150 00151 } 00152 00153 #endif // DOXYGEN_NOTFOR_DEVEL 00154 00155 #endif // Tulip_GLEDGE_H 00156 ///@endcond