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