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

Command for adding one graph point. More...

#include <CmdAddPointGraph.h>

Inheritance diagram for CmdAddPointGraph:
Inheritance graph
Collaboration diagram for CmdAddPointGraph:
Collaboration graph

Public Member Functions

 CmdAddPointGraph (MainWindow &mainWindow, Document &document, const QString &curveName, const QPointF &posScreen, double ordinal)
 Constructor for normal creation. More...
 
 CmdAddPointGraph (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdAddPointGraph ()
 
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 CmdPointChangeBase
 CmdPointChangeBase (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdPointChangeBase ()
 
- 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 CmdPointChangeBase
void restoreDocumentState (Document &document) const
 Restore the document previously saved by saveDocumentState. More...
 
void saveDocumentState (const Document &document)
 Save the document state for restoration by restoreDocumentState. More...
 
- 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 adding one graph point.

Definition at line 16 of file CmdAddPointGraph.h.

Constructor & Destructor Documentation

◆ CmdAddPointGraph() [1/2]

CmdAddPointGraph::CmdAddPointGraph ( MainWindow mainWindow,
Document document,
const QString &  curveName,
const QPointF &  posScreen,
double  ordinal 
)

Constructor for normal creation.

Definition at line 19 of file CmdAddPointGraph.cpp.

23  :
25  document,
27  m_curveName (curveName),
28  m_posScreen (posScreen),
29  m_ordinal (ordinal)
30 {
31  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph"
32  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
33  << " ordinal=" << m_ordinal;
34 }

◆ CmdAddPointGraph() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 36 of file CmdAddPointGraph.cpp.

39  :
41  document,
42  cmdDescription)
43 {
44  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";
45 
46  QXmlStreamAttributes attributes = reader.attributes();
47 
48  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
49  !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
50  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME) ||
51  !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
52  !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
53  xmlExitWithError (reader,
54  QString ("Missing attribute(s) %1, %2, %3, %4 and/or %5")
60  }
61 
62  m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
63  m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
64  m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
65  m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
66  m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
67 }

◆ ~CmdAddPointGraph()

CmdAddPointGraph::~CmdAddPointGraph ( )
virtual

Definition at line 69 of file CmdAddPointGraph.cpp.

70 {
71 }

Member Function Documentation

◆ cmdRedo()

void CmdAddPointGraph::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 73 of file CmdAddPointGraph.cpp.

74 {
75  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::cmdRedo";
76 
80  m_posScreen,
81  m_identifierAdded,
82  m_ordinal);
83  document().updatePointOrdinals (mainWindow().transformation());
86 }

◆ cmdUndo()

void CmdAddPointGraph::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 88 of file CmdAddPointGraph.cpp.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 98 of file CmdAddPointGraph.cpp.

99 {
100  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
102  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
103  writer.writeAttribute(DOCUMENT_SERIALIZE_CURVE_NAME, m_curveName);
104  writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen.x()));
105  writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen.y()));
106  writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded);
107  writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal));
108  writer.writeEndElement();
109 }

The documentation for this class was generated from the following files:
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
CMD_DESCRIPTION
const QString CMD_DESCRIPTION("Add graph point")
DOCUMENT_SERIALIZE_CURVE_NAME
const QString DOCUMENT_SERIALIZE_CURVE_NAME
DOCUMENT_SERIALIZE_ORDINAL
const QString DOCUMENT_SERIALIZE_ORDINAL
DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_IDENTIFIER
CmdPointChangeBase::saveDocumentState
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
Definition: CmdPointChangeBase.cpp:40
MainWindow::updateAfterCommand
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Definition: MainWindow.cpp:3240
DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_SCREEN_Y
DOCUMENT_SERIALIZE_SCREEN_X
const QString DOCUMENT_SERIALIZE_SCREEN_X
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
CmdPointChangeBase
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications.
Definition: CmdPointChangeBase.h:21
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
DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH
CmdPointChangeBase::restoreDocumentState
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Definition: CmdPointChangeBase.cpp:29
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
Document::updatePointOrdinals
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
Definition: Document.cpp:1066
CmdAbstract::mainWindow
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
Document::addPointGraphWithGeneratedIdentifier
void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
Definition: Document.cpp:195
DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD
QPointFToString
QString QPointFToString(const QPointF &pos)
Definition: QtToString.cpp:17