Tulip  5.2.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  bool _shouldRecreate;
72  const tlp::Color getColor();
73  int _currentColor;
74 
75  /**
76  * Create the hierarchy of ConvexHullItem
77  */
78  void buildComposite(tlp::Graph *current, tlp::GlComposite *composite);
79 
80  Graph *_graph;
81  GlLayer *_layer;
82  GlComposite *_composite;
83  LayoutProperty *_layout;
84  SizeProperty *_size;
85  DoubleProperty *_rotation;
86  std::vector<Color> _fillColors;
87  std::string _layerName;
88  bool _isVisible;
89  const std::string _subCompositesSuffix;
90  const std::string _nameAttribute;
91 
92  const static std::string temporaryPropertyValue;
93  /**
94  * This map contains the composite that contains the associated graph's hull.
95  */
96  std::map<tlp::Graph *, std::pair<tlp::GlComposite *, GlConvexGraphHull *>> _graphsComposites;
97 };
98 
99 class GlHierarchyMainComposite : public GlComposite {
100 public:
101  GlHierarchyMainComposite(GlCompositeHierarchyManager *manager);
102  void setVisible(bool visible) override;
103 
104 private:
105  GlCompositeHierarchyManager *_manager;
106 };
107 }
108 
109 #endif
110 ///@endcond
GlSimpleEntity used to agregate other GlEntity.
Definition: GlComposite.h:39