15#include <QXmlStreamReader>
16#include <QXmlStreamWriter>
19unsigned int Point::m_identifierIndex = 0;
36 m_identifier (uniqueIdentifierGenerator(curveName)),
38 m_hasPosGraph (false),
45 <<
" curveName=" << curveName.toLatin1().data()
46 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
57 m_identifier (uniqueIdentifierGenerator(curveName)),
69 <<
" curveName=" << curveName.toLatin1().data()
70 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
73 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
96 <<
" curveName=" << curveName.toLatin1().data()
97 <<
" identifier=" << m_identifier.toLatin1().data()
101 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
111 m_isAxisPoint (true),
112 m_identifier (uniqueIdentifierGenerator(curveName)),
114 m_hasPosGraph (true),
123 <<
" curveName=" << curveName.toLatin1().data()
124 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
128 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
137 m_isAxisPoint (false),
140 m_hasPosGraph (false),
149 <<
" curveName=" << curveName.toLatin1().data()
150 <<
" identifier=" <<
identifier.toLatin1().data()
160 m_isAxisPoint (false),
161 m_identifier (uniqueIdentifierGenerator(curveName)),
163 m_hasPosGraph (false),
172 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
185 <<
" isAxisPoint=" << (other.
isAxisPoint() ?
"true" :
"false")
186 <<
" identifier=" << other.
identifier ().toLatin1().data()
188 <<
" hasPosGraph=" << (other.
hasPosGraph() ?
"true" :
"false")
190 <<
" hasOrdinal=" << (other.
hasOrdinal() ?
"true" :
"false")
192 <<
" isXOnly=" << other.
isXOnly ();
207 <<
" isAxisPoint=" << (point.
isAxisPoint() ?
"true" :
"false")
208 <<
" identifier=" << point.
identifier ().toLatin1().data()
210 <<
" hasPosGraph=" << (point.
hasPosGraph() ?
"true" :
"false")
212 <<
" hasOrdinal=" << (point.
hasOrdinal() ?
"true" :
"false")
243 return tokens.value (0);
246QString Point::fixUnderscores (
const QString &identifier)
const
265 return m_hasPosGraph;
276 <<
" identifierIndex=" << m_identifierIndex;
278 return m_identifierIndex;
283 return m_isAxisPoint;
291void Point::loadXml(QXmlStreamReader &reader)
297 QXmlStreamAttributes attributes = reader.attributes();
321 m_hasPosGraph =
false;
326 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
330 if (reader.atEnd()) {
335 if (reader.tokenType () == QXmlStreamReader::StartElement) {
339 attributes = reader.attributes();
353 m_hasPosGraph =
true;
354 attributes = reader.attributes();
371 <<
" identifier=" << m_identifier.toLatin1().data()
372 <<
" identifierIndex=" << m_identifierIndex
375 <<
" ordinal=" << m_ordinal;
382 reader.raiseError(QObject::tr (
"Cannot read point data"));
410 QTextStream &str)
const
412 const QString UNDEFINED (
"undefined");
414 str << indentation <<
"Point\n";
418 str << indentation <<
"identifier=" << m_identifier <<
"\n";
419 str << indentation <<
"posScreen=" <<
QPointFToString (m_posScreen) <<
"\n";
421 str << indentation <<
"posGraph=" <<
QPointFToString (m_posGraph) <<
"\n";
423 str << indentation <<
"posGraph=" << UNDEFINED <<
"\n";
426 str << indentation <<
"ordinal=" << m_ordinal <<
"\n";
428 str << indentation <<
"ordinal=" << UNDEFINED <<
"\n";
453 writer.writeEndElement();
459 const char FORMAT =
'g';
460 const int PRECISION = 16;
465 writer.writeEndElement();
468 writer.writeEndElement();
475 m_identifier = curveNameNew + m_identifier.mid (curveNameOld.length());
489 <<
" identifier=" << m_identifier.toLatin1().data()
499 <<
" identifier=" << m_identifier.toLatin1().data()
506 m_hasPosGraph =
true;
513 <<
" identifier=" << m_identifier.toLatin1().data()
521 return QString (
"%1%2%3")
527QString Point::uniqueIdentifierGenerator (
const QString &curveName)
530 <<
" curveName=" << curveName.toLatin1().data()
531 <<
" identifierIndex=" << m_identifierIndex;
533 return QString (
"%1%2point%3%4")
537 .arg (m_identifierIndex++);
const QString AXIS_CURVE_NAME
const QString DUMMY_CURVE_NAME
const QString DOCUMENT_SERIALIZE_POINT_POSITION_GRAPH
const QString DOCUMENT_SERIALIZE_POINT_Y
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER
const QString DOCUMENT_SERIALIZE_POINT_POSITION_SCREEN
const QString DOCUMENT_SERIALIZE_POINT_IS_AXIS_POINT
const QString DOCUMENT_SERIALIZE_POINT
const QString DOCUMENT_SERIALIZE_POINT_X
const QString DOCUMENT_SERIALIZE_POINT_ORDINAL
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER_INDEX
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
const QString INDENTATION_DELTA
const QString POINT_IDENTIFIER_DELIMITER_XML("_")
const double MISSING_ORDINAL_VALUE
const double MISSING_POSGRAPH_VALUE
const QString POINT_IDENTIFIER_DELIMITER_SAFE
QString QPointFToString(const QPointF &pos)
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
void setCurveName(const QString &curveName)
Update the point identifier to match the specified curve name.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
bool hasPosGraph() const
True if graph position is defined.
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
static unsigned int identifierIndex()
Return the current index for storage in case we need to reset it later while performing a Redo.
QPointF posScreen() const
Accessor for screen position.
QString identifier() const
Unique identifier for a specific Point.
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
bool hasOrdinal() const
True if ordinal is defined.
Point & operator=(const Point &point)
Assignment constructor.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
Point()
Default constructor so this class can be used inside a container.
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)