Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GraphDecorator.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 DOXYGEN_NOTFOR_DEVEL
22 
23 #ifndef Tulip_GraphDecorator_H
24 #define Tulip_GraphDecorator_H
25 
26 #include <tulip/Graph.h>
27 
28 namespace tlp {
29 
30 class TLP_SCOPE GraphDecorator : public Graph { // non-orient�, planaire
31 public:
32  GraphDecorator(Graph* s) {
33  assert(s);
34  graph_component = s;
35  }
36  virtual ~GraphDecorator() {
37  notifyDestroy();
38  }
39 
40  virtual void clear();
41  virtual Graph *addSubGraph(BooleanProperty *selection=0,
42  unsigned int id = 0);
43  virtual void delSubGraph(Graph * s);
44  virtual void delAllSubGraphs(Graph *s);
45  virtual Graph* getSuperGraph()const;
46  virtual void setSuperGraph(Graph* s);
47  virtual Graph* getRoot() const;
48  virtual Iterator<Graph *> * getSubGraphs() const;
49  virtual bool isSubGraph(const Graph* sg) const;
50  virtual bool isDescendantGraph(const Graph* sg) const;
51  virtual Graph* getSubGraph(unsigned int id) const;
52  virtual Graph* getSubGraph(const std::string &name) const;
53  virtual Graph* getDescendantGraph(unsigned int id) const;
54  virtual Graph* getDescendantGraph(const std::string &name) const;
55  virtual unsigned int numberOfSubGraphs() const;
56  virtual unsigned int numberOfDescendantGraphs() const;
57 
58  //============================================================
59  virtual node source(const edge e)const;
60  virtual void setSource(const edge, const node);
61  virtual node target(const edge e)const;
62  virtual void setTarget(const edge, const node);
63  virtual node opposite(const edge e, const node n)const;
64  virtual edge existEdge(const node n, const node m, bool directed = true)const;
65  virtual const std::pair<node, node>& ends(const edge e) const;
66  virtual void setEnds(const edge, const node, const node);
67  virtual void reverse(const edge e);
68  virtual unsigned int deg(const node n)const;
69  virtual unsigned int indeg(const node n)const;
70  virtual unsigned int outdeg(const node n)const;
71  virtual Graph* getNodeMetaInfo(const node n)const;
72 
73  //============================================================
74  virtual node getOneNode() const;
75  virtual node getInNode(const node n,unsigned int i)const;
76  virtual node getOutNode(const node n,unsigned int i) const;
77  virtual edge getOneEdge() const;
78 
79  virtual unsigned int numberOfNodes()const;
80  virtual unsigned int numberOfEdges()const;
81 
82  //=========================================================================
83 
84  virtual void reserveNodes(unsigned int nbNodes);
85  virtual void reserveEdges(unsigned int nbEdges);
86 
87  //============================================================
88  virtual bool isElement(const node n) const;
89  virtual bool isMetaNode(const node n) const;
90  virtual bool isElement(const edge e) const;
91  virtual bool isMetaEdge(const edge e) const;
92  virtual node addNode();
93  virtual void addNodes(unsigned int nb, std::vector<node>& addedNodes);
94  virtual void addNode(const node);
95  virtual void addNodes(Iterator<node>* nodes);
96  virtual edge addEdge(const node n1, const node n2);
97  virtual void addEdges(const std::vector<std::pair<node, node> >& edges,
98  std::vector<edge>& addedEdges);
99  virtual void addEdge(const edge);
100  virtual void addEdges(Iterator<edge>* edges);
101  virtual void delNode(const tlp::node n, bool deleteInAllGraphs = false);
102  virtual void delNodes(Iterator<node>* itN, bool deleteInAllGraphs);
103  virtual void delEdge(const tlp::edge e, bool deleteInAllGraphs = false);
104  virtual void delEdges(Iterator<edge>* itE, bool deleteInAllGraphs = false);
105  virtual void setEdgeOrder(const node n,const std::vector<edge> & s);
106  virtual void swapEdgeOrder(const node n ,const edge e1, const edge e2);
107 
108  virtual Iterator<node>* getNodes() const;
109  virtual Iterator<node>* getInNodes(const node n) const;
110  virtual Iterator<node>* getOutNodes(const node n) const;
111  virtual Iterator<node>* getInOutNodes(const node n) const;
112  virtual Iterator<edge>* getEdges() const;
113  virtual Iterator<edge>* getOutEdges(const node n) const;
114  virtual Iterator<edge>* getInOutEdges(const node n) const;
115  virtual Iterator<edge>* getInEdges(const node n) const;
116  virtual Iterator<edge>* getEdgeMetaInfo(const edge) const;
117  //============================================================
118  virtual PropertyInterface* getProperty(const std::string &name) const;
119  virtual bool existProperty(const std::string&name) const;
120  virtual bool existLocalProperty(const std::string&name) const;
121  virtual void delLocalProperty(const std::string&name);
122  virtual void addLocalProperty(const std::string &name, PropertyInterface *prop);
123  virtual Iterator<std::string>* getLocalProperties() const;
124  virtual Iterator<std::string>* getInheritedProperties() const;
125  virtual Iterator<std::string>* getProperties() const;
126  virtual Iterator<PropertyInterface*>* getLocalObjectProperties() const;
127  virtual Iterator<PropertyInterface*>* getInheritedObjectProperties() const;
128  virtual Iterator<PropertyInterface*>* getObjectProperties() const;
129  // updates management
130  virtual void push(bool unpopAllowed = true,
131  std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
132  virtual void pop(bool unpopAllowed = true);
133  virtual void unpop();
134  virtual bool canPop();
135  virtual bool canUnpop();
136  virtual bool canPopThenUnpop();
137  //============================================================
138 
139  virtual void setName(const std::string &name);
140  virtual std::string getName() const;
141 
142 protected:
143  virtual DataSet & getNonConstAttributes();
144  Graph* graph_component;
145  // designed to reassign an id to a previously deleted elt
146  // called by GraphUpdatesRecorder
147  virtual node restoreNode(node);
148  virtual edge restoreEdge(edge, node source, node target);
149  virtual void restoreNodes(const std::vector<node>&);
150  virtual void restoreEdges(const std::vector<edge>& edges,
151  const std::vector<std::pair<node, node> >& ends);
152  // designed to only update own structures
153  // used by GraphUpdatesRecorder
154  virtual void removeNode(const node);
155  virtual void removeEdge(const edge);
156  // internally used to deal with sub graph deletion
157  virtual void removeSubGraph(Graph*);
158  virtual void clearSubGraphs();
159  virtual void restoreSubGraph(Graph*);
160  virtual void setSubGraphToKeep(Graph*);
161 };
162 
163 }
164 
165 #endif
166 
167 #endif //DOXYGEN_NOTFOR_DEVEL
168 ///@endcond