![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef TULIP_INT_H 00022 #define TULIP_INT_H 00023 00024 #include <tulip/tuliphash.h> 00025 #include <tulip/PropertyTypes.h> 00026 #include <tulip/AbstractProperty.h> 00027 #include <tulip/PropertyAlgorithm.h> 00028 #include <tulip/Observable.h> 00029 #include <tulip/minmaxproperty.h> 00030 #include <tulip/NumericProperty.h> 00031 00032 namespace tlp { 00033 00034 class Graph; 00035 class PropertyContext; 00036 00037 typedef MinMaxProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> IntegerMinMaxProperty; 00038 00039 /** 00040 * @ingroup Graph 00041 * @brief A graph property that maps an integer value to graph elements. 00042 */ 00043 class TLP_SCOPE IntegerProperty : public IntegerMinMaxProperty { 00044 00045 public : 00046 IntegerProperty(Graph *, const std::string& n = ""); 00047 00048 PropertyInterface* clonePrototype(Graph *, const std::string& ); 00049 static const std::string propertyTypename; 00050 const std::string& getTypename() const { 00051 return propertyTypename; 00052 } 00053 virtual void setNodeValue(const node n, const int &v); 00054 virtual void setEdgeValue(const edge e, const int &v); 00055 virtual void setAllNodeValue(const int &v); 00056 virtual void setAllEdgeValue(const int &v); 00057 00058 int compare(const node n1, const node n2) const; 00059 int compare(const edge e1, const edge e2) const; 00060 00061 // NumericProperty interface 00062 virtual double getNodeDoubleValue(const node n) const { 00063 return (double) getNodeValue(n); 00064 } 00065 virtual double getNodeDoubleDefaultValue() const { 00066 return (double) getNodeDefaultValue(); 00067 } 00068 virtual double getNodeDoubleMin(Graph* g = NULL) { 00069 return (double) getNodeMin(g); 00070 } 00071 virtual double getNodeDoubleMax(Graph* g = NULL) { 00072 return (double) getNodeMax(g); 00073 } 00074 virtual double getEdgeDoubleValue(const edge e) const { 00075 return (double) getEdgeValue(e); 00076 } 00077 virtual double getEdgeDoubleDefaultValue() const { 00078 return (double) getEdgeDefaultValue(); 00079 } 00080 virtual double getEdgeDoubleMin(Graph* g = NULL) { 00081 return (double) getEdgeMin(g); 00082 } 00083 virtual double getEdgeDoubleMax(Graph* g = NULL) { 00084 return (double) getEdgeMax(g); 00085 } 00086 00087 void nodesUniformQuantification(unsigned int); 00088 00089 void edgesUniformQuantification(unsigned int); 00090 00091 NumericProperty* copyProperty(Graph *g) { 00092 IntegerProperty* newProp = new IntegerProperty(g); 00093 newProp->copy(this); 00094 00095 return newProp; 00096 } 00097 00098 protected: 00099 virtual void clone_handler(AbstractProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> &); 00100 00101 private: 00102 // override Observable::treatEvent 00103 void treatEvent(const Event&); 00104 }; 00105 00106 /** 00107 * @ingroup Graph 00108 * @brief A graph property that maps a std::vector<int> value to graph elements. 00109 */ 00110 class TLP_SCOPE IntegerVectorProperty:public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> { 00111 public : 00112 IntegerVectorProperty(Graph *g, const std::string& n =""):AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {} 00113 // redefinition of some PropertyInterface methods 00114 PropertyInterface* clonePrototype(Graph *, const std::string& ); 00115 static const std::string propertyTypename; 00116 const std::string& getTypename() const { 00117 return propertyTypename; 00118 } 00119 00120 }; 00121 00122 00123 } 00124 #endif 00125 ///@endcond