Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
Glyph.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 GLYPH_H
22 #define GLYPH_H
23 
24 #ifndef DOXYGEN_NOTFOR_DEVEL
25 
26 
27 #include <tulip/Plugin.h>
28 #include <tulip/Size.h>
29 #include <tulip/Coord.h>
30 #include <tulip/Color.h>
31 #include <tulip/BoundingBox.h>
32 #include <tulip/TlpTools.h>
33 #include <tulip/PluginLister.h>
34 
35 #include <tulip/GlGraphInputData.h>
36 #include <tulip/Plugin.h>
37 
38 
39 namespace tlp {
40 
41 static const std::string GLYPH_CATEGORY = "Node shape";
42 
43 class Graph;
44 struct node;
45 
46 class GlyphContext : public PluginContext {
47 public:
48  GlGraphInputData *glGraphInputData;
49  ///
50  GlyphContext(Graph ** =NULL, GlGraphInputData *glGraphInputData=NULL, int =5, int =5):
51  glGraphInputData(glGraphInputData) {
52  }
53  ///
54  ~GlyphContext() {
55  }
56 };
57 //==========================================================
58 class TLP_GL_SCOPE Glyph : public tlp::Plugin {
59 public:
60  std::string category() const {
61  return GLYPH_CATEGORY;
62  }
63  std::string icon() const {
64  return ":/tulip/gui/icons/32/plugin_glyph.png";
65  }
66 
67  Glyph(const tlp::PluginContext* context);
68  virtual ~Glyph();
69 
70  virtual std::string getGroup() const {
71  return "";
72  }
73 
74  virtual void getIncludeBoundingBox(BoundingBox &boundingBox,node) {
75  boundingBox[0] = Coord(-0.5,-0.5,-0.5);
76  boundingBox[1] = Coord(0.5,0.5,0.5);
77  }
78 
79  virtual void getTextBoundingBox(BoundingBox &boundingBox,node n) {
80  getIncludeBoundingBox(boundingBox,n);
81  }
82 
83  virtual void draw(node,float)=0;
84  /*
85  * return a point where an edge coming from "from" can be attached
86  * by default, the point will be on the surface of the largest sphere contained
87  * inside the unit cube (before scaling).
88  */
89  virtual Coord getAnchor(const Coord &nodeCenter, const Coord &from,
90  const Size &scale, const double zRotation) const;
91 
92  /**
93  * Return if the Glyph render its label (return true) of if GlNode have to render label (return false)
94  */
95  virtual bool renderLabel() {
96  return false;
97  }
98 
99  GlGraphInputData *glGraphInputData;
100 
101 protected:
102  /*
103  * called by public method getAnchor to actually compute the anchor point
104  * vector is coordinate of the point to anchor to, relative to nodecenter
105  * glyph size is (1,1,1)
106  * this is the method to redefine for each glyph where the default 'getAnchor' method
107  * is inapropriated
108  * Returned value is a vector to be applied to 'nodeCenter' in the public method
109  */
110  virtual Coord getAnchor(const Coord &vector) const;
111 };
112 
113 }
114 
115 #define GLYPHINFORMATIONS(NAME, AUTHOR, DATE, INFO, RELEASE, ID) \
116 PLUGININFORMATIONS(NAME, AUTHOR, DATE, INFO, RELEASE, "")\
117 int id() const { return ID; }
118 
119 #endif // DOXYGEN_NOTFOR_DEVEL
120 
121 #endif //GLYPH_H
122 ///@endcond