30#include <QDomDocument>
36#include <QXmlStreamReader>
37#include <QXmlStreamWriter>
58 <<
" image=" << image.width() <<
"x" << image.height();
62 m_successfulRead =
true;
64 m_pixmap.convertFromImage (image);
72 <<
" fileName=" <<
fileName.toLatin1().data();
74 m_successfulRead =
true;
86 if (
file->open (QIODevice::ReadOnly)) {
90 loadPreVersion6 (
str);
94 m_successfulRead =
false;
95 m_reasonForUnsuccessfulRead = QObject::tr (
"Operating system says file is not readable");
101 if (
file->open (QIODevice::ReadOnly | QIODevice::Text)) {
116 loadVersions7AndUp (
file);
120 m_successfulRead =
false;
121 m_reasonForUnsuccessfulRead =
QString (
"Engauge %1 %2 %3 %4 Engauge")
123 .arg (QObject::tr (
"cannot read newer files from version"))
125 .arg (QObject::tr (
"of"));
136 m_successfulRead =
false;
137 m_reasonForUnsuccessfulRead = QObject::tr (
"Operating system says file is not readable");
142 m_successfulRead =
false;
143 m_reasonForUnsuccessfulRead =
QString (
"%1 '%2' %3")
144 .arg (QObject::tr (
"File"))
146 .arg (QObject::tr (
"was not found"));
281 m_documentAxesPointsRequired);
297 m_documentAxesPointsRequired);
365 return m_documentAxesPointsRequired;
398 int width = 800,
height = 500;
435 boundingRectGraphMax,
504 m_pixmap = QPixmap::fromImage (
img);
507 while ((
reader.tokenType() != QXmlStreamReader::EndElement) ||
517 reader.raiseError (QObject::tr (
"Cannot read image data"));
538 m_documentAxesPointsRequired);
563 (
tokenType == QXmlStreamReader::StartElement)) {
565 generateEmptyPixmap (
reader.attributes());
570 (
tokenType == QXmlStreamReader::StartElement)) {
575 (
tokenType == QXmlStreamReader::EndElement)) {
584 if (
tokenType == QXmlStreamReader::StartElement) {
594 m_documentAxesPointsRequired);
604 m_successfulRead =
false;
605 m_reasonForUnsuccessfulRead =
reader.errorString();
611void Document::loadVersions7AndUp (
QFile *
file)
630 (
tokenType == QXmlStreamReader::StartElement)) {
632 generateEmptyPixmap (
reader.attributes());
637 (
tokenType == QXmlStreamReader::StartElement)) {
649 (
tokenType == QXmlStreamReader::EndElement)) {
658 if (
tokenType == QXmlStreamReader::StartElement) {
674 m_successfulRead =
false;
675 m_reasonForUnsuccessfulRead =
reader.errorString();
772void Document::overrideGraphDefaultsWithMapDefaults ()
799 QStringList::const_iterator
itr;
800 for (
itr = curveNames.begin();
itr != curveNames.end();
itr++) {
839 std::cerr <<
text.toLatin1().data();
850 str <<
indentation <<
"pixmap=" << m_pixmap.width() <<
"x" << m_pixmap.height() <<
"\n";
860 return m_reasonForUnsuccessfulRead;
947 overrideGraphDefaultsWithMapDefaults ();
963 ColorFilterSettingsList::const_iterator
itr;
972 curve->setColorFilterSettings (colorFilterSettings);
989 QStringList::iterator
itr;
990 for (
itr = curveNames.begin();
itr != curveNames.end();
itr++) {
996 curve->setCurveStyle (curveStyle);
1053 m_pixmap = QPixmap::fromImage (image);
1063 return m_successfulRead;
1073int Document::versionFromFile (
QFile *
file)
const
1083 if (
nodes.count() > 0) {
const QString AXIS_CURVE_NAME
unsigned int CoordSystemIndex
Zero-based index for identifying CoordSystem instantiations.
@ CONNECT_AS_RELATION_STRAIGHT
const int INNER_RADIUS_MIN
DocumentAxesPointsRequired
@ DOCUMENT_AXES_POINTS_REQUIRED_3
@ DOCUMENT_AXES_POINTS_REQUIRED_2
const QString DOCUMENT_SERIALIZE_COORD_SYSTEM
const QString DOCUMENT_SERIALIZE_AXES_POINTS_REQUIRED
const QString DOCUMENT_SERIALIZE_IMAGE
const QString DOCUMENT_SERIALIZE_IMAGE_HEIGHT
const QString DOCUMENT_SERIALIZE_IMAGE_WIDTH
const QString DOCUMENT_SERIALIZE_DOCUMENT
const QString DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER
const int NOMINAL_COORD_SYSTEM_COUNT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
log4cpp::Category * mainCat
const QString INDENTATION_DELTA
const char * VERSION_NUMBER
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
unsigned int coordSystemCount() const
Number of CoordSystem.
void loadVersions7AndUp(QXmlStreamReader &reader)
Load one CoordSystem from file in version 7 format or newer, into the most recent CoordSystem which w...
virtual void addPointGraphWithSpecifiedIdentifier(const QString &curveName, const QPointF &posScreen, const QString &identifier, double ordinal)
Add a single graph point with the specified point identifer. Note that PointStyle is not applied to t...
virtual DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
CoordSystemIndex coordSystemIndex() const
Index of current CoordSystem.
virtual CurveStyles modelCurveStyles() const
Get method for CurveStyles.
virtual void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
virtual void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes curve.
virtual const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
const CoordSystem & coordSystem() const
Current CoordSystem.
virtual void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...
virtual void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
virtual void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
virtual void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
virtual const Curve & curveAxes() const
Get method for axis curve.
virtual void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
virtual void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
virtual void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void loadPreVersion6(QDataStream &str, double version, DocumentAxesPointsRequired &documentAxesPointsRequired)
Load from file in pre-version 6 format.
virtual void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
virtual DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
void loadVersion6(QXmlStreamReader &reader, DocumentAxesPointsRequired &documentAxesPointsRequired)
Load from file in version 6 format, into the single CoordSystem.
virtual int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
virtual QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
virtual void checkAddPointAxis(const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, bool isXOnly, DocumentAxesPointsRequired documentAxesPointsRequired)
Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes...
bool isXOnly(const QString &pointIdentifier) const
True/false if y/x value is empty.
virtual void setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
virtual DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
virtual DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
virtual Curve * curveForCurveName(const QString &curveName)
See CurvesGraphs::curveForCurveName, although this also works for AXIS_CURVE_NAME.
virtual int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
virtual DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
virtual DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
virtual void addGraphCurveAtEnd(const QString &curveName)
Add new graph curve to the list of existing graph curves.
virtual void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
virtual void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs. Applies to current coordinate system.
virtual void saveXml(QXmlStreamWriter &writer) const
Save graph to xml.
virtual DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
virtual void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
virtual void removePointGraph(const QString &identifier)
Perform the opposite of addPointGraph.
void addCoordSystems(unsigned int numberCoordSystemToAdd)
Add specified number of coordinate systems to the original one created by the constructor.
void setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
Index of current CoordSystem.
virtual void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve. Applies to current coordinate system.
virtual DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
virtual void addPointAxisWithGeneratedIdentifier(const QPointF &posScreen, const QPointF &posGraph, QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with a generated point identifier.
virtual 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.
virtual void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
virtual DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
virtual QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
virtual void iterateThroughCurveSegments(const QString &curveName, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
See Curve::iterateThroughCurveSegments, for any axes or graph curve.
virtual void addPointAxisWithSpecifiedIdentifier(const QPointF &posScreen, const QPointF &posGraph, const QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with the specified point identifier.
virtual void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
virtual void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
virtual void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, DocumentAxesPointsRequired documentAxesPointsRequired)
Check before calling editPointAxis.
virtual QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow.
virtual void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
virtual void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
virtual DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
virtual QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
virtual void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
Storage of data belonging to one coordinate system.
Container for LineStyle and PointStyle for one Curve.
LineStyle lineStyle() const
Get method for LineStyle.
void setPointStyle(const PointStyle &pointStyle)
Set method for PointStyle.
PointStyle pointStyle() const
Get method for PointStyle.
void setLineStyle(const LineStyle &lineStyle)
Set method for LineStyle.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
QStringList curveNames() const
List of all curve names.
Container for one set of digitized Points.
Container for all graph curves. The axes point curve is external to this class.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
const ColorFilterSettingsList & colorFilterSettingsList() const
Get method for copying all color filters in one step.
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
bool stable() const
Get method for stable flag.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Model for DlgSettingsSegments and CmdSettingsSegments.
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
unsigned int coordSystemCount() const
Number of CoordSystem.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
void iterateThroughCurveSegments(const QString &curveName, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
See Curve::iterateThroughCurveSegments, for any axes or graph curve.
void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
void setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
Set the index of current active CoordSystem.
void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes 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 updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
QPixmap pixmap() const
Return the image that is being digitized.
void setDocumentAxesPointsRequired(DocumentAxesPointsRequired documentAxesPointsRequired)
Set the number of axes points required.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
void addPointAxisWithGeneratedIdentifier(const QPointF &posScreen, const QPointF &posGraph, QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with a generated point identifier.
QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
const Curve & curveAxes() const
Get method for axis curve.
CoordSystemIndex coordSystemIndex() const
Index of current active CoordSystem.
QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow.
void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
void addPointGraphWithSpecifiedIdentifier(const QString &curveName, const QPointF &posScreen, const QString &identifier, double ordinal)
Add a single graph point with the specified point identifer. Note that PointStyle is not applied to t...
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
bool isXOnly(const QString &pointIdentifier) const
See Curve::isXOnly.
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
Document(const QImage &image)
Constructor for imported images and dragged images. Only one coordinate system is create - others are...
void removePointGraph(const QString &identifier)
Perform the opposite of addPointGraph.
void setModelCurveStyles(const CurveStyles &modelCurveStyles)
Set method for CurveStyles.
void addPointAxisWithSpecifiedIdentifier(const QPointF &posScreen, const QPointF &posGraph, const QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with the specified point identifier.
const CoordSystem & coordSystem() const
Currently active CoordSystem.
void initializeGridDisplay(const Transformation &transformation)
Initialize grid display. This is called immediately after the transformation has been defined for the...
void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
void print() const
Debugging method for printing directly from symbolic debugger.
bool successfulRead() const
Return true if startup loading succeeded. If the loading failed then reasonForUnsuccessfulRed will ex...
void addCoordSystems(unsigned int numberCoordSystemToAdd)
Add some number (0 or more) of additional coordinate systems.
void addGraphCurveAtEnd(const QString &curveName)
Add new graph curve to the list of existing graph curves.
void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter)
Set method for DocumentModelColorFilter.
void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
QString reasonForUnsuccessfulRead() const
Return an informative text message explaining why startup loading failed. Applies if successfulRead r...
void saveXml(QXmlStreamWriter &writer) const
Save document to xml.
void addScaleWithGeneratedIdentifier(const QPointF &posScreen0, const QPointF &posScreen1, double scaleLength, QString &identifier0, QString &identifier1, double ordinal0, double ordinal1)
Add scale with a generated point identifier.
DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
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.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage)
Check before calling editPointAxis.
void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
void setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
void setPixmap(const QImage &image)
Set method for the background pixmap.
void checkAddPointAxis(const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, bool isXOnly)
Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes...
void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
This class initializes the count, start, step and stop parameters for one coordinate (either x/theta ...
Details for a specific Line.
void setCurveConnectAs(CurveConnectAs curveConnectAs)
Set connect as.
void setWidth(int width)
Set width of line.
void setPaletteColor(ColorPalette paletteColor)
Set method for line color.
Details for a specific Point.
void setPaletteColor(ColorPalette paletteColor)
Set method for point color.
void setShape(PointShape shape)
Set method for point shape.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)