Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ProcrustesSubLayout.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/basic.h>
36
37namespace ogdf {
38class GraphAttributes;
39
41public:
43 explicit ProcrustesPointSet(int numPoints);
44
47
49 void normalize(bool flip = false);
50
52 void rotateTo(const ProcrustesPointSet& other);
53
55 double compare(const ProcrustesPointSet& other) const;
56
58 void set(int i, double x, double y) {
59 m_x[i] = x;
60 m_y[i] = y;
61 }
62
64 double getX(int i) const { return m_x[i]; }
65
67 double getY(int i) const { return m_y[i]; }
68
70 double originX() const { return m_originX; }
71
73 double originY() const { return m_originY; }
74
76 double scale() const { return m_scale; }
77
79 double angle() const { return m_angle; }
80
82 bool isFlipped() const { return m_flipped; }
83
84private:
87
89 double* m_x;
90
92 double* m_y;
93
95 double m_originX;
96
98 double m_originY;
99
101 double m_scale;
102
104 double m_angle;
105
107};
108
111public:
113 explicit ProcrustesSubLayout(LayoutModule* pSubLayout);
114
116 virtual ~ProcrustesSubLayout() { delete m_pSubLayout; }
117
118 virtual void call(GraphAttributes& GA) override;
119
121 void setScaleToInitialLayout(bool flag) { m_scaleToInitialLayout = flag; }
122
124 bool scaleToInitialLayout() const { return m_scaleToInitialLayout; }
125
126private:
128 void reverseTransform(GraphAttributes& graphAttributes, const ProcrustesPointSet& pointSet);
129
131 void translate(GraphAttributes& graphAttributes, double dx, double dy);
132
134 void rotate(GraphAttributes& graphAttributes, double angle);
135
137 void scale(GraphAttributes& graphAttributes, double scale);
138
140 void flipY(GraphAttributes& graphAttributes);
141
143 void copyFromGraphAttributes(const GraphAttributes& graphAttributes,
144 ProcrustesPointSet& pointSet);
145
148
151};
152
153}
Declaration of interface for layout algorithms (class LayoutModule)
Basic declarations, included by all source files.
Stores additional attributes of a graph (like layout information).
Interface of general layout algorithms.
~ProcrustesPointSet()
Destructor.
double getX(int i) const
Returns i'th x-coordinate.
void rotateTo(const ProcrustesPointSet &other)
Rotates the point set so it fits somehow on other.
int m_numPoints
Number of points.
double * m_y
Y coordinates.
double originY() const
Returns the origin's y.
double getY(int i) const
Returns i'th y-coordinate.
double * m_x
X coordinates.
double m_originY
Original average center's y when normalized.
bool isFlipped() const
Returns true if the point set is flipped by y coord.
double m_angle
If rotated, the angle.
double m_originX
Original average center's x when normalized.
ProcrustesPointSet(int numPoints)
Constructor for allocating memory for numPoints points.
void normalize(bool flip=false)
Translates and scales the set such that the average center is 0, 0 and the average size is 1....
double angle() const
Returns the rotation angle.
double compare(const ProcrustesPointSet &other) const
Calculates a value how good the two point sets match.
double originX() const
Returns the origin's x.
void set(int i, double x, double y)
Sets i'th coordinate.
double scale() const
Returns the scale factor.
Simple procrustes analysis.
void scale(GraphAttributes &graphAttributes, double scale)
Scales all coords in graphAttributes by scale.
void flipY(GraphAttributes &graphAttributes)
Flips all y coordinates.
void rotate(GraphAttributes &graphAttributes, double angle)
Rotates all coords in graphAttributes by angle.
void copyFromGraphAttributes(const GraphAttributes &graphAttributes, ProcrustesPointSet &pointSet)
Copies the coords in graph attributes to the point set.
virtual ~ProcrustesSubLayout()
Destructor.
void reverseTransform(GraphAttributes &graphAttributes, const ProcrustesPointSet &pointSet)
Does a reverse transform of graph attributes by using the origin, scale and angle in pointset.
bool m_scaleToInitialLayout
Option for enabling/disabling scaling to initial layout scale.
LayoutModule * m_pSubLayout
Layout module to call for a new layout.
virtual void call(GraphAttributes &GA) override
Computes a layout of graph GA.
ProcrustesSubLayout(LayoutModule *pSubLayout)
Constructor.
void setScaleToInitialLayout(bool flag)
Should the new layout scale be used or the initial scale? Defaults to true.
void translate(GraphAttributes &graphAttributes, double dx, double dy)
Moves all coords in graphAttributes by dx, dy.
bool scaleToInitialLayout() const
Should the new layout scale be used or the initial scale? Defaults to true.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.