Engauge Digitizer 2
Loading...
Searching...
No Matches
CmdEditPointGraph Class Reference

Command for editing the graph coordinates of one or more graph points. More...

#include <CmdEditPointGraph.h>

Inheritance diagram for CmdEditPointGraph:
Inheritance graph
Collaboration diagram for CmdEditPointGraph:
Collaboration graph

Public Member Functions

 CmdEditPointGraph (MainWindow &mainWindow, Document &document, const QStringList &pointIdentifiers, bool isX, bool isY, double x, double y)
 Constructor for normal creation.
 CmdEditPointGraph (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdEditPointGraph ()
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 editing the graph coordinates of one or more graph points.

The screen coordinates are handled by another command

Definition at line 18 of file CmdEditPointGraph.h.

Constructor & Destructor Documentation

◆ CmdEditPointGraph() [1/2]

CmdEditPointGraph::CmdEditPointGraph ( MainWindow & mainWindow,
Document & document,
const QStringList & pointIdentifiers,
bool isX,
bool isY,
double x,
double y )

Constructor for normal creation.

Definition at line 20 of file CmdEditPointGraph.cpp.

26 :
30 m_pointIdentifiers (pointIdentifiers),
31 m_isX (isX),
32 m_isY (isY),
33 m_x (x),
34 m_y (y)
35{
36 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::CmdEditPointGraph point="
37 << pointIdentifiers.join(" ").toLatin1 ().data ()
38 << " x=" << (m_isX ? QString::number (x).toLatin1().data() : "")
39 << " y=" << (m_isY ? QString::number (y).toLatin1().data() : "");
40}
const QString CMD_DESCRIPTION("Add axis point")
log4cpp::Category * mainCat
Definition Logger.cpp:14
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

◆ CmdEditPointGraph() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 42 of file CmdEditPointGraph.cpp.

45 :
48 cmdDescription)
49{
50 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::CmdEditPointGraph";
51
52 QXmlStreamAttributes attributes = reader.attributes();
53
54 QStringList requiredAttributesLeaf;
55 requiredAttributesLeaf << DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_X
59 leafAndBaseAttributes (attributes,
60 requiredAttributesLeaf,
61 reader);
62
63 // Boolean attributes
64 QString isX = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_X).toString();
65 QString isY = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_Y).toString();
66
67 m_isX = (isX == DOCUMENT_SERIALIZE_BOOL_TRUE);
68 m_isY = (isY == DOCUMENT_SERIALIZE_BOOL_TRUE);
69 m_x = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_X).toDouble();
70 m_y = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_Y).toDouble();
71
72 bool success = true;
73 while (loadNextFromReader (reader)) {
74
75 if (reader.atEnd() || reader.hasError ()) {
76 success = false;
77 break;
78 }
79
80 if ((reader.tokenType() == QXmlStreamReader::EndElement) &
81 (reader.name() == DOCUMENT_SERIALIZE_CMD)) {
82 break;
83 }
84
85 // Not done yet
86 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
87 (reader.name() == DOCUMENT_SERIALIZE_POINT)) {
88
89 // This is an entry that we need to add
90 QXmlStreamAttributes attributes = reader.attributes ();
91
92 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
93
94 m_pointIdentifiers << attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
95 }
96 }
97
98 if (!success) {
99 reader.raiseError (QObject::tr ("Cannot read graph points"));
100 }
101 }
102}
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_X
const QString DOCUMENT_SERIALIZE_POINT
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_EDIT_GRAPH_X
const QString DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_Y
const QString DOCUMENT_SERIALIZE_EDIT_GRAPH_Y
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
QXmlStreamReader::TokenType loadNextFromReader(QXmlStreamReader &reader)
Load next token from xml reader.
Definition Xml.cpp:14
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...

◆ ~CmdEditPointGraph()

CmdEditPointGraph::~CmdEditPointGraph ( )
virtual

Definition at line 104 of file CmdEditPointGraph.cpp.

105{
106}

Member Function Documentation

◆ cmdRedo()

void CmdEditPointGraph::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 108 of file CmdEditPointGraph.cpp.

109{
110 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::cmdRedo";
111
112 restoreState ();
115 document().editPointGraph (m_isX,
116 m_isY,
117 m_x,
118 m_y,
119 m_pointIdentifiers,
120 mainWindow().transformation());
121 document().updatePointOrdinals (mainWindow().transformation());
124}
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 editPointGraph(bool isX, bool isY, double x, double y, const QStringList &identifiers, const Transformation &transformation)
Edit the graph coordinates of one or more graph points.
Definition Document.cpp:383
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdEditPointGraph::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 126 of file CmdEditPointGraph.cpp.

127{
128 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::cmdUndo";
129
130 restoreState ();
135}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 137 of file CmdEditPointGraph.cpp.

138{
139 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
141 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
142 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_X, m_isX ?
145 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_Y, m_isY ?
148 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_X, QString::number (m_x));
149 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_Y, QString::number (m_y));
150
151 for (int index = 0; index < m_pointIdentifiers.count(); index++) {
152
153 writer.writeStartElement (DOCUMENT_SERIALIZE_POINT);
154 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_pointIdentifiers.at (index));
155 writer.writeEndElement();
156 }
157 baseAttributes (writer);
158 writer.writeEndElement();
159}
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_EDIT_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
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: