Tulip  5.1.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,
53  const std::string& layerName,
54  LayoutProperty* layout, SizeProperty* size,
55  DoubleProperty* rotation, bool visible = false,
56  const std::string& namingProperty = "name",
57  const std::string& subCompositeSuffix = " sub-hulls");
58 
59  void setGraph(tlp::Graph* graph);
60  DataSet getData();
61  void setData(const DataSet &dataSet);
62 
63  void createComposite();
64 
65  void setVisible(bool visible);
66  bool isVisible() const;
67 
68 protected :
69  virtual void treatEvents(const std::vector<Event> &events );
70  virtual void treatEvent(const Event&);
71 
72 private:
73  bool _shouldRecreate;
74  const tlp::Color getColor();
75  int _currentColor;
76 
77  /**
78  * Create the hierarchy of ConvexHullItem
79  */
80  void buildComposite(tlp::Graph* current, tlp::GlComposite* composite);
81 
82  Graph* _graph;
83  GlLayer* _layer;
84  GlComposite* _composite;
85  LayoutProperty* _layout;
86  SizeProperty* _size;
87  DoubleProperty* _rotation;
88  std::vector<Color> _fillColors;
89  std::string _layerName;
90  bool _isVisible;
91  const std::string _subCompositesSuffix;
92  const std::string _nameAttribute;
93 
94  const static std::string temporaryPropertyValue;
95  /**
96  * This map contains the composite that contains the associated graph's hull.
97  */
98  std::map<tlp::Graph*, std::pair<tlp::GlComposite*, GlConvexGraphHull*> > _graphsComposites;
99 };
100 
101 class GlHierarchyMainComposite : public GlComposite {
102 public:
103  GlHierarchyMainComposite(GlCompositeHierarchyManager* manager);
104  virtual void setVisible(bool visible);
105 private:
106  GlCompositeHierarchyManager* _manager;
107 };
108 }
109 
110 #endif
111 ///@endcond
GlSimpleEntity used to agregate other GlEntity.
Definition: GlComposite.h:39