21#include <QXmlStreamReader>
22#include <QXmlStreamWriter>
47 m_points (curve.
points ()),
55 const int CONVERT_ENUM_TO_RADIUS = 6;
58 qint32 int32, xScreen, yScreen;
59 double xGraph, yGraph;
69 m_curveStyle.setPointShape(migrate.
pointShape (int32));
71 m_curveStyle.setPointRadius(int32 + CONVERT_ENUM_TO_RADIUS);
73 m_curveStyle.setPointLineWidth (int32);
75 m_curveStyle.setPointColor(migrate.
colorPalette (int32));
78 m_curveStyle.setLineWidth(int32);
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;
297 << pointIdentifier.toLatin1().data();
305 QList<Point>::const_iterator itr;
306 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
308 const Point &point = *itr;
322 QList<Point>::const_iterator itr;
323 const Point *pointBefore =
nullptr;
324 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
326 const Point &point = *itr;
328 if (pointBefore !=
nullptr) {
338 pointBefore = &point;
342void Curve::loadCurvePoints(QXmlStreamReader &reader)
348 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
353 if (reader.atEnd()) {
358 if (tokenType == QXmlStreamReader::StartElement) {
362 Point point (reader);
363 m_points.push_back (point);
369 reader.raiseError(QObject::tr (
"Cannot read curve data"));
373void Curve::loadXml(QXmlStreamReader &reader)
379 QXmlStreamAttributes attributes = reader.attributes();
386 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
391 if (reader.atEnd()) {
396 if (tokenType == QXmlStreamReader::StartElement) {
399 m_colorFilterSettings.loadXml(reader);
401 loadCurvePoints(reader);
403 m_curveStyle.loadXml(reader);
410 if (reader.hasError()) {
421 reader.raiseError (QObject::tr (
"Cannot read curve data"));
426 const QPointF &deltaScreen)
428 Point *point = pointForPointIdentifier (pointIdentifier);
430 QPointF posScreen = deltaScreen + point->
posScreen ();
436 return m_points.count ();
439Point *Curve::pointForPointIdentifier (
const QString pointIdentifier)
441 Points::iterator itr;
442 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
450 << pointIdentifier.toLatin1().data();
465 Points::const_iterator itr;
466 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
467 const Point &point = *itr;
482 Points::const_iterator itr;
483 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
484 const Point &point = *itr;
495 QTextStream &str)
const
497 str << indentation <<
"Curve=" << m_curveName <<
"\n";
501 Points::const_iterator itr;
502 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
503 const Point &point = *itr;
508 m_colorFilterSettings.printStream (indentation,
510 m_curveStyle.printStream (indentation,
517 Points::iterator itr;
518 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
521 m_points.erase (itr);
533 m_colorFilterSettings.saveXml (writer,
535 m_curveStyle.saveXml (writer,
540 Points::const_iterator itr;
541 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
542 const Point &point = *itr;
545 writer.writeEndElement();
547 writer.writeEndElement();
560 QList<Point>::iterator itr;
561 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
574 CurveConnectAs curveConnectAs = m_curveStyle.lineStyle().curveConnectAs();
577 <<
" curve=" << m_curveName.toLatin1().data()
585 updatePointOrdinalsFunctions (transformation);
590 updatePointOrdinalsRelations ();
594 LOG4CPP_ERROR_S ((*
mainCat)) <<
"Curve::updatePointOrdinals encountered unexpected connection configuration";
599 std::sort (m_points.begin(),
604void Curve::updatePointOrdinalsFunctions (
const Transformation &transformation)
609 <<
" curve=" << m_curveName.toLatin1().data()
616 Points::iterator itr;
617 for (itr = m_points.begin (); itr != m_points.end (); itr++) {
633 xOrThetaToPointIdentifier.insert (posGraph.x(),
639 ENGAUGE_ASSERT (xOrThetaToPointIdentifier.count () == m_points.count ());
643 QMap<QString, double> pointIdentifierToOrdinal;
645 XOrThetaToPointIdentifier::const_iterator itrX;
646 for (itrX = xOrThetaToPointIdentifier.begin(); itrX != xOrThetaToPointIdentifier.end(); itrX++) {
648 QString pointIdentifier = itrX.value();
649 pointIdentifierToOrdinal [pointIdentifier] = ordinal++;
653 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
662 int ordinalNew = qFloor (pointIdentifierToOrdinal [point.
identifier()]);
667void Curve::updatePointOrdinalsRelations ()
669 CurveConnectAs curveConnectAs = m_curveStyle.lineStyle().curveConnectAs();
672 <<
" curve=" << m_curveName.toLatin1().data()
676 Points::iterator itr;
678 for (itr = m_points.begin(); itr != m_points.end(); itr++) {
const QString AXIS_CURVE_NAME
CallbackSearchReturn
Return values for search callback methods.
@ CALLBACK_SEARCH_RETURN_INTERRUPT
Immediately terminate the current search.
const QString DUMMY_CURVE_NAME
@ COLOR_PALETTE_TRANSPARENT
QString curveConnectAsToString(CurveConnectAs curveConnectAs)
@ CONNECT_AS_FUNCTION_STRAIGHT
@ CONNECT_AS_RELATION_STRAIGHT
@ CONNECT_AS_RELATION_SMOOTH
@ CONNECT_AS_FUNCTION_SMOOTH
QMultiMap< double, QString > XOrThetaToPointIdentifier
const QString TAB_DELIMITER("\t")
const QString AXIS_CURVE_NAME
const QString SCALE_CURVE_NAME
const QString DEFAULT_GRAPH_CURVE_NAME
const QString DOCUMENT_SERIALIZE_COLOR_FILTER
const QString DOCUMENT_SERIALIZE_CURVE_NAME
const QString DOCUMENT_SERIALIZE_CURVE_STYLE
const QString DOCUMENT_SERIALIZE_POINT
const QString DOCUMENT_SERIALIZE_CURVE
const QString DOCUMENT_SERIALIZE_CURVE_POINTS
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
log4cpp::Category * mainCat
const QString INDENTATION_DELTA
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
Container for LineStyle and PointStyle for one Curve.
LineStyle lineStyle() const
Get method for LineStyle.
void setPointStyle(const PointStyle &pointStyle)
Set method for PointStyle.
void setLineStyle(const LineStyle &lineStyle)
Set method for LineStyle.
bool isXOnly(const QString &pointIdentifier) const
Determine if specified point has just x coordinate. Otherwise has just y coordinate,...
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
Translate the position of a point by the specified distance vector.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Curve & operator=(const Curve &curve)
Assignment constructor.
CurveStyle curveStyle() const
Return the curve style.
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.
void setCurveStyle(const CurveStyle &curveStyle)
Set curve style.
void updatePointOrdinals(const Transformation &transformation)
See CurveGraphs::updatePointOrdinals.
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.
ColorFilterSettings colorFilterSettings() const
Return the color filter.
void removePoint(const QString &identifier)
Perform the opposite of addPointAtEnd.
const Points points() const
Return a shallow copy of the Points.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings)
Set color filter.
void addPoint(const Point &point)
Add Point to this Curve.
void setCurveName(const QString &curveName)
Change the curve name.
QString curveName() const
Name of this Curve.
QPointF positionScreen(const QString &pointIdentifier) const
Return the position, in screen coordinates, of the specified Point.
Curve(const QString &curveName, const ColorFilterSettings &colorFilterSettings, const CurveStyle &curveStyle)
Constructor from scratch.
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
QPointF positionGraph(const QString &pointIdentifier) const
Return the position, in graph coordinates, of the specified Point.
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 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.
int numPoints() const
Number of points.
Container for all graph curves. The axes point curve is external to this class.
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for the specified curve name.
int numCurves() const
Current number of graphs curves.
void addGraphCurveAtEnd(const Curve &curve)
Append new graph Curve to end of Curve list.
static LineStyle defaultAxesCurve()
Initial default for axes curve.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Converts old (=pre version 6) enums to new (=version 6) enums, for reading of old document files.
CurveConnectAs curveConnectAs(int preVersion6) const
Line drawn between points.
ColorPalette colorPalette(int preVersion6) const
Color from color palette.
PointShape pointShape(int preVersion6) const
Point shape.
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
void setOrdinal(double ordinal)
Set the ordinal used for ordering Points.
void setCurveName(const QString &curveName)
Update the point identifier to match the specified curve name.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPosScreen(const QPointF &posScreen)
Set method for position in screen coordinates.
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
QPointF posScreen() const
Accessor for screen position.
QString identifier() const
Unique identifier for a specific Point.
void saveXml(QXmlStreamWriter &writer) const
Serialize to stream.
void setPosGraph(const QPointF &posGraph)
Set method for position in graph coordinates.
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_ERROR_S(logger)
Comparator for sorting Point class.