![]() |
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 GLYPH_H 00022 #define GLYPH_H 00023 00024 #ifndef DOXYGEN_NOTFOR_DEVEL 00025 00026 #include <tulip/Plugin.h> 00027 #include <tulip/Size.h> 00028 #include <tulip/Coord.h> 00029 #include <tulip/BoundingBox.h> 00030 #include <tulip/PluginContext.h> 00031 00032 namespace tlp { 00033 00034 static const std::string GLYPH_CATEGORY = "Node shape"; 00035 00036 class Graph; 00037 struct node; 00038 class GlGraphInputData; 00039 00040 class GlyphContext : public PluginContext { 00041 public: 00042 GlGraphInputData *glGraphInputData; 00043 /// 00044 GlyphContext(Graph ** =NULL, GlGraphInputData *glGraphInputData=NULL, int =5, int =5): 00045 glGraphInputData(glGraphInputData) { 00046 } 00047 /// 00048 ~GlyphContext() { 00049 } 00050 }; 00051 //========================================================== 00052 class TLP_GL_SCOPE Glyph : public tlp::Plugin { 00053 public: 00054 std::string category() const { 00055 return GLYPH_CATEGORY; 00056 } 00057 std::string icon() const { 00058 return ":/tulip/gui/icons/32/plugin_glyph.png"; 00059 } 00060 00061 Glyph(const tlp::PluginContext* context); 00062 virtual ~Glyph(); 00063 00064 virtual std::string getGroup() const { 00065 return ""; 00066 } 00067 00068 virtual void getIncludeBoundingBox(BoundingBox &boundingBox,node) { 00069 boundingBox[0] = Coord(-0.5,-0.5,-0.5); 00070 boundingBox[1] = Coord(0.5,0.5,0.5); 00071 } 00072 00073 virtual void getTextBoundingBox(BoundingBox &boundingBox,node n) { 00074 getIncludeBoundingBox(boundingBox,n); 00075 } 00076 00077 virtual void draw(node,float)=0; 00078 /* 00079 * return a point where an edge coming from "from" can be attached 00080 * by default, the point will be on the surface of the largest sphere contained 00081 * inside the unit cube (before scaling). 00082 */ 00083 virtual Coord getAnchor(const Coord &nodeCenter, const Coord &from, 00084 const Size &scale, const double zRotation) const; 00085 00086 /** 00087 * Return if the Glyph render its label (return true) of if GlNode have to render label (return false) 00088 */ 00089 virtual bool renderLabel() { 00090 return false; 00091 } 00092 00093 GlGraphInputData *glGraphInputData; 00094 00095 protected: 00096 /* 00097 * called by public method getAnchor to actually compute the anchor point 00098 * vector is coordinate of the point to anchor to, relative to nodecenter 00099 * glyph size is (1,1,1) 00100 * this is the method to redefine for each glyph where the default 'getAnchor' method 00101 * is inapropriated 00102 * Returned value is a vector to be applied to 'nodeCenter' in the public method 00103 */ 00104 virtual Coord getAnchor(const Coord &vector) const; 00105 }; 00106 00107 } 00108 00109 #define GLYPHINFORMATION(NAME, AUTHOR, DATE, INFO, RELEASE, ID) \ 00110 PLUGININFORMATION(NAME, AUTHOR, DATE, INFO, RELEASE, "")\ 00111 int id() const { return ID; } 00112 00113 #define GLYPHINFORMATIONS(NAME, AUTHOR, DATE, INFO, RELEASE, ID) \ 00114 PLUGININFORMATION(NAME, AUTHOR, DATE, INFO, RELEASE, "")\ 00115 int id() const { return ID; } 00116 00117 #endif // DOXYGEN_NOTFOR_DEVEL 00118 00119 #endif //GLYPH_H 00120 ///@endcond