00001
00002
00003
00004
00005
00006
00007 #ifndef CURVE_H
00008 #define CURVE_H
00009
00010 #include "CallbackSearchReturn.h"
00011 #include "ColorFilterSettings.h"
00012 #include "CurveStyle.h"
00013 #include "functor.h"
00014 #include "Point.h"
00015 #include "Points.h"
00016 #include <QHash>
00017 #include <QList>
00018 #include <QString>
00019
00020 extern const QString AXIS_CURVE_NAME;
00021 extern const QString DEFAULT_GRAPH_CURVE_NAME;
00022 extern const QString DUMMY_CURVE_NAME;
00023 extern const QString SCALE_CURVE_NAME;
00024
00025 class CurvesGraphs;
00026 class QDataStream;
00027 class QTextStream;
00028 class QXmlStreamReader;
00029 class QXmlStreamWriter;
00030 class Transformation;
00031
00033 class Curve
00034 {
00035 public:
00037 Curve(const QString &curveName,
00038 const ColorFilterSettings &colorFilterSettings,
00039 const CurveStyle &curveStyle);
00040
00042 Curve (QDataStream &str);
00043
00045 Curve (QXmlStreamReader &reader);
00046
00048 Curve (const Curve &curve);
00049
00051 Curve &operator=(const Curve &curve);
00052
00054 void addPoint (Point point);
00055
00057 ColorFilterSettings colorFilterSettings () const;
00058
00060 QString curveName () const;
00061
00063 CurveStyle curveStyle() const;
00064
00066 void editPointAxis (const QPointF &posGraph,
00067 const QString &identifier);
00068
00070 void editPointGraph (bool isX,
00071 bool isY,
00072 double x,
00073 double y,
00074 const QStringList &identifiers,
00075 const Transformation &transformation);
00076
00078 void exportToClipboard (const QHash<QString, bool> &selectedHash,
00079 const Transformation &transformation,
00080 QTextStream &strCsv,
00081 QTextStream &strHtml,
00082 CurvesGraphs &curvesGraphs) const;
00083
00085 bool isXOnly (const QString &pointIdentifier) const;
00086
00088 void iterateThroughCurvePoints (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
00089
00091 void iterateThroughCurveSegments (const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
00092
00094 void movePoint (const QString &pointIdentifier,
00095 const QPointF &deltaScreen);
00096
00098 int numPoints () const;
00099
00101 const Points points () const;
00102
00104 QPointF positionGraph (const QString &pointIdentifier) const;
00105
00107 QPointF positionScreen (const QString &pointIdentifier) const;
00108
00110 void printStream (QString indentation,
00111 QTextStream &str) const;
00112
00114 void removePoint (const QString &identifier);
00115
00117 void saveXml(QXmlStreamWriter &writer) const;
00118
00120 void setColorFilterSettings (const ColorFilterSettings &colorFilterSettings);
00121
00123 void setCurveName (const QString &curveName);
00124
00126 void setCurveStyle (const CurveStyle &curveStyle);
00127
00130 void updatePointOrdinals (const Transformation &transformation);
00131
00132 private:
00133 Curve();
00134
00135 void loadCurvePoints(QXmlStreamReader &reader);
00136 void loadXml(QXmlStreamReader &reader);
00137 Point *pointForPointIdentifier (const QString pointIdentifier);
00138 void updatePointOrdinalsFunctions (const Transformation &transformation);
00139 void updatePointOrdinalsRelations ();
00140
00141 QString m_curveName;
00142 Points m_points;
00143
00144 ColorFilterSettings m_colorFilterSettings;
00145 CurveStyle m_curveStyle;
00146 };
00147
00148 #endif // CURVE_H