1 #include "CmdEditPointAxis.h"
3 #include "DocumentSerialize.h"
4 #include "EngaugeAssert.h"
6 #include "MainWindow.h"
8 #include "QtToString.h"
9 #include <QXmlStreamReader>
11 const QString CMD_DESCRIPTION (
"Edit axis point");
15 const QString &pointIdentifier,
16 const QPointF &posGraphBefore,
17 const QPointF &posGraphAfter) :
21 m_pointIdentifier (pointIdentifier),
22 m_posGraphBefore (posGraphBefore),
23 m_posGraphAfter (posGraphAfter)
25 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdEditPointAxis::CmdEditPointAxis point="
26 << pointIdentifier.toLatin1 ().data ()
27 <<
" posGraphBefore=" << QPointFToString (posGraphBefore).toLatin1 ().data ()
28 <<
" posGraphAfter=" << QPointFToString (posGraphAfter).toLatin1 ().data ();
33 const QString &cmdDescription,
34 QXmlStreamReader &reader) :
39 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdEditPointAxis::CmdEditPointAxis";
41 QXmlStreamAttributes attributes = reader.attributes();
43 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE) ||
44 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE) ||
45 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X_AFTER) ||
46 !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER) ||
47 !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
48 ENGAUGE_ASSERT (
false);
51 m_posGraphBefore.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE).toDouble());
52 m_posGraphBefore.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE).toDouble());
53 m_posGraphAfter.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_AFTER).toDouble());
54 m_posGraphAfter.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER).toDouble());
55 m_pointIdentifier = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
58 CmdEditPointAxis::~CmdEditPointAxis ()
64 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdEditPointAxis::cmdRedo";
74 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdEditPointAxis::cmdUndo";
84 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
85 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS);
86 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
87 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_pointIdentifier);
88 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE, QString::number (m_posGraphBefore.x()));
89 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE, QString::number (m_posGraphBefore.y()));
90 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_AFTER, QString::number (m_posGraphAfter.x()));
91 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER, QString::number (m_posGraphAfter.y()));
92 writer.writeEndElement();
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
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.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
CmdEditPointAxis(MainWindow &mainWindow, Document &document, const QString &pointIdentifier, const QPointF &posGraphBefore, const QPointF &posGraphAfter)
Constructor for normal creation.
Document & document()
Return the Document that this command will modify during redo and undo.
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.