Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Cmd
CmdGuidelineMoveXT.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 "
CmdGuidelineMoveXT.h
"
8
#include "
Document.h
"
9
#include "
DocumentSerialize.h
"
10
#include "
Logger.h
"
11
#include "
MainWindow.h
"
12
#include "
Xml.h
"
13
14
const
QString
CMD_DESCRIPTION
(
"GuidelineMoveXT"
);
15
16
CmdGuidelineMoveXT::CmdGuidelineMoveXT
(
MainWindow
&
mainWindow
,
17
Document
&
document
,
18
const
QString &identifier,
19
double
valueBefore,
20
double
valueAfter) :
21
CmdAbstract
(
mainWindow
,
22
document
,
23
CMD_DESCRIPTION
),
24
m_identifier (identifier),
25
m_valueBefore (valueBefore),
26
m_valueAfter (valueAfter)
27
{
28
qCInfo(ENGAUGE_LOG) <<
"CmdGuidelineMoveXT::CmdGuidelineMoveXT"
;
29
}
30
31
CmdGuidelineMoveXT::CmdGuidelineMoveXT
(
MainWindow
&
mainWindow
,
32
Document
&
document
,
33
const
QString &cmdDescription,
34
QXmlStreamReader &reader) :
35
CmdAbstract
(
mainWindow
,
36
document
,
37
cmdDescription)
38
{
39
qCInfo(ENGAUGE_LOG) <<
"CmdGuidelineMoveXT::CmdGuidelineMoveXT"
;
40
41
QXmlStreamAttributes attributes = reader.attributes();
42
43
QStringList requiredAttributesLeaf;
44
requiredAttributesLeaf <<
DOCUMENT_SERIALIZE_IDENTIFIER
45
<<
DOCUMENT_SERIALIZE_GRAPH_BEFORE
46
<<
DOCUMENT_SERIALIZE_GRAPH_AFTER
;
47
leafAndBaseAttributes
(attributes,
48
requiredAttributesLeaf,
49
reader);
50
51
m_identifier = attributes.value(
DOCUMENT_SERIALIZE_IDENTIFIER
).toString();
52
m_valueBefore = attributes.value(
DOCUMENT_SERIALIZE_GRAPH_BEFORE
).toDouble();
53
m_valueAfter = attributes.value(
DOCUMENT_SERIALIZE_GRAPH_AFTER
).toDouble();
54
}
55
56
CmdGuidelineMoveXT::~CmdGuidelineMoveXT
()
57
{
58
}
59
60
void
CmdGuidelineMoveXT::cmdRedo
()
61
{
62
qCInfo(ENGAUGE_LOG) <<
"CmdGuidelineMoveXT::cmdRedo"
63
<<
" identifier="
<< m_identifier.toLatin1().data()
64
<<
" value="
<< m_valueAfter;
65
66
restoreState
();
67
mainWindow
().
guidelineMoveXT
(m_identifier,
68
m_valueAfter);
69
}
70
71
void
CmdGuidelineMoveXT::cmdUndo
()
72
{
73
qCInfo(ENGAUGE_LOG) <<
"CmdGuidelineMoveXT::cmdUndo"
74
<<
" identifier="
<< m_identifier.toLatin1().data()
75
<<
" value="
<< m_valueBefore;
76
77
restoreState
();
78
mainWindow
().
guidelineMoveXT
(m_identifier,
79
m_valueBefore);
80
}
81
82
void
CmdGuidelineMoveXT::saveXml
(QXmlStreamWriter &writer)
const
83
{
84
writer.writeStartElement(
DOCUMENT_SERIALIZE_CMD
);
85
writer.writeAttribute(
DOCUMENT_SERIALIZE_CMD_TYPE
,
DOCUMENT_SERIALIZE_CMD_GUIDELINE_MOVE_X_T
);
86
writer.writeAttribute(
DOCUMENT_SERIALIZE_CMD_DESCRIPTION
, QUndoCommand::text ());
87
writer.writeAttribute(
DOCUMENT_SERIALIZE_IDENTIFIER
, m_identifier);
88
writer.writeAttribute(
DOCUMENT_SERIALIZE_GRAPH_BEFORE
, QString::number (m_valueBefore));
89
writer.writeAttribute(
DOCUMENT_SERIALIZE_GRAPH_AFTER
, QString::number (m_valueAfter));
90
baseAttributes
(writer);
91
writer.writeEndElement();
92
}
CMD_DESCRIPTION
const QString CMD_DESCRIPTION("Add axis point")
CmdGuidelineMoveXT.h
DocumentSerialize.h
DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_IDENTIFIER
DOCUMENT_SERIALIZE_GRAPH_AFTER
const QString DOCUMENT_SERIALIZE_GRAPH_AFTER
DOCUMENT_SERIALIZE_GRAPH_BEFORE
const QString DOCUMENT_SERIALIZE_GRAPH_BEFORE
DOCUMENT_SERIALIZE_CMD_GUIDELINE_MOVE_X_T
const QString DOCUMENT_SERIALIZE_CMD_GUIDELINE_MOVE_X_T
DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD
DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_TYPE
DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
Document.h
Logger.h
MainWindow.h
Xml.h
CmdAbstract::document
Document & document()
Return the Document that this command will modify during redo and undo.
Definition
CmdAbstract.cpp:48
CmdAbstract::mainWindow
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition
CmdAbstract.cpp:96
CmdAbstract::restoreState
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
Definition
CmdAbstract.cpp:153
CmdAbstract::leafAndBaseAttributes
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...
Definition
CmdAbstract.cpp:79
CmdAbstract::baseAttributes
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.
Definition
CmdAbstract.cpp:42
CmdAbstract::CmdAbstract
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
Definition
CmdAbstract.cpp:26
CmdGuidelineMoveXT::~CmdGuidelineMoveXT
virtual ~CmdGuidelineMoveXT()
Definition
CmdGuidelineMoveXT.cpp:56
CmdGuidelineMoveXT::CmdGuidelineMoveXT
CmdGuidelineMoveXT(MainWindow &mainWindow, Document &document, const QString &identifier, double valueBefore, double valueAfter)
Constructor for normal creation.
Definition
CmdGuidelineMoveXT.cpp:16
CmdGuidelineMoveXT::cmdRedo
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
Definition
CmdGuidelineMoveXT.cpp:60
CmdGuidelineMoveXT::saveXml
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
Definition
CmdGuidelineMoveXT.cpp:82
CmdGuidelineMoveXT::cmdUndo
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
Definition
CmdGuidelineMoveXT.cpp:71
Document
Storage of one imported image and the data attached to that image.
Definition
Document.h:44
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition
MainWindow.h:95
MainWindow::guidelineMoveXT
void guidelineMoveXT(const QString &identifier, double xTAfter)
Move a X/T Guideline.
Definition
MainWindow.cpp:921
Generated on
for Engauge Digitizer by
1.18.0