Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
GlGlyphRenderer.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
20#ifndef GLGLYPHRENDERER_H
21#define GLGLYPHRENDERER_H
22
23#include <tulip/Coord.h>
24#include <tulip/Size.h>
25#include <tulip/Color.h>
26#include <tulip/Node.h>
27#include <tulip/Edge.h>
28
29#include <vector>
30
31namespace tlp {
32
33class GlGraphInputData;
34class GlShaderProgram;
35class Glyph;
36class EdgeExtremityGlyph;
37class GlBox;
38
39struct TLP_GL_SCOPE NodeGlyphData {
40
41 NodeGlyphData() {}
42
43 NodeGlyphData(Glyph *glyph, node n, float lod, const Coord &nodePos, const Size &nodeSize,
44 float nodeRot, bool selected)
45 : glyph(glyph), n(n), lod(lod), nodePos(nodePos), nodeSize(nodeSize), nodeRot(nodeRot),
46 selected(selected) {}
47
48 Glyph *glyph;
49 node n;
50 float lod;
51 Coord nodePos;
52 Size nodeSize;
53 float nodeRot;
54 bool selected;
55};
56
57struct TLP_GL_SCOPE EdgeExtremityGlyphData {
58
59 EdgeExtremityGlyphData() {}
60
61 EdgeExtremityGlyphData(EdgeExtremityGlyph *glyph, edge e, node source, Color glyphColor,
62 Color glyphBorderColor, float lod, Coord beginAnchor, Coord srcAnchor,
63 Size size, bool selected)
64 : glyph(glyph), e(e), source(source), glyphColor(glyphColor),
65 glyphBorderColor(glyphBorderColor), lod(lod), beginAnchor(beginAnchor),
66 srcAnchor(srcAnchor), size(size), selected(selected) {}
67
68 EdgeExtremityGlyph *glyph;
69 edge e;
70 node source;
71 Color glyphColor;
72 Color glyphBorderColor;
73 float lod;
74 Coord beginAnchor;
75 Coord srcAnchor;
76 Size size;
77 bool selected;
78};
79
80class TLP_GL_SCOPE GlGlyphRenderer {
81
82public:
83 GlGlyphRenderer(GlGraphInputData *inputData) : _inputData(inputData), _renderingStarted(false) {}
84
85 void startRendering();
86
87 bool renderingHasStarted();
88
89 void addNodeGlyphRendering(Glyph *glyph, node n, float lod, const Coord &nodePos,
90 const Size &nodeSize, float nodeRot, bool selected);
91
92 void addEdgeExtremityGlyphRendering(EdgeExtremityGlyph *glyph, edge e, node source,
93 Color glyphColor, Color glyphBorderColor, float lod,
94 Coord beginAnchor, Coord srcAnchor, Size size, bool selected);
95
96 void endRendering();
97
98private:
99 GlGraphInputData *_inputData;
100 bool _renderingStarted;
101 std::vector<NodeGlyphData> _nodeGlyphsToRender;
102 std::vector<EdgeExtremityGlyphData> _edgeExtremityGlyphsToRender;
103 static GlShaderProgram *_glyphShader;
104 static GlBox *_selectionBox;
105};
106} // namespace tlp
107
108#endif // GLYPHRENDERER_H