Engauge Digitizer 2
Loading...
Searching...
No Matches
Point.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 POINT_H
8#define POINT_H
9
10#include <QPointF>
11#include <QString>
12
13class QTextStream;
14class QXmlStreamReader;
15class QXmlStreamWriter;
16
17enum ApplyHasCheck {
18 KEEP_HAS_CHECK,
19 SKIP_HAS_CHECK
20};
21
23class Point
24{
25public:
27 Point ();
28
31 Point (const QString &curveName,
32 const QPointF &posScreen);
33
36 Point (const QString &curveName,
37 const QPointF &posScreen,
38 const QPointF &posGraph,
39 bool isXOnly);
40
42 Point (const QString &curveName,
43 const QString &identifier,
44 const QPointF &posScreen,
45 const QPointF &posGraph,
46 double ordinal,
47 bool isXOnly);
48
50 Point (const QString &curveName,
51 const QPointF &posScreen,
52 const QPointF &posGraph,
53 double ordinal,
54 bool isXOnly);
55
57 Point (const QString &curveName,
58 const QString &identifier,
59 const QPointF &posScreen,
60 double ordinal);
61
63 Point (const QString &curveName,
64 const QPointF &posScreen,
65 double ordinal);
66
68 Point (QXmlStreamReader &reader);
69
71 Point &operator=(const Point &point);
72
74 Point (const Point &point);
75
77 static QString curveNameFromPointIdentifier (const QString &pointIdentifier);
78
80 bool hasOrdinal () const;
81
83 bool hasPosGraph () const;
84
86 QString identifier () const;
87
89 bool isXOnly() const;
90
92 static unsigned int identifierIndex ();
93
95 bool isAxisPoint () const;
96
98 double ordinal (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
99
101 QPointF posGraph (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
102
104 QPointF posScreen () const;
105
107 void printStream (QString indentation,
108 QTextStream &str) const;
109
111 void saveXml(QXmlStreamWriter &writer) const;
112
114 void setCurveName (const QString &curveName);
115
117 static void setIdentifierIndex (unsigned int identifierIndex);
118
120 void setOrdinal (double ordinal);
121
123 void setPosGraph (const QPointF &posGraph);
124
126 void setPosScreen (const QPointF &posScreen);
127
129 static QString temporaryPointIdentifier ();
130
132 static double UNDEFINED_ORDINAL () { return -1.0; }
133
134private:
135
137 void loadXml(QXmlStreamReader &reader);
138
144 static QString uniqueIdentifierGenerator(const QString &curveName);
145
146 bool m_isAxisPoint;
147 QString m_identifier;
148 QPointF m_posScreen;
149 bool m_hasPosGraph;
150 QPointF m_posGraph;
151 bool m_hasOrdinal;
152 double m_ordinal;
153 bool m_isXOnly; // For DOCUMENT_AXES_POINTS_REQUIRED_4, true/false when x/y coordinate is undefed
154
155 static unsigned int m_identifierIndex; // For generating unique identifiers
156};
157
158#endif // POINT_H
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition Point.h:24
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
Definition Point.cpp:468
void setCurveName(const QString &curveName)
Update the point identifer to match the specified curve name.
Definition Point.cpp:453
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition Point.cpp:397
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
Definition Point.cpp:492
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
Definition Point.cpp:227
bool hasPosGraph() const
True if graph position is defined.
Definition Point.cpp:251
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition Point.cpp:383
static unsigned int identifierIndex()
Return the current index for storage in case we need to reset it later while performing a Redo.
Definition Point.cpp:261
QPointF posScreen() const
Accessor for screen position.
Definition Point.cpp:392
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:256
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
Definition Point.cpp:460
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition Point.cpp:374
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Definition Point.cpp:420
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
Definition Point.h:132
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
Definition Point.cpp:478
bool hasOrdinal() const
True if ordinal is defined.
Definition Point.cpp:246
Point & operator=(const Point &point)
Assignment constructor.
Definition Point.cpp:204
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
Definition Point.cpp:501
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
Definition Point.cpp:269
Point()
Default constructor so this class can be used inside a container.
Definition Point.cpp:29
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
Definition Point.cpp:274