Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
DoubleProperty.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 
20 #ifndef TULIP_METRIC_H
21 #define TULIP_METRIC_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/minmaxproperty.h>
28 
29 namespace tlp {
30 
31 class PropertyContext;
32 
33 typedef MinMaxProperty<tlp::DoubleType, tlp::DoubleType> DoubleMinMaxProperty;
34 
35 /**
36  * @ingroup Graph
37  * @brief A graph property that maps a double value to graph elements.
38  */
39 class TLP_SCOPE DoubleProperty : public DoubleMinMaxProperty {
40 public :
41  DoubleProperty (Graph *, std::string n="");
42  void uniformQuantification(unsigned int);
43  void nodesUniformQuantification(unsigned int);
44  void edgesUniformQuantification(unsigned int);
45 
46  virtual void clone_handler(AbstractProperty<tlp::DoubleType, tlp::DoubleType> &);
47 
48  PropertyInterface* clonePrototype(Graph *, const std::string& );
49  static const std::string propertyTypename;
50  std::string getTypename() const {
51  return propertyTypename;
52  }
53 
54 
55  virtual void setNodeValue(const node n, const double &v);
56  virtual void setEdgeValue(const edge e, const double &v);
57  virtual void setAllNodeValue(const double &v);
58  virtual void setAllEdgeValue(const double &v);
59 
60  enum PredefinedMetaValueCalculator {NO_CALC = 0, AVG_CALC = 1, SUM_CALC = 2,
61  MAX_CALC = 3, MIN_CALC = 4
62  };
63 
64  // setMetaValueCalculator overloading
65  virtual void setMetaValueCalculator(PropertyInterface::MetaValueCalculator* calc);
66  void setMetaValueCalculator(PredefinedMetaValueCalculator nodeCalc = AVG_CALC,
67  PredefinedMetaValueCalculator edgeCalc = AVG_CALC);
68 
69 private:
70  // override Observable::treatEvent
71  void treatEvent(const Event&);
72 
73 };
74 
75 /**
76  * @ingroup Graph
77  * @brief A graph property that maps a std::vector<double> value to graph elements.
78  */
79 
80 class TLP_SCOPE DoubleVectorProperty:public AbstractVectorProperty<tlp::DoubleVectorType, tlp::DoubleType> {
81 public :
82  DoubleVectorProperty(Graph *g, std::string n=""):AbstractVectorProperty<DoubleVectorType, tlp::DoubleType>(g, n) {}
83  // redefinition of some PropertyInterface methods
84  PropertyInterface* clonePrototype(Graph *, const std::string& );
85  static const std::string propertyTypename;
86  std::string getTypename() const {
87  return propertyTypename;
88  }
89 
90 };
91 
92 
93 }
94 #endif