00001
00002
00003
00004
00005
00006
00007 #ifndef DOCUMENT_H
00008 #define DOCUMENT_H
00009
00010 #include "CoordSystemContext.h"
00011 #include "CoordSystemIndex.h"
00012 #include "CurvesGraphs.h"
00013 #include "CurveStyles.h"
00014 #include "DocumentAxesPointsRequired.h"
00015 #include "DocumentModelAxesChecker.h"
00016 #include "DocumentModelColorFilter.h"
00017 #include "DocumentModelCoords.h"
00018 #include "DocumentModelDigitizeCurve.h"
00019 #include "DocumentModelExportFormat.h"
00020 #include "DocumentModelGeneral.h"
00021 #include "DocumentModelGridDisplay.h"
00022 #include "DocumentModelGridRemoval.h"
00023 #include "DocumentModelPointMatch.h"
00024 #include "DocumentModelSegments.h"
00025 #include "PointStyle.h"
00026 #include <QList>
00027 #include <QPixmap>
00028 #include <QString>
00029 #include <QXmlStreamReader>
00030
00031 class CoordSystem;
00032 class Curve;
00033 class QByteArray;
00034 class QFile;
00035 class QImage;
00036 class QTransform;
00037 class QXmlStreamWriter;
00038 class Transformation;
00039
00041 class Document
00042 {
00043 public:
00045 Document (const QImage &image);
00046
00048 Document (const QString &fileName);
00049
00052 void addCoordSystems(unsigned int numberCoordSystemToAdd);
00053
00055 void addGraphCurveAtEnd (const QString &curveName);
00056
00063 void addPointAxisWithGeneratedIdentifier (const QPointF &posScreen,
00064 const QPointF &posGraph,
00065 QString &identifier,
00066 double ordinal,
00067 bool isXOnly);
00068
00075 void addPointAxisWithSpecifiedIdentifier (const QPointF &posScreen,
00076 const QPointF &posGraph,
00077 const QString &identifier,
00078 double ordinal,
00079 bool isXOnly);
00080
00082 void addPointGraphWithGeneratedIdentifier (const QString &curveName,
00083 const QPointF &posScreen,
00084 QString &generatedIentifier,
00085 double ordinal);
00086
00088 void addPointGraphWithSpecifiedIdentifier (const QString &curveName,
00089 const QPointF &posScreen,
00090 const QString &identifier,
00091 double ordinal);
00092
00094 void addPointsInCurvesGraphs (CurvesGraphs &curvesGraphs);
00095
00097 void checkAddPointAxis (const QPointF &posScreen,
00098 const QPointF &posGraph,
00099 bool &isError,
00100 QString &errorMessage,
00101 bool isXOnly);
00102
00104 void checkEditPointAxis (const QString &pointIdentifier,
00105 const QPointF &posScreen,
00106 const QPointF &posGraph,
00107 bool &isError,
00108 QString &errorMessage);
00109
00111 const CoordSystem &coordSystem() const;
00112
00114 unsigned int coordSystemCount() const;
00115
00117 CoordSystemIndex coordSystemIndex() const;
00118
00120 const Curve &curveAxes () const;
00121
00123 const Curve *curveForCurveName (const QString &curveName) const;
00124
00126 const CurvesGraphs &curvesGraphs () const;
00127
00129 QStringList curvesGraphsNames () const;
00130
00132 int curvesGraphsNumPoints (const QString &curveName) const;
00133
00135 DocumentAxesPointsRequired documentAxesPointsRequired () const;
00136
00138 void editPointAxis (const QPointF &posGraph,
00139 const QString &identifier);
00140
00142 void initializeGridDisplay (const Transformation &transformation);
00143
00145 bool isXOnly (const QString &pointIdentifier) const;
00146
00148 void iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback);
00149
00151 void iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
00152
00154 void iterateThroughCurveSegments (const QString &curveName,
00155 const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
00156
00158 void iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback);
00159
00161 void iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const;
00162
00164 bool loadCurvesFile (const QString &curvesFile);
00165
00167 DocumentModelAxesChecker modelAxesChecker() const;
00168
00170 DocumentModelColorFilter modelColorFilter() const;
00171
00173 DocumentModelCoords modelCoords () const;
00174
00176 CurveStyles modelCurveStyles() const;
00177
00179 DocumentModelDigitizeCurve modelDigitizeCurve() const;
00180
00182 DocumentModelExportFormat modelExport() const;
00183
00185 DocumentModelGeneral modelGeneral() const;
00186
00188 DocumentModelGridDisplay modelGridDisplay() const;
00189
00191 DocumentModelGridRemoval modelGridRemoval() const;
00192
00194 DocumentModelPointMatch modelPointMatch() const;
00195
00197 DocumentModelSegments modelSegments() const;
00198
00200 void movePoint (const QString &pointIdentifier,
00201 const QPointF &deltaScreen);
00202
00204 int nextOrdinalForCurve (const QString &curveName) const;
00205
00207 QPixmap pixmap () const;
00208
00210 QPointF positionGraph (const QString &pointIdentifier) const;
00211
00213 QPointF positionScreen (const QString &pointIdentifier) const;
00214
00216 void print () const;
00217
00219 void printStream (QString indentation,
00220 QTextStream &str) const;
00221
00223 QString reasonForUnsuccessfulRead () const;
00224
00226 void removePointAxis (const QString &identifier);
00227
00229 void removePointGraph (const QString &identifier);
00230
00232 void removePointsInCurvesGraphs (CurvesGraphs &curvesGraphs);
00233
00235 void saveXml (QXmlStreamWriter &writer) const;
00236
00238 QString selectedCurveName () const;
00239
00241 void setCoordSystemIndex(CoordSystemIndex coordSystemIndex);
00242
00244 void setCurveAxes (const Curve &curveAxes);
00245
00247 void setCurvesGraphs (const CurvesGraphs &curvesGraphs);
00248
00251 void setDocumentAxesPointsRequired (DocumentAxesPointsRequired documentAxesPointsRequired);
00252
00254 void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker);
00255
00257 void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter);
00258
00260 void setModelCoords (const DocumentModelCoords &modelCoords);
00261
00263 void setModelCurveStyles(const CurveStyles &modelCurveStyles);
00264
00266 void setModelDigitizeCurve (const DocumentModelDigitizeCurve &modelDigitizeCurve);
00267
00269 void setModelExport(const DocumentModelExportFormat &modelExport);
00270
00272 void setModelGeneral (const DocumentModelGeneral &modelGeneral);
00273
00275 void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay);
00276
00278 void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval);
00279
00281 void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch);
00282
00284 void setModelSegments(const DocumentModelSegments &modelSegments);
00285
00287 void setSelectedCurveName (const QString &selectedCurveName);
00288
00290 bool successfulRead () const;
00291
00294 void updatePointOrdinals (const Transformation &transformation);
00295
00296 private:
00297 Document ();
00298
00299 bool bytesIndicatePreVersion6 (const QByteArray &bytes) const;
00300 Curve *curveForCurveName (const QString &curveName);
00301 void generateEmptyPixmap(const QXmlStreamAttributes &attributes);
00302 void loadImage(QXmlStreamReader &reader);
00303 void loadPreVersion6 (QDataStream &str);
00304 void loadVersion6 (QFile *file);
00305 void loadVersions7AndUp (QFile *file);
00306 int versionFromFile (QFile *file) const;
00307
00308
00309 QString m_name;
00310 QPixmap m_pixmap;
00311
00312
00313 DocumentAxesPointsRequired m_documentAxesPointsRequired;
00314
00315
00316 bool m_successfulRead;
00317 QString m_reasonForUnsuccessfulRead;
00318
00319 CoordSystemContext m_coordSystemContext;
00320 };
00321
00322 #endif // DOCUMENT_H