Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ProcrustesSubLayout.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 
36 namespace ogdf {
37 
39 {
40 public:
42  explicit ProcrustesPointSet(int numPoints);
43 
46 
48  void normalize(bool flip = false);
49 
51  void rotateTo(const ProcrustesPointSet& other);
52 
54  double compare(const ProcrustesPointSet& other) const;
55 
57  void set(int i, double x, double y)
58  {
59  m_x[i] = x;
60  m_y[i] = y;
61  }
62 
64  double getX(int i) const
65  {
66  return m_x[i];
67  }
68 
70  double getY(int i) const
71  {
72  return m_y[i];
73  }
74 
76  double originX() const
77  {
78  return m_originX;
79  }
80 
82  double originY() const
83  {
84  return m_originY;
85  }
86 
88  double scale() const
89  {
90  return m_scale;
91  }
92 
94  double angle() const
95  {
96  return m_angle;
97  }
98 
100  bool isFlipped() const
101  {
102  return m_flipped;
103  }
104 
105 private:
108 
110  double* m_x;
111 
113  double* m_y;
114 
116  double m_originX;
117 
119  double m_originY;
120 
122  double m_scale;
123 
125  double m_angle;
126 
127  bool m_flipped;
128 };
129 
132 {
133 public:
135  explicit ProcrustesSubLayout(LayoutModule* pSubLayout);
136 
139  delete m_pSubLayout;
140  }
141 
142  virtual void call(GraphAttributes &GA) override;
143 
145  void setScaleToInitialLayout(bool flag)
146  {
147  m_scaleToInitialLayout = flag;
148  }
149 
151  bool scaleToInitialLayout() const
152  {
153  return m_scaleToInitialLayout;
154  }
155 
156 private:
158  void reverseTransform(GraphAttributes& graphAttributes, const ProcrustesPointSet& pointSet);
159 
161  void translate(GraphAttributes& graphAttributes, double dx, double dy);
162 
164  void rotate(GraphAttributes& graphAttributes, double angle);
165 
167  void scale(GraphAttributes& graphAttributes, double scale);
168 
170  void flipY(GraphAttributes& graphAttributes);
171 
173  void copyFromGraphAttributes(const GraphAttributes& graphAttributes, ProcrustesPointSet& pointSet);
174 
177 
180 };
181 
182 }
void setScaleToInitialLayout(bool flag)
Should the new layout scale be used or the initial scale? Defaults to true.
double m_originY
Original average center's y when normalized.
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 getX(int i) const
Returns i'th x-coordinate.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
double getY(int i) const
Returns i'th y-coordinate.
void rotateTo(const ProcrustesPointSet &other)
Rotates the point set so it fits somehow on other.
double * m_x
X coordinates.
bool m_scaleToInitialLayout
Option for enabling/disabling scaling to initial layout scale.
double * m_y
Y coordinates.
ProcrustesPointSet(int numPoints)
Constructor for allocating memory for numPoints points.
bool scaleToInitialLayout() const
Should the new layout scale be used or the initial scale? Defaults to true.
double m_angle
If rotated, the angle.
double scale() const
Returns the scale factor.
double angle() const
Returns the rotation angle.
Stores additional attributes of a graph (like layout information).
double compare(const ProcrustesPointSet &other) const
Calculates a value how good the two point sets match.
LayoutModule * m_pSubLayout
Layout module to call for a new layout.
Declaration of interface for layout algorithms (class LayoutModule)
~ProcrustesPointSet()
Destructor.
int m_numPoints
Number of points.
bool isFlipped() const
Returns true if the point set is flipped by y coord.
Interface of general layout algorithms.
Definition: LayoutModule.h:44
double m_originX
Original average center's x when normalized.
double originY() const
Returns the origin's y.
Simple procrustes analysis.
virtual ~ProcrustesSubLayout()
Destructor.
double originX() const
Returns the origin's x.
The namespace for all OGDF objects.
double m_scale
Scale factor.