Engauge Digitizer 2
Loading...
Searching...
No Matches
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.
 CmdAddPointGraph (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdAddPointGraph ()
virtual void cmdRedo ()
 Redo method that is called when QUndoStack is moved one command forward.
virtual void cmdUndo ()
 Undo method that is called when QUndoStack is moved one command backward.
virtual void saveXml (QXmlStreamWriter &writer) const
 Save commands as xml for later uploading.
Public Member Functions inherited from CmdPointChangeBase
 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 ()

Additional Inherited Members

Protected Member Functions inherited from CmdPointChangeBase
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

Command for adding one graph point.

Definition at line 17 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 20 of file CmdAddPointGraph.cpp.

24 :
28 m_curveName (curveName),
29 m_posScreen (posScreen),
30 m_ordinal (ordinal)
31{
32 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph"
33 << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
34 << " ordinal=" << m_ordinal;
35}
const QString CMD_DESCRIPTION("Add axis point")
log4cpp::Category * mainCat
Definition Logger.cpp:14
QString QPointFToString(const QPointF &pos)
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.
CmdPointChangeBase(MainWindow &mainWindow, Document &document, const QString &cmdDescription)
Single constructor.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ CmdAddPointGraph() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 37 of file CmdAddPointGraph.cpp.

40 :
43 cmdDescription)
44{
45 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";
46
47 QXmlStreamAttributes attributes = reader.attributes();
48
49 // Base attributes are handled by CmdPointChangeBase
50 QStringList requiredAttributesLeaf;
51 requiredAttributesLeaf << DOCUMENT_SERIALIZE_SCREEN_X
56 leafAttributes (attributes,
57 requiredAttributesLeaf,
58 reader);
59
60 m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
61 m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
62 m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
63 m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
64 m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
65}
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_CURVE_NAME
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_ORDINAL
const QString DOCUMENT_SERIALIZE_SCREEN_X
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 inher...

◆ ~CmdAddPointGraph()

CmdAddPointGraph::~CmdAddPointGraph ( )
virtual

Definition at line 67 of file CmdAddPointGraph.cpp.

68{
69}

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 71 of file CmdAddPointGraph.cpp.

72{
73 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::cmdRedo";
74
75 restoreState ();
79 m_posScreen,
80 m_identifierAdded,
81 m_ordinal);
82 document().updatePointOrdinals (mainWindow().transformation());
84 selectAddedPointForMoving(m_identifierAdded);
86}
void selectAddedPointForMoving(const QString &pointAdded)
Select point that was just added so it can be moved by the user next for convenience.
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void restoreState()
Before any other operations associated with a Cmd class are performed, this method is called to resto...
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
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:201
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ 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.

89{
90 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::cmdUndo";
91
92 restoreState ();
97}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 99 of file CmdAddPointGraph.cpp.

100{
101 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
103 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
104 writer.writeAttribute(DOCUMENT_SERIALIZE_CURVE_NAME, m_curveName);
105 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen.x()));
106 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen.y()));
107 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded);
108 writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal));
109 baseAttributes (writer);
110 writer.writeEndElement();
111}
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
void baseAttributes(QXmlStreamWriter &writer) const
After writing leaf class attributes, this writes the base class atributes.

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