Engauge Digitizer 2
Loading...
Searching...
No Matches
Point.h
Go to the documentation of this file.
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
21
22extern const QString POINT_IDENTIFIER_DELIMITER_SAFE;
23
25class Point
26{
27public:
29 Point ();
30
33 Point (const QString &curveName,
34 const QPointF &posScreen);
35
38 Point (const QString &curveName,
39 const QPointF &posScreen,
40 const QPointF &posGraph,
41 bool isXOnly);
42
44 Point (const QString &curveName,
45 const QString &identifier,
46 const QPointF &posScreen,
47 const QPointF &posGraph,
48 double ordinal,
49 bool isXOnly);
50
52 Point (const QString &curveName,
53 const QPointF &posScreen,
54 const QPointF &posGraph,
55 double ordinal,
56 bool isXOnly);
57
59 Point (const QString &curveName,
60 const QString &identifier,
61 const QPointF &posScreen,
62 double ordinal);
63
65 Point (const QString &curveName,
66 const QPointF &posScreen,
67 double ordinal);
68
70 Point (QXmlStreamReader &reader);
71
73 Point &operator=(const Point &point);
74
76 Point (const Point &point);
77
79 static QString curveNameFromPointIdentifier (const QString &pointIdentifier);
80
82 bool hasOrdinal () const;
83
85 bool hasPosGraph () const;
86
88 QString identifier () const;
89
91 bool isXOnly() const;
92
94 static unsigned int identifierIndex ();
95
97 bool isAxisPoint () const;
98
100 double ordinal (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
101
103 QPointF posGraph (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
104
106 QPointF posScreen () const;
107
109 void printStream (QString indentation,
110 QTextStream &str) const;
111
113 void saveXml(QXmlStreamWriter &writer) const;
114
116 void setCurveName (const QString &curveName);
117
119 static void setIdentifierIndex (unsigned int identifierIndex);
120
122 void setOrdinal (double ordinal);
123
125 void setPosGraph (const QPointF &posGraph);
126
128 void setPosScreen (const QPointF &posScreen);
129
131 static QString temporaryPointIdentifier ();
132
134 static double UNDEFINED_ORDINAL () { return -1.0; }
135
136private:
137
140 QString fixUnderscores (const QString &identifier) const;
141
143 void loadXml(QXmlStreamReader &reader);
144
150 static QString uniqueIdentifierGenerator(const QString &curveName);
151
152 bool m_isAxisPoint;
153 QString m_identifier;
154 QPointF m_posScreen;
155 bool m_hasPosGraph;
156 QPointF m_posGraph;
157 bool m_hasOrdinal;
158 double m_ordinal;
159 bool m_isXOnly; // For DOCUMENT_AXES_POINTS_REQUIRED_4, true/false when x/y coordinate is undefined
160
161 static unsigned int m_identifierIndex; // For generating unique identifiers
162};
163
164#endif // POINT_H
const QString POINT_IDENTIFIER_DELIMITER_SAFE
ApplyHasCheck
Definition Point.h:17
@ SKIP_HAS_CHECK
Definition Point.h:19
@ KEEP_HAS_CHECK
Definition Point.h:18
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
Definition Point.cpp:486
void setCurveName(const QString &curveName)
Update the point identifier to match the specified curve name.
Definition Point.cpp:471
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:409
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
Definition Point.cpp:510
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:263
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition Point.cpp:395
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:273
QPointF posScreen() const
Accessor for screen position.
Definition Point.cpp:404
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
Definition Point.cpp:478
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition Point.cpp:386
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Definition Point.cpp:432
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
Definition Point.h:134
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
Definition Point.cpp:496
bool hasOrdinal() const
True if ordinal is defined.
Definition Point.cpp:258
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:519
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
Definition Point.cpp:281
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:286