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