Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ProcrustesSubLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 #include <ogdf/basic/basic.h>
36 
37 namespace ogdf {
38 class GraphAttributes;
39 
41 public:
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 
84 private:
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 
106  bool m_flipped;
107 };
108 
111 public:
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 
126 private:
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 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ogdf::ProcrustesSubLayout::m_pSubLayout
LayoutModule * m_pSubLayout
Layout module to call for a new layout.
Definition: ProcrustesSubLayout.h:147
ogdf::ProcrustesSubLayout::~ProcrustesSubLayout
virtual ~ProcrustesSubLayout()
Destructor.
Definition: ProcrustesSubLayout.h:116
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:124
ogdf::ProcrustesPointSet::m_x
double * m_x
X coordinates.
Definition: ProcrustesSubLayout.h:89
ogdf::ProcrustesPointSet::m_numPoints
int m_numPoints
Number of points.
Definition: ProcrustesSubLayout.h:86
ogdf::ProcrustesPointSet::m_originX
double m_originX
Original average center's x when normalized.
Definition: ProcrustesSubLayout.h:95
ogdf::ProcrustesPointSet::m_flipped
bool m_flipped
Definition: ProcrustesSubLayout.h:106
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::ProcrustesPointSet::m_scale
double m_scale
Scale factor.
Definition: ProcrustesSubLayout.h:101
ogdf::ProcrustesPointSet::scale
double scale() const
Returns the scale factor.
Definition: ProcrustesSubLayout.h:76
ogdf::ProcrustesPointSet::angle
double angle() const
Returns the rotation angle.
Definition: ProcrustesSubLayout.h:79
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:98
ogdf::ProcrustesPointSet::m_angle
double m_angle
If rotated, the angle.
Definition: ProcrustesSubLayout.h:104
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:73
ogdf::ProcrustesPointSet::m_y
double * m_y
Y coordinates.
Definition: ProcrustesSubLayout.h:92
ogdf::ProcrustesPointSet::isFlipped
bool isFlipped() const
Returns true if the point set is flipped by y coord.
Definition: ProcrustesSubLayout.h:82
ogdf::ProcrustesSubLayout
Simple procrustes analysis.
Definition: ProcrustesSubLayout.h:110
ogdf::ProcrustesPointSet::compare
double compare(const ProcrustesPointSet &other) const
Calculates a value how good the two point sets match.
basic.h
Basic declarations, included by all source files.
ogdf::ProcrustesSubLayout::m_scaleToInitialLayout
bool m_scaleToInitialLayout
Option for enabling/disabling scaling to initial layout scale.
Definition: ProcrustesSubLayout.h:150
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:67
ogdf::ProcrustesPointSet::originX
double originX() const
Returns the origin's x.
Definition: ProcrustesSubLayout.h:70
ogdf::ProcrustesPointSet::getX
double getX(int i) const
Returns i'th x-coordinate.
Definition: ProcrustesSubLayout.h:64
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:58
ogdf::ProcrustesPointSet
Definition: ProcrustesSubLayout.h:40
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45
ogdf::ProcrustesSubLayout::setScaleToInitialLayout
void setScaleToInitialLayout(bool flag)
Should the new layout scale be used or the initial scale? Defaults to true.
Definition: ProcrustesSubLayout.h:121