Tulip  5.7.4
Large graphs analysis and drawing
GlCompositeHierarchyManager.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 GL_HCVXHULL_H
22 #define GL_HCVXHULL_H
23 
24 #include <string>
25 #include <map>
26 
27 #include <tulip/DataSet.h>
28 #include <tulip/Observable.h>
29 #include <tulip/GlConvexGraphHull.h>
30 
31 namespace tlp {
32 
33 struct node;
34 class Color;
35 class LayoutProperty;
36 class DoubleProperty;
37 class SizeProperty;
38 class Graph;
39 class GlLayer;
40 
41 /**
42  * Create a GlComposite item for each and every graph and subgraph.
43  * This class observes the graph to update said hierarchy when a subgraph is added or deleted.
44  */
45 class TLP_QT_SCOPE GlCompositeHierarchyManager : private Observable {
46 
47 public:
48  GlCompositeHierarchyManager(Graph *graph, GlLayer *layer, const std::string &layerName,
49  LayoutProperty *layout, SizeProperty *size, DoubleProperty *rotation,
50  bool visible = false, const std::string &namingProperty = "name",
51  const std::string &subCompositeSuffix = " sub-hulls");
52 
53  void setGraph(tlp::Graph *graph);
54  DataSet getData();
55  void setData(const DataSet &dataSet);
56 
57  void createComposite();
58 
59  void setVisible(bool visible);
60  bool isVisible() const;
61 
62 protected:
63  void treatEvents(const std::vector<Event> &events) override;
64  void treatEvent(const Event &) override;
65 
66 private:
67  const tlp::Color &getColor();
68  int _currentColor;
69  const std::string &getTexture();
70  int _currentTexture;
71 
72  /**
73  * Create the hierarchy of GlConvexGraphHull
74  */
75  void buildComposite(tlp::Graph *current, tlp::GlConvexGraphHullsComposite *composite);
76 
77  Graph *_graph;
78  GlLayer *_layer;
79  GlConvexGraphHullsComposite *_composite;
80  LayoutProperty *_layout;
81  SizeProperty *_size;
82  DoubleProperty *_rotation;
83  std::vector<Color> _fillColors;
84  std::vector<std::string> _fillTextures;
85  std::string _layerName;
86  bool _isVisible;
87  const std::string _subCompositesSuffix;
88  const std::string _nameAttribute;
89 
90  const static std::string temporaryPropertyValue;
91  /**
92  * This map contains the composite that contains the associated graph's hull.
93  */
94  std::map<tlp::Graph *, std::pair<tlp::GlConvexGraphHullsComposite *, GlConvexGraphHull *>>
95  _graphsComposites;
96 };
97 } // namespace tlp
98 
99 #endif
100 ///@endcond