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;
100 const QStringList &identifiers,
103 CurveList::iterator itr;
104 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
117 const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
120 CurveList::const_iterator itr;
121 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
123 const Curve &curve = *itr;
124 if (curve.
curveName () == curveNameWanted) {
131 ENGAUGE_ASSERT (
false);
135 const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback)
const 138 CurveList::const_iterator itr;
139 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
141 const Curve &curve = *itr;
142 if (curve.
curveName () == curveNameWanted) {
149 ENGAUGE_ASSERT (
false);
154 CurveList::const_iterator itr;
155 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
157 const Curve &curve = *itr;
164 CurveList::const_iterator itr;
165 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
167 const Curve &curve = *itr;
174 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadPreVersion6";
179 m_curvesGraphs.clear();
181 qint32 numberCurvesGraphs;
182 str >> numberCurvesGraphs;
183 for (i = 0; i < numberCurvesGraphs; i++) {
185 m_curvesGraphs.append (curve);
188 qint32 numberCurvesMeasures;
189 str >> numberCurvesMeasures;
190 for (i = 0; i < numberCurvesMeasures; i++) {
199 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::loadXml";
204 m_curvesGraphs.clear();
207 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
208 (reader.name() != DOCUMENT_SERIALIZE_CURVES_GRAPHS)){
210 loadNextFromReader(reader);
211 if (reader.atEnd()) {
216 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
217 (reader.name () == DOCUMENT_SERIALIZE_CURVE)) {
219 Curve curve (reader);
223 QString DUPLICATE = QString (
"-%1").arg (QObject::tr (
"DUPLICATE"));
226 curveName += DUPLICATE;
231 m_curvesGraphs.push_back (curve);
237 reader.raiseError (QObject::tr (
"Cannot read graph curves data"));
243 return m_curvesGraphs.count ();
247 QTextStream &str)
const 249 str << indentation <<
"CurvesGraphs\n";
251 indentation += INDENTATION_DELTA;
253 CurveList::const_iterator itr;
254 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
256 const Curve &curve = *itr;
272 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::saveXml";
274 writer.writeStartElement(DOCUMENT_SERIALIZE_CURVES_GRAPHS);
276 CurveList::const_iterator itr;
277 for (itr = m_curvesGraphs.begin (); itr != m_curvesGraphs.end (); itr++) {
279 const Curve &curve = *itr;
283 writer.writeEndElement();
288 LOG4CPP_INFO_S ((*mainCat)) <<
"CurvesGraphs::updatePointOrdinals";
290 CurveList::iterator itr;
291 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...
int curvesGraphsNumPoints(const QString &curveName) const
Point count.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for the specified curve name.
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...
int numPoints() const
Number of points.
void editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Set the x and/or y coordinate values of the specified points.
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
QString identifier() const
Unique identifier for a specific Point.
void addPoint(const Point &point)
Append new Point to the specified Curve.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
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 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...
int numCurves() const
Current number of graphs curves.
void setCurveName(const QString &curveName)
Change the curve name.
QString curveName() const
Name of this Curve.
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 iterateThroughCurveSegments(const QString &curveNameWanted, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to segments on the specified axis or graph Curve.
void editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Edit the graph coordinates of one or more graph points. This method does not apply to an axis point...
QStringList curvesGraphsNames() const
List of graph curve names.
void loadPreVersion6(QDataStream &str)
Load from serialized binary pre-version 6 file.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
void removePoint(const QString &pointIdentifier)
Remove the Point from its Curve.