Tulip  4.10.0
Better Visualization Through Research
IntegerProperty.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
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 
20 #ifndef TULIP_INT_H
21 #define TULIP_INT_H
22 
23 #include <tulip/tuliphash.h>
24 #include <tulip/PropertyTypes.h>
25 #include <tulip/AbstractProperty.h>
26 #include <tulip/PropertyAlgorithm.h>
27 #include <tulip/Observable.h>
28 #include <tulip/minmaxproperty.h>
29 #include <tulip/NumericProperty.h>
30 
31 namespace tlp {
32 
33 class Graph;
34 class PropertyContext;
35 
36 typedef MinMaxProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> IntegerMinMaxProperty;
37 
38 /**
39  * @ingroup Graph
40  * @brief A graph property that maps an integer value to graph elements.
41  */
42 class TLP_SCOPE IntegerProperty : public IntegerMinMaxProperty {
43 
44 public :
45  IntegerProperty(Graph *, const std::string& n = "");
46 
47  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
48  static const std::string propertyTypename;
49  const std::string& getTypename() const {
50  return propertyTypename;
51  }
52  virtual void setNodeValue(const node n, const int &v);
53  virtual void setEdgeValue(const edge e, const int &v);
54  virtual void setAllNodeValue(const int &v, const Graph *graph = NULL);
55  virtual void setAllEdgeValue(const int &v, const Graph *graph = NULL);
56 
57  int compare(const node n1, const node n2) const;
58  int compare(const edge e1, const edge e2) const;
59 
60  // NumericProperty interface
61  virtual double getNodeDoubleValue(const node n) const {
62  return (double) getNodeValue(n);
63  }
64  virtual double getNodeDoubleDefaultValue() const {
65  return (double) getNodeDefaultValue();
66  }
67  virtual double getNodeDoubleMin(const Graph* g = NULL) {
68  return (double) getNodeMin(g);
69  }
70  virtual double getNodeDoubleMax(const Graph* g = NULL) {
71  return (double) getNodeMax(g);
72  }
73  virtual double getEdgeDoubleValue(const edge e) const {
74  return (double) getEdgeValue(e);
75  }
76  virtual double getEdgeDoubleDefaultValue() const {
77  return (double) getEdgeDefaultValue();
78  }
79  virtual double getEdgeDoubleMin(const Graph* g = NULL) {
80  return (double) getEdgeMin(g);
81  }
82  virtual double getEdgeDoubleMax(const Graph* g = NULL) {
83  return (double) getEdgeMax(g);
84  }
85 
86  void nodesUniformQuantification(unsigned int);
87 
88  void edgesUniformQuantification(unsigned int);
89 
90  NumericProperty* copyProperty(Graph *g) {
91  IntegerProperty* newProp = new IntegerProperty(g);
92  newProp->copy(this);
93 
94  return newProp;
95  }
96 
97 protected:
99 
100 private:
101  // override Observable::treatEvent
102  void treatEvent(const Event&);
103 };
104 
105 /**
106  * @ingroup Graph
107  * @brief A graph property that maps a std::vector<int> value to graph elements.
108  */
109 class TLP_SCOPE IntegerVectorProperty:public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
110 public :
111  IntegerVectorProperty(Graph *g, const std::string& n =""):AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
112  // redefinition of some PropertyInterface methods
113  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
114  static const std::string propertyTypename;
115  const std::string& getTypename() const {
116  return propertyTypename;
117  }
118 
119 };
120 
121 
122 }
123 #endif
124 ///@endcond
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
PropertyInterface describes the interface of a graph property.
The edge struct represents an edge in a Graph object.
Definition: Edge.h:39
The node struct represents a node in a Graph object.
Definition: Node.h:39
A graph property that maps a std::vector<int> value to graph elements.
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:47
Interface all numerical properties. Property values are always returned as double.
A graph property that maps an integer value to graph elements.