Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
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
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

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
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition CmdAbstract.h:20
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

◆ ~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)
#endif
void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs.
Definition Document.cpp:932
void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve.
Definition Document.cpp:925

◆ 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}
Container for one set of digitized Points.
Definition Curve.h:34
Container for all graph curves. The axes point curve is external to this class.
const Curve & curveAxes() const
Get method for axis curve.
Definition Document.cpp:321
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition Document.cpp:342

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