21#include <QGraphicsItem>
22#include <QXmlStreamReader>
23#include <QXmlStreamWriter>
28 const QString &cmdDescription) :
29 QUndoCommand (cmdDescription),
59 const QStringList &requiredAttributesLeaf,
60 QXmlStreamReader &reader)
63 QStringList::const_iterator itr;
64 QStringList missingAttributes;
65 for (itr = requiredAttributesLeaf.begin (); itr != requiredAttributesLeaf.end (); itr++) {
67 QString attribute = *itr;
68 if (!attributes.hasAttribute (attribute)) {
69 missingAttributes << attribute;
73 if (missingAttributes.size () > 0) {
75 QString (
"Missing attribute(s) %1"). arg (missingAttributes.join (
", ")));
80 const QStringList &requiredAttributesLeaf,
81 QXmlStreamReader &reader)
84 QStringList requiredAttributes = requiredAttributesLeaf;
101void CmdAbstract::redo ()
123 m_isFirstRedo =
false;
128 LOG4CPP_INFO_S ((*
mainCat)) <<
"CmdAbstract::redo identifierIndex=" << m_identifierIndexBeforeRedo <<
"->"
129 << m_identifierIndexAfterRedo;
137 QList<QGraphicsItem *>::iterator itrS;
138 for (itrS = items.begin (); itrS != items.end (); itrS++) {
140 QGraphicsItem *item = *itrS;
141 bool selected =
false;
146 selected = pointIdentifiersToSelect.
contains (pointIdentifier);
149 item->setSelected (selected);
157 m_mainWindow.updateDigitizeStateIfSoftwareTriggered (m_digitizeState);
167 if (m_documentHashPost.count() == 0) {
170 m_documentHashPost = documentHash;
179 LOG4CPP_INFO_S ((*
mainCat)) <<
"CmdAbstract::saveOrCheckPostCommandDocumentStateHash stateHash=" << m_documentHashPost.data ();
190 if (m_documentHashPre.count() == 0) {
193 m_documentHashPre = documentHash;
202 LOG4CPP_INFO_S ((*
mainCat)) <<
"CmdAbstract::saveOrCheckPreCommandDocumentStateHash stateHash=" << m_documentHashPre.data ();
218 QStringList::const_iterator itr;
219 for (itr = pointsAdded.begin(); itr != pointsAdded.end(); itr++) {
220 QString pointAdded = *itr;
226void CmdAbstract::undo ()
228 LOG4CPP_INFO_S ((*
mainCat)) <<
"CmdAbstract::undo identifierIndex=" << m_identifierIndexAfterRedo <<
"->"
229 << m_identifierIndexBeforeRedo;
@ DATA_KEY_GRAPHICS_ITEM_TYPE
QString digitizeStateAsString(DigitizeState state)
DigitizeState
Set of possible states of Digitize toolbar.
const QString DOCUMENT_SERIALIZE_DIGITIZE_STATE
const QString DOCUMENT_SERIALIZE_DIGITIZE_STATE_STRING
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
@ GRAPHICS_ITEM_TYPE_POINT
log4cpp::Category * mainCat
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Document & document()
Return the Document that this command will modify during redo and undo.
void selectAddedPointForMoving(const QString &pointAdded)
Select point that was just added so it can be moved by the user next for convenience.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
virtual void cmdUndo()=0
Undo method that is called when QUndoStack is moved one command backward.
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 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 inher...
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 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...
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
void selectAddedPointsForMoving(const QStringList &pointsAdded)
Select points that were just added so they can be moved by the user next for convenience.
virtual void cmdRedo()=0
Redo method that is called when QUndoStack is moved one command forward.
Generates a DocumentHash value representing the state of the entire Document.
DocumentHash generate(const Document &document) const
Generate the hash for external storage.
Storage of one imported image and the data attached to that image.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
Hash table class that tracks point identifiers as the key, with a corresponding boolean value.
bool contains(const QString &pointIdentifier) const
True if specified entry exists in the table.
void setKeyValue(const QString &pointIdentifier, bool value)
Set key/value pair.
static unsigned int identifierIndex()
Return the current index for storage in case we need to reset it later while performing a Redo.
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
#define LOG4CPP_INFO_S(logger)