Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ProcrustesSubLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 
36 namespace ogdf {
37 
39 public:
41  explicit ProcrustesPointSet(int numPoints);
42 
45 
47  void normalize(bool flip = false);
48 
50  void rotateTo(const ProcrustesPointSet& other);
51 
53  double compare(const ProcrustesPointSet& other) const;
54 
56  void set(int i, double x, double y) {
57  m_x[i] = x;
58  m_y[i] = y;
59  }
60 
62  double getX(int i) const { return m_x[i]; }
63 
65  double getY(int i) const { return m_y[i]; }
66 
68  double originX() const { return m_originX; }
69 
71  double originY() const { return m_originY; }
72 
74  double scale() const { return m_scale; }
75 
77  double angle() const { return m_angle; }
78 
80  bool isFlipped() const { return m_flipped; }
81 
82 private:
85 
87  double* m_x;
88 
90  double* m_y;
91 
93  double m_originX;
94 
96  double m_originY;
97 
99  double m_scale;
100 
102  double m_angle;
103 
104  bool m_flipped;
105 };
106 
109 public:
111  explicit ProcrustesSubLayout(LayoutModule* pSubLayout);
112 
114  virtual ~ProcrustesSubLayout() { delete m_pSubLayout; }
115 
116  virtual void call(GraphAttributes& GA) override;
117 
119  void setScaleToInitialLayout(bool flag) { m_scaleToInitialLayout = flag; }
120 
122  bool scaleToInitialLayout() const { return m_scaleToInitialLayout; }
123 
124 private:
126  void reverseTransform(GraphAttributes& graphAttributes, const ProcrustesPointSet& pointSet);
127 
129  void translate(GraphAttributes& graphAttributes, double dx, double dy);
130 
132  void rotate(GraphAttributes& graphAttributes, double angle);
133 
135  void scale(GraphAttributes& graphAttributes, double scale);
136 
138  void flipY(GraphAttributes& graphAttributes);
139 
141  void copyFromGraphAttributes(const GraphAttributes& graphAttributes,
142  ProcrustesPointSet& pointSet);
143 
146 
149 };
150 
151 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
ogdf::ProcrustesSubLayout::m_pSubLayout
LayoutModule * m_pSubLayout
Layout module to call for a new layout.
Definition: ProcrustesSubLayout.h:145
ogdf::ProcrustesSubLayout::~ProcrustesSubLayout
virtual ~ProcrustesSubLayout()
Destructor.
Definition: ProcrustesSubLayout.h:114
ogdf::ProcrustesPointSet::~ProcrustesPointSet
~ProcrustesPointSet()
Destructor.
ogdf::ProcrustesSubLayout::scaleToInitialLayout
bool scaleToInitialLayout() const
Should the new layout scale be used or the initial scale? Defaults to true.
Definition: ProcrustesSubLayout.h:122
ogdf::ProcrustesPointSet::m_x
double * m_x
X coordinates.
Definition: ProcrustesSubLayout.h:87
ogdf::ProcrustesPointSet::m_numPoints
int m_numPoints
Number of points.
Definition: ProcrustesSubLayout.h:84
ogdf::ProcrustesPointSet::m_originX
double m_originX
Original average center's x when normalized.
Definition: ProcrustesSubLayout.h:93
ogdf::ProcrustesPointSet::m_flipped
bool m_flipped
Definition: ProcrustesSubLayout.h:104
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::ProcrustesPointSet::m_scale
double m_scale
Scale factor.
Definition: ProcrustesSubLayout.h:99
ogdf::ProcrustesPointSet::scale
double scale() const
Returns the scale factor.
Definition: ProcrustesSubLayout.h:74
ogdf::ProcrustesPointSet::angle
double angle() const
Returns the rotation angle.
Definition: ProcrustesSubLayout.h:77
ogdf::ProcrustesPointSet::ProcrustesPointSet
ProcrustesPointSet(int numPoints)
Constructor for allocating memory for numPoints points.
ogdf::ProcrustesPointSet::m_originY
double m_originY
Original average center's y when normalized.
Definition: ProcrustesSubLayout.h:96
ogdf::ProcrustesPointSet::m_angle
double m_angle
If rotated, the angle.
Definition: ProcrustesSubLayout.h:102
ogdf::ProcrustesPointSet::normalize
void normalize(bool flip=false)
Translates and scales the set such that the average center is 0, 0 and the average size is 1....
ogdf::ProcrustesPointSet::originY
double originY() const
Returns the origin's y.
Definition: ProcrustesSubLayout.h:71
ogdf::ProcrustesPointSet::m_y
double * m_y
Y coordinates.
Definition: ProcrustesSubLayout.h:90
ogdf::ProcrustesPointSet::isFlipped
bool isFlipped() const
Returns true if the point set is flipped by y coord.
Definition: ProcrustesSubLayout.h:80
ogdf::ProcrustesSubLayout
Simple procrustes analysis.
Definition: ProcrustesSubLayout.h:108
ogdf::ProcrustesPointSet::compare
double compare(const ProcrustesPointSet &other) const
Calculates a value how good the two point sets match.
ogdf::ProcrustesSubLayout::m_scaleToInitialLayout
bool m_scaleToInitialLayout
Option for enabling/disabling scaling to initial layout scale.
Definition: ProcrustesSubLayout.h:148
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::ProcrustesPointSet::getY
double getY(int i) const
Returns i'th y-coordinate.
Definition: ProcrustesSubLayout.h:65
ogdf::ProcrustesPointSet::originX
double originX() const
Returns the origin's x.
Definition: ProcrustesSubLayout.h:68
ogdf::ProcrustesPointSet::getX
double getX(int i) const
Returns i'th x-coordinate.
Definition: ProcrustesSubLayout.h:62
ogdf::ProcrustesPointSet::rotateTo
void rotateTo(const ProcrustesPointSet &other)
Rotates the point set so it fits somehow on other.
ogdf::ProcrustesPointSet::set
void set(int i, double x, double y)
Sets i'th coordinate.
Definition: ProcrustesSubLayout.h:56
ogdf::ProcrustesPointSet
Definition: ProcrustesSubLayout.h:38
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:44
ogdf::ProcrustesSubLayout::setScaleToInitialLayout
void setScaleToInitialLayout(bool flag)
Should the new layout scale be used or the initial scale? Defaults to true.
Definition: ProcrustesSubLayout.h:119