Tulip  5.2.0
Large graphs analysis and drawing
GlGlyphRenderer.h
1 /*
2  *
3  * This file is part of Tulip (http://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 
31 namespace tlp {
32 
33 class GlGraphInputData;
34 class GlShaderProgram;
35 class Glyph;
36 class EdgeExtremityGlyph;
37 class GlBox;
38 
39 struct 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 
57 struct 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 
80 class TLP_GL_SCOPE GlGlyphRenderer {
81 
82 public:
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 
98 private:
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 }
107 
108 #endif // GLYPHRENDERER_H