Engauge Digitizer  2
ExportOrdinalsStraight.cpp
1 #include "ExportOrdinalsStraight.h"
2 #include "Logger.h"
3 #include <qdebug.h>
4 #include <qmath.h>
5 #include <QPointF>
6 #include "Transformation.h"
7 
8 using namespace std;
9 
11 {
12 }
13 
15  double pointsInterval) const
16 {
17  LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
18 
19  // Results
20  ExportValuesOrdinal ordinals;
21 
22  // Integrate the distances for the subintervals
23  double distanceAlongSegment = 0;
24  QPointF posLast (points [0].posScreen().x(),
25  points [0].posScreen().y());
26  double ordinalLast = 0;
27 
28  // Simplest method to find the intervals is to break up the curve into many smaller intervals, and then aggregate them
29  // into intervals that, as much as possible, have the desired length. Simplicity wins out over accuracy in this
30  // approach - accuracy is sacrificed to achieve simplicity
31  for (int iP = 0; iP < points.count(); iP++) {
32 
33  const Point &pointNew = points.at (iP);
34  QPointF posNew = pointNew.posScreen();
35 
36  QPointF posDelta = posNew - posLast;
37  double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
38 
39  while (distanceAlongSegment < segmentLength) {
40 
41  double sLocal = distanceAlongSegment / segmentLength;
42 
43  ordinals.push_back (ordinalLast + sLocal);
44 
45  distanceAlongSegment += pointsInterval;
46  }
47 
48  distanceAlongSegment -= segmentLength;
49  ordinalLast = pointNew.ordinal();
50  posLast = posNew;
51  }
52 
53  return ordinals;
54 }
55 
57  const Transformation &transformation,
58  double pointsInterval) const
59 {
60  LOG4CPP_INFO_S ((*mainCat)) << "ExportOrdinalsStraight::ordinalsAtIntervalsGraph";
61 
62  // Results
63  ExportValuesOrdinal ordinals;
64 
65  // Integrate the distances for the subintervals
66  double distanceAlongSegment = 0;
67  QPointF posLast;
68  transformation.transformScreenToRawGraph (points [0].posScreen(),
69  posLast);
70  double ordinalLast = 0;
71 
72  // Simplest method to find the intervals is to break up the curve into many smaller intervals, and then aggregate them
73  // into intervals that, as much as possible, have the desired length. Simplicity wins out over accuracy in this
74  // approach - accuracy is sacrificed to achieve simplicity
75  for (int iP = 0; iP < points.count(); iP++) {
76 
77  const Point &pointNew = points.at (iP);
78  QPointF posNew;
79  transformation.transformScreenToRawGraph (pointNew.posScreen(),
80  posNew);
81 
82  QPointF posDelta = posNew - posLast;
83  double segmentLength = qSqrt (posDelta.x() * posDelta.x() + posDelta.y() * posDelta.y());
84 
85  while (distanceAlongSegment < segmentLength) {
86 
87  double sLocal = distanceAlongSegment / segmentLength;
88 
89  ordinals.push_back (ordinalLast + sLocal);
90 
91  distanceAlongSegment += pointsInterval;
92  }
93 
94  ordinalLast = pointNew.ordinal();
95  posLast = posNew;
96  }
97 
98  return ordinals;
99 }
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:17
QPointF posScreen() const
Accessor for screen position.
Definition: Point.cpp:342
ExportOrdinalsStraight()
Single constructor.
Affine transformation between screen and graph coordinates, based on digitized axis points...
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation(const Points &points, double pointsInterval) const
Compute ordinals, without any conversion to graph coordinates.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition: Point.cpp:324
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation(const Points &points, const Transformation &transformation, double pointsInterval) const
Compute ordinals, converting screen coordinates to graph coordinates.