Engauge Digitizer  2
CmdAbstract.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef CMD_ABSTRACT_H
8 #define CMD_ABSTRACT_H
9 
10 #include "PointIdentifiers.h"
11 #include <QUndoCommand>
12 
13 class Document;
14 class MainWindow;
15 class QXmlStreamWriter;
16 
18 class CmdAbstract : public QUndoCommand
19 {
20 public:
24  const QString &cmdDescription);
25 
26  virtual ~CmdAbstract();
27 
29  virtual void cmdRedo () = 0;
30 
32  virtual void cmdUndo () = 0;
33 
35  virtual void saveXml (QXmlStreamWriter &writer) const = 0;
36 
37 protected:
39  Document &document();
40 
42  const Document &document() const;
43 
46 
49  void resetSelection(const PointIdentifiers &pointIdentifiersToSelect);
50 
51 private:
52  CmdAbstract();
53 
54  virtual void redo (); // Calls cmdRedo
55  virtual void undo (); // Calls cmdUndo
56 
57  MainWindow &m_mainWindow;
58  Document &m_document;
59 
60  // Snapshots of GraphicsPointAbstractBase::identifierIndex before and after redo
61  bool m_isFirstRedo;
62  unsigned int m_identifierIndexBeforeRedo;
63  unsigned int m_identifierIndexAfterRedo;
64 };
65 
66 #endif // CMD_ABSTRACT_H
Hash table class that tracks point identifiers as the key, with a corresponding boolean value...
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:18
virtual void cmdRedo()=0
Redo method that is called when QUndoStack is moved one command forward.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:43
Storage of one imported image and the data attached to that image.
Definition: Document.h:40
virtual void cmdUndo()=0
Undo method that is called when QUndoStack is moved one command backward.
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:33
virtual void saveXml(QXmlStreamWriter &writer) const =0
Save commands as xml for later uploading.
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:79
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:77