Tulip  4.3.0
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 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 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 *, std::string n = "");
47 
48  PropertyInterface* clonePrototype(Graph *, const std::string& );
49  static const std::string propertyTypename;
50  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 getNodeDoubleMin(Graph* g = NULL) {
66  return (double) getNodeMin(g);
67  }
68  virtual double getNodeDoubleMax(Graph* g = NULL) {
69  return (double) getNodeMax(g);
70  }
71  virtual double getEdgeDoubleValue(const edge e) const {
72  return (double) getEdgeValue(e);
73  }
74  virtual double getEdgeDoubleMin(Graph* g = NULL) {
75  return (double) getEdgeMin(g);
76  }
77  virtual double getEdgeDoubleMax(Graph* g = NULL) {
78  return (double) getEdgeMax(g);
79  }
80 
81  void nodesUniformQuantification(unsigned int);
82 
83  void edgesUniformQuantification(unsigned int);
84 
85  NumericProperty* copyProperty(Graph *g) {
86  IntegerProperty* newProp = new IntegerProperty(g);
87  newProp->copy(this);
88 
89  return newProp;
90  }
91 
92 protected:
93  virtual void clone_handler(AbstractProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> &);
94 
95 private:
96  // override Observable::treatEvent
97  void treatEvent(const Event&);
98 };
99 
100 /**
101  * @ingroup Graph
102  * @brief A graph property that maps a std::vector<int> value to graph elements.
103  */
104 class TLP_SCOPE IntegerVectorProperty:public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
105 public :
106  IntegerVectorProperty(Graph *g, std::string n =""):AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
107  // redefinition of some PropertyInterface methods
108  PropertyInterface* clonePrototype(Graph *, const std::string& );
109  static const std::string propertyTypename;
110  std::string getTypename() const {
111  return propertyTypename;
112  }
113 
114 };
115 
116 
117 }
118 #endif
119 ///@endcond