Engauge Digitizer  2
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. More...
 
 CmdMoveBy (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdMoveBy ()
 
virtual void cmdRedo ()
 Redo method that is called when QUndoStack is moved one command forward. More...
 
virtual void cmdUndo ()
 Undo method that is called when QUndoStack is moved one command backward. More...
 
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading. More...
 
- Public Member Functions inherited from CmdPointChangeBase
 CmdPointChangeBase (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdPointChangeBase ()
 
- Public Member Functions inherited from CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdAbstract ()
 

Additional Inherited Members

- Protected Member Functions inherited from CmdPointChangeBase
void restoreDocumentState (Document &document) const
 Restore the document previously saved by saveDocumentState. More...
 
void saveDocumentState (const Document &document)
 Save the document state for restoration by restoreDocumentState. More...
 
- Protected Member Functions inherited from CmdAbstract
Documentdocument ()
 Return the Document that this command will modify during redo and undo. More...
 
const Documentdocument () const
 Return a const copy of the Document for non redo/undo interaction. More...
 
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step. More...
 
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Since the set of selected points has probably changed, changed that set back to the specified set. More...
 
void saveOrCheckPostCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 
void saveOrCheckPreCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 

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  :
27  document,
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
QString QPointFToString(const QPointF &pos)
Definition: QtToString.cpp:17
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35

◆ 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  :
51  document,
52  cmdDescription)
53 {
54  LOG4CPP_INFO_S ((*mainCat)) << "CmdMoveBy::CmdMoveBy";
55 
56  QXmlStreamAttributes attributes = reader.attributes();
57 
58  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X_DELTA) ||
59  !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y_DELTA) ) {
60  xmlExitWithError (reader,
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_X_DELTA
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
void loadXml(QXmlStreamReader &reader)
Load from serialized xml.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition: Xml.cpp:25
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA

◆ ~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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
QString QPointFToString(const QPointF &pos)
Definition: QtToString.cpp:17
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set...
Definition: CmdAbstract.cpp:81
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
QString QPointFToString(const QPointF &pos)
Definition: QtToString.cpp:17
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set...
Definition: CmdAbstract.cpp:81
int count() const
Number of entries.

◆ 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_SCREEN_X_DELTA
void saveXml(QXmlStreamWriter &writer) const
Serialize table to xml.
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_SCREEN_Y_DELTA
const QString DOCUMENT_SERIALIZE_CMD

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