Engauge Digitizer  2
 All Classes Functions Variables Typedefs Enumerations Friends Pages
CoordSystem.cpp
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 #include "CallbackAddPointsInCurvesGraphs.h"
8 #include "CallbackCheckAddPointAxis.h"
9 #include "CallbackCheckEditPointAxis.h"
10 #include "CallbackNextOrdinal.h"
11 #include "CallbackRemovePointsInCurvesGraphs.h"
12 #include "CoordSystem.h"
13 #include "Curve.h"
14 #include "CurvesGraphs.h"
15 #include "CurveStyles.h"
16 #include "DocumentSerialize.h"
17 #include "EngaugeAssert.h"
18 #include "EnumsToQt.h"
19 #include <iostream>
20 #include "Logger.h"
21 #include "OrdinalGenerator.h"
22 #include "Point.h"
23 #include <QByteArray>
24 #include <QDataStream>
25 #include <QDebug>
26 #include <QFile>
27 #include <QImage>
28 #include <qmath.h>
29 #include <QtToString.h>
30 #include <QXmlStreamReader>
31 #include <QXmlStreamWriter>
32 #include "SettingsForGraph.h"
33 #include "Transformation.h"
34 #include "Version.h"
35 #include "Xml.h"
36 
37 const int FOUR_BYTES = 4;
38 
40  m_curveAxes (new Curve (AXIS_CURVE_NAME,
41  ColorFilterSettings::defaultFilter (),
42  CurveStyle (LineStyle::defaultAxesCurve(),
43  PointStyle::defaultAxesCurve ())))
44 {
45  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::CoordSystem";
46 
47  SettingsForGraph settingsForGraph;
48 
49  // Create one curve, or as many curve as specified in the configuration file, whichever is greater
50  for (int indexOneBased = 1; indexOneBased <= settingsForGraph.numberOfCurvesForImport (); indexOneBased++) {
51 
52  QString curveName = settingsForGraph.defaultCurveName (indexOneBased,
53  DEFAULT_GRAPH_CURVE_NAME);
54  m_curvesGraphs.addGraphCurveAtEnd (Curve (curveName,
57  PointStyle::defaultGraphCurve (m_curvesGraphs.numCurves ()))));
58 
59  resetSelectedCurveNameIfNecessary ();
60  }
61 }
62 
63 CoordSystem::~CoordSystem()
64 {
65  delete m_curveAxes;
66 }
67 
68 void CoordSystem::addGraphCurveAtEnd (const QString &curveName)
69 {
70  m_curvesGraphs.addGraphCurveAtEnd (Curve (curveName,
73  PointStyle::defaultGraphCurve(m_curvesGraphs.numCurves()))));
74 
75  resetSelectedCurveNameIfNecessary ();
76 }
77 
78 void CoordSystem::addPointAxisWithGeneratedIdentifier (const QPointF &posScreen,
79  const QPointF &posGraph,
80  QString &identifier,
81  double ordinal,
82  bool isXOnly)
83 {
84  Point point (AXIS_CURVE_NAME,
85  posScreen,
86  posGraph,
87  ordinal,
88  isXOnly);
89  m_curveAxes->addPoint (point);
90 
91  identifier = point.identifier();
92 
93  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::addPointAxisWithGeneratedIdentifier"
94  << " ordinal=" << ordinal
95  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
96  << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ()
97  << " identifier=" << identifier.toLatin1 ().data ();
98 }
99 
101  const QPointF &posGraph,
102  const QString &identifier,
103  double ordinal,
104  bool isXOnly)
105 {
106  Point point (AXIS_CURVE_NAME,
107  identifier,
108  posScreen,
109  posGraph,
110  ordinal,
111  isXOnly);
112  m_curveAxes->addPoint (point);
113 
114  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::addPointAxisWithSpecifiedIdentifier"
115  << " ordinal=" << ordinal
116  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
117  << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ()
118  << " identifier=" << identifier.toLatin1 ().data ();
119 }
120 
122  const QPointF &posScreen,
123  QString &identifier,
124  double ordinal)
125 {
126  Point point (curveName,
127  posScreen,
128  ordinal);
129  m_curvesGraphs.addPoint (point);
130 
131  identifier = point.identifier();
132 
133  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::addPointGraphWithGeneratedIdentifier"
134  << " ordinal=" << ordinal
135  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
136  << " identifier=" << identifier.toLatin1 ().data ();
137 }
138 
140  const QPointF &posScreen,
141  const QString &identifier,
142  double ordinal)
143 {
144  Point point (curveName,
145  identifier,
146  posScreen,
147  ordinal);
148  m_curvesGraphs.addPoint (point);
149 
150  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::addPointGraphWithSpecifiedIdentifier"
151  << " ordinal=" << ordinal
152  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
153  << " identifier=" << identifier.toLatin1 ().data ();
154 }
155 
157 {
158  CallbackAddPointsInCurvesGraphs ftor (*this);
159 
160  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
162 
163  curvesGraphs.iterateThroughCurvesPoints (ftorWithCallback);
164 }
165 
166 bool CoordSystem::bytesIndicatePreVersion6 (const QByteArray &bytes) const
167 {
168  QByteArray preVersion6MagicNumber;
169  preVersion6MagicNumber.resize (FOUR_BYTES);
170 
171  // Windows compiler gives warning if 0x## is used instead of '\x##' below
172  preVersion6MagicNumber[0] = '\x00';
173  preVersion6MagicNumber[1] = '\x00';
174  preVersion6MagicNumber[2] = '\xCA';
175  preVersion6MagicNumber[3] = '\xFE';
176 
177  return (bytes == preVersion6MagicNumber);
178 }
179 
180 void CoordSystem::checkAddPointAxis (const QPointF &posScreen,
181  const QPointF &posGraph,
182  bool &isError,
183  QString &errorMessage,
184  bool isXOnly,
185  DocumentAxesPointsRequired documentAxesPointsRequired)
186 {
187  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::checkAddPointAxis"
188  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
189  << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ();
190 
191  CallbackCheckAddPointAxis ftor (m_modelCoords,
192  posScreen,
193  posGraph,
194  documentAxesPointsRequired,
195  isXOnly);
196 
197  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
199  m_curveAxes->iterateThroughCurvePoints (ftorWithCallback);
200 
201  isError = ftor.isError ();
202  errorMessage = ftor.errorMessage ();
203 }
204 
205 void CoordSystem::checkEditPointAxis (const QString &pointIdentifier,
206  const QPointF &posScreen,
207  const QPointF &posGraph,
208  bool &isError,
209  QString &errorMessage,
210  DocumentAxesPointsRequired documentAxesPointsRequired)
211 {
212  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::checkEditPointAxis"
213  << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ();
214 
215  CallbackCheckEditPointAxis ftor (m_modelCoords,
216  pointIdentifier,
217  posScreen,
218  posGraph,
219  documentAxesPointsRequired);
220 
221  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
223  m_curveAxes->iterateThroughCurvePoints (ftorWithCallback);
224 
225  isError = ftor.isError ();
226  errorMessage = ftor.errorMessage ();
227 }
228 
230 {
231  ENGAUGE_CHECK_PTR (m_curveAxes);
232 
233  return *m_curveAxes;
234 }
235 
236 Curve *CoordSystem::curveForCurveName (const QString &curveName)
237 {
238  if (curveName == AXIS_CURVE_NAME) {
239 
240  return m_curveAxes;
241 
242  } else {
243 
244  return m_curvesGraphs.curveForCurveName (curveName);
245 
246  }
247 }
248 
249 const Curve *CoordSystem::curveForCurveName (const QString &curveName) const
250 {
251  if (curveName == AXIS_CURVE_NAME) {
252 
253  return m_curveAxes;
254 
255  } else {
256 
257  return m_curvesGraphs.curveForCurveName (curveName);
258 
259  }
260 }
261 
263 {
264  return m_curvesGraphs;
265 }
266 
268 {
269  return m_curvesGraphs.curvesGraphsNames();
270 }
271 
272 int CoordSystem::curvesGraphsNumPoints(const QString &curveName) const
273 {
274  return m_curvesGraphs.curvesGraphsNumPoints(curveName);
275 }
276 
277 void CoordSystem::editPointAxis (const QPointF &posGraph,
278  const QString &identifier)
279 {
280  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::editPointAxis"
281  << " posGraph=(" << posGraph.x () << ", " << posGraph.y () << ") identifier="
282  << " identifier=" << identifier.toLatin1 ().data ();
283 
284  m_curveAxes->editPointAxis (posGraph,
285  identifier);
286 }
287 
289  bool isY,
290  double x,
291  double y,
292  const QStringList &identifiers,
293  const Transformation &transformation)
294 {
295  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::editPointGraph posGraph=("
296  << " x=" << (isX ? QString::number (x).toLatin1().data() : "")
297  << " y=" << (isY ? QString::number (y).toLatin1().data() : "")
298  << ") identifiers=" << identifiers.join(" ").toLatin1 ().data ();
299 
300  m_curvesGraphs.editPointGraph (isX,
301  isY,
302  x,
303  y,
304  identifiers,
305  transformation);
306 }
307 
308 void CoordSystem::initializeUnsetGridRemovalFromGridDisplay (double version)
309 {
310  // In issue #273 a broken dig file was encountered with grid removal values that were apparently
311  // corrupted, from version 4.1. This code was inserted to accomodate that file and other files presumably having
312  // the same issue. Newer versions are assumed to be properly initialized, and this code is not applied
313  // so it does not interfere with properly set values
314 
315  if (version < 5) {
316 
317  // Most reliable indicator of a problem is very unrealistic values for counts
318  if (m_modelGridRemoval.countX () < 2 ||
319  m_modelGridRemoval.countY () < 2 ||
320  m_modelGridRemoval.countX () > 100 ||
321  m_modelGridRemoval.countY () > 100) {
322 
323  // Problem found. Prevent issues later by copying values from m_modelGridDisplay
324  m_modelGridRemoval.setStartX (m_modelGridDisplay.startX ());
325  m_modelGridRemoval.setStartY (m_modelGridDisplay.startY ());
326  m_modelGridRemoval.setStepX (m_modelGridDisplay.stepX ());
327  m_modelGridRemoval.setStepY (m_modelGridDisplay.stepY ());
328  m_modelGridRemoval.setStopX (m_modelGridDisplay.stopX ());
329  m_modelGridRemoval.setStopY (m_modelGridDisplay.stopY ());
330  m_modelGridRemoval.setCountX (signed (m_modelGridDisplay.countX ()));
331  m_modelGridRemoval.setCountY (signed (m_modelGridDisplay.countY ()));
332  }
333  }
334 }
335 
336 bool CoordSystem::isXOnly (const QString &pointIdentifier) const
337 {
338  return m_curveAxes->isXOnly (pointIdentifier);
339 }
340 
341 void CoordSystem::iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
342 {
343  ENGAUGE_CHECK_PTR (m_curveAxes);
344 
345  m_curveAxes->iterateThroughCurvePoints (ftorWithCallback);
346 }
347 
348 void CoordSystem::iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
349 {
350  ENGAUGE_CHECK_PTR (m_curveAxes);
351 
352  m_curveAxes->iterateThroughCurvePoints (ftorWithCallback);
353 }
354 
355 void CoordSystem::iterateThroughCurveSegments (const QString &curveName,
356  const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
357 {
358  if (curveName == AXIS_CURVE_NAME) {
359  m_curveAxes->iterateThroughCurveSegments(ftorWithCallback);
360  } else {
361  m_curvesGraphs.iterateThroughCurveSegments(curveName,
362  ftorWithCallback);
363  }
364 }
365 
366 void CoordSystem::iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
367 {
368  ENGAUGE_CHECK_PTR (m_curveAxes);
369 
370  m_curvesGraphs.iterateThroughCurvesPoints (ftorWithCallback);
371 }
372 
373 void CoordSystem::iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
374 {
375  ENGAUGE_CHECK_PTR (m_curveAxes);
376 
377  m_curvesGraphs.iterateThroughCurvesPoints (ftorWithCallback);
378 }
379 
380 bool CoordSystem::loadCurvesFile(const QString & /* curvesFile */)
381 {
382  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::loadCurvesFile";
383 
384  return true;
385 }
386 
387 void CoordSystem::loadPreVersion6 (QDataStream &str,
388  double version,
389  DocumentAxesPointsRequired &documentAxesPointsRequired)
390 {
391  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::loadPreVersion6";
392 
393  qint32 int32;
394  double dbl, radius = 0.0;
395  QString st;
396 
397  str >> st; // CurveCmbText selection
398  str >> st; // MeasureCmbText selection
399  str >> int32;
400  m_modelCoords.setCoordsType(static_cast<CoordsType> (int32));
401  if (version >= 3) {
402  str >> static_cast<double &> (radius);
403  }
404  m_modelCoords.setOriginRadius(radius);
405  str >> int32;
406  m_modelCoords.setCoordUnitsRadius(COORD_UNITS_NON_POLAR_THETA_NUMBER);
407  m_modelCoords.setCoordUnitsTheta(static_cast<CoordUnitsPolarTheta> (int32));
408  str >> int32;
409  m_modelCoords.setCoordScaleXTheta(static_cast<CoordScale> (int32));
410  str >> int32;
411  m_modelCoords.setCoordScaleYRadius(static_cast<CoordScale> (int32));
412 
413  str >> int32;
414  m_modelExport.setDelimiter(static_cast<ExportDelimiter> (int32));
415  str >> int32;
416  m_modelExport.setLayoutFunctions(static_cast<ExportLayoutFunctions> (int32));
417  str >> int32;
418  m_modelExport.setPointsSelectionFunctions(static_cast<ExportPointsSelectionFunctions> (int32));
419  m_modelExport.setPointsSelectionRelations(EXPORT_POINTS_SELECTION_RELATIONS_RAW); // Best for maps
420  m_modelExport.setPointsIntervalUnitsFunctions(static_cast<ExportPointsIntervalUnits> (int32));
421  m_modelExport.setPointsIntervalUnitsRelations(static_cast<ExportPointsIntervalUnits> (int32));
422  str >> int32;
423  m_modelExport.setHeader(static_cast<ExportHeader> (int32));
424  if (version >= 5.1) {
425  str >> st; // X label
426  if (m_modelCoords.coordsType() == COORDS_TYPE_CARTESIAN) {
427  m_modelExport.setXLabel(st);
428  }
429  str >> st; // Theta label
430  if (m_modelCoords.coordsType() == COORDS_TYPE_POLAR) {
431  m_modelExport.setXLabel(st);
432  }
433  }
434 
435  // Stable flag in m_modelGridRemoval is set below after points are read in
436  str >> int32; // Remove thin lines parallel to axes
437  str >> dbl; // Thin thickness
438  str >> int32;
439  m_modelGridRemoval.setRemoveDefinedGridLines(int32);
440  str >> int32; // Initialized
441  str >> int32;
442  m_modelGridRemoval.setCountX(int32);
443  str >> int32;
444  m_modelGridRemoval.setCountY(int32);
445  str >> int32;
446  m_modelGridRemoval.setGridCoordDisableX(static_cast<GridCoordDisable> (int32));
447  str >> int32;
448  m_modelGridRemoval.setGridCoordDisableY(static_cast<GridCoordDisable> (int32));
449  str >> dbl;
450  m_modelGridRemoval.setStartX(dbl);
451  str >> dbl;
452  m_modelGridRemoval.setStartY(dbl);
453  str >> dbl;
454  m_modelGridRemoval.setStepX(dbl);
455  str >> dbl;
456  m_modelGridRemoval.setStepY(dbl);
457  str >> dbl;
458  m_modelGridRemoval.setStopX(dbl);
459  str >> dbl;
460  m_modelGridRemoval.setStopY(dbl);
461  str >> dbl;
462  m_modelGridRemoval.setCloseDistance(dbl);
463  str >> int32; // Boolean remove color flag
464  if (version >= 5) {
465  QColor color;
466  str >> color;
467  } else {
468  str >> int32; // Rgb color
469  }
470  str >> int32; // Foreground threshold low
471  str >> int32; // Foreground threshold high
472  str >> dbl; // Gap separation
473 
474  str >> int32;
475  m_modelGridDisplay.setStable(int32);
476  str >> int32;
477  m_modelGridDisplay.setCountX(unsigned (int32));
478  str >> int32;
479  m_modelGridDisplay.setCountY(unsigned (int32));
480  str >> int32;
481  m_modelGridDisplay.setDisableX(static_cast<GridCoordDisable> (int32));
482  str >> int32;
483  m_modelGridDisplay.setDisableY(static_cast<GridCoordDisable> (int32));
484  str >> dbl;
485  m_modelGridDisplay.setStartX (dbl);
486  str >> dbl;
487  m_modelGridDisplay.setStartY (dbl);
488  str >> dbl;
489  m_modelGridDisplay.setStepX (dbl);
490  str >> dbl;
491  m_modelGridDisplay.setStepY (dbl);
492  str >> dbl;
493  m_modelGridDisplay.setStopX (dbl);
494  str >> dbl;
495  m_modelGridDisplay.setStopY (dbl);
496 
497  initializeUnsetGridRemovalFromGridDisplay (version);
498 
499  str >> int32;
500  m_modelSegments.setMinLength(int32);
501  str >> int32;
502  m_modelSegments.setPointSeparation(int32);
503  str >> int32;
504  m_modelSegments.setLineWidth(int32);
505  str >> int32;
506  m_modelSegments.setLineColor(static_cast<ColorPalette> (int32));
507 
508  str >> int32; // Point separation
509  str >> int32;
510  m_modelPointMatch.setMaxPointSize(int32);
511  str >> int32;
512  m_modelPointMatch.setPaletteColorAccepted(static_cast<ColorPalette> (int32));
513  str >> int32;
514  m_modelPointMatch.setPaletteColorRejected(static_cast<ColorPalette> (int32));
515  if (version < 4) {
516  m_modelPointMatch.setPaletteColorCandidate(COLOR_PALETTE_BLUE);
517  } else {
518  str >> int32;
519  m_modelPointMatch.setPaletteColorCandidate(static_cast<ColorPalette> (int32));
520  }
521 
522  str >> int32; // Discretize method
523  str >> int32; // Intensity threshold low
524  str >> int32; // Intensity threshold high
525  str >> int32; // Foreground threshold low
526  str >> int32; // Foreground threshold high
527  str >> int32; // Hue threshold low
528  str >> int32; // Hue threshold high
529  str >> int32; // Saturation threshold low
530  str >> int32; // Saturation threshold high
531  str >> int32; // Value threshold low
532  str >> int32; // Value threshold high
533 
534  // Old versions have two Curve objects for 3 point axes and 2 point scales. New version picks one Curve
535  Curve *curveAxesIn = new Curve (str);
536  Curve *curveScaleIn = new Curve (str);
537  if (curveScaleIn->numPoints() == 2) {
538  // Nondefault case is map with scale bar
539  documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_2;
540  m_curveAxes = curveScaleIn;
541  m_curveAxes->setCurveName (AXIS_CURVE_NAME); // Override existing "Scale" name
542  delete curveAxesIn;
543  } else {
544  // Default case is graph with axes
545  documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_3;
546  m_curveAxes = curveAxesIn;
547  delete curveScaleIn;
548  }
549  m_curvesGraphs.loadPreVersion6 (str);
550 
551  // Information from curves and points can affect some data structures that were (mostly) set earlier
552  if (m_curveAxes->numPoints () >= documentAxesPointsRequired) {
553  m_modelGridRemoval.setStable();
554  }
555 
556  resetSelectedCurveNameIfNecessary ();
557 }
558 
559 void CoordSystem::loadVersion6 (QXmlStreamReader &reader,
560  DocumentAxesPointsRequired &documentAxesPointsRequired)
561 {
562  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::loadVersion6";
563 
564  documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_3;
565 
566  // Import from xml. Loop to end of data or error condition occurs, whichever is first
567  while (!reader.atEnd() &&
568  !reader.hasError()) {
569  QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
570 
571  if ((reader.name() == DOCUMENT_SERIALIZE_DOCUMENT) &&
572  (tokenType == QXmlStreamReader::EndElement)) {
573 
574  // Exit out of loop immediately
575  break;
576  }
577 
578  // Iterate to next StartElement
579  if (tokenType == QXmlStreamReader::StartElement) {
580 
581  // This is a StartElement, so process it
582  QString tag = reader.name().toString();
583  if (tag == DOCUMENT_SERIALIZE_AXES_CHECKER){
584  m_modelAxesChecker.loadXml (reader);
585  } else if (tag == DOCUMENT_SERIALIZE_COORDS) {
586  m_modelCoords.loadXml (reader);
587  } else if (tag == DOCUMENT_SERIALIZE_CURVE) {
588  m_curveAxes = new Curve (reader);
589  } else if (tag == DOCUMENT_SERIALIZE_CURVES_GRAPHS) {
590  m_curvesGraphs.loadXml (reader);
591  } else if (tag == DOCUMENT_SERIALIZE_DIGITIZE_CURVE) {
592  m_modelDigitizeCurve.loadXml (reader);
593  } else if (tag == DOCUMENT_SERIALIZE_EXPORT) {
594  m_modelExport.loadXml (reader);
595  } else if (tag == DOCUMENT_SERIALIZE_GENERAL || tag == DOCUMENT_SERIALIZE_COMMON) {
596  m_modelGeneral.loadXml (reader);
597  } else if (tag == DOCUMENT_SERIALIZE_GRID_REMOVAL) {
598  m_modelGridRemoval.loadXml (reader);
599  } else if (tag == DOCUMENT_SERIALIZE_IMAGE) {
600  ENGAUGE_ASSERT (false); // The image should have been read before this method was called
601  } else if (tag == DOCUMENT_SERIALIZE_POINT_MATCH) {
602  m_modelPointMatch.loadXml (reader);
603  } else if (tag == DOCUMENT_SERIALIZE_SEGMENTS) {
604  m_modelSegments.loadXml (reader);
605  } else {
606  m_successfulRead = false;
607  m_reasonForUnsuccessfulRead = QString ("%1 '%2' %3")
608  .arg (QObject::tr ("Unexpected xml token"))
609  .arg (tag)
610  .arg ("encountered");
611  break;
612  }
613  }
614  }
615 
616  resetSelectedCurveNameIfNecessary ();
617 }
618 
619 void CoordSystem::loadVersions7AndUp (QXmlStreamReader &reader)
620 {
621  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::loadVersions7AndUp";
622 
623  // Import from xml. Loop to end of data or error condition occurs, whichever is first
624  while (!reader.atEnd() &&
625  !reader.hasError()) {
626  QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
627 
628  if ((reader.name() == DOCUMENT_SERIALIZE_COORD_SYSTEM) &&
629  (tokenType == QXmlStreamReader::EndElement)) {
630 
631  // Exit out of loop immediately
632  break;
633  }
634 
635  // Iterate to next StartElement
636  if (tokenType == QXmlStreamReader::StartElement) {
637 
638  // This is a StartElement, so process it
639  QString tag = reader.name().toString();
640  if (tag == DOCUMENT_SERIALIZE_AXES_CHECKER){
641  m_modelAxesChecker.loadXml (reader);
642  } else if (tag == DOCUMENT_SERIALIZE_COORDS) {
643  m_modelCoords.loadXml (reader);
644  } else if (tag == DOCUMENT_SERIALIZE_CURVE) {
645  m_curveAxes = new Curve (reader);
646  } else if (tag == DOCUMENT_SERIALIZE_CURVES_GRAPHS) {
647  m_curvesGraphs.loadXml (reader);
648  } else if (tag == DOCUMENT_SERIALIZE_DIGITIZE_CURVE) {
649  m_modelDigitizeCurve.loadXml (reader);
650  } else if (tag == DOCUMENT_SERIALIZE_EXPORT) {
651  m_modelExport.loadXml (reader);
652  } else if (tag == DOCUMENT_SERIALIZE_GENERAL || tag == DOCUMENT_SERIALIZE_COMMON) {
653  m_modelGeneral.loadXml (reader);
654  } else if (tag == DOCUMENT_SERIALIZE_GRID_DISPLAY) {
655  m_modelGridDisplay.loadXml (reader);
656  } else if (tag == DOCUMENT_SERIALIZE_GRID_REMOVAL) {
657  m_modelGridRemoval.loadXml (reader);
658  } else if (tag == DOCUMENT_SERIALIZE_IMAGE) {
659  ENGAUGE_ASSERT (false); // The image should have been read before this method was called
660  } else if (tag == DOCUMENT_SERIALIZE_POINT_MATCH) {
661  m_modelPointMatch.loadXml (reader);
662  } else if (tag == DOCUMENT_SERIALIZE_SEGMENTS) {
663  m_modelSegments.loadXml (reader);
664  } else {
665  m_successfulRead = false;
666  m_reasonForUnsuccessfulRead = QString ("Unexpected xml token '%1' encountered").arg (tag);
667  break;
668  }
669  }
670  }
671 
672  resetSelectedCurveNameIfNecessary ();
673 }
674 
676 {
677  return m_modelAxesChecker;
678 }
679 
681 {
682  // Construct a curve-specific model
684 
685  return modelColorFilter;
686 }
687 
689 {
690  return m_modelCoords;
691 }
692 
694 {
695  // Construct a curve-specific model
697 
698  return modelCurveStyles;
699 }
700 
702 {
703  return m_modelDigitizeCurve;
704 }
705 
707 {
708  return m_modelExport;
709 }
710 
712 {
713  return m_modelGeneral;
714 }
715 
717 {
718  return m_modelGridDisplay;
719 }
720 
722 {
723  return m_modelGridRemoval;
724 }
725 
727 {
728  return m_modelPointMatch;
729 }
730 
732 {
733  return m_modelSegments;
734 }
735 
736 void CoordSystem::movePoint (const QString &pointIdentifier,
737  const QPointF &deltaScreen)
738 {
739  QString curveName = Point::curveNameFromPointIdentifier (pointIdentifier);
740 
741  Curve *curve = curveForCurveName (curveName);
742  ENGAUGE_CHECK_PTR (curve);
743  curve->movePoint (pointIdentifier,
744  deltaScreen);
745 }
746 
747 int CoordSystem::nextOrdinalForCurve (const QString &curveName) const
748 {
749  CallbackNextOrdinal ftor (curveName);
750 
751  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
753 
754  if (curveName == AXIS_CURVE_NAME) {
755  m_curveAxes->iterateThroughCurvePoints (ftorWithCallback);
756  } else {
757  m_curvesGraphs.iterateThroughCurvesPoints (ftorWithCallback);
758  }
759 
760  return qFloor (ftor.nextOrdinal ());
761 }
762 
763 QPointF CoordSystem::positionGraph (const QString &pointIdentifier) const
764 {
765  QString curveName = Point::curveNameFromPointIdentifier (pointIdentifier);
766 
767  const Curve *curve = curveForCurveName (curveName);
768  return curve->positionGraph (pointIdentifier);
769 }
770 
771 QPointF CoordSystem::positionScreen (const QString &pointIdentifier) const
772 {
773  QString curveName = Point::curveNameFromPointIdentifier (pointIdentifier);
774 
775  const Curve *curve = curveForCurveName (curveName);
776  return curve->positionScreen (pointIdentifier);
777 }
778 
779 void CoordSystem::print () const
780 {
781  QString text;
782  QTextStream str (&text);
783 
784  printStream ("",
785  str);
786  std::cerr << text.toLatin1().data();
787 }
788 
789 void CoordSystem::printStream (QString indentation,
790  QTextStream &str) const
791 {
792  str << indentation << "Graph\n";
793 
794  indentation += INDENTATION_DELTA;
795 
796  // str << indentation << "name=" << m_name << "\n";
797  // str << indentation << "pixmap=" << m_pixmap.width() << "x" << m_pixmap.height() << "\n";
798 
799  m_curveAxes->printStream (indentation,
800  str);
801  m_curvesGraphs.printStream (indentation,
802  str);
803 
804  m_modelAxesChecker.printStream (indentation,
805  str);
806  m_modelCoords.printStream (indentation,
807  str);
808  m_modelDigitizeCurve.printStream (indentation,
809  str);
810  m_modelExport.printStream (indentation,
811  str);
812  m_modelGeneral.printStream (indentation,
813  str);
814  m_modelGridDisplay.printStream (indentation,
815  str);
816  m_modelGridRemoval.printStream (indentation,
817  str);
818  m_modelPointMatch.printStream (indentation,
819  str);
820  m_modelSegments.printStream (indentation,
821  str);
822 }
823 
825 {
826  ENGAUGE_ASSERT (!m_successfulRead);
827 
828  return m_reasonForUnsuccessfulRead;
829 }
830 
831 void CoordSystem::removePointAxis (const QString &identifier)
832 {
833  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::removePointAxis identifier=" << identifier.toLatin1 ().data ();
834 
835  m_curveAxes->removePoint (identifier);
836 }
837 
838 void CoordSystem::removePointGraph (const QString &identifier)
839 {
840  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::removePointGraph identifier=" << identifier.toLatin1 ().data ();
841 
842  m_curvesGraphs.removePoint (identifier);
843 }
844 
846 {
848 
849  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
851 
852  curvesGraphs.iterateThroughCurvesPoints (ftorWithCallback);
853 }
854 
855 void CoordSystem::resetSelectedCurveNameIfNecessary ()
856 {
857  if (m_selectedCurveName.isEmpty () ||
858  curveForCurveName (m_selectedCurveName) == nullptr) {
859 
860  // Selected curve name is empty, or the curve has been removed so we pick another. The first is arbitrarily picked
861  m_selectedCurveName = m_curvesGraphs.curvesGraphsNames().first();
862  }
863 
864 }
865 
866 void CoordSystem::saveXml (QXmlStreamWriter &writer) const
867 {
868  writer.writeStartElement(DOCUMENT_SERIALIZE_COORD_SYSTEM);
869 
870  // Serialize the Document variables
871  m_modelGeneral.saveXml (writer);
872  m_modelCoords.saveXml (writer);
873  m_modelDigitizeCurve.saveXml (writer);
874  m_modelExport.saveXml (writer);
875  m_modelAxesChecker.saveXml (writer);
876  m_modelGridDisplay.saveXml (writer);
877  m_modelGridRemoval.saveXml (writer);
878  m_modelPointMatch.saveXml (writer);
879  m_modelSegments.saveXml (writer);
880  m_curveAxes->saveXml (writer);
881  m_curvesGraphs.saveXml (writer);
882  writer.writeEndElement();
883 }
884 
886 {
887  return m_selectedCurveName;
888 }
889 
890 void CoordSystem::setCurveAxes (const Curve &curveAxes)
891 {
892  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::setCurveAxes";
893 
894  delete m_curveAxes;
895 
896  m_curveAxes = new Curve (curveAxes);
897 }
898 
899 void CoordSystem::setCurvesGraphs (const CurvesGraphs &curvesGraphs)
900 {
901  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::setCurvesGraphs";
902 
903  m_curvesGraphs = curvesGraphs;
904 
905  resetSelectedCurveNameIfNecessary ();
906 }
907 
909 {
910  m_modelAxesChecker = modelAxesChecker;
911 }
912 
914 {
915  // Save the CurveFilter for each Curve
916  ColorFilterSettingsList::const_iterator itr;
917  for (itr = modelColorFilter.colorFilterSettingsList().constBegin ();
918  itr != modelColorFilter.colorFilterSettingsList().constEnd();
919  itr++) {
920 
921  QString curveName = itr.key();
922  const ColorFilterSettings &colorFilterSettings = itr.value();
923 
924  Curve *curve = curveForCurveName (curveName);
925  curve->setColorFilterSettings (colorFilterSettings);
926  }
927 }
928 
930 {
931  m_modelCoords = modelCoords;
932 }
933 
934 void CoordSystem::setModelCurveStyles(const CurveStyles &modelCurveStyles)
935 {
936  // Save the LineStyle and PointStyle for each Curve
937  QStringList curveNames = modelCurveStyles.curveNames();
938  QStringList::iterator itr;
939  for (itr = curveNames.begin(); itr != curveNames.end(); itr++) {
940 
941  QString curveName = *itr;
942  const CurveStyle &curveStyle = modelCurveStyles.curveStyle (curveName);
943 
944  Curve *curve = curveForCurveName (curveName);
945  curve->setCurveStyle (curveStyle);
946  }
947 }
948 
950 {
951  m_modelDigitizeCurve = modelDigitizeCurve;
952 }
953 
955 {
956  m_modelExport = modelExport;
957 }
958 
960 {
961  m_modelGeneral = modelGeneral;
962 }
963 
965 {
966  m_modelGridDisplay = modelGridDisplay;
967 }
968 
970 {
971  m_modelGridRemoval = modelGridRemoval;
972 }
973 
975 {
976  m_modelPointMatch = modelPointMatch;
977 }
978 
980 {
981  m_modelSegments = modelSegments;
982 }
983 
984 void CoordSystem::setSelectedCurveName(const QString &selectedCurveName)
985 {
986  m_selectedCurveName = selectedCurveName;
987 }
988 
990 {
991  return m_successfulRead;
992 }
993 
995 {
996  LOG4CPP_INFO_S ((*mainCat)) << "CoordSystem::updatePointOrdinals";
997 
998  // The graph coordinates of all points in m_curvesGraphs must have already been updated at this point. See applyTransformation
999  m_curvesGraphs.updatePointOrdinals (transformation);
1000 }
virtual DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
void setPointsSelectionFunctions(ExportPointsSelectionFunctions exportPointsSelectionFunctions)
Set method for point selection for functions.
double stopX() const
Get method for x grid line upper bound (inclusive).
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
void removePoint(const QString &identifier)
Perform the opposite of addPointAtEnd.
Definition: Curve.cpp:510
QStringList curveNames() const
List of all curve names.
Definition: CurveStyles.cpp:67
Manage storage and retrieval of the settings for the curves.
QPointF positionScreen(const QString &pointIdentifier) const
Return the position, in screen coordinates, of the specified Point.
Definition: Curve.cpp:473
Model for DlgSettingsGeneral and CmdSettingsGeneral.
static QString curveNameFromPointIdentifier(const QString &pointIdentifier)
Parse the curve name from the specified point identifier. This does the opposite of uniqueIdentifierG...
Definition: Point.cpp:227
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
QString errorMessage() const
Error message that explains the problem indicated by isError.
double stepX() const
Get method for x grid line increment.
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Callback for computing the next ordinal for a new point.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
virtual QString reasonForUnsuccessfulRead() const
Return an informative text message explaining why startup loading failed. Applies if successfulRead r...
static LineStyle defaultGraphCurve(int index)
Initial default for index&#39;th graph curve.
Definition: LineStyle.cpp:84
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
virtual void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Callback that is used when iterating through a read-only CurvesGraphs to remove corresponding points ...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
virtual DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
void setCurveStyle(const CurveStyle &curveStyle)
Set curve style.
Definition: Curve.cpp:563
void setCloseDistance(double closeDistance)
Set method for close distance.
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
void setLineColor(ColorPalette lineColor)
Set method for line color.
void setCountY(unsigned int countY)
Set method for y grid line count.
void setStepX(double stepX)
Set method for x grid line increment.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Definition: CurveStyles.h:22
void setCountX(int countX)
Set method for x count.
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
void setMinLength(double minLength)
Set method for min length.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
void setPointsSelectionRelations(ExportPointsSelectionRelations exportPointsSelectionRelations)
Set method for point selection for relations.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings)
Set color filter.
Definition: Curve.cpp:546
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
void setPaletteColorCandidate(ColorPalette paletteColorCandidate)
Set method for candidate color.
virtual void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
void iterateThroughCurveSegments(const QString &curveNameWanted, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to segments on the specified axis or graph Curve.
void setStopY(double stopY)
Set method for y stop.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
Curve * curveForCurveName(const QString &curveName)
Return the axis or graph curve for 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(...
virtual DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
int numCurves() const
Current number of graphs curves.
QString errorMessage() const
Error message that explains the problem indicated by isError.
void loadVersions7AndUp(QXmlStreamReader &reader)
Load from file in versions 7 and 8 formats. Number of axes points is already defined at Document leve...
int numPoints() const
Number of points.
Definition: Curve.cpp:432
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...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setCoordScaleYRadius(CoordScale coordScale)
Set method for linear/log scale on y/radius.
Callback that is used when iterating through a read-only CurvesGraphs to add corresponding points in ...
virtual bool successfulRead() const
Return true if startup loading succeeded. If the loading failed then reasonForUnsuccessfulRed will ex...
virtual void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
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...
Definition: Curve.cpp:154
virtual void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
bool isError() const
True if an error occurred during iteration.
bool isXOnly(const QString &pointIdentifier) const
Determine if specified point has just x coordinate. Otherwise has just y coordinate, or both x and y coordinates.
Definition: Curve.cpp:285
void iterateThroughCurvesPoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
Apply functor to Points on all of the Curves.
void setStartY(double startY)
Set method for y start.
void setStepY(double stepY)
Set method for y step.
double startX() const
Get method for x grid line lower bound (inclusive).
virtual DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition: Point.h:25
void addGraphCurveAtEnd(const Curve &curve)
Append new graph Curve to end of Curve list.
void setStepY(double yStep)
Set method for y grid line increment.
QPointF positionGraph(const QString &pointIdentifier) const
Return the position, in graph coordinates, of the specified Point.
Definition: Curve.cpp:456
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
virtual DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
bool isError() const
True if an error occurred during iteration.
QString defaultCurveName(int indexOneBased, const QString &defaultName) const
Default graph name for the specified curve index.
Callback for sanity checking the screen and graph coordinates of an axis point that is in the axes cu...
void setDelimiter(ExportDelimiter exportDelimiter)
Set method for delimiter.
void setStartX(double startX)
Set method for x start.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: Curve.cpp:490
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
virtual void setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
virtual void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
void setLineWidth(double lineWidth)
Set method for line width.
void editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Set the x and/or y coordinate values of the specified points.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
QString identifier() const
Unique identifier for a specific Point.
Definition: Point.cpp:268
virtual void saveXml(QXmlStreamWriter &writer) const
Save graph to xml.
double nextOrdinal() const
Computed next ordinal.
void setCountY(int countY)
Set method for y count.
CoordSystem()
Single constructor.
Definition: CoordSystem.cpp:39
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
Translate the position of a point by the specified distance vector.
Definition: Curve.cpp:423
virtual void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
void setLayoutFunctions(ExportLayoutFunctions exportLayoutFunctions)
Set method for functions layout.
int numberOfCurvesForImport() const
Return the number of curve names to be generated. Value is maximum of 1 and the number in the configu...
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
void setStable(bool stable)
Set method for stable flag.
virtual void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
virtual void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs. Applies to current coordinate system.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Affine transformation between screen and graph coordinates, based on digitized axis points...
void loadVersion6(QXmlStreamReader &reader, DocumentAxesPointsRequired &documentAxesPointsRequired)
Load from file in version 6 format. Number of axes points is read in and passed to Document...
virtual DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
Details for a specific Point.
Definition: PointStyle.h:20
void setStepX(double stepX)
Set method for x step.
void setMaxPointSize(double maxPointSize)
Set method for max point size.
void addPoint(const Point &point)
Append new Point to the specified Curve.
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:24
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
virtual void print() const
Debugging method for printing directly from symbolic debugger.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
virtual void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve. Applies to current coordinate system.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
void setPointsIntervalUnitsFunctions(ExportPointsIntervalUnits pointsIntervalUnitsFunctions)
Set method for points interval units for functions.
virtual int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified 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 loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
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 removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
bool isXOnly(const QString &pointIdentifier) const
Return true if y coordinate is undefined, otherwise x coordinae is undefined in DOCUMENT_AXES_POINT_R...
virtual CurveStyles modelCurveStyles() const
Get method for CurveStyles.
virtual const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
virtual void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter)
Set method for DocumentModelColorFilter.
void iterateThroughCurvePoints(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
Apply functor to Points on Curve.
Definition: Curve.cpp:301
void setCoordUnitsTheta(CoordUnitsPolarTheta coordUnits)
Set method for theta units.
void setRemoveDefinedGridLines(bool removeDefinedGridLines)
Set method for removing defined grid lines.
virtual int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
virtual void removePointGraph(const QString &identifier)
Perform the opposite of addPointGraph.
CoordsType coordsType() const
Get method for coordinates type.
void setCurveName(const QString &curveName)
Change the curve name.
Definition: Curve.cpp:551
void setDisableX(GridCoordDisable disableX)
Set method for x grid line disabled variable.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Model for DlgSettingsCoords and CmdSettingsCoords.
virtual QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
int curvesGraphsNumPoints(const QString &curveName) const
Point count.
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:18
void setOriginRadius(double originRadius)
Set method for origin radius in polar mode.
void setGridCoordDisableY(GridCoordDisable gridCoordDisable)
Set method for y coord parameter to disable.
void setDisableY(GridCoordDisable disableY)
Set method for y grid line disabled variable.
virtual const Curve & curveAxes() const
Get method for axis curve.
double stopY() const
Get method for y grid line upper bound (inclusive).
Container for one set of digitized Points.
Definition: Curve.h:33
double startY() const
Get method for y grid line lower bound (inclusive).
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals to be consistent with their CurveStyle and x/theta coordinate.
Details for a specific Line.
Definition: LineStyle.h:19
virtual QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
virtual void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setCoordUnitsRadius(CoordUnitsNonPolarTheta coordUnits)
Set method for radius units.
void setGridCoordDisableX(GridCoordDisable gridCoordDisable)
Set method for x coord parameter to disable.
void loadPreVersion6(QDataStream &str, double version, DocumentAxesPointsRequired &documentAxesPointsRequired)
Load from file in pre-version 6 format. Number of axes points is read in and passed to Document...
void setPaletteColorRejected(ColorPalette paletteColorRejected)
Set method for rejected color.
virtual void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, DocumentAxesPointsRequired documentAxesPointsRequired)
Check before calling editPointAxis.
int countX() const
Get method for x count.
virtual Curve * curveForCurveName(const QString &curveName)
See CurvesGraphs::curveForCurveName, although this also works for AXIS_CURVE_NAME.
void setCountX(unsigned int countX)
Set method for x grid line count.
int countY() const
Get method for y count.
virtual QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow...
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
virtual void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
virtual void addGraphCurveAtEnd(const QString &curveName)
Add new graph curve to the list of existing graph curves.
Definition: CoordSystem.cpp:68
double stepY() const
Get method for y grid line increment.
void setStable()
Set the stable flag to true. This public version has no argument since it cannot be undone...
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
virtual bool loadCurvesFile(const QString &curvesFile)
Load the curve names in the specified Engauge file into the current graph. This is called near the en...
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...
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Definition: CurveStyles.cpp:79
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.
Definition: CoordSystem.cpp:78
void addPoint(const Point &point)
Add Point to this Curve.
Definition: Curve.cpp:134
virtual void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
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.
void setPointsIntervalUnitsRelations(ExportPointsIntervalUnits pointsIntervalUnitsRelations)
Set method for points interval units for relations.
virtual void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
virtual DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
virtual DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
virtual void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
Model for DlgSettingsSegments and CmdSettingsSegments.
void loadPreVersion6(QDataStream &str)
Load from serialized binary pre-version 6 file.
Callback for sanity checking the screen and graph coordinates of an axis point, before it is added to...
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 setHeader(ExportHeader exportHeader)
Set method for header.
virtual QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
QStringList curvesGraphsNames() const
List of graph curve names.
virtual void setModelCurveStyles(const CurveStyles &modelCurveStyles)
Set method for CurveStyles.
virtual void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...
void removePoint(const QString &pointIdentifier)
Remove the Point from its Curve.
const ColorFilterSettingsList & colorFilterSettingsList() const
Get method for copying all color filters in one step.
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 DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
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...
Definition: Curve.cpp:316
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
void saveXml(QXmlStreamWriter &writer) const
Serialize curve.
Definition: Curve.cpp:523
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
static PointStyle defaultGraphCurve(int index)
Initial default for index&#39;th graph curve.
Definition: PointStyle.cpp:83
void setPointSeparation(double pointSeparation)
Set method for point separation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
virtual DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
unsigned int countX() const
Get method for x grid line count.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setPaletteColorAccepted(ColorPalette paletteColorAccepted)
Set method for accepted color.
void setStopX(double stopX)
Set method for x stop.
virtual void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes curve.
unsigned int countY() const
Get method for y grid line count.
void setCoordScaleXTheta(CoordScale coordScale)
Set method for linear/log scale on x/theta.
virtual void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
void setXLabel(const QString &xLabel)
Set method for x label.
virtual void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
void setCoordsType(CoordsType coordsType)
Set method for coordinates type.