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