Engauge Digitizer  2
Public Member Functions | List of all members
CmdSettingsCurveList Class Reference

Command for DlgSettingsCurveList. More...

#include <CmdSettingsCurveList.h>

Inheritance diagram for CmdSettingsCurveList:
Inheritance graph
Collaboration diagram for CmdSettingsCurveList:
Collaboration graph

Public Member Functions

 CmdSettingsCurveList (MainWindow &mainWindow, Document &document, const CurveNameList &modelCurves)
 Constructor for normal creation. More...
 
 CmdSettingsCurveList (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdSettingsCurveList ()
 
virtual void cmdRedo ()
 Redo method that is called when QUndoStack is moved one command forward. More...
 
virtual void cmdUndo ()
 Undo method that is called when QUndoStack is moved one command backward. More...
 
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading. More...
 
- Public Member Functions inherited from CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdAbstract ()
 

Additional Inherited Members

- Protected Member Functions inherited from CmdAbstract
Documentdocument ()
 Return the Document that this command will modify during redo and undo. More...
 
const Documentdocument () const
 Return a const copy of the Document for non redo/undo interaction. More...
 
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step. More...
 
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Since the set of selected points has probably changed, changed that set back to the specified set. More...
 
void saveOrCheckPostCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 
void saveOrCheckPreCommandDocumentStateHash (const Document &document)
 Save, when called the first time, a hash value representing the state of the Document. More...
 

Detailed Description

Command for DlgSettingsCurveList.

Definition at line 16 of file CmdSettingsCurveList.h.

Constructor & Destructor Documentation

◆ CmdSettingsCurveList() [1/2]

CmdSettingsCurveList::CmdSettingsCurveList ( MainWindow mainWindow,
Document document,
const CurveNameList modelCurves 
)

Constructor for normal creation.

Definition at line 17 of file CmdSettingsCurveList.cpp.

20  :
22  document,
24 {
25  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::CmdSettingsCurveList";
26 
27  m_curvesGraphsBefore = document.curvesGraphs ();
28 
29  // Build the 'after' state
30  for (int row = 0; row < modelCurves.rowCount (); row++) {
31 
32  QModelIndex idxCurrent = modelCurves.index (row, CURVE_NAME_LIST_COLUMN_CURRENT);
33 
34  QString curveNameCurrent = modelCurves.data (idxCurrent).toString ();
35  QString curveNameOriginal = modelCurves.currentCurveToOriginalCurve (curveNameCurrent);
36  if (!curveNameOriginal.isEmpty ()) {
37 
38  // There was an original Curve
39  const Document &documentConst = const_cast<Document&> (document);
40  const Curve *curveOriginal = documentConst.curveForCurveName (curveNameOriginal);
41  Curve curveCurrent (*curveOriginal);
42  curveCurrent.setCurveName (curveNameCurrent);
43 
44  m_curvesGraphsAfter.addGraphCurveAtEnd (curveCurrent); // Save Curve
45 
46  } else {
47 
48  // There was no original Curve
49  Curve curveCurrent (curveNameCurrent,
51  CurveStyle (LineStyle::defaultGraphCurve(m_curvesGraphsAfter.numCurves()),
52  PointStyle::defaultGraphCurve(m_curvesGraphsAfter.numCurves())));
53 
54  m_curvesGraphsAfter.addGraphCurveAtEnd (curveCurrent); // Save Curve
55  }
56  }

◆ CmdSettingsCurveList() [2/2]

CmdSettingsCurveList::CmdSettingsCurveList ( MainWindow mainWindow,
Document document,
const QString &  cmdDescription,
QXmlStreamReader &  reader 
)

Constructor for parsing error report file xml.

Definition at line 58 of file CmdSettingsCurveList.cpp.

62  :
64  document,
65  cmdDescription)
66 {
67  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::CmdSettingsCurveList";
68 
69  bool success = true;
70 
71  // Read until end of this subtree
72  bool isBefore = true;
73  while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
74  (reader.name() != DOCUMENT_SERIALIZE_CMD)){
75  loadNextFromReader(reader);
76  if (reader.atEnd()) {
77  xmlExitWithError (reader,
78  QString ("%1 %2")
79  .arg (QObject::tr ("Reached end of file before finding end element for"))
80  .arg (DOCUMENT_SERIALIZE_CMD));
81  success = false;
82  break;
83  }
84 
85  if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
86  (reader.name() == DOCUMENT_SERIALIZE_CURVES_GRAPHS)) {
87 
88  if (isBefore) {
89 
90  m_curvesGraphsBefore.loadXml (reader);
91  isBefore = false;
92 
93  } else {
94 
95  m_curvesGraphsAfter.loadXml (reader);
96 
97  }
98  }
99  }
100 
101  if (!success) {
102  reader.raiseError ("Cannot read curve add/remove settings");
103  }

◆ ~CmdSettingsCurveList()

CmdSettingsCurveList::~CmdSettingsCurveList ( )
virtual

Definition at line 105 of file CmdSettingsCurveList.cpp.

107 {

Member Function Documentation

◆ cmdRedo()

void CmdSettingsCurveList::cmdRedo ( )
virtual

Redo method that is called when QUndoStack is moved one command forward.

Implements CmdAbstract.

Definition at line 109 of file CmdSettingsCurveList.cpp.

111 {
112  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::cmdRedo";
113 
115  mainWindow().updateSettingsCurveList(m_curvesGraphsAfter);

◆ cmdUndo()

void CmdSettingsCurveList::cmdUndo ( )
virtual

Undo method that is called when QUndoStack is moved one command backward.

Implements CmdAbstract.

Definition at line 119 of file CmdSettingsCurveList.cpp.

121 {
122  LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::cmdUndo";
123 
125  mainWindow().updateSettingsCurveList(m_curvesGraphsBefore);

◆ saveXml()

void CmdSettingsCurveList::saveXml ( QXmlStreamWriter &  writer) const
virtual

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 129 of file CmdSettingsCurveList.cpp.

131 {
132  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
134  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
135  m_curvesGraphsBefore.saveXml(writer);
136  m_curvesGraphsAfter.saveXml(writer);
137  writer.writeEndElement();

The documentation for this class was generated from the following files:
LineStyle::defaultGraphCurve
static LineStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Definition: LineStyle.cpp:84
CurvesGraphs::saveXml
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
Definition: CurvesGraphs.cpp:270
xmlExitWithError
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition: Xml.cpp:25
CmdAbstract::document
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
PointStyle::defaultGraphCurve
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Definition: PointStyle.cpp:88
CMD_DESCRIPTION
const QString CMD_DESCRIPTION("Curve list")
CurveNameList::currentCurveToOriginalCurve
QString currentCurveToOriginalCurve(const QString &currentCurve) const
Return the original curve for the specified current curve.
Definition: CurveNameList.cpp:72
Document::curveForCurveName
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition: Document.cpp:335
CurvesGraphs::loadXml
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
Definition: CurvesGraphs.cpp:197
Document
Storage of one imported image and the data attached to that image.
Definition: Document.h:40
Curve
Container for one set of digitized Points.
Definition: Curve.h:32
CurveStyle
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:17
MainWindow::updateAfterCommand
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Definition: MainWindow.cpp:3240
ColorFilterSettings::defaultFilter
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
Definition: ColorFilterSettings.cpp:128
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_TYPE
CmdAbstract::saveOrCheckPostCommandDocumentStateHash
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:102
CurveNameList::rowCount
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
One row per curve name.
Definition: CurveNameList.cpp:249
CmdAbstract::saveOrCheckPreCommandDocumentStateHash
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
Definition: CmdAbstract.cpp:125
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow::updateSettingsCurveList
void updateSettingsCurveList(const CurvesGraphs &curvesGraphs)
Update with new curves.
Definition: MainWindow.cpp:3625
CurvesGraphs::numCurves
int numCurves() const
Current number of graphs curves.
Definition: CurvesGraphs.cpp:241
DOCUMENT_SERIALIZE_CURVES_GRAPHS
const QString DOCUMENT_SERIALIZE_CURVES_GRAPHS
CurvesGraphs::addGraphCurveAtEnd
void addGraphCurveAtEnd(const Curve &curve)
Append new graph Curve to end of Curve list.
Definition: CurvesGraphs.cpp:24
CmdAbstract::mainWindow
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD
CmdAbstract
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:18
loadNextFromReader
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition: Xml.cpp:14
CURVE_NAME_LIST_COLUMN_CURRENT
Definition: CurveNameList.h:20
Document::curvesGraphs
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition: Document.cpp:342
DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST
const QString DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST