Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
Document.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 "CallbackBoundingRects.h"
9 #include "CallbackCheckAddPointAxis.h"
10 #include "CallbackCheckEditPointAxis.h"
11 #include "CallbackNextOrdinal.h"
12 #include "CallbackRemovePointsInCurvesGraphs.h"
13 #include "Curve.h"
14 #include "CurvesGraphs.h"
15 #include "CurveStyles.h"
16 #include "Document.h"
17 #include "DocumentSerialize.h"
18 #include "EngaugeAssert.h"
19 #include "EnumsToQt.h"
20 #include "GridInitializer.h"
21 #include <iostream>
22 #include "Logger.h"
23 #include "OrdinalGenerator.h"
24 #include "Point.h"
25 #include <QByteArray>
26 #include <QDataStream>
27 #include <QDebug>
28 #include <QDomDocument>
29 #include <QFile>
30 #include <QImage>
31 #include <qmath.h>
32 #include <QObject>
33 #include <QtToString.h>
34 #include <QXmlStreamReader>
35 #include <QXmlStreamWriter>
36 #include "SettingsForGraph.h"
37 #include "Transformation.h"
38 #include "Version.h"
39 #include "Xml.h"
40 
41 const int FOUR_BYTES = 4;
42 const int NOMINAL_COORD_SYSTEM_COUNT = 1;
43 const int VERSION_6 = 6;
44 const int VERSION_7 = 7;
45 const int VERSION_8 = 8;
46 const int VERSION_9 = 9;
47 
48 Document::Document (const QImage &image) :
49  m_name ("untitled"),
50  m_documentAxesPointsRequired (DOCUMENT_AXES_POINTS_REQUIRED_3)
51 {
52  LOG4CPP_INFO_S ((*mainCat)) << "Document::Document"
53  << " image=" << image.width() << "x" << image.height();
54 
55  m_coordSystemContext.addCoordSystems(m_documentAxesPointsRequired,
56  NOMINAL_COORD_SYSTEM_COUNT);
57 
58  m_successfulRead = true; // Reading from QImage always succeeds, resulting in empty Document
59 
60  m_pixmap.convertFromImage (image);
61 }
62 
63 Document::Document (const QString &fileName) :
64  m_name (fileName),
65  m_documentAxesPointsRequired (DOCUMENT_AXES_POINTS_REQUIRED_3)
66 {
67  LOG4CPP_INFO_S ((*mainCat)) << "Document::Document"
68  << " fileName=" << fileName.toLatin1().data();
69 
70  m_successfulRead = true;
71 
72  // Grab first few bytes to determine the version number
73  QFile *file = new QFile (fileName);
74  if (file->open(QIODevice::ReadOnly)) {
75 
76  QByteArray bytesStart = file->read (FOUR_BYTES);
77  file->close ();
78 
79  if (bytesIndicatePreVersion6 (bytesStart)) {
80 
81  QFile *file = new QFile (fileName);
82  if (file->open (QIODevice::ReadOnly)) {
83  QDataStream str (file);
84 
85  m_coordSystemContext.addCoordSystems(m_documentAxesPointsRequired,
86  NOMINAL_COORD_SYSTEM_COUNT);
87  loadPreVersion6 (str);
88 
89  } else {
90 
91  m_successfulRead = false;
92  m_reasonForUnsuccessfulRead = QObject::tr ("Operating system says file is not readable");
93 
94  }
95  } else {
96 
97  QFile *file = new QFile (fileName);
98  if (file->open (QIODevice::ReadOnly | QIODevice::Text)) {
99 
100  int version = versionFromFile (file);
101  switch (version)
102  {
103  case VERSION_6:
104  loadVersion6 (file);
105  break;
106 
107  case VERSION_7:
108  case VERSION_8:
109  case VERSION_9:
110  loadVersions7AndUp (file);
111  break;
112 
113  default:
114  m_successfulRead = false;
115  m_reasonForUnsuccessfulRead = QString ("Engauge %1 %2 %3 %4 Engauge")
116  .arg (VERSION_NUMBER)
117  .arg (QObject::tr ("cannot read newer files from version"))
118  .arg (version)
119  .arg (QObject::tr ("of"));
120  break;
121  }
122 
123  // Close and deactivate
124  file->close ();
125  delete file;
126  file = 0;
127 
128  } else {
129 
130  m_successfulRead = false;
131  m_reasonForUnsuccessfulRead = QObject::tr ("Operating system says file is not readable");
132  }
133  }
134  } else {
135  file->close ();
136  m_successfulRead = false;
137  m_reasonForUnsuccessfulRead = QString ("%1 '%2' %3")
138  .arg (QObject::tr ("File"))
139  .arg (fileName)
140  .arg (QObject::tr ("was not found"));
141 
142  }
143 }
144 
145 void Document::addCoordSystems(unsigned int numberCoordSystemToAdd)
146 {
147  LOG4CPP_INFO_S ((*mainCat)) << "Document::addCoordSystems"
148  << " toAdd=" << numberCoordSystemToAdd;
149 
150  m_coordSystemContext.addCoordSystems(m_documentAxesPointsRequired,
151  numberCoordSystemToAdd);
152 }
153 
154 void Document::addGraphCurveAtEnd (const QString &curveName)
155 {
156  LOG4CPP_INFO_S ((*mainCat)) << "Document::addGraphCurveAtEnd";
157 
158  m_coordSystemContext.addGraphCurveAtEnd (curveName);
159 }
160 
161 void Document::addPointAxisWithGeneratedIdentifier (const QPointF &posScreen,
162  const QPointF &posGraph,
163  QString &identifier,
164  double ordinal,
165  bool isXOnly)
166 {
167  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointAxisWithGeneratedIdentifier";
168 
169  m_coordSystemContext.addPointAxisWithGeneratedIdentifier(posScreen,
170  posGraph,
171  identifier,
172  ordinal,
173  isXOnly);
174 }
175 
176 void Document::addPointAxisWithSpecifiedIdentifier (const QPointF &posScreen,
177  const QPointF &posGraph,
178  const QString &identifier,
179  double ordinal,
180  bool isXOnly)
181 {
182  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointAxisWithSpecifiedIdentifier";
183 
184  m_coordSystemContext.addPointAxisWithSpecifiedIdentifier(posScreen,
185  posGraph,
186  identifier,
187  ordinal,
188  isXOnly);
189 }
190 
191 void Document::addPointGraphWithGeneratedIdentifier (const QString &curveName,
192  const QPointF &posScreen,
193  QString &identifier,
194  double ordinal)
195 {
196  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointGraphWithGeneratedIdentifier";
197 
198  m_coordSystemContext.addPointGraphWithGeneratedIdentifier(curveName,
199  posScreen,
200  identifier,
201  ordinal);
202 }
203 
204 void Document::addPointGraphWithSpecifiedIdentifier (const QString &curveName,
205  const QPointF &posScreen,
206  const QString &identifier,
207  double ordinal)
208 {
209  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointGraphWithSpecifiedIdentifier";
210 
211  m_coordSystemContext.addPointGraphWithSpecifiedIdentifier(curveName,
212  posScreen,
213  identifier,
214  ordinal);
215 }
216 
218 {
219  LOG4CPP_INFO_S ((*mainCat)) << "Document::addPointsInCurvesGraphs";
220 
221  m_coordSystemContext.addPointsInCurvesGraphs(curvesGraphs);
222 }
223 
224 bool Document::bytesIndicatePreVersion6 (const QByteArray &bytes) const
225 {
226  LOG4CPP_INFO_S ((*mainCat)) << "Document::bytesIndicatePreVersion6";
227 
228  QByteArray preVersion6MagicNumber;
229  preVersion6MagicNumber.resize (FOUR_BYTES);
230 
231  // Windows compiler gives warning if 0x## is used instead of '\x##' below
232  preVersion6MagicNumber[0] = '\x00';
233  preVersion6MagicNumber[1] = '\x00';
234  preVersion6MagicNumber[2] = '\xCA';
235  preVersion6MagicNumber[3] = '\xFE';
236 
237  return (bytes == preVersion6MagicNumber);
238 }
239 
240 void Document::checkAddPointAxis (const QPointF &posScreen,
241  const QPointF &posGraph,
242  bool &isError,
243  QString &errorMessage,
244  bool isXOnly)
245 {
246  LOG4CPP_INFO_S ((*mainCat)) << "Document::checkAddPointAxis";
247 
248  m_coordSystemContext.checkAddPointAxis(posScreen,
249  posGraph,
250  isError,
251  errorMessage,
252  isXOnly);
253 }
254 
255 void Document::checkEditPointAxis (const QString &pointIdentifier,
256  const QPointF &posScreen,
257  const QPointF &posGraph,
258  bool &isError,
259  QString &errorMessage)
260 {
261  LOG4CPP_INFO_S ((*mainCat)) << "Document::checkEditPointAxis";
262 
263  m_coordSystemContext.checkEditPointAxis(pointIdentifier,
264  posScreen,
265  posGraph,
266  isError,
267  errorMessage);
268 }
269 
271 {
272  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystem";
273 
274  return m_coordSystemContext.coordSystem();
275 }
276 
277 unsigned int Document::coordSystemCount () const
278 {
279  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystemCount";
280 
281  return m_coordSystemContext.coordSystemCount();
282 }
283 
284 CoordSystemIndex Document::coordSystemIndex() const
285 {
286  LOG4CPP_INFO_S ((*mainCat)) << "Document::coordSystemIndex";
287 
288  return m_coordSystemContext.coordSystemIndex();
289 }
290 
291 const Curve &Document::curveAxes () const
292 {
293  LOG4CPP_INFO_S ((*mainCat)) << "Document::curveAxes";
294 
295  return m_coordSystemContext.curveAxes();
296 }
297 
298 Curve *Document::curveForCurveName (const QString &curveName)
299 {
300  LOG4CPP_INFO_S ((*mainCat)) << "Document::curveForCurveName";
301 
302  return m_coordSystemContext.curveForCurveName(curveName);
303 }
304 
305 const Curve *Document::curveForCurveName (const QString &curveName) const
306 {
307  LOG4CPP_INFO_S ((*mainCat)) << "Document::curveForCurveName";
308 
309  return m_coordSystemContext.curveForCurveName (curveName);
310 }
311 
313 {
314  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphs";
315 
316  return m_coordSystemContext.curvesGraphs();
317 }
318 
319 QStringList Document::curvesGraphsNames() const
320 {
321  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphsNames";
322 
323  return m_coordSystemContext.curvesGraphsNames();
324 }
325 
326 int Document::curvesGraphsNumPoints(const QString &curveName) const
327 {
328  LOG4CPP_INFO_S ((*mainCat)) << "Document::curvesGraphsNumPoints";
329 
330  return m_coordSystemContext.curvesGraphsNumPoints(curveName);
331 }
332 
333 DocumentAxesPointsRequired Document::documentAxesPointsRequired () const
334 {
335  return m_documentAxesPointsRequired;
336 }
337 
338 void Document::editPointAxis (const QPointF &posGraph,
339  const QString &identifier)
340 {
341  LOG4CPP_INFO_S ((*mainCat)) << "Document::editPointAxis";
342 
343  m_coordSystemContext.editPointAxis(posGraph,
344  identifier);
345 }
346 
348  bool isY,
349  double x,
350  double y,
351  const QStringList &identifiers,
352  const Transformation &transformation)
353 {
354  LOG4CPP_INFO_S ((*mainCat)) << "Document::editPointCurve";
355 
356  m_coordSystemContext.editPointGraph (isX,
357  isY,
358  x,
359  y,
360  identifiers,
361  transformation);
362 }
363 
364 void Document::generateEmptyPixmap(const QXmlStreamAttributes &attributes)
365 {
366  LOG4CPP_INFO_S ((*mainCat)) << "Document::generateEmptyPixmap";
367 
368  int width = 800, height = 500; // Defaults
369 
370  if (attributes.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH) &&
371  attributes.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT)) {
372 
373  width = attributes.value (DOCUMENT_SERIALIZE_IMAGE_WIDTH).toInt();
374  height = attributes.value (DOCUMENT_SERIALIZE_IMAGE_HEIGHT).toInt();
375 
376  }
377 
378  m_pixmap = QPixmap (width, height);
379 }
380 
382 {
383  LOG4CPP_INFO_S ((*mainCat)) << "Document::initializeGridDisplay";
384 
385  ENGAUGE_ASSERT (!m_coordSystemContext.modelGridDisplay().stable());
386 
387  // Get graph coordinate bounds
388  CallbackBoundingRects ftor (transformation);
389 
390  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
392 
393  iterateThroughCurvePointsAxes (ftorWithCallback);
394 
395  // Initialize. Note that if there are no graph points then these next steps have no effect
396  bool isEmpty;
397  QRectF boundingRectGraph = ftor.boundingRectGraph(isEmpty);
398  if (!isEmpty) {
399 
400  GridInitializer gridInitializer;
401 
403  modelCoords(),
404  transformation,
405  m_pixmap.size ());
406 
407  m_coordSystemContext.setModelGridDisplay (modelGridDisplay);
408  }
409 }
410 
411 bool Document::isXOnly (const QString &pointIdentifier) const
412 {
413  return m_coordSystemContext.isXOnly (pointIdentifier);
414 }
415 
416 void Document::iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
417 {
418  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurvePointsAxes";
419 
420  m_coordSystemContext.iterateThroughCurvePointsAxes(ftorWithCallback);
421 }
422 
423 void Document::iterateThroughCurvePointsAxes (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
424 {
425  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurvePointsAxes";
426 
427  m_coordSystemContext.iterateThroughCurvePointsAxes(ftorWithCallback);
428 }
429 
430 void Document::iterateThroughCurveSegments (const QString &curveName,
431  const Functor2wRet<const Point &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
432 {
433  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurveSegments";
434 
435  m_coordSystemContext.iterateThroughCurveSegments(curveName,
436  ftorWithCallback);
437 }
438 
439 void Document::iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback)
440 {
441  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurvesPointsGraphs";
442 
443  m_coordSystemContext.iterateThroughCurvesPointsGraphs(ftorWithCallback);
444 }
445 
446 void Document::iterateThroughCurvesPointsGraphs (const Functor2wRet<const QString &, const Point &, CallbackSearchReturn> &ftorWithCallback) const
447 {
448  LOG4CPP_INFO_S ((*mainCat)) << "Document::iterateThroughCurvesPointsGraphs";
449 
450  m_coordSystemContext.iterateThroughCurvesPointsGraphs(ftorWithCallback);
451 }
452 
453 void Document::loadImage(QXmlStreamReader &reader)
454 {
455  LOG4CPP_INFO_S ((*mainCat)) << "Document::loadImage";
456 
457  loadNextFromReader(reader); // Read to CDATA
458  if (reader.isCDATA ()) {
459 
460  // Get base64 array
461  QByteArray array64 = reader.text().toString().toUtf8();
462 
463  // Decoded array
464  QByteArray array;
465  array = QByteArray::fromBase64(array64);
466 
467  // Read decoded array into image
468  QDataStream str (&array, QIODevice::ReadOnly);
469  QImage img = m_pixmap.toImage ();
470  str >> img;
471  m_pixmap = QPixmap::fromImage (img);
472 
473  // Read until end of this subtree
474  while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
475  (reader.name() != DOCUMENT_SERIALIZE_IMAGE)){
476  loadNextFromReader(reader);
477  }
478 
479  } else {
480 
481  // This point can be reached if:
482  // 1) File is broken
483  // 2) Bad character is in text, and NetworkClient::cleanXml did not do its job
484  reader.raiseError (QObject::tr ("Cannot read image data"));
485  }
486 }
487 
488 void Document::loadPreVersion6 (QDataStream &str)
489 {
490  LOG4CPP_INFO_S ((*mainCat)) << "Document::loadPreVersion6";
491 
492  qint32 int32;
493  double version;
494  QString st;
495 
496  m_documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_3;
497 
498  str >> int32; // Magic number
499  str >> version;
500  str >> st; // Version string
501  str >> int32; // Background
502  str >> m_pixmap;
503  str >> m_name;
504 
505  m_coordSystemContext.loadPreVersion6 (str,
506  version);
507 }
508 
509 void Document::loadVersion6 (QFile *file)
510 {
511  LOG4CPP_INFO_S ((*mainCat)) << "Document::loadVersion6";
512 
513  QXmlStreamReader reader (file);
514 
515  m_documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_3;
516 
517  // Create the single CoordSystem used in versions before version 7
518  m_coordSystemContext.addCoordSystems(m_documentAxesPointsRequired,
519  NOMINAL_COORD_SYSTEM_COUNT);
520 
521  // If this is purely a serialized Document then we process every node under the root. However, if this is an error report file
522  // then we need to skip the non-Document stuff. The common solution is to skip nodes outside the Document subtree using this flag
523  bool inDocumentSubtree = false;
524 
525  // Import from xml. Loop to end of data or error condition occurs, whichever is first
526  while (!reader.atEnd() &&
527  !reader.hasError()) {
528  QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
529 
530  // Special processing of DOCUMENT_SERIALIZE_IMAGE outside DOCUMENT_SERIALIZE_DOCUMENT, for an error report file
531  if ((reader.name() == DOCUMENT_SERIALIZE_IMAGE) &&
532  (tokenType == QXmlStreamReader::StartElement)) {
533 
534  generateEmptyPixmap (reader.attributes());
535  }
536 
537  // Branching to skip non-Document nodes, with the exception of any DOCUMENT_SERIALIZE_IMAGE outside DOCUMENT_SERIALIZE_DOCUMENT
538  if ((reader.name() == DOCUMENT_SERIALIZE_DOCUMENT) &&
539  (tokenType == QXmlStreamReader::StartElement)) {
540 
541  inDocumentSubtree = true;
542 
543  } else if ((reader.name() == DOCUMENT_SERIALIZE_DOCUMENT) &&
544  (tokenType == QXmlStreamReader::EndElement)) {
545 
546  // Exit out of loop immediately
547  break;
548  }
549 
550  if (inDocumentSubtree) {
551 
552  // Iterate to next StartElement
553  if (tokenType == QXmlStreamReader::StartElement) {
554 
555  // This is a StartElement, so process it
556  QString tag = reader.name().toString();
557  if (tag == DOCUMENT_SERIALIZE_IMAGE) {
558  // A standard Document file has DOCUMENT_SERIALIZE_IMAGE inside DOCUMENT_SERIALIZE_DOCUMENT, versus an error report file
559  loadImage(reader);
560 
561  // Now that we have the image at the DOCUMENT_SERIALIZE_DOCUMENT level, we read the rest at this level into CoordSystem
562  m_coordSystemContext.loadVersion6 (reader);
563 
564  // Reading of DOCUMENT_SERIALIZE_DOCUMENT has just finished, so the reading has finished
565  break;
566  }
567  }
568  }
569  }
570  if (reader.hasError ()) {
571 
572  m_successfulRead = false;
573  m_reasonForUnsuccessfulRead = reader.errorString();
574  }
575 
576  // There are already one axes curve and at least one graph curve so we do not need to add any more graph curves
577 }
578 
579 void Document::loadVersions7AndUp (QFile *file)
580 {
581  LOG4CPP_INFO_S ((*mainCat)) << "Document::loadVersions7AndUp";
582 
583  const int ONE_COORDINATE_SYSTEM = 1;
584 
585  QXmlStreamReader reader (file);
586 
587  // If this is purely a serialized Document then we process every node under the root. However, if this is an error report file
588  // then we need to skip the non-Document stuff. The common solution is to skip nodes outside the Document subtree using this flag
589  bool inDocumentSubtree = false;
590 
591  // Import from xml. Loop to end of data or error condition occurs, whichever is first
592  while (!reader.atEnd() &&
593  !reader.hasError()) {
594  QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
595 
596  // Special processing of DOCUMENT_SERIALIZE_IMAGE outside DOCUMENT_SERIALIZE_DOCUMENT, for an error report file
597  if ((reader.name() == DOCUMENT_SERIALIZE_IMAGE) &&
598  (tokenType == QXmlStreamReader::StartElement)) {
599 
600  generateEmptyPixmap (reader.attributes());
601  }
602 
603  // Branching to skip non-Document nodes, with the exception of any DOCUMENT_SERIALIZE_IMAGE outside DOCUMENT_SERIALIZE_DOCUMENT
604  if ((reader.name() == DOCUMENT_SERIALIZE_DOCUMENT) &&
605  (tokenType == QXmlStreamReader::StartElement)) {
606 
607  inDocumentSubtree = true;
608 
609  QXmlStreamAttributes attributes = reader.attributes();
610  if (attributes.hasAttribute (DOCUMENT_SERIALIZE_AXES_POINTS_REQUIRED)) {
611  m_documentAxesPointsRequired = (DocumentAxesPointsRequired) attributes.value (DOCUMENT_SERIALIZE_AXES_POINTS_REQUIRED).toInt();
612  } else {
613  m_documentAxesPointsRequired = DOCUMENT_AXES_POINTS_REQUIRED_3;
614  }
615 
616  } else if ((reader.name() == DOCUMENT_SERIALIZE_DOCUMENT) &&
617  (tokenType == QXmlStreamReader::EndElement)) {
618 
619  // Exit out of loop immediately
620  break;
621  }
622 
623  if (inDocumentSubtree) {
624 
625  // Iterate to next StartElement
626  if (tokenType == QXmlStreamReader::StartElement) {
627 
628  // This is a StartElement, so process it
629  QString tag = reader.name().toString();
630  if (tag == DOCUMENT_SERIALIZE_COORD_SYSTEM) {
631  m_coordSystemContext.addCoordSystems (m_documentAxesPointsRequired,
632  ONE_COORDINATE_SYSTEM);
633  m_coordSystemContext.loadVersions7AndUp (reader,
634  m_documentAxesPointsRequired);
635  } else if (tag == DOCUMENT_SERIALIZE_IMAGE) {
636  // A standard Document file has DOCUMENT_SERIALIZE_IMAGE inside DOCUMENT_SERIALIZE_DOCUMENT, versus an error report file
637  loadImage(reader);
638  }
639  }
640  }
641  }
642  if (reader.hasError ()) {
643 
644  m_successfulRead = false;
645  m_reasonForUnsuccessfulRead = reader.errorString();
646  }
647 
648  // There are already one axes curve and at least one graph curve so we do not need to add any more graph curves
649 }
650 
652 {
653  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelAxesChecker";
654 
655  return m_coordSystemContext.modelAxesChecker();
656 }
657 
659 {
660  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelColorFilter";
661 
662  return m_coordSystemContext.modelColorFilter();
663 }
664 
666 {
667  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelCoords";
668 
669  return m_coordSystemContext.modelCoords();
670 }
671 
673 {
674  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelCurveStyles";
675 
676  return m_coordSystemContext.modelCurveStyles();
677 }
678 
680 {
681  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelDigitizeCurve";
682 
683  return m_coordSystemContext.modelDigitizeCurve();
684 }
685 
687 {
688  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelExport";
689 
690  return m_coordSystemContext.modelExport();
691 }
692 
694 {
695  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelGeneral";
696 
697  return m_coordSystemContext.modelGeneral();
698 }
699 
701 {
702  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelGridDisplay";
703 
704  return m_coordSystemContext.modelGridDisplay();
705 }
706 
708 {
709  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelGridRemoval";
710 
711  return m_coordSystemContext.modelGridRemoval();
712 }
713 
715 {
716  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelPointMatch";
717 
718  return m_coordSystemContext.modelPointMatch();
719 }
720 
722 {
723  LOG4CPP_DEBUG_S ((*mainCat)) << "Document::modelSegments";
724 
725  return m_coordSystemContext.modelSegments();
726 }
727 
728 void Document::movePoint (const QString &pointIdentifier,
729  const QPointF &deltaScreen)
730 {
731  m_coordSystemContext.movePoint (pointIdentifier,
732  deltaScreen);
733 }
734 
735 int Document::nextOrdinalForCurve (const QString &curveName) const
736 {
737  LOG4CPP_INFO_S ((*mainCat)) << "Document::nextOrdinalForCurve";
738 
739  return m_coordSystemContext.nextOrdinalForCurve(curveName);
740 }
741 
742 QPixmap Document::pixmap () const
743 {
744  return m_pixmap;
745 }
746 
747 QPointF Document::positionGraph (const QString &pointIdentifier) const
748 {
749  return m_coordSystemContext.positionGraph(pointIdentifier);
750 }
751 
752 QPointF Document::positionScreen (const QString &pointIdentifier) const
753 {
754  return m_coordSystemContext.positionScreen(pointIdentifier);
755 }
756 
757 void Document::print () const
758 {
759  QString text;
760  QTextStream str (&text);
761 
762  printStream ("",
763  str);
764  std::cerr << text.toLatin1().data();
765 }
766 
767 void Document::printStream (QString indentation,
768  QTextStream &str) const
769 {
770  str << indentation << "Document\n";
771 
772  indentation += INDENTATION_DELTA;
773 
774  str << indentation << "name=" << m_name << "\n";
775  str << indentation << "pixmap=" << m_pixmap.width() << "x" << m_pixmap.height() << "\n";
776 
777  m_coordSystemContext.printStream(indentation,
778  str);
779 }
780 
782 {
783  ENGAUGE_ASSERT (!m_successfulRead);
784 
785  return m_reasonForUnsuccessfulRead;
786 }
787 
788 void Document::removePointAxis (const QString &identifier)
789 {
790  LOG4CPP_INFO_S ((*mainCat)) << "Document::removePointAxis";
791 
792  m_coordSystemContext.removePointAxis(identifier);
793 }
794 
795 void Document::removePointGraph (const QString &identifier)
796 {
797  LOG4CPP_INFO_S ((*mainCat)) << "Document::removePointGraph";
798 
799  m_coordSystemContext.removePointGraph(identifier);
800 }
801 
803 {
804  LOG4CPP_INFO_S ((*mainCat)) << "Document::removePointsInCurvesGraphs";
805 
806  m_coordSystemContext.removePointsInCurvesGraphs(curvesGraphs);
807 }
808 
809 void Document::saveXml (QXmlStreamWriter &writer) const
810 {
811  writer.writeStartElement(DOCUMENT_SERIALIZE_DOCUMENT);
812 
813  // Version number is tacked onto DOCUMENT_SERIALIZE_DOCUMENT since the alternative (creating a new start element)
814  // causes the code to complain during loading
815  writer.writeAttribute(DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER, VERSION_NUMBER);
816 
817  // Number of axes points required
818  writer.writeAttribute(DOCUMENT_SERIALIZE_AXES_POINTS_REQUIRED, QString::number (m_documentAxesPointsRequired));
819 
820  // Serialize the Document image. That binary data is encoded as base64
821  QByteArray array;
822  QDataStream str (&array, QIODevice::WriteOnly);
823  QImage img = m_pixmap.toImage ();
824  str << img;
825  writer.writeStartElement(DOCUMENT_SERIALIZE_IMAGE);
826 
827  // Image width and height are explicitly inserted for error reports, since the CDATA is removed
828  // but we still want the image size for reconstructing the error(s)
829  writer.writeAttribute(DOCUMENT_SERIALIZE_IMAGE_WIDTH, QString::number (img.width()));
830  writer.writeAttribute(DOCUMENT_SERIALIZE_IMAGE_HEIGHT, QString::number (img.height()));
831 
832  writer.writeCDATA (array.toBase64 ());
833  writer.writeEndElement();
834 
835  m_coordSystemContext.saveXml (writer);
836 }
837 
839 {
840  return m_coordSystemContext.selectedCurveName();
841 }
842 
843 void Document::setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
844 {
845  LOG4CPP_INFO_S ((*mainCat)) << "Document::setCoordSystemIndex";
846 
847  m_coordSystemContext.setCoordSystemIndex (coordSystemIndex);
848 }
849 
850 void Document::setCurveAxes (const Curve &curveAxes)
851 {
852  LOG4CPP_INFO_S ((*mainCat)) << "Document::setCurveAxes";
853 
854  m_coordSystemContext.setCurveAxes (curveAxes);
855 }
856 
857 void Document::setCurvesGraphs (const CurvesGraphs &curvesGraphs)
858 {
859  LOG4CPP_INFO_S ((*mainCat)) << "Document::setCurvesGraphs";
860 
861  m_coordSystemContext.setCurvesGraphs(curvesGraphs);
862 }
863 
864 void Document::setDocumentAxesPointsRequired(DocumentAxesPointsRequired documentAxesPointsRequired)
865 {
866  LOG4CPP_INFO_S ((*mainCat)) << "Document::setDocumentAxesPointsRequired";
867 
868  m_documentAxesPointsRequired = documentAxesPointsRequired;
869 }
870 
872 {
873  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelAxesChecker";
874 
875  m_coordSystemContext.setModelAxesChecker(modelAxesChecker);
876 }
877 
879 {
880  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelColorFilter";
881 
882  // Save the CurveFilter for each Curve
883  ColorFilterSettingsList::const_iterator itr;
884  for (itr = modelColorFilter.colorFilterSettingsList().constBegin ();
885  itr != modelColorFilter.colorFilterSettingsList().constEnd();
886  itr++) {
887 
888  QString curveName = itr.key();
889  const ColorFilterSettings &colorFilterSettings = itr.value();
890 
891  Curve *curve = curveForCurveName (curveName);
892  curve->setColorFilterSettings (colorFilterSettings);
893  }
894 }
895 
897 {
898  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelCoords";
899 
900  m_coordSystemContext.setModelCoords(modelCoords);
901 }
902 
903 void Document::setModelCurveStyles(const CurveStyles &modelCurveStyles)
904 {
905  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelCurveStyles";
906 
907  // Save the LineStyle and PointStyle for each Curve
908  QStringList curveNames = modelCurveStyles.curveNames();
909  QStringList::iterator itr;
910  for (itr = curveNames.begin(); itr != curveNames.end(); itr++) {
911 
912  QString curveName = *itr;
913  const CurveStyle &curveStyle = modelCurveStyles.curveStyle (curveName);
914 
915  Curve *curve = curveForCurveName (curveName);
916  curve->setCurveStyle (curveStyle);
917  }
918 }
919 
921 {
922  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelDigitizeCurve";
923 
924  m_coordSystemContext.setModelDigitizeCurve(modelDigitizeCurve);
925 }
926 
928 {
929  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelExport";
930 
931  m_coordSystemContext.setModelExport (modelExport);
932 }
933 
935 {
936  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelGeneral";
937 
938  m_coordSystemContext.setModelGeneral(modelGeneral);
939 }
940 
942 {
943  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelGridDisplay";
944 
945  m_coordSystemContext.setModelGridDisplay(modelGridDisplay);
946 }
947 
949 {
950  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelGridRemoval";
951 
952  m_coordSystemContext.setModelGridRemoval(modelGridRemoval);
953 }
954 
956 {
957  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelPointMatch";
958 
959  m_coordSystemContext.setModelPointMatch(modelPointMatch);
960 }
961 
963 {
964  LOG4CPP_INFO_S ((*mainCat)) << "Document::setModelSegments";
965 
966  m_coordSystemContext.setModelSegments (modelSegments);
967 }
968 
969 void Document::setPixmap(const QImage &image)
970 {
971  LOG4CPP_INFO_S ((*mainCat)) << "Document::setPixmap";
972 
973  m_pixmap = QPixmap::fromImage (image);
974 }
975 
976 void Document::setSelectedCurveName(const QString &selectedCurveName)
977 {
978  m_coordSystemContext.setSelectedCurveName (selectedCurveName);
979 }
980 
982 {
983  return m_successfulRead;
984 }
985 
986 void Document::updatePointOrdinals (const Transformation &transformation)
987 {
988  LOG4CPP_INFO_S ((*mainCat)) << "Document::updatePointOrdinals";
989 
990  m_coordSystemContext.updatePointOrdinals(transformation);
991 }
992 
993 int Document::versionFromFile (QFile *file) const
994 {
995  LOG4CPP_INFO_S ((*mainCat)) << "Document::versionFromFile";
996 
997  int version = VERSION_6; // Use default if tag is missing
998 
999  QDomDocument doc;
1000  if (doc.setContent (file)) {
1001 
1002  QDomNodeList nodes = doc.elementsByTagName (DOCUMENT_SERIALIZE_DOCUMENT);
1003  if (nodes.count() > 0) {
1004  QDomNode node = nodes.at (0);
1005 
1006  QDomNamedNodeMap attributes = node.attributes();
1007 
1008  if (attributes.contains (DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER)) {
1009 
1010  QDomElement elem = node.toElement();
1011  version = (int) elem.attribute (DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER).toDouble();
1012  }
1013  }
1014  }
1015 
1016  file->seek (0); // Go back to beginning
1017 
1018  return version;
1019 }
void addCoordSystems(unsigned int numberCoordSystemToAdd)
Add some number (0 or more) of additional coordinate systems.
Definition: Document.cpp:145
virtual QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow...
void addCoordSystems(DocumentAxesPointsRequired documentAxesPointsRequired, unsigned int numberCoordSystemToAdd)
Add specified number of coordinate systems to the original one created by the constructor.
void addGraphCurveAtEnd(const QString &curveName)
Add new graph curve to the list of existing graph curves.
Definition: Document.cpp:154
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
Definition: Document.cpp:752
QStringList curveNames() const
List of all curve names.
Definition: CurveStyles.cpp:67
virtual DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition: Document.cpp:333
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
virtual void saveXml(QXmlStreamWriter &writer) const
Save graph to xml.
void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
Definition: Document.cpp:728
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
Definition: Document.cpp:767
unsigned int coordSystemCount() const
Number of CoordSystem.
Definition: Document.cpp:277
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
bool isXOnly(const QString &pointIdentifier) const
See Curve::isXOnly.
Definition: Document.cpp:411
DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
Definition: Document.cpp:658
void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
Definition: Document.cpp:871
void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
Definition: Document.cpp:948
virtual void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
Definition: Document.cpp:191
DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
Definition: Document.cpp:714
void setCurveStyle(const CurveStyle &curveStyle)
Set curve style.
Definition: Curve.cpp:554
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
Definition: Document.cpp:955
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
Definition: Document.cpp:788
void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
Definition: Document.cpp:934
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Definition: CurveStyles.h:22
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 setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
Definition: Document.cpp:962
const CoordSystem & coordSystem() const
Currently active CoordSystem.
Definition: Document.cpp:270
virtual DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings)
Set color filter.
Definition: Curve.cpp:537
virtual void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage)
Check before calling editPointAxis.
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...
Storage of data belonging to one coordinate system.
Definition: CoordSystem.h:42
const CoordSystem & coordSystem() const
Current CoordSystem.
void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
Definition: Document.cpp:941
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...
Definition: Document.cpp:204
virtual DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes curve.
Definition: Document.cpp:416
const Curve & curveAxes() const
Get method for axis curve.
Definition: Document.cpp:291
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:665
virtual Curve * curveForCurveName(const QString &curveName)
See CurvesGraphs::curveForCurveName, although this also works for AXIS_CURVE_NAME.
void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
Definition: Document.cpp:920
int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
Definition: Document.cpp:326
QPixmap pixmap() const
Return the image that is being digitized.
Definition: Document.cpp:742
unsigned int coordSystemCount() const
Number of CoordSystem.
virtual void checkAddPointAxis(const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, bool isXOnly)
Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes...
bool successfulRead() const
Return true if startup loading succeeded. If the loading failed then reasonForUnsuccessfulRed will ex...
Definition: Document.cpp:981
CoordSystemIndex coordSystemIndex() const
Index of current CoordSystem.
virtual void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
Definition: Document.cpp:896
virtual void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
void checkAddPointAxis(const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, bool isXOnly)
Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes...
Definition: Document.cpp:240
virtual const Curve & curveAxes() const
Get method for axis curve.
void setPixmap(const QImage &image)
Set method for the background pixmap.
Definition: Document.cpp:969
void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage)
Check before calling editPointAxis.
Definition: Document.cpp:255
virtual void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...
virtual void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
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.
void setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
Set the index of current active CoordSystem.
Definition: Document.cpp:843
void removePointGraph(const QString &identifier)
Perform the opposite of addPointGraph.
Definition: Document.cpp:795
virtual void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs. Applies to current coordinate system.
virtual CurveStyles modelCurveStyles() const
Get method for CurveStyles.
void loadVersions7AndUp(QXmlStreamReader &reader, DocumentAxesPointsRequired documentAxesPointsRequired)
Load one CoordSystem from file in version 7 format or newer, into the most recent CoordSystem which w...
void loadVersion6(QXmlStreamReader &reader)
Load from file in version 6 format, into the single CoordSystem.
virtual DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
virtual void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve. Applies to current coordinate system.
virtual void iterateThroughCurveSegments(const QString &curveName, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
See Curve::iterateThroughCurveSegments, for any axes or graph curve.
CoordSystemIndex coordSystemIndex() const
Index of current active CoordSystem.
Definition: Document.cpp:284
virtual void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
Definition: Document.cpp:927
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
Definition: Document.cpp:338
virtual void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
void loadPreVersion6(QDataStream &str, double version)
Load from file in pre-version 6 format.
Affine transformation between screen and graph coordinates, based on digitized axis points...
bool isXOnly(const QString &pointIdentifier) const
True/false if y/x value is empty.
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:24
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
virtual void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
virtual void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
void setModelCurveStyles(const CurveStyles &modelCurveStyles)
Set method for CurveStyles.
Definition: Document.cpp:903
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Definition: Document.cpp:672
virtual QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
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: Document.cpp:176
virtual void addGraphCurveAtEnd(const QString &curveName)
Add new graph curve to the list of existing graph curves.
void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve.
Definition: Document.cpp:850
DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
Definition: Document.cpp:651
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
Definition: Document.cpp:802
This class initializes the count, start, step and stop parameters for one coordinate (either x/theta ...
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Definition: Document.cpp:679
virtual void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
QString selectedCurveName() const
Currently selected curve name. This is used to set the selected curve combobox in MainWindow...
Definition: Document.cpp:838
virtual void removePointGraph(const QString &identifier)
Perform the opposite of addPointGraph.
virtual void setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter)
Set method for DocumentModelColorFilter.
Definition: Document.cpp:878
Model for DlgSettingsCoords and CmdSettingsCoords.
QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
Definition: Document.cpp:747
virtual void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:18
virtual DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
Container for one set of digitized Points.
Definition: Curve.h:32
DocumentModelGridDisplay initializeWithWidePolarCoverage(const QRectF &boundingRectGraph, const DocumentModelCoords &modelCoords, const Transformation &transformation, const QSize &imageSize) const
Initialize given the boundaries of the graph coordinates, and then extra processing for polar coordin...
virtual int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
virtual QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Definition: Document.cpp:319
void print() const
Debugging method for printing directly from symbolic debugger.
Definition: Document.cpp:757
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
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: Document.cpp:161
virtual void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
virtual void addPointAxisWithSpecifiedIdentifier(const QPointF &posScreen, const QPointF &posGraph, const QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with the specified point identifier.
virtual void 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 QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
void setDocumentAxesPointsRequired(DocumentAxesPointsRequired documentAxesPointsRequired)
Set the number of axes points required.
Definition: Document.cpp:864
void iterateThroughCurveSegments(const QString &curveName, const Functor2wRet< const Point &, const Point &, CallbackSearchReturn > &ftorWithCallback) const
See Curve::iterateThroughCurveSegments, for any axes or graph curve.
Definition: Document.cpp:430
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Definition: CurveStyles.cpp:79
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
Definition: Document.cpp:735
virtual void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
bool stable() const
Get method for stable flag.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition: Document.cpp:312
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition: Document.cpp:305
virtual void iterateThroughCurvePointsAxes(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for the axes curve.
virtual int curvesGraphsNumPoints(const QString &curveName) const
See CurvesGraphs::curvesGraphsNumPoints.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition: Document.cpp:721
Model for DlgSettingsSegments and CmdSettingsSegments.
void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
Definition: Document.cpp:439
void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs.
Definition: Document.cpp:857
virtual const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
virtual void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
virtual DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
Definition: Document.cpp:217
Document(const QImage &image)
Constructor for imported images and dragged images. Only one coordinate system is create - others are...
Definition: Document.cpp:48
virtual DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
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.
Definition: Document.cpp:347
void initializeGridDisplay(const Transformation &transformation)
Initialize grid display. This is called immediately after the transformation has been defined for the...
Definition: Document.cpp:381
virtual void movePoint(const QString &pointIdentifier, const QPointF &deltaScreen)
See Curve::movePoint.
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
Definition: Document.cpp:700
void saveXml(QXmlStreamWriter &writer) const
Save document to xml.
Definition: Document.cpp:809
virtual DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
const ColorFilterSettingsList & colorFilterSettingsList() const
Get method for copying all color filters in one step.
virtual DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
QString reasonForUnsuccessfulRead() const
Return an informative text message explaining why startup loading failed. Applies if successfulRead r...
Definition: Document.cpp:781
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
Definition: Document.cpp:707
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
Definition: Document.cpp:986
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
Definition: Document.cpp:686
void setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
Index of current CoordSystem.
void setSelectedCurveName(const QString &selectedCurveName)
Save curve name that is selected for the current coordinate system, for the next time the coordinate ...
Definition: Document.cpp:976
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition: Document.cpp:693
virtual void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
virtual DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.