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