Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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
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.
 
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step.
 
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Since the set of selected points has probably changed, changed that set back to the specified set.
 
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.
 

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
36
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}
const int INNER_RADIUS_MIN
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.
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications.
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
#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
57
61 QString ("%1 %2 %3 %4")
62 .arg (QObject::tr ("Missing attribute(s)"))
64 .arg (QObject::tr ("and/or"))
66 }
67
68 m_deltaScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X_DELTA).toDouble());
69 m_deltaScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y_DELTA).toDouble());
70 m_movedPoints.loadXml (reader);
71}
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA
const QString DOCUMENT_SERIALIZE_SCREEN_X_DELTA
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition Xml.cpp:25
void loadXml(QXmlStreamReader &reader)
Load from serialized xml.

◆ ~CmdMoveBy()

CmdMoveBy::~CmdMoveBy ( )
virtual

Definition at line 73 of file CmdMoveBy.cpp.

74{
75}

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 77 of file CmdMoveBy.cpp.

78{
79 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::cmdRedo"
80 << " deltaScreen=" << QPointFToString (m_deltaScreen).toLatin1().data()
81 << " moving=" << m_movedPoints.count ();
82
85 moveBy (m_deltaScreen);
87 resetSelection(m_movedPoints);
89}
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 resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
int count() const
Number of entries.

◆ cmdUndo()

void CmdMoveBy::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 91 of file CmdMoveBy.cpp.

92{
93 LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::cmdUndo"
94 << " deltaScreen=" << QPointFToString (-1.0 * m_deltaScreen).toLatin1().data()
95 << " moving=" << m_movedPoints.count ();
96
100 resetSelection(m_movedPoints);
102}
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 146 of file CmdMoveBy.cpp.

147{
148 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
150 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
151 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X_DELTA, QString::number (m_deltaScreen.x()));
152 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y_DELTA, QString::number (m_deltaScreen.y()));
153 m_movedPoints.saveXml (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 saveXml(QXmlStreamWriter &writer) const
Serialize table to xml.

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