Engauge Digitizer  2
CmdPointChangeBase.cpp
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 #include "CmdPointChangeBase.h"
8 #include "Curve.h"
9 #include "CurvesGraphs.h"
10 #include "Document.h"
11 #include "EngaugeAssert.h"
12 #include "Logger.h"
13 
15  Document &document,
16  const QString &cmdDescription) :
17  CmdAbstract (mainWindow,
18  document,
19  cmdDescription),
20  m_curveAxes (0),
21  m_curvesGraphs (0)
22 {
23  LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::CmdPointChangeBase";
24 }
25 
26 CmdPointChangeBase::~CmdPointChangeBase()
27 {
28 }
29 
31 {
32  LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::restoreDocumentState";
33 
34  ENGAUGE_ASSERT (m_curveAxes != 0);
35  ENGAUGE_ASSERT (m_curvesGraphs != 0);
36 
37  document.setCurveAxes (*m_curveAxes);
38  document.setCurvesGraphs (*m_curvesGraphs);
39 }
40 
42 {
43  LOG4CPP_INFO_S ((*mainCat)) << "CmdPointChangeBase::saveDocumentState";
44 
45  if (m_curveAxes != 0) {
46  delete m_curveAxes;
47  m_curveAxes = 0;
48  }
49 
50  if (m_curvesGraphs != 0) {
51  delete m_curvesGraphs;
52  m_curvesGraphs = 0;
53  }
54 
55  m_curveAxes = new Curve (document.curveAxes());
56  m_curvesGraphs = new CurvesGraphs (document.curvesGraphs());
57 }
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:19
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:24
void setCurveAxes(const Curve &curveAxes)
Let CmdAbstract classes overwrite axes Curve.
Definition: Document.cpp:919
Storage of one imported image and the data attached to that image.
Definition: Document.h:41
Container for one set of digitized Points.
Definition: Curve.h:33
void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs.
Definition: Document.cpp:926
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
CmdPointChangeBase(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition: Document.cpp:339
const Curve & curveAxes() const
Get method for axis curve.
Definition: Document.cpp:318
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:89
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.