Tulip  5.5.1
Large graphs analysis and drawing
SizeProperty.h
1 /*
2  *
3  * This file is part of Tulip (http://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 
44  Size getMax(const Graph *sg = nullptr);
45  Size getMin(const Graph *sg = nullptr);
46  void scale(const tlp::Vector<float, 3> &, const Graph *sg = nullptr);
47  void scale(const tlp::Vector<float, 3> &, Iterator<node> *, Iterator<edge> *);
48 
49  // redefinition of some PropertyInterface methods
50  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
51  static const std::string propertyTypename;
52  const std::string &getTypename() const override {
53  return propertyTypename;
54  }
55  DEFINE_GET_CPP_CLASS_NAME;
56 
57  // redefinition of some AbstractProperty methods
58  void setNodeValue(const node n, tlp::StoredType<Size>::ReturnedConstValue v) override;
59  void setAllNodeValue(tlp::StoredType<Size>::ReturnedConstValue v) override;
60  void setValueToGraphNodes(tlp::StoredType<Size>::ReturnedConstValue v,
61  const Graph *graph) override;
62 
63  int compare(const node n1, const node n2) const override;
64 
65 protected:
66  void resetMinMax();
67 
68 private:
69  std::unordered_map<unsigned int, Size> max, min;
70  std::unordered_map<unsigned int, bool> minMaxOk;
71  void computeMinMax(const Graph *sg = nullptr);
72 };
73 
74 /**
75  * @ingroup Graph
76  * @brief A graph property that maps a std::vector<tlp::Size> value to graph elements.
77  */
78 class TLP_SCOPE SizeVectorProperty
79  : public AbstractVectorProperty<tlp::SizeVectorType, tlp::SizeType> {
80 public:
81  SizeVectorProperty(Graph *g, const std::string &n = "")
82  : AbstractVectorProperty<SizeVectorType, SizeType>(g, n) {}
83 
84  // redefinition of some PropertyInterface methods
85  PropertyInterface *clonePrototype(Graph *, const std::string &) const override;
86  static const std::string propertyTypename;
87  const std::string &getTypename() const override {
88  return propertyTypename;
89  }
90  DEFINE_GET_CPP_CLASS_NAME;
91 };
92 } // namespace tlp
93 #endif
tlp::Graph
Definition: Graph.h:234
tlp::SizeVectorProperty
A graph property that maps a std::vector<tlp::Size> value to graph elements.
Definition: SizeProperty.h:78
tlp::SizeProperty::getTypename
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: SizeProperty.h:52
tlp::SizeVectorProperty::getTypename
const std::string & getTypename() const override
Gets a string describing the type of the property value (e.g. "graph", "double", "layout",...
Definition: SizeProperty.h:87
tlp::SizeProperty
A graph property that maps a tlp::Size value to graph elements.
Definition: SizeProperty.h:39
tlp::PropertyInterface
PropertyInterface describes the interface of a graph property.
Definition: PropertyInterface.h:60
tlp::AbstractProperty
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
Definition: AbstractProperty.h:55
tlp::Iterator
Interface for Tulip iterators. Allows basic iteration operations only.
Definition: Graph.h:43
tlp
Definition: AbstractProperty.h:34
tlp::node
The node struct represents a node in a Graph object.
Definition: Node.h:40