Engauge Digitizer  2
Point.h
1 #ifndef POINT_H
2 #define POINT_H
3 
4 #include <QPointF>
5 #include <QString>
6 
7 class QTextStream;
8 class QXmlStreamReader;
9 class QXmlStreamWriter;
10 
11 enum ApplyHasCheck {
12  KEEP_HAS_CHECK,
13  SKIP_HAS_CHECK
14 };
15 
17 class Point
18 {
19 public:
21  Point ();
22 
25  Point (const QString &curveName,
26  const QPointF &posScreen);
27 
30  Point (const QString &curveName,
31  const QPointF &posScreen,
32  const QPointF &posGraph);
33 
35  Point (const QString &curveName,
36  const QString &identifier,
37  const QPointF &posScreen,
38  const QPointF &posGraph,
39  double ordinal);
40 
42  Point (const QString &curveName,
43  const QPointF &posScreen,
44  const QPointF &posGraph,
45  double ordinal);
46 
48  Point (const QString &curveName,
49  const QString &identifier,
50  const QPointF &posScreen,
51  double ordinal);
52 
54  Point (const QString &curveName,
55  const QPointF &posScreen,
56  double ordinal);
57 
59  Point (QXmlStreamReader &reader);
60 
62  Point &operator=(const Point &point);
63 
65  Point (const Point &point);
66 
68  static QString curveNameFromPointIdentifier (const QString &pointIdentifier);
69 
71  bool hasOrdinal () const;
72 
74  bool hasPosGraph () const;
75 
77  QString identifier () const;
78 
80  static unsigned int identifierIndex ();
81 
83  bool isAxisPoint () const;
84 
86  double ordinal (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
87 
89  QPointF posGraph (ApplyHasCheck applyHasCheck = KEEP_HAS_CHECK) const;
90 
92  QPointF posScreen () const;
93 
95  void printStream (QString indentation,
96  QTextStream &str) const;
97 
99  void saveXml(QXmlStreamWriter &writer) const;
100 
102  static void setIdentifierIndex (unsigned int identifierIndex);
103 
105  void setOrdinal (double ordinal);
106 
108  void setPosGraph (const QPointF &posGraph);
109 
111  void setPosScreen (const QPointF &posScreen);
112 
114  static QString temporaryPointIdentifier ();
115 
117  static double UNDEFINED_ORDINAL () { return -1.0; }
118 
119 private:
120 
122  void loadXml(QXmlStreamReader &reader);
123 
129  static QString uniqueIdentifierGenerator(const QString &curveName);
130 
131  bool m_isAxisPoint;
132  QString m_identifier;
133  QPointF m_posScreen;
134  bool m_hasPosGraph;
135  QPointF m_posGraph;
136  bool m_hasOrdinal;
137  double m_ordinal;
138 
139  static unsigned int m_identifierIndex; // For generating unique identifiers
140 };
141 
142 #endif // POINT_H
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition: Point.cpp:333
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
Definition: Point.cpp:202
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
Definition: Point.cpp:231
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
Definition: Point.cpp:401
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:223
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
Definition: Point.cpp:370
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
Point & operator=(const Point &point)
Assignment constructor.
Definition: Point.cpp:160
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
Definition: Point.cpp:419
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
Definition: Point.cpp:442
QString identifier() const
Unique identifier for a specific Point.
Definition: Point.cpp:218
bool hasPosGraph() const
True if graph position is defined.
Definition: Point.cpp:213
static double UNDEFINED_ORDINAL()
Get method for undefined ordinal constant.
Definition: Point.h:117
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:347
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
Definition: Point.cpp:433
Point()
Default constructor so this class can be used inside a container.
Definition: Point.cpp:20
bool hasOrdinal() const
True if ordinal is defined.
Definition: Point.cpp:208
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition: Point.cpp:324
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
Definition: Point.cpp:409