2 #include "CurvesGraphs.h"
3 #include "CurveStyles.h"
4 #include "DocumentSerialize.h"
5 #include "EngaugeAssert.h"
10 #include <QXmlStreamWriter>
11 #include "Transformation.h"
14 CurvesGraphs::CurvesGraphs()
20 m_curvesGraphs.push_back (curve);
28 curve->addPoint (point);
34 CurveList::iterator itr;
35 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
49 CurveList::const_iterator itr;
50 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
52 const Curve &curve = *itr;
65 CurveList::const_iterator itr;
66 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
68 const Curve &curve = *itr;
78 CurveList::const_iterator itr;
79 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
81 const Curve &curve = *itr;
91 const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
94 CurveList::const_iterator itr;
95 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
97 const Curve &curve = *itr;
98 if (curve.
curveName () == curveNameWanted) {
105 ENGAUGE_ASSERT (
false);
109 const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback)
const
112 CurveList::const_iterator itr;
113 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
115 const Curve &curve = *itr;
116 if (curve.
curveName () == curveNameWanted) {
123 ENGAUGE_ASSERT (
false);
128 CurveList::const_iterator itr;
129 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
131 const Curve &curve = *itr;
138 CurveList::const_iterator itr;
139 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
141 const Curve &curve = *itr;
148 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadPreVersion6";
152 qint32 numberCurvesGraphs;
153 str >> numberCurvesGraphs;
154 for (i = 0; i < numberCurvesGraphs; i++) {
156 m_curvesGraphs.append (curve);
159 qint32 numberCurvesMeasures;
160 str >> numberCurvesMeasures;
161 for (i = 0; i < numberCurvesMeasures; i++) {
170 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadXml";
175 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
176 (reader.name() != DOCUMENT_SERIALIZE_CURVES_GRAPHS)){
178 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
179 (reader.name () == DOCUMENT_SERIALIZE_CURVE)) {
181 Curve curve (reader);
183 m_curvesGraphs.push_back (curve);
187 loadNextFromReader(reader);
188 if (reader.hasError()) {
193 if (reader.atEnd()) {
201 reader.raiseError (
"Cannot read graph curves data");
207 return m_curvesGraphs.count ();
211 QTextStream &str)
const
213 str << indentation <<
"CurvesGraphs\n";
215 indentation += INDENTATION_DELTA;
217 CurveList::const_iterator itr;
218 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
220 const Curve &curve = *itr;
236 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::saveXml";
238 writer.writeStartElement(DOCUMENT_SERIALIZE_CURVES_GRAPHS);
240 CurveList::const_iterator itr;
241 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
243 const Curve &curve = *itr;
247 writer.writeEndElement();
252 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::updatePointOrdinals";
254 CurveList::iterator itr;
255 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.
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.