Engauge Digitizer  2
Curve.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef CURVE_H
8 #define CURVE_H
9 
10 #include "CallbackSearchReturn.h"
11 #include "ColorFilterSettings.h"
12 #include "CurveStyle.h"
13 #include "functor.h"
14 #include "Point.h"
15 #include "Points.h"
16 #include <QHash>
17 #include <QList>
18 #include <QString>
19 
20 extern const QString AXIS_CURVE_NAME;
21 extern const QString DEFAULT_GRAPH_CURVE_NAME;
22 extern const QString DUMMY_CURVE_NAME;
23 extern const QString SCALE_CURVE_NAME;
24 
25 class CurvesGraphs;
26 class QDataStream;
27 class QTextStream;
28 class QXmlStreamReader;
29 class QXmlStreamWriter;
30 class Transformation;
31 
33 class Curve
34 {
35 public:
37  Curve(const QString &curveName,
39  const CurveStyle &curveStyle);
40 
42  Curve (QDataStream &str);
43 
45  Curve (QXmlStreamReader &reader);
46 
48  Curve (const Curve &curve);
49 
51  Curve &operator=(const Curve &curve);
52 
54  void addPoint (Point point);
55 
58 
60  QString curveName () const;
61 
63  CurveStyle curveStyle() const;
64 
66  void editPointAxis (const QPointF &posGraph,
67  const QString &identifier);
68 
70  void editPointGraph (bool isX,
71  bool isY,
72  double x,
73  double y,
74  const QStringList &identifiers,
75  const Transformation &transformation);
76 
78  void exportToClipboard (const QHash<QString, bool> &selectedHash,
79  const Transformation &transformation,
80  QTextStream &strCsv,
81  QTextStream &strHtml,
82  CurvesGraphs &curvesGraphs) const;
83 
85  bool isXOnly (const QString &pointIdentifier) const;
86 
88  void iterateThroughCurvePoints (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
89 
91  void iterateThroughCurveSegments (const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
92 
94  void movePoint (const QString &pointIdentifier,
95  const QPointF &deltaScreen);
96 
98  int numPoints () const;
99 
101  const Points points () const;
102 
104  QPointF positionGraph (const QString &pointIdentifier) const;
105 
107  QPointF positionScreen (const QString &pointIdentifier) const;
108 
110  void printStream (QString indentation,
111  QTextStream &str) const;
112 
114  void removePoint (const QString &identifier);
115 
117  void saveXml(QXmlStreamWriter &writer) const;
118 
120  void setColorFilterSettings (const ColorFilterSettings &colorFilterSettings);
121 
123  void setCurveName (const QString &curveName);
124 
126  void setCurveStyle (const CurveStyle &curveStyle);
127 
130  void updatePointOrdinals (const Transformation &transformation);
131 
132 private:
133  Curve();
134 
135  void loadCurvePoints(QXmlStreamReader &reader);
136  void loadXml(QXmlStreamReader &reader);
137  Point *pointForPointIdentifier (const QString pointIdentifier);
138  void updatePointOrdinalsFunctions (const Transformation &transformation);
139  void updatePointOrdinalsRelations ();
140 
141  QString m_curveName;
142  Points m_points;
143 
144  ColorFilterSettings m_colorFilterSettings;
145  CurveStyle m_curveStyle;
146 };
147 
148 #endif // CURVE_H
void removePoint(const QString &identifier)
Perform the opposite of addPointAtEnd.
Definition: Curve.cpp:510
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
void setCurveStyle(const CurveStyle &curveStyle)
Set curve style.
Definition: Curve.cpp:563
ColorFilterSettings colorFilterSettings() const
Return the color filter.
Definition: Curve.cpp:138
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
Definition: Curve.cpp:301
void addPoint(Point point)
Add Point to this Curve.
Definition: Curve.cpp:133
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings)
Set color filter.
Definition: Curve.cpp:546
QPointF positionScreen(const QString &pointIdentifier) const
Return the position, in screen coordinates, of the specified Point.
Definition: Curve.cpp:473
void updatePointOrdinals(const Transformation &transformation)
See CurveGraphs::updatePointOrdinals.
Definition: Curve.cpp:568
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of an axis point. This method does not apply to a graph point...
Definition: Curve.cpp:153
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:23
const Points points() const
Return a shallow copy of the Points.
Definition: Curve.cpp:451
int numPoints() const
Number of points.
Definition: Curve.cpp:432
Curve & operator=(const Curve &curve)
Assignment constructor.
Definition: Curve.cpp:123
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
Translate the position of a point by the specified distance vector.
Definition: Curve.cpp:423
Affine transformation between screen and graph coordinates, based on digitized axis points...
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:24
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: Curve.cpp:490
void iterateThroughCurveSegments(const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to successive Points, as line segments, on Curve. This could be a bit slow...
Definition: Curve.cpp:316
void setCurveName(const QString &curveName)
Change the curve name.
Definition: Curve.cpp:551
QString curveName() const
Name of this Curve.
Definition: Curve.cpp:143
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:18
Container for one set of digitized Points.
Definition: Curve.h:33
void editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Edit the graph coordinates of one or more graph points. This method does not apply to an axis point...
Definition: Curve.cpp:170
void exportToClipboard(const QHash< QString, bool > &selectedHash, const Transformation &transformation, QTextStream &strCsv, QTextStream &strHtml, CurvesGraphs &curvesGraphs) const
Export points in this Curve found in the specified point list.
Definition: Curve.cpp:219
QPointF positionGraph(const QString &pointIdentifier) const
Return the position, in graph coordinates, of the specified Point.
Definition: Curve.cpp:456
CurveStyle curveStyle() const
Return the curve style.
Definition: Curve.cpp:148
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
Definition: Curve.cpp:523
bool isXOnly(const QString &pointIdentifier) const
Determine if specified point has just x coordinate. Otherwise has just y coordinate, or both x and y coordinates.
Definition: Curve.cpp:284