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