Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/GlCompositeHierarchyManager.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef GL_HCVXHULL_H
00022 #define GL_HCVXHULL_H
00023 
00024 #include <string>
00025 #include <map>
00026 
00027 #include <tulip/DataSet.h>
00028 #include <tulip/Observable.h>
00029 #include <tulip/GlComposite.h>
00030 
00031 namespace tlp {
00032 
00033 class GlConvexGraphHull;
00034 
00035 struct node;
00036 class Color;
00037 class LayoutProperty;
00038 class DoubleProperty;
00039 class SizeProperty;
00040 struct ConvexHullItem;
00041 class GlConvexHull;
00042 class Graph;
00043 class GlLayer;
00044 
00045 /**
00046  * Create a GlComposite item for each and every graph and subgraph.
00047  * This class observes the graph to update said hierarchy when a subgraph is added or deleted.
00048  */
00049 class TLP_QT_SCOPE GlCompositeHierarchyManager : private Observable {
00050 
00051 public:
00052   GlCompositeHierarchyManager(Graph* graph, GlLayer* layer,
00053                               const std::string& layerName,
00054                               LayoutProperty* layout, SizeProperty* size,
00055                               DoubleProperty* rotation, bool visible = false,
00056                               const std::string& namingProperty = "name",
00057                               const std::string& subCompositeSuffix = " sub-hulls");
00058 
00059   void setGraph(tlp::Graph* graph);
00060   DataSet getData();
00061   void setData(const DataSet &dataSet);
00062 
00063   void createComposite();
00064 
00065   void setVisible(bool visible);
00066   bool isVisible() const;
00067 
00068 protected :
00069   virtual void treatEvents(const  std::vector<Event> &events );
00070   virtual void treatEvent(const Event&);
00071 
00072 private:
00073   bool _shouldRecreate;
00074   const tlp::Color getColor();
00075   int _currentColor;
00076 
00077   /**
00078    * Create the hierarchy of ConvexHullItem
00079    */
00080   void buildComposite(tlp::Graph* current, tlp::GlComposite* composite);
00081 
00082   Graph* _graph;
00083   GlLayer* _layer;
00084   GlComposite* _composite;
00085   LayoutProperty* _layout;
00086   SizeProperty* _size;
00087   DoubleProperty* _rotation;
00088   std::vector<Color> _fillColors;
00089   std::string _layerName;
00090   bool _isVisible;
00091   const std::string _subCompositesSuffix;
00092   const std::string _nameAttribute;
00093 
00094   const static std::string temporaryPropertyValue;
00095   /**
00096    * This map contains the composite that contains the associated graph's hull.
00097    */
00098   std::map<tlp::Graph*, std::pair<tlp::GlComposite*, GlConvexGraphHull*> > _graphsComposites;
00099 };
00100 
00101 class GlHierarchyMainComposite : public GlComposite {
00102 public:
00103   GlHierarchyMainComposite(GlCompositeHierarchyManager* manager);
00104   virtual void setVisible(bool visible);
00105 private:
00106   GlCompositeHierarchyManager* _manager;
00107 };
00108 }
00109 
00110 #endif
00111 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties