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