Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
CmdAbstract Class Referenceabstract

Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand. More...

#include <CmdAbstract.h>

Inheritance diagram for CmdAbstract:
Inheritance graph
Collaboration diagram for CmdAbstract:
Collaboration graph

Public Member Functions

 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
 
virtual ~CmdAbstract ()
 
virtual void cmdRedo ()=0
 Redo method that is called when QUndoStack is moved one command forward.
 
virtual void cmdUndo ()=0
 Undo method that is called when QUndoStack is moved one command backward.
 
virtual void saveXml (QXmlStreamWriter &writer) const =0
 Save commands as xml for later uploading.
 

Protected Member Functions

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

Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.

Definition at line 19 of file CmdAbstract.h.

Constructor & Destructor Documentation

◆ CmdAbstract()

CmdAbstract::CmdAbstract ( MainWindow & mainWindow,
Document & document,
const QString & cmdDescription )

Single constructor.

Definition at line 20 of file CmdAbstract.cpp.

22 :
23 QUndoCommand (cmdDescription),
24 m_mainWindow (mainWindow),
25 m_document (document),
26 m_isFirstRedo (true)
27{
28 LOG4CPP_INFO_S ((*mainCat)) << "CmdAbstract::CmdAbstract";
29}
log4cpp::Category * mainCat
Definition Logger.cpp:14
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.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~CmdAbstract()

CmdAbstract::~CmdAbstract ( )
virtual

Definition at line 31 of file CmdAbstract.cpp.

32{
33}

Member Function Documentation

◆ cmdRedo()

virtual void CmdAbstract::cmdRedo ( )
pure virtual

◆ cmdUndo()

virtual void CmdAbstract::cmdUndo ( )
pure virtual

◆ document() [1/2]

Document & CmdAbstract::document ( )
protected

Return the Document that this command will modify during redo and undo.

Definition at line 35 of file CmdAbstract.cpp.

36{
37 return m_document;
38}

◆ document() [2/2]

const Document & CmdAbstract::document ( ) const
protected

Return a const copy of the Document for non redo/undo interaction.

Definition at line 40 of file CmdAbstract.cpp.

41{
42 return m_document;
43}

◆ mainWindow()

MainWindow & CmdAbstract::mainWindow ( )
protected

Return the MainWindow so it can be updated by this command as a last step.

Definition at line 45 of file CmdAbstract.cpp.

46{
47 return m_mainWindow;
48}

◆ resetSelection()

void CmdAbstract::resetSelection ( const PointIdentifiers & pointIdentifiersToSelect)
protected

Since the set of selected points has probably changed, changed that set back to the specified set.

This lets the user move selected point(s) repeatedly using arrow keys. Also provides expected behavior when pasting

Definition at line 81 of file CmdAbstract.cpp.

82{
83 LOG4CPP_INFO_S ((*mainCat)) << "CmdAbstract::resetSelection";
84
86 QList<QGraphicsItem *>::iterator itrS;
87 for (itrS = items.begin (); itrS != items.end (); itrS++) {
88
89 QGraphicsItem *item = *itrS;
90 bool selected = false;
91 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT) {
92
93 QString pointIdentifier = item->data (DATA_KEY_IDENTIFIER).toString ();
94
96 }
97
98 item->setSelected (selected);
99 }
100}
@ DATA_KEY_GRAPHICS_ITEM_TYPE
‍Unique identifier for QGraphicsItem object
Definition DataKey.h:15
@ DATA_KEY_IDENTIFIER
Definition DataKey.h:14
const int INNER_RADIUS_MIN
@ GRAPHICS_ITEM_TYPE_POINT
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.

◆ saveOrCheckPostCommandDocumentStateHash()

void CmdAbstract::saveOrCheckPostCommandDocumentStateHash ( const Document & document)
protected

Save, when called the first time, a hash value representing the state of the Document.

Then on succeeding calls the hash is recomputed and compared to the original value to check for consistency. This "post" method is called immediately after the redo method of the subclass has done its processing. See also saveOrCheckPreCommandDocumentState

Definition at line 102 of file CmdAbstract.cpp.

103{
104 // LOG4CPP_INFO_S is below
105
108
109 if (m_documentHashPost.count() == 0) {
110
111 // This is the first time through here so save the initial value
112 m_documentHashPost = documentHash;
113
114 } else {
115
116 // This is not the first time through here so compare the current value to the initial value
117 ENGAUGE_ASSERT (documentHash == m_documentHashPost);
118
119 }
120
121 LOG4CPP_INFO_S ((*mainCat)) << "CmdAbstract::saveOrCheckPostCommandDocumentStateHash stateHash=" << m_documentHashPost.data ();
122
123}
QByteArray DocumentHash
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Generates a DocumentHash value representing the state of the entire Document.
DocumentHash generate(const Document &document) const
Generate the hash for external storage.

◆ saveOrCheckPreCommandDocumentStateHash()

void CmdAbstract::saveOrCheckPreCommandDocumentStateHash ( const Document & document)
protected

Save, when called the first time, a hash value representing the state of the Document.

Then on succeeding calls the hash is recomputed and compared to the original value to check for consistency. This "pre" method is called immediately after the redo method of the subclass has done its processing. See also saveOrCheckPostCommandDocumentState

Definition at line 125 of file CmdAbstract.cpp.

126{
127 // LOG4CPP_INFO_S is below
128
131
132 if (m_documentHashPre.count() == 0) {
133
134 // This is the first time through here so save the initial value
135 m_documentHashPre = documentHash;
136
137 } else {
138
139 // This is not the first time through here so compare the current value to the initial value
140 ENGAUGE_ASSERT (documentHash == m_documentHashPre);
141
142 }
143
144 LOG4CPP_INFO_S ((*mainCat)) << "CmdAbstract::saveOrCheckPreCommandDocumentStateHash stateHash=" << m_documentHashPre.data ();
145
146}

◆ saveXml()

virtual void CmdAbstract::saveXml ( QXmlStreamWriter & writer) const
pure virtual

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