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