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

Command for moving all selected Points by a specified translation. More...

#include <CmdMoveBy.h>

Inheritance diagram for CmdMoveBy:
Inheritance graph
Collaboration diagram for CmdMoveBy:
Collaboration graph

Public Member Functions

 CmdMoveBy (MainWindow &mainWindow, Document &document, const QPointF &deltaScreen, const QString &moveText, const QStringList &selectedPointIdentifiers)
 Constructor for normal creation.
 CmdMoveBy (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdMoveBy ()
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 moving all selected Points by a specified translation.

Definition at line 18 of file CmdMoveBy.h.

Constructor & Destructor Documentation

◆ CmdMoveBy() [1/2]

CmdMoveBy::CmdMoveBy ( MainWindow & mainWindow,
Document & document,
const QPointF & deltaScreen,
const QString & moveText,
const QStringList & selectedPointIdentifiers )

Constructor for normal creation.

Definition at line 21 of file CmdMoveBy.cpp.

25 :
28 moveText),
29 m_deltaScreen (deltaScreen)
30{
31 QStringList selected; // For debug
32 QStringList::const_iterator itr;
33 for (itr = selectedPointIdentifiers.begin (); itr != selectedPointIdentifiers.end (); itr++) {
34
35 QString selectedPointIdentifier = *itr;
36
37 selected << selectedPointIdentifier;
38 m_movedPoints.setKeyValue (selectedPointIdentifier, true);
39 }
40
41 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::CmdMoveBy"
42 << " deltaScreen=" << QPointFToString (deltaScreen).toLatin1 ().data ()
43 << " selected=" << selected.join (", ").toLatin1 ().data () << ")";
44}
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

◆ CmdMoveBy() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 46 of file CmdMoveBy.cpp.

49 :
52 cmdDescription)
53{
54 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::CmdMoveBy";
55
56 QXmlStreamAttributes attributes = reader.attributes();
57
58 QStringList requiredAttributesLeaf;
59 requiredAttributesLeaf << DOCUMENT_SERIALIZE_SCREEN_X_DELTA
61 leafAndBaseAttributes (attributes,
62 requiredAttributesLeaf,
63 reader);
64
65 m_deltaScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X_DELTA).toDouble());
66 m_deltaScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y_DELTA).toDouble());
67 m_movedPoints.loadXml (reader);
68}
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA
const QString DOCUMENT_SERIALIZE_SCREEN_X_DELTA
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...

◆ ~CmdMoveBy()

CmdMoveBy::~CmdMoveBy ( )
virtual

Definition at line 70 of file CmdMoveBy.cpp.

71{
72}

Member Function Documentation

◆ cmdRedo()

void CmdMoveBy::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 74 of file CmdMoveBy.cpp.

75{
76 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::cmdRedo"
77 << " deltaScreen=" << QPointFToString (m_deltaScreen).toLatin1().data()
78 << " moving=" << m_movedPoints.count ();
79
80 restoreState ();
83 moveBy (m_deltaScreen);
85 resetSelection(m_movedPoints);
87}
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 resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Call this (for consistency) after writing leaf class attributes, to write the base class attributes.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdMoveBy::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 89 of file CmdMoveBy.cpp.

90{
91 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::cmdUndo"
92 << " deltaScreen=" << QPointFToString (-1.0 * m_deltaScreen).toLatin1().data()
93 << " moving=" << m_movedPoints.count ();
94
95 restoreState ();
99 resetSelection(m_movedPoints);
101}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 145 of file CmdMoveBy.cpp.

146{
147 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
149 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
150 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X_DELTA, QString::number (m_deltaScreen.x()));
151 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y_DELTA, QString::number (m_deltaScreen.y()));
152 m_movedPoints.saveXml (writer);
153 baseAttributes (writer);
154 writer.writeEndElement();
155}
const QString DOCUMENT_SERIALIZE_CMD_MOVE_BY
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
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: