1 /****************************************************************************************************** 2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 5 ******************************************************************************************************/ 6 7 #ifndef COORD_SYSTEM_INTERFACE_H 8 #define COORD_SYSTEM_INTERFACE_H 9 10 #include "CallbackSearchReturn.h" 11 #include "CurveStyles.h" 12 #include "DocumentAxesPointsRequired.h" 13 #include "DocumentModelAxesChecker.h" 14 #include "DocumentModelColorFilter.h" 15 #include "DocumentModelCoords.h" 16 #include "DocumentModelDigitizeCurve.h" 17 #include "DocumentModelExportFormat.h" 18 #include "DocumentModelGeneral.h" 19 #include "DocumentModelGridDisplay.h" 20 #include "DocumentModelGridRemoval.h" 21 #include "DocumentModelGuidelines.h" 22 #include "DocumentModelPointMatch.h" 23 #include "DocumentModelSegments.h" 24 #include "functor.h" 25 #include "Point.h" 26 27 class Curve; 28 class CurvesGraphs; 29 class QPointF; 30 class QString; 31 class QStringList; 32 class Transformation; 33 34 /// Interface common to CoordSystemContext and CoordSystem classes 35 class CoordSystemInterface 36 { 37 public: 38 /// Single constructor 39 CoordSystemInterface (); 40 virtual ~CoordSystemInterface (); 41 42 /// Add new graph curve to the list of existing graph curves. 43 virtual void addGraphCurveAtEnd (const QString &curveName) = 0; 44 45 /// Add a single axis point with a generated point identifier. Call this after checkAddPointAxis to guarantee success in this call. 46 /// \param posScreen Screen coordinates from QGraphicsView 47 /// \param posGraph Graph coordiantes from user 48 /// \param identifier Identifier for new axis point 49 /// \param ordinal Unique, for curve, ordinal number 50 /// \param isXOnly True if graph coordinates have only x coordinate 51 virtual void addPointAxisWithGeneratedIdentifier (const QPointF &posScreen, 52 const QPointF &posGraph, 53 QString &identifier, 54 double ordinal, 55 bool isXOnly) = 0; 56 57 /// Add a single axis point with the specified point identifier. Call this after checkAddPointAxis to guarantee success in this call. 58 /// \param posScreen Screen coordinates from QGraphicsView 59 /// \param posGraph Graph coordiantes from user 60 /// \param identifier Identifier for new axis point 61 /// \param ordinal Unique, for curve, ordinal number 62 /// \param isXOnly True if graph coordinates have only x coordinate 63 virtual void addPointAxisWithSpecifiedIdentifier (const QPointF &posScreen, 64 const QPointF &posGraph, 65 const QString &identifier, 66 double ordinal, 67 bool isXOnly) = 0; 68 69 /// Add a single graph point with a generated point identifier. 70 virtual void addPointGraphWithGeneratedIdentifier (const QString &curveName, 71 const QPointF &posScreen, 72 QString &generatedIentifier, 73 double ordinal) = 0; 74 75 /// Add a single graph point with the specified point identifier. Note that PointStyle is not applied to the point within the Graph. 76 virtual void addPointGraphWithSpecifiedIdentifier (const QString &curveName, 77 const QPointF &posScreen, 78 const QString &identifier, 79 double ordinal) = 0; 80 81 /// Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs 82 virtual void addPointsInCurvesGraphs (CurvesGraphs &curvesGraphs) = 0; 83 84 /// Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes) 85 virtual void checkAddPointAxis (const QPointF &posScreen, 86 const QPointF &posGraph, 87 bool &isError, 88 QString &errorMessage, 89 bool isXOnly, 90 DocumentAxesPointsRequired documentAxesPointsRequired) = 0; 91 92 /// Check before calling editPointAxis 93 virtual void checkEditPointAxis (const QString &pointIdentifier, 94 const QPointF &posScreen, 95 const QPointF &posGraph, 96 bool &isError, 97 QString &errorMessage, 98 DocumentAxesPointsRequired documentAxesPointsRequired) = 0; 99 100 /// Get method for axis curve. 101 virtual const Curve &curveAxes () const = 0; 102 103 /// See CurvesGraphs::curveForCurveName, although this also works for AXIS_CURVE_NAME. 104 virtual Curve *curveForCurveName (const QString &curveName) = 0; 105 106 /// See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME. 107 virtual const Curve *curveForCurveName (const QString &curveName) const = 0; 108 109 /// Make all Curves available, read only, for CmdAbstract classes only. 110 virtual const CurvesGraphs &curvesGraphs () const = 0; 111 112 /// See CurvesGraphs::curvesGraphsNames. 113 virtual QStringList curvesGraphsNames () const = 0; 114 115 /// See CurvesGraphs::curvesGraphsNumPoints. 116 virtual int curvesGraphsNumPoints (const QString &curveName) const = 0; 117 118 /// Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee success in this call 119 virtual void editPointAxis (const QPointF &posGraph, 120 const QString &identifier) = 0; 121 122 /// Edit the graph coordinates of one or more graph points 123 virtual void editPointGraph (bool isX, 124 bool isY, 125 double x, 126 double y, 127 const QStringList &identifiers, 128 const Transformation &transformation) = 0; 129 130 /// See Curve::iterateThroughCurvePoints, for the axes curve. 131 virtual void iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) = 0; 132 133 /// See Curve::iterateThroughCurvePoints, for the axes curve. 134 virtual void iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const = 0; 135 136 /// See Curve::iterateThroughCurveSegments, for any axes or graph curve 137 virtual void iterateThroughCurveSegments (const QString &curveName, 138 const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const = 0; 139 140 /// See Curve::iterateThroughCurvePoints, for all the graphs curves. 141 virtual void iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) = 0; 142 143 /// See Curve::iterateThroughCurvePoints, for all the graphs curves. 144 virtual void iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const = 0; 145 146 /// Load the curve names in the specified Engauge file into the current graph. This is called near the end of the import process only 147 virtual bool loadCurvesFile (const QString &curvesFile) = 0; 148 149 /// Get method for DocumentModelAxesChecker. 150 virtual DocumentModelAxesChecker modelAxesChecker() const = 0; 151 152 /// Get method for DocumentModelColorFilter. 153 virtual DocumentModelColorFilter modelColorFilter() const = 0; 154 155 /// Get method for DocumentModelCoords. 156 virtual DocumentModelCoords modelCoords () const = 0; 157 158 /// Get method for CurveStyles. 159 virtual CurveStyles modelCurveStyles() const = 0; 160 161 /// Get method for DocumentModelDigitizeCurve. 162 virtual DocumentModelDigitizeCurve modelDigitizeCurve() const = 0; 163 164 /// Get method for DocumentModelExportFormat. 165 virtual DocumentModelExportFormat modelExport() const = 0; 166 167 /// Get method for DocumentModelGeneral. 168 virtual DocumentModelGeneral modelGeneral() const = 0; 169 170 /// Get method for DocumentModelGridDisplay. 171 virtual DocumentModelGridDisplay modelGridDisplay() const = 0; 172 173 /// Get method for DocumentModelGridRemoval. 174 virtual DocumentModelGridRemoval modelGridRemoval() const = 0; 175 176 /// Get method for DocumentModelGuidelines. 177 virtual DocumentModelGuidelines modelGuidelines() const = 0; 178 179 /// Get method for DocumentModelPointMatch. 180 virtual DocumentModelPointMatch modelPointMatch() const = 0; 181 182 /// Get method for DocumentModelSegments. 183 virtual DocumentModelSegments modelSegments() const = 0; 184 185 /// See Curve::movePoint 186 virtual void movePoint (const QString &pointIdentifier, 187 const QPointF &deltaScreen) = 0; 188 189 /// Default next ordinal value for specified curve 190 virtual int nextOrdinalForCurve (const QString &curveName) const = 0; 191 192 /// See Curve::positionGraph. 193 virtual QPointF positionGraph (const QString &pointIdentifier) const = 0; 194 195 /// See Curve::positionScreen. 196 virtual QPointF positionScreen (const QString &pointIdentifier) const = 0; 197 198 /// Debugging method for printing directly from symbolic debugger 199 virtual void print () const = 0; 200 201 /// Debugging method that supports print method of this class and printStream method of some other class(es) 202 virtual void printStream (QString indentation, 203 QTextStream &str) const = 0; 204 205 /// Return an informative text message explaining why startup loading failed. Applies if successfulRead returns false 206 virtual QString reasonForUnsuccessfulRead () const = 0; 207 208 /// Perform the opposite of addPointAxis. 209 virtual void removePointAxis (const QString &identifier) = 0; 210 211 /// Perform the opposite of addPointGraph. 212 virtual void removePointGraph (const QString &identifier) = 0; 213 214 /// Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs 215 virtual void removePointsInCurvesGraphs (CurvesGraphs &curvesGraphs) = 0; 216 217 /// Save graph to xml 218 virtual void saveXml (QXmlStreamWriter &writer) const = 0; 219 220 /// Currently selected curve name. This is used to set the selected curve combobox in MainWindow 221 virtual QString selectedCurveName () const = 0; 222 223 /// Let CmdAbstract classes overwrite axes Curve. Applies to current coordinate system 224 virtual void setCurveAxes (const Curve &curveAxes) = 0; 225 226 /// Let CmdAbstract classes overwrite CurvesGraphs. Applies to current coordinate system 227 virtual void setCurvesGraphs (const CurvesGraphs &curvesGraphs) = 0; 228 229 /// Set method for DocumentModelAxesChecker. 230 virtual void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker) = 0; 231 232 /// Set method for DocumentModelColorFilter. 233 virtual void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter) = 0; 234 235 /// Set method for DocumentModelCoords. 236 virtual void setModelCoords (const DocumentModelCoords &modelCoords) = 0; 237 238 /// Set method for CurveStyles. 239 virtual void setModelCurveStyles(const CurveStyles &modelCurveStyles) = 0; 240 241 /// Set method for DocumentModelDigitizeCurve. 242 virtual void setModelDigitizeCurve (const DocumentModelDigitizeCurve &modelDigitizeCurve) = 0; 243 244 /// Set method for DocumentModelExportFormat. 245 virtual void setModelExport(const DocumentModelExportFormat &modelExport) = 0; 246 247 /// Set method for DocumentModelGeneral. 248 virtual void setModelGeneral (const DocumentModelGeneral &modelGeneral) = 0; 249 250 /// Set method for DocumentModelGridDisplay. 251 virtual void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay) = 0; 252 253 /// Set method for DocumentModelGridRemoval. 254 virtual void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval) = 0; 255 256 /// Set method for DocumentModelGuidelines. 257 virtual void setModelGuidelines(const DocumentModelGuidelines &modelGuidelines) = 0; 258 259 /// Set method for DocumentModelPointMatch. 260 virtual void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch) = 0; 261 262 /// Set method for DocumentModelSegments. 263 virtual void setModelSegments(const DocumentModelSegments &modelSegments) = 0; 264 265 /// Save curve name that is selected for the current coordinate system, for the next time the coordinate system reappears 266 virtual void setSelectedCurveName(const QString &selectedCurveName) = 0; 267 268 /// Return true if startup loading succeeded. If the loading failed then reasonForUnsuccessfulRed will explain why 269 virtual bool successfulRead () const = 0; 270 271 /// Update point ordinals after point addition/removal or dragging. See GraphicsScene::updatePointOrdinalsAfterDrag. 272 /// Graph coordinates of point must be up to date 273 virtual void updatePointOrdinals (const Transformation &transformation) = 0; 274 }; 275 276 #endif // COORD_SYSTEM_INTERFACE_H 277