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++);