12 #include <QStringList> 13 #include <QTextStream> 15 #include <QXmlStreamReader> 16 #include <QXmlStreamWriter> 19 unsigned int Point::m_identifierIndex = 0;
34 const QPointF &posScreen) :
36 m_identifier (uniqueIdentifierGenerator(curveName)),
37 m_posScreen (posScreen),
38 m_hasPosGraph (false),
45 <<
" curveName=" << curveName.toLatin1().data()
46 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
53 const QPointF &posScreen,
54 const QPointF &posGraph,
57 m_identifier (uniqueIdentifierGenerator(curveName)),
58 m_posScreen (posScreen),
60 m_posGraph (posGraph),
69 <<
" curveName=" << curveName.toLatin1().data()
70 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
73 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
79 const QString &identifier,
80 const QPointF &posScreen,
81 const QPointF &posGraph,
85 m_identifier (identifier),
86 m_posScreen (posScreen),
88 m_posGraph (posGraph),
96 <<
" curveName=" << curveName.toLatin1().data()
97 <<
" identifier=" << m_identifier.toLatin1().data()
101 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
107 const QPointF &posScreen,
108 const QPointF &posGraph,
111 m_isAxisPoint (true),
112 m_identifier (uniqueIdentifierGenerator(curveName)),
113 m_posScreen (posScreen),
114 m_hasPosGraph (true),
115 m_posGraph (posGraph),
123 <<
" curveName=" << curveName.toLatin1().data()
124 <<
" identifierGenerated=" << m_identifier.toLatin1().data()
128 <<
" isXOnly=" << (
isXOnly ?
"true" :
"false");
134 const QString &identifier,
135 const QPointF &posScreen,
137 m_isAxisPoint (false),
138 m_identifier (identifier),
139 m_posScreen (posScreen),
140 m_hasPosGraph (false),
149 <<
" curveName=" << curveName.toLatin1().data()
150 <<
" identifier=" <<
identifier.toLatin1().data()
158 const QPointF &posScreen,
160 m_isAxisPoint (false),
161 m_identifier (uniqueIdentifierGenerator(curveName)),
162 m_posScreen (posScreen),
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);
246 QString Point::fixUnderscores (
const QString &identifier)
const 265 return m_hasPosGraph;
276 <<
" identifierIndex=" << m_identifierIndex;
278 return m_identifierIndex;
283 return m_isAxisPoint;
291 void 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")
527 QString 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++);
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
static unsigned int identifierIndex()
Return the current index for storage in case we need to reset it later while performing a Redo.
const double MISSING_POSGRAPH_VALUE
const QString INDENTATION_DELTA
const QString DOCUMENT_SERIALIZE_POINT_ORDINAL
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
const QString DOCUMENT_SERIALIZE_POINT
const QString POINT_IDENTIFIER_DELIMITER_XML("_")
const QString DOCUMENT_SERIALIZE_POINT_POSITION_SCREEN
#define LOG4CPP_INFO_S(logger)
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
Point & operator=(const Point &point)
Assignment constructor.
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
QString QPointFToString(const QPointF &pos)
const QString DOCUMENT_SERIALIZE_POINT_X
const double MISSING_ORDINAL_VALUE
QString identifier() const
Unique identifier for a specific Point.
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
bool hasOrdinal() const
True if ordinal is defined.
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
bool hasPosGraph() const
True if graph position is defined.
const QString DOCUMENT_SERIALIZE_POINT_Y
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString AXIS_CURVE_NAME
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
Point()
Default constructor so this class can be used inside a container.
const QString DOCUMENT_SERIALIZE_POINT_IS_AXIS_POINT
log4cpp::Category * mainCat
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER
const QString DUMMY_CURVE_NAME
const QString DOCUMENT_SERIALIZE_POINT_POSITION_GRAPH
const QString DOCUMENT_SERIALIZE_POINT_IDENTIFIER_INDEX
const QString POINT_IDENTIFIER_DELIMITER_SAFE("\t")
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setCurveName(const QString &curveName)
Update the point identifer to match the specified curve name.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
#define LOG4CPP_DEBUG_S(logger)