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