Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlCompositeHierarchyManager.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 1 and Inria Bordeaux - Sud Ouest
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, std::string layerName, LayoutProperty* layout, SizeProperty* size,
53  DoubleProperty* rotation, bool visible = false, std::string namingProperty = "name", std::string subCompositeSuffix = " sub-hulls");
54 
55  void setGraph(tlp::Graph* graph);
56  DataSet getData();
57  void setData(const DataSet &dataSet);
58 
59  void createComposite();
60 
61  void setVisible(bool visible);
62  bool isVisible() const;
63 
64 protected :
65  virtual void treatEvents(const std::vector<Event> &events );
66  virtual void treatEvent(const Event&);
67 
68 private:
69  bool _shouldRecreate;
70  const tlp::Color getColor();
71  int _currentColor;
72 
73  /**
74  * Create the hierarchy of ConvexHullItem
75  */
76  void buildComposite(tlp::Graph* current, tlp::GlComposite* composite);
77 
78  Graph* _graph;
79  GlLayer* _layer;
80  GlComposite* _composite;
81  LayoutProperty* _layout;
82  SizeProperty* _size;
83  DoubleProperty* _rotation;
84  std::vector<Color> _fillColors;
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::GlComposite*, GlConvexGraphHull*> > _graphsComposites;
95 };
96 
97 class GlHierarchyMainComposite : public GlComposite {
98 public:
99  GlHierarchyMainComposite(GlCompositeHierarchyManager* manager);
100  virtual void setVisible(bool visible);
101 private:
102  GlCompositeHierarchyManager* _manager;
103 };
104 }
105 
106 #endif
107 ///@endcond