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