8 #include "CurvesGraphs.h"
9 #include "CurveStyles.h"
10 #include "DocumentSerialize.h"
11 #include "EngaugeAssert.h"
15 #include <QTextStream>
16 #include <QXmlStreamWriter>
17 #include "Transformation.h"
20 CurvesGraphs::CurvesGraphs()
26 m_curvesGraphs.push_back (curve);
34 curve->addPoint (point);
40 CurveList::iterator itr;
41 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
55 CurveList::const_iterator itr;
56 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
58 const Curve &curve = *itr;
71 CurveList::const_iterator itr;
72 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
74 const Curve &curve = *itr;
84 CurveList::const_iterator itr;
85 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
87 const Curve &curve = *itr;
97 const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
100 CurveList::const_iterator itr;
101 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
103 const Curve &curve = *itr;
104 if (curve.
curveName () == curveNameWanted) {
111 ENGAUGE_ASSERT (
false);
115 const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback)
const
118 CurveList::const_iterator itr;
119 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
121 const Curve &curve = *itr;
122 if (curve.
curveName () == curveNameWanted) {
129 ENGAUGE_ASSERT (
false);
134 CurveList::const_iterator itr;
135 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
137 const Curve &curve = *itr;
144 CurveList::const_iterator itr;
145 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
147 const Curve &curve = *itr;
154 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadPreVersion6";
158 qint32 numberCurvesGraphs;
159 str >> numberCurvesGraphs;
160 for (i = 0; i < numberCurvesGraphs; i++) {
162 m_curvesGraphs.append (curve);
165 qint32 numberCurvesMeasures;
166 str >> numberCurvesMeasures;
167 for (i = 0; i < numberCurvesMeasures; i++) {
176 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadXml";
181 m_curvesGraphs.clear();
184 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
185 (reader.name() != DOCUMENT_SERIALIZE_CURVES_GRAPHS)){
187 loadNextFromReader(reader);
188 if (reader.atEnd()) {
193 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
194 (reader.name () == DOCUMENT_SERIALIZE_CURVE)) {
196 Curve curve (reader);
200 QString DUPLICATE = QString (
"-%1").arg (QObject::tr (
"DUPLICATE"));
203 curveName += DUPLICATE;
208 m_curvesGraphs.push_back (curve);
214 reader.raiseError (QObject::tr (
"Cannot read graph curves data"));
220 return m_curvesGraphs.count ();
224 QTextStream &str)
const
226 str << indentation <<
"CurvesGraphs\n";
228 indentation += INDENTATION_DELTA;
230 CurveList::const_iterator itr;
231 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
233 const Curve &curve = *itr;
249 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::saveXml";
251 writer.writeStartElement(DOCUMENT_SERIALIZE_CURVES_GRAPHS);
253 CurveList::const_iterator itr;
254 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
256 const Curve &curve = *itr;
260 writer.writeEndElement();
265 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::updatePointOrdinals";
267 CurveList::iterator itr;
268 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
void removePoint(const QString &identifier)
Perform the opposite of addPointAtEnd.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
void iterateThroughCurveSegments(const QString &curveNameWanted, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to segments on the specified axis or graph Curve.
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for the specified curve name.
int numCurves() const
Current number of graphs curves.
int numPoints() const
Number of points.
void updatePointOrdinals(const Transformation &transformation)
See CurveGraphs::updatePointOrdinals.
void addGraphCurveAtEnd(Curve curve)
Append new graph Curve to end of Curve list.
void iterateThroughCurvesPoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
Apply functor to Points on all of the Curves.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
QString identifier() const
Unique identifier for a specific Point.
void addPoint(const Point &point)
Append new Point to the specified Curve.
void iterateThroughCurvePoints(const QString &curveNameWanted, const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
Apply functor to Points in the specified axis or graph Curve.
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
void setCurveName(const QString &curveName)
Change the curve name.
int curvesGraphsNumPoints(const QString &curveName) const
Point count.
Container for one set of digitized Points.
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals to be consistent with their CurveStyle and x/theta coordinate.
void loadPreVersion6(QDataStream &str)
Load from serialized binary pre-version 6 file.
QStringList curvesGraphsNames() const
List of graph curve names.
void removePoint(const QString &pointIdentifier)
Remove the Point from its Curve.
void iterateThroughCurveSegments(const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to successive Points, as line segments, on Curve. This could be a bit slow...
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
QString curveName() const
Name of this Curve.