Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdGuidelineRemoveYR.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
8#include "Document.h"
9#include "DocumentSerialize.h"
10#include "Logger.h"
11#include "MainWindow.h"
12#include "Xml.h"
13
14const QString CMD_DESCRIPTION ("GuidelineRemoveYR");
15
17 Document &document,
18 const QString &identifier,
19 double valueBefore) :
20 CmdAbstract(mainWindow,
21 document,
23 m_identifier (identifier),
24 m_valueBefore (valueBefore)
25{
26 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineRemoveYR::CmdGuidelineRemoveYR";
27}
28
30 Document &document,
31 const QString &cmdDescription,
32 QXmlStreamReader &reader) :
33 CmdAbstract (mainWindow,
34 document,
35 cmdDescription)
36{
37 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineRemoveYR::CmdGuidelineRemoveYR";
38
39 QXmlStreamAttributes attributes = reader.attributes();
40
41 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER) ||
42 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_BEFORE)) {
43 xmlExitWithError (reader,
44 QString ("%1 %2 %3 %4")
45 .arg (QObject::tr ("Missing attribute(s)"))
47 .arg (QObject::tr ("and/or"))
49 }
50
51 m_identifier = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
52 m_valueBefore = attributes.value(DOCUMENT_SERIALIZE_GRAPH_BEFORE).toDouble();
53}
54
58
60{
61 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineRemoveYR::cmdRedo"
62 << " identifier=" << m_identifier.toLatin1().data();
63
64 mainWindow().guidelineRemove (m_identifier);
65}
66
68{
69 LOG4CPP_INFO_S ((*mainCat)) << "CmdGuidelineRemoveYR::cmdUndo"
70 << " identifier=" << m_identifier.toLatin1().data()
71 << " value=" << m_valueBefore;
72
73 mainWindow().guidelineAddYR (m_identifier,
74 m_valueBefore);
75}
76
77void CmdGuidelineRemoveYR::saveXml (QXmlStreamWriter &writer) const
78{
79 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
81 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
82 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifier);
83 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_BEFORE, QString::number (m_valueBefore));
84 writer.writeEndElement();
85}
const QString CMD_DESCRIPTION("GuidelineRemoveYR")
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_GRAPH_BEFORE
const QString DOCUMENT_SERIALIZE_CMD_GUIDELINE_REMOVE_Y_R
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
log4cpp::Category * mainCat
Definition Logger.cpp:14
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition Xml.cpp:25
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition CmdAbstract.h:20
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
CmdGuidelineRemoveYR(MainWindow &mainWindow, Document &document, const QString &identifier, double oldBefore)
Constructor for normal creation.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
Storage of one imported image and the data attached to that image.
Definition Document.h:44
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:96
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