Tulip  5.0.0
Large graphs analysis and drawing
GlGlyphRenderer.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 
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, float nodeRot, bool selected) :
44  glyph(glyph), n(n), lod(lod), nodePos(nodePos), nodeSize(nodeSize), nodeRot(nodeRot), selected(selected) {}
45 
46  Glyph *glyph;
47  node n;
48  float lod;
49  Coord nodePos;
50  Size nodeSize;
51  float nodeRot;
52  bool selected;
53 
54 };
55 
56 struct TLP_GL_SCOPE EdgeExtremityGlyphData {
57 
58  EdgeExtremityGlyphData() {}
59 
60  EdgeExtremityGlyphData(EdgeExtremityGlyph *glyph, edge e, node source,
61  Color glyphColor, Color glyphBorderColor, float lod,
62  Coord beginAnchor, Coord srcAnchor, Size size, bool selected) :
63  glyph(glyph), e(e), source(source), glyphColor(glyphColor), glyphBorderColor(glyphBorderColor),
64  lod(lod), beginAnchor(beginAnchor), srcAnchor(srcAnchor), size(size), selected(selected) {}
65 
66  EdgeExtremityGlyph *glyph;
67  edge e;
68  node source;
69  Color glyphColor;
70  Color glyphBorderColor;
71  float lod;
72  Coord beginAnchor;
73  Coord srcAnchor;
74  Size size;
75  bool selected;
76 
77 };
78 
79 class TLP_GL_SCOPE GlGlyphRenderer {
80 
81 public:
82 
83  GlGlyphRenderer(GlGraphInputData *inputData) :
84  _inputData(inputData), _renderingStarted(false) {}
85 
86  void startRendering();
87 
88  bool renderingHasStarted();
89 
90  void addNodeGlyphRendering(Glyph *glyph, node n, float lod, const Coord &nodePos,
91  const Size &nodeSize, float nodeRot, bool selected);
92 
93  void addEdgeExtremityGlyphRendering(EdgeExtremityGlyph *glyph, edge e, node source,
94  Color glyphColor, Color glyphBorderColor, float lod,
95  Coord beginAnchor, Coord srcAnchor, Size size, bool selected);
96 
97  void endRendering();
98 
99 private:
100 
101  GlGraphInputData *_inputData;
102  bool _renderingStarted;
103  std::vector<NodeGlyphData> _nodeGlyphsToRender;
104  std::vector<EdgeExtremityGlyphData> _edgeExtremityGlyphsToRender;
105  static GlShaderProgram *_glyphShader;
106  static GlBox* _selectionBox;
107 
108 };
109 
110 }
111 
112 #endif // GLYPHRENDERER_H