1 #include "CmdAddPointAxis.h"
3 #include "DocumentSerialize.h"
4 #include "EngaugeAssert.h"
6 #include "MainWindow.h"
7 #include "QtToString.h"
8 #include <QXmlStreamReader>
10 const QString CMD_DESCRIPTION (
"Add axis point");
14 const QPointF &posScreen,
15 const QPointF &posGraph,
20 m_posScreen (posScreen),
21 m_posGraph (posGraph),
24 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAddPointAxis::CmdAddPointAxis"
25 <<
" posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
26 <<
" posGraph=" << QPointFToString (posGraph).toLatin1 ().data ()
27 <<
" ordinal=" << ordinal;
32 const QString &cmdDescription,
33 QXmlStreamReader &reader) :
38 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAddPointAxis::CmdAddPointAxis";
40 QXmlStreamAttributes attributes = reader.attributes();
42 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
43 !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
44 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X) ||
45 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y) ||
46 !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER) ||
47 !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL)) {
48 ENGAUGE_ASSERT (
false);
51 m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
52 m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
53 m_posGraph.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X).toDouble());
54 m_posGraph.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y).toDouble());
55 m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
56 m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
59 CmdAddPointAxis::~CmdAddPointAxis ()
65 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAddPointAxis::cmdRedo";
77 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAddPointAxis::cmdUndo";
86 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
87 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS);
88 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
89 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen.x()));
90 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen.y()));
91 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X, QString::number (m_posGraph.x()));
92 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y, QString::number (m_posGraph.y()));
93 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded);
94 writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal));
95 writer.writeEndElement();
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
void removePointAxis(const QString &identifier)
Perform the opposite of addPointAxis.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
void addPointAxisWithGeneratedIdentifier(const QPointF &posScreen, const QPointF &posGraph, QString &identifier, double ordinal)
Add a single axis point with a generated point identifier.
Document & document()
Return the Document that this command will modify during redo and undo.
CmdAddPointAxis(MainWindow &mainWindow, Document &document, const QPointF &posScreen, const QPointF &posGraph, double ordinal)
Constructor for normal creation.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.