16 #include <QDataStream> 20 #include <QTextStream> 21 #include <QXmlStreamReader> 22 #include <QXmlStreamWriter> 39 m_curveName (curveName),
40 m_colorFilterSettings (colorFilterSettings),
41 m_curveStyle (curveStyle)
46 m_curveName (curve.curveName ()),
47 m_points (curve.points ()),
48 m_colorFilterSettings (curve.colorFilterSettings ()),
49 m_curveStyle (curve.curveStyle ())
55 const int CONVERT_ENUM_TO_RADIUS = 6;
58 qint32 int32, xScreen, yScreen;
59 double xGraph, yGraph;
91 for (
int i = 0; i < count; i++) {
100 Point point (m_curveName,
101 QPointF (xScreen, yScreen),
102 QPointF (xGraph, yGraph),
110 Point point (m_curveName,
111 QPointF (xScreen, yScreen));
127 m_points = curve.
points ();
136 m_points.push_back (point);
141 return m_colorFilterSettings;
155 const QString &identifier)
158 QList<Point>::iterator itr;
159 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
175 const QStringList &identifiers,
179 <<
" identifiers=" << identifiers.join(
" ").toLatin1().data();
184 QList<Point>::iterator itr;
185 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
189 if (identifiers.contains (point.
identifier ())) {
223 QTextStream &strHtml,
227 <<
" hashCount=" << selectedHash.count();
232 QList<Point>::const_iterator itr;
233 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
235 const Point &point = *itr;
236 if (selectedHash.contains (point.
identifier ())) {
243 strHtml <<
"<table>\n" 244 <<
"<tr><th>X</th><th>" << m_curveName <<
"</th></tr>\n";
254 Curve curve(m_curveName,
273 strHtml <<
"<tr><td>" << pos.x() <<
"</td><td>" << pos.y() <<
"</td></tr>\n";
281 strHtml <<
"</table>\n";
288 Points::const_iterator itr;
289 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
290 const Point &point = *itr;
303 QList<Point>::const_iterator itr;
304 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
306 const Point &point = *itr;
320 QList<Point>::const_iterator itr;
321 const Point *pointBefore =
nullptr;
322 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
324 const Point &point = *itr;
326 if (pointBefore !=
nullptr) {
336 pointBefore = &point;
340 void Curve::loadCurvePoints(QXmlStreamReader &reader)
346 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
351 if (reader.atEnd()) {
356 if (tokenType == QXmlStreamReader::StartElement) {
360 Point point (reader);
361 m_points.push_back (point);
367 reader.raiseError(QObject::tr (
"Cannot read curve data"));
371 void Curve::loadXml(QXmlStreamReader &reader)
377 QXmlStreamAttributes attributes = reader.attributes();
384 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
389 if (reader.atEnd()) {
394 if (tokenType == QXmlStreamReader::StartElement) {
397 m_colorFilterSettings.
loadXml(reader);
399 loadCurvePoints(reader);
408 if (reader.hasError()) {
419 reader.raiseError (QObject::tr (
"Cannot read curve data"));
424 const QPointF &deltaScreen)
426 Point *point = pointForPointIdentifier (pointIdentifier);
428 QPointF posScreen = deltaScreen + point->
posScreen ();
434 return m_points.count ();
437 Point *Curve::pointForPointIdentifier (
const QString pointIdentifier)
439 Points::iterator itr;
440 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
461 Points::const_iterator itr;
462 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
463 const Point &point = *itr;
478 Points::const_iterator itr;
479 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
480 const Point &point = *itr;
491 QTextStream &str)
const 493 str << indentation <<
"Curve=" << m_curveName <<
"\n";
497 Points::const_iterator itr;
498 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
499 const Point &point = *itr;
513 Points::iterator itr;
514 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
517 m_points.erase (itr);
529 m_colorFilterSettings.
saveXml (writer,
536 Points::const_iterator itr;
537 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
538 const Point &point = *itr;
541 writer.writeEndElement();
543 writer.writeEndElement();
556 QList<Point>::iterator itr;
557 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
573 <<
" curve=" << m_curveName.toLatin1().data()
581 updatePointOrdinalsFunctions (transformation);
586 updatePointOrdinalsRelations ();
595 qSort (m_points.begin(),
600 void Curve::updatePointOrdinalsFunctions (
const Transformation &transformation)
605 <<
" curve=" << m_curveName.toLatin1().data()
612 Points::iterator itr;
613 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
629 xOrThetaToPointIdentifier.insert (posGraph.x(),
635 ENGAUGE_ASSERT (xOrThetaToPointIdentifier.count () == m_points.count ());
639 QMap<QString, double> pointIdentifierToOrdinal;
641 XOrThetaToPointIdentifier::const_iterator itrX;
642 for (itrX = xOrThetaToPointIdentifier.begin(); itrX != xOrThetaToPointIdentifier.end(); itrX++) {
644 QString pointIdentifier = itrX.value();
645 pointIdentifierToOrdinal [pointIdentifier] = ordinal++;
649 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
658 int ordinalNew = qFloor (pointIdentifierToOrdinal [point.
identifier()]);
663 void Curve::updatePointOrdinalsRelations ()
668 <<
" curve=" << m_curveName.toLatin1().data()
672 Points::iterator itr;
674 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
void removePoint(const QString &identifier)
Perform the opposite of addPointAtEnd.
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined...
const QString AXIS_CURVE_NAME("Axes")
CurveConnectAs curveConnectAs() const
Get method for connect type.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Comparator for sorting Point class.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
const QString DEFAULT_GRAPH_CURVE_NAME("Curve1")
const QString DOCUMENT_SERIALIZE_CURVE_POINTS
void setCurveStyle(const CurveStyle &curveStyle)
Set curve style.
const QString INDENTATION_DELTA
ColorFilterSettings colorFilterSettings() const
Return the color filter.
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings)
Set color filter.
const QString DOCUMENT_SERIALIZE_POINT
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for the specified curve name.
QPointF positionScreen(const QString &pointIdentifier) const
Return the position, in screen coordinates, of the specified Point.
void updatePointOrdinals(const Transformation &transformation)
See CurveGraphs::updatePointOrdinals.
void setPointShape(PointShape shape)
Set method for curve point shape in specified curve.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of an axis point. This method does not apply to a graph point...
#define LOG4CPP_INFO_S(logger)
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
static LineStyle defaultAxesCurve()
Initial default for axes curve.
void addGraphCurveAtEnd(const Curve &curve)
Append new graph Curve to end of Curve list.
void setLineConnectAs(CurveConnectAs curveConnectAs)
Set method for connect as method for lines in specified curve.
QPointF posScreen() const
Accessor for screen position.
void setLineStyle(const LineStyle &lineStyle)
Set method for LineStyle.
Curve(const QString &curveName, const ColorFilterSettings &colorFilterSettings, const CurveStyle &curveStyle)
Constructor from scratch.
const QString DOCUMENT_SERIALIZE_CURVE
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
const QString SCALE_CURVE_NAME("Scale")
const Points points() const
Return a shallow copy of the Points.
int numPoints() const
Number of points.
const QString TAB_DELIMITER("\)
Curve & operator=(const Curve &curve)
Assignment constructor.
CallbackSearchReturn
Return values for search callback methods.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
#define LOG4CPP_ERROR_S(logger)
Converts old (=pre version 6) enums to new (=version 6) enums, for reading of old document files...
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
Translate the position of a point by the specified distance vector.
void setPointRadius(int radius)
Set method for curve point radius.
void setPointLineWidth(int width)
Set method for curve point perimeter line width.
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
QString identifier() const
Unique identifier for a specific Point.
const QString DOCUMENT_SERIALIZE_COLOR_FILTER
QString loadXml(QXmlStreamReader &reader)
Load from serialized xml. Returns the curve name.
Container for all graph curves. The axes point curve is external to this class.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
LineStyle lineStyle() const
Get method for LineStyle.
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
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.
const QString DOCUMENT_SERIALIZE_CURVE_STYLE
Container for LineStyle and PointStyle for one Curve.
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
Container for one set of digitized Points.
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...
void exportToClipboard(const QHash< QString, bool > &selectedHash, const Transformation &transformation, QTextStream &strCsv, QTextStream &strHtml, CurvesGraphs &curvesGraphs) const
Export points in this Curve found in the specified point list.
QPointF positionGraph(const QString &pointIdentifier) const
Return the position, in graph coordinates, of the specified Point.
void setLineColor(ColorPalette lineColor)
Set method for line color in specified curve.
void saveXml(QXmlStreamWriter &writer, const QString &curveName) const
Serialize to xml.
log4cpp::Category * mainCat
void loadXml(QXmlStreamReader &reader)
Load curve filter to stream.
CurveConnectAs curveConnectAs(int preVersion6) const
Line drawn between points.
void addPoint(const Point &point)
Add Point to this Curve.
void saveXml(QXmlStreamWriter &writer, const QString &curveName) const
Save curve filter to stream.
QString curveConnectAsToString(CurveConnectAs curveConnectAs)
void setPointColor(ColorPalette curveColor)
Set method curve point color in specified curve.
Immediately terminate the current search.
CurveStyle curveStyle() const
Return the curve style.
const QString DUMMY_CURVE_NAME("dummy")
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
void setLineWidth(int width)
Set method for line width in specified curve.
void setPointStyle(const PointStyle &pointStyle)
Set method for PointStyle.
QMultiMap< double, QString > XOrThetaToPointIdentifier
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(...
const QString DOCUMENT_SERIALIZE_CURVE_NAME
bool isXOnly(const QString &pointIdentifier) const
Determine if specified point has just x coordinate. Otherwise has just y coordinate, or both x and y coordinates.
ColorPalette colorPalette(int preVersion6) const
Color from color palette.
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
PointShape pointShape(int preVersion6) const
Point shape.
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...