Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdPointChangeBase Class Reference

Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications. More...

#include <CmdPointChangeBase.h>

Inheritance diagram for CmdPointChangeBase:
Inheritance graph
Collaboration diagram for CmdPointChangeBase:
Collaboration graph

Public Member Functions

 CmdPointChangeBase (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor.
virtual ~CmdPointChangeBase ()
Public Member Functions inherited from CmdAbstract
 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

void restoreDocumentState (Document &document) const
 Restore the document previously saved by saveDocumentState.
void saveDocumentState (const Document &document)
 Save the document state for restoration by restoreDocumentState.
Protected Member Functions inherited from CmdAbstract
void baseAttributes (QXmlStreamWriter &writer) const
 After writing leaf class attributes, this writes the base class atributes.
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.
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 inherits from another class (e.g.
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 included, then extract the parent class attributes.
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step.
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Call this (for consistency) after writing leaf class attributes, to write the base class attributes.
void restoreState ()
 Before any other operations associated with a Cmd class are performed, this method is called to restore original states to all relevant state machines.
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.
void selectAddedPointForMoving (const QString &pointAdded)
 Select point that was just added so it can be moved by the user next for convenience.
void selectAddedPointsForMoving (const QStringList &pointsAdded)
 Select points that were just added so they can be moved by the user next for convenience.

Detailed Description

Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications.

This class uses a strategy of taking a snapshot of all points before the redo, and then applying that snapshot to the Document to (later) perform the undo. Before this strategy, the strategy was to just do the opposite steps of the redo, but that strategy was too fragile since it implicity assumed no point changes occurred after the redo of this command and before the redo of the next command. However, point updates like "ordinal maintenance" do occur during that time period

Definition at line 22 of file CmdPointChangeBase.h.

Constructor & Destructor Documentation

◆ CmdPointChangeBase()

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

Single constructor.

Definition at line 14 of file CmdPointChangeBase.cpp.

16 :
19 cmdDescription),
20 m_curveAxes (nullptr),
21 m_curvesGraphs (nullptr)
22{
23 LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::CmdPointChangeBase";
24}
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.
CmdAbstract(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ ~CmdPointChangeBase()

CmdPointChangeBase::~CmdPointChangeBase ( )
virtual

Definition at line 26 of file CmdPointChangeBase.cpp.

27{
28}

Member Function Documentation

◆ restoreDocumentState()

void CmdPointChangeBase::restoreDocumentState ( Document & document) const
protected

Restore the document previously saved by saveDocumentState.

Definition at line 30 of file CmdPointChangeBase.cpp.

31{
32 LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::restoreDocumentState";
33
34 ENGAUGE_CHECK_PTR (m_curveAxes);
35 ENGAUGE_CHECK_PTR (m_curvesGraphs);
36
37 document.setCurveAxes (*m_curveAxes);
38 document.setCurvesGraphs (*m_curvesGraphs);
39}
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.

◆ saveDocumentState()

void CmdPointChangeBase::saveDocumentState ( const Document & document)
protected

Save the document state for restoration by restoreDocumentState.

Definition at line 41 of file CmdPointChangeBase.cpp.

42{
43 LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::saveDocumentState";
44
45 delete m_curveAxes;
46 delete m_curvesGraphs;
47
48 m_curveAxes = new Curve (document.curveAxes());
49 m_curvesGraphs = new CurvesGraphs (document.curvesGraphs());
50}

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