Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdEditPointAxis Class Reference

Command for editing the graph coordinates one axis point. More...

#include <CmdEditPointAxis.h>

Inheritance diagram for CmdEditPointAxis:
Inheritance graph
Collaboration diagram for CmdEditPointAxis:
Collaboration graph

Public Member Functions

 CmdEditPointAxis (MainWindow &mainWindow, Document &document, const QString &pointIdentifier, const QPointF &posGraphBefore, const QPointF &posGraphAfter, bool isXOnly)
 Constructor for normal creation.
 CmdEditPointAxis (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdEditPointAxis ()
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.
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading.
Public Member Functions inherited from CmdPointChangeBase
 CmdPointChangeBase (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdPointChangeBase ()
Public Member Functions inherited from CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdAbstract ()

Additional Inherited Members

Protected Member Functions inherited from CmdPointChangeBase
void restoreDocumentState (Document &document) const
 Restore the document previously saved by saveDocumentState.
void saveDocumentState (const Document &document)
 Save the document state for restoration by restoreDocumentState.
Protected Member Functions inherited from CmdAbstract
void baseAttributes (QXmlStreamWriter &writer) const
 After writing leaf class attributes, this writes the base class atributes.
Documentdocument ()
 Return the Document that this command will modify during redo and undo.
const Documentdocument () const
 Return a const copy of the Document for non redo/undo interaction.
void leafAttributes (const QXmlStreamAttributes &attributes, const QStringList &requiredAttributesLeaf, QXmlStreamReader &reader)
 Same as often-used leafAndBaseAttributes, except this is used in the special case where a class inherits from another class (e.g.
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 included, then extract the parent class attributes.
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step.
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Call this (for consistency) after writing leaf class attributes, to write the base class attributes.
void restoreState ()
 Before any other operations associated with a Cmd class are performed, this method is called to restore original states to all relevant state machines.
void saveOrCheckPostCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document.
void saveOrCheckPreCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document.
void selectAddedPointForMoving (const QString &pointAdded)
 Select point that was just added so it can be moved by the user next for convenience.
void selectAddedPointsForMoving (const QStringList &pointsAdded)
 Select points that were just added so they can be moved by the user next for convenience.

Detailed Description

Command for editing the graph coordinates one axis point.

The screen coordinates are handled by another command

Definition at line 18 of file CmdEditPointAxis.h.

Constructor & Destructor Documentation

◆ CmdEditPointAxis() [1/2]

CmdEditPointAxis::CmdEditPointAxis ( MainWindow & mainWindow,
Document & document,
const QString & pointIdentifier,
const QPointF & posGraphBefore,
const QPointF & posGraphAfter,
bool isXOnly )

Constructor for normal creation.

Definition at line 20 of file CmdEditPointAxis.cpp.

25 :
29 m_pointIdentifier (pointIdentifier),
30 m_posGraphBefore (posGraphBefore),
31 m_posGraphAfter (posGraphAfter),
32 m_isXOnly (isXOnly)
33{
34 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::CmdEditPointAxis point="
35 << pointIdentifier.toLatin1 ().data ()
36 << " posGraphBefore=" << QPointFToString (posGraphBefore).toLatin1 ().data ()
37 << " posGraphAfter=" << QPointFToString (posGraphAfter).toLatin1 ().data ();
38}
const QString CMD_DESCRIPTION("Add axis point")
log4cpp::Category * mainCat
Definition Logger.cpp:14
QString QPointFToString(const QPointF &pos)
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.
CmdPointChangeBase(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ CmdEditPointAxis() [2/2]

CmdEditPointAxis::CmdEditPointAxis ( MainWindow & mainWindow,
Document & document,
const QString & cmdDescription,
QXmlStreamReader & reader )

Constructor for parsing error report file xml.

Definition at line 40 of file CmdEditPointAxis.cpp.

43 :
46 cmdDescription)
47{
48 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::CmdEditPointAxis";
49
50 QXmlStreamAttributes attributes = reader.attributes();
51
52 QStringList requiredAttributesLeaf;
53 requiredAttributesLeaf << DOCUMENT_SERIALIZE_GRAPH_X_BEFORE
59 leafAndBaseAttributes (attributes,
60 requiredAttributesLeaf,
61 reader);
62
63 // Boolean values
64 QString isXOnlyValue = attributes.value(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY).toString();
65
66 m_posGraphBefore.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE).toDouble());
67 m_posGraphBefore.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE).toDouble());
68 m_posGraphAfter.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_AFTER).toDouble());
69 m_posGraphAfter.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER).toDouble());
70 m_pointIdentifier = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
71 m_isXOnly = (isXOnlyValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
72}
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE
const QString DOCUMENT_SERIALIZE_GRAPH_Y_AFTER
const QString DOCUMENT_SERIALIZE_GRAPH_X_BEFORE
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_GRAPH_X_AFTER
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
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...

◆ ~CmdEditPointAxis()

CmdEditPointAxis::~CmdEditPointAxis ( )
virtual

Definition at line 74 of file CmdEditPointAxis.cpp.

75{
76}

Member Function Documentation

◆ cmdRedo()

void CmdEditPointAxis::cmdRedo ( )
virtual

Redo method that is called when QUndoStack is moved one command forward.

Implements CmdAbstract.

Definition at line 78 of file CmdEditPointAxis.cpp.

79{
80 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::cmdRedo";
81
82 restoreState ();
85 document().editPointAxis (m_posGraphAfter,
86 m_pointIdentifier);
87 document().updatePointOrdinals (mainWindow().transformation());
90}
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
Definition Document.cpp:374
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdEditPointAxis::cmdUndo ( )
virtual

Undo method that is called when QUndoStack is moved one command backward.

Implements CmdAbstract.

Definition at line 92 of file CmdEditPointAxis.cpp.

93{
94 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::cmdUndo";
95
96 restoreState ();
101}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

void CmdEditPointAxis::saveXml ( QXmlStreamWriter & writer) const
virtual

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 103 of file CmdEditPointAxis.cpp.

104{
105 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
107 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
108 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_pointIdentifier);
109 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE, QString::number (m_posGraphBefore.x()));
110 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE, QString::number (m_posGraphBefore.y()));
111 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_AFTER, QString::number (m_posGraphAfter.x()));
112 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER, QString::number (m_posGraphAfter.y()));
113 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY, m_isXOnly ?
116 baseAttributes (writer);
117 writer.writeEndElement();
118}
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.

The documentation for this class was generated from the following files: