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