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