Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdGuidelineAddYR.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
7#include "CmdGuidelineAddYR.h"
8#include "Document.h"
9#include "DocumentSerialize.h"
11#include "Logger.h"
12#include "MainWindow.h"
13#include "Xml.h"
14
15const QString CMD_DESCRIPTION ("GuidelineAddYR");
16
19 double value) :
23 m_identifier (GuidelineIdentifierGenerator::next ()),
24 m_value (value)
25{
26 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineAddYR::CmdGuidelineAddYR";
27}
28
31 const QString &cmdDescription,
32 QXmlStreamReader &reader) :
35 cmdDescription)
36{
37 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineAddYR::CmdGuidelineAddYR";
38
39 QXmlStreamAttributes attributes = reader.attributes();
40
41 QStringList requiredAttributesLeaf;
42 requiredAttributesLeaf << DOCUMENT_SERIALIZE_IDENTIFIER
44 leafAndBaseAttributes (attributes,
45 requiredAttributesLeaf,
46 reader);
47
48 m_identifier = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
49 m_value = attributes.value(DOCUMENT_SERIALIZE_GRAPH_AFTER).toDouble();
50}
51
55
57{
58 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineAddYR::cmdRedo"
59 << " identifier=" << m_identifier.toLatin1().data()
60 << " value=" << m_value;
61
62 restoreState ();
63 mainWindow().guidelineAddYR (m_identifier,
64 m_value);
65}
66
68{
69 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineAddYR::cmdUndo"
70 << " identifier=" << m_identifier.toLatin1().data();
71
72 restoreState ();
73 mainWindow().guidelineRemove (m_identifier);
74}
75
76void CmdGuidelineAddYR::saveXml (QXmlStreamWriter &writer) const
77{
78 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
80 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
81 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifier);
82 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_AFTER, QString::number (m_value));
83 baseAttributes (writer);
84 writer.writeEndElement();
85}
const QString CMD_DESCRIPTION("Add axis point")
const QString CMD_DESCRIPTION("GuidelineAddYR")
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_GRAPH_AFTER
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_GUIDELINE_ADD_Y_R
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
log4cpp::Category * mainCat
Definition Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
void leafAndBaseAttributes(const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
Before reading leaf class attributes, check all required attributes from leaf and this base class are...
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
CmdGuidelineAddYR(MainWindow &mainWindow, Document &document, double value)
Constructor for normal creation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
Storage of one imported image and the data attached to that image.
Definition Document.h:44
Generate unique Guideline identifiers.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:95
void guidelineRemove(const QString &identifier)
Remove a X/T or Y/R Guideline.
void guidelineAddYR(const QString &identifier, double yR)
Add a Y/R Guideline.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18