7 #include "CmdAbstract.h" 10 #include "DocumentHashGenerator.h" 11 #include "EngaugeAssert.h" 12 #include "GraphicsItemType.h" 13 #include "GraphicsScene.h" 14 #include "GraphicsView.h" 16 #include "MainWindow.h" 18 #include <QGraphicsItem> 22 const QString &cmdDescription) :
23 QUndoCommand (cmdDescription),
24 m_mainWindow (mainWindow),
25 m_document (document),
28 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::CmdAbstract";
31 CmdAbstract::~CmdAbstract()
50 void CmdAbstract::redo ()
53 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::redo";
72 m_isFirstRedo =
false;
77 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::redo identifierIndex=" << m_identifierIndexBeforeRedo <<
"->" 78 << m_identifierIndexAfterRedo;
83 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::resetSelection";
86 QList<QGraphicsItem *>::iterator itrS;
87 for (itrS = items.begin (); itrS != items.end (); itrS++) {
89 QGraphicsItem *item = *itrS;
90 bool selected =
false;
91 if (item->data (DATA_KEY_GRAPHICS_ITEM_TYPE).toInt () == GRAPHICS_ITEM_TYPE_POINT) {
93 QString pointIdentifier = item->data (DATA_KEY_IDENTIFIER).toString ();
95 selected = pointIdentifiersToSelect.
contains (pointIdentifier);
98 item->setSelected (selected);
107 DocumentHash documentHash = documentHashGenerator.
generate (document);
109 if (m_documentHashPost.count() == 0) {
112 m_documentHashPost = documentHash;
117 ENGAUGE_ASSERT (documentHash == m_documentHashPost);
121 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::saveOrCheckPostCommandDocumentStateHash stateHash=" << m_documentHashPost.data ();
130 DocumentHash documentHash = documentHashGenerator.
generate (document);
132 if (m_documentHashPre.count() == 0) {
135 m_documentHashPre = documentHash;
140 ENGAUGE_ASSERT (documentHash == m_documentHashPre);
144 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::saveOrCheckPreCommandDocumentStateHash stateHash=" << m_documentHashPre.data ();
148 void CmdAbstract::undo ()
150 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdAbstract::undo identifierIndex=" << m_identifierIndexAfterRedo <<
"->" 151 << m_identifierIndexBeforeRedo;
Hash table class that tracks point identifiers as the key, with a corresponding boolean value...
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
static unsigned int identifierIndex()
Return the current index for storage in case we need to reset it later while performing a Redo...
Generates a DocumentHash value representing the state of the entire Document.
virtual void cmdRedo()=0
Redo method that is called when QUndoStack is moved one command forward.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
DocumentHash generate(const Document &document) const
Generate the hash for external storage.
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Storage of one imported image and the data attached to that image.
virtual void cmdUndo()=0
Undo method that is called when QUndoStack is moved one command backward.
bool contains(const QString &pointIdentifier) const
True if specified entry exists in the table.
Document & document()
Return the Document that this command will modify during redo and undo.
void resetSelection(const PointIdentifiers &pointIdentifiersToSelect)
Since the set of selected points has probably changed, changed that set back to the specified set...
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...