Tulip  5.7.4
Large graphs analysis and drawing
SizeProperty.h
1 /*
2  *
3  * This file is part of Tulip (https://tulip.labri.fr)
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_SIZES_H
21 #define TULIP_SIZES_H
22 
23 #include <unordered_map>
24 
25 #include <tulip/PropertyTypes.h>
26 #include <tulip/AbstractProperty.h>
27 #include <tulip/PropertyAlgorithm.h>
28 
29 namespace tlp {
30 
31 class PropertyContext;
32 
33 typedef AbstractProperty<tlp::SizeType, tlp::SizeType> AbstractSizeProperty;
34 
35 /**
36  * @ingroup Graph
37  * @brief A graph property that maps a tlp::Size value to graph elements.
38  */
39 class TLP_SCOPE SizeProperty : public AbstractSizeProperty {
40 
41 public:
42  SizeProperty(Graph *, const std::string &n = "");
43  using AbstractSizeProperty::operator=;
44 
45  Size getMax(const Graph *sg = nullptr);
46  Size getMin(const Graph *sg = nullptr);
47  void scale(const tlp::Vector<float, 3> &, const Graph *sg = nullptr);
48  void scale(const tlp::Vector<float, 3> &, Iterator<node> *, Iterator<edge> *);
49 
50  // redefinition of some PropertyInterface methods
51  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
52  static const std::string propertyTypename;
53  const std::string &getTypename() const override {
54  return propertyTypename;
55  }
56  DEFINE_GET_CPP_CLASS_NAME;
57 
58  // redefinition of some AbstractProperty methods
59  void setNodeValue(const node n,
60  tlp::StoredType<tlp::SizeType::RealType>::ReturnedConstValue v) override;
61  void setAllNodeValue(tlp::StoredType<tlp::SizeType::RealType>::ReturnedConstValue v) override;
62  void setValueToGraphNodes(tlp::StoredType<tlp::SizeType::RealType>::ReturnedConstValue v,
63  const Graph *graph) override;
64 
65  int compare(const node n1, const node n2) const override;
66 
67 protected:
68  void resetMinMax();
69 
70 private:
71  std::unordered_map<unsigned int, Size> max, min;
72  std::unordered_map<unsigned int, bool> minMaxOk;
73  void computeMinMax(const Graph *sg = nullptr);
74 };
75 
76 /**
77  * @ingroup Graph
78  * @brief A graph property that maps a std::vector<tlp::Size> value to graph elements.
79  */
80 class TLP_SCOPE SizeVectorProperty
81  : public AbstractVectorProperty<tlp::SizeVectorType, tlp::SizeType> {
82 public:
83  SizeVectorProperty(Graph *g, const std::string &n = "")
84  : AbstractVectorProperty<SizeVectorType, SizeType>(g, n) {}
85  using AbstractVectorProperty<tlp::SizeVectorType, tlp::SizeType>::operator=;
86 
87  // redefinition of some PropertyInterface methods
88  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
89  static const std::string propertyTypename;
90  const std::string &getTypename() const override {
91  return propertyTypename;
92  }
93  DEFINE_GET_CPP_CLASS_NAME;
94 };
95 } // namespace tlp
96 #endif
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.
A graph property that maps a tlp::Size value to graph elements.
Definition: SizeProperty.h:39
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: SizeProperty.h:53
PropertyInterface * clonePrototype(Graph *, const std::string &) const override
Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph. The new property will no...
int compare(const node n1, const node n2) const override
Compares the value this property holds for the two given nodes.
A graph property that maps a std::vector<tlp::Size> value to graph elements.
Definition: SizeProperty.h:81
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: SizeProperty.h:90
PropertyInterface * clonePrototype(Graph *, const std::string &) const override
Creates a property of the same type (e.g. tlp::DoubleProperty) in the graph. The new property will no...
Interface for Tulip iterators. Allows basic iteration operations only.
Definition: Iterator.h:74
The node struct represents a node in a Graph object.
Definition: Node.h:40