Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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
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.
 
MainWindowmainWindow ()
 Return the MainWindow so it can be updated by this command as a last step.
 
void resetSelection (const PointIdentifiers &pointIdentifiersToSelect)
 Since the set of selected points has probably changed, changed that set back to the specified set.
 
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.
 

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")
const int INNER_RADIUS_MIN
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.
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications.
#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
53
59 QString ("%1 %2, %3, %4 %5 %6")
60 .arg (QObject::tr ("Missing attribute(s)"))
64 .arg (QObject::tr ("and/or"))
66 } else {
67
68 // Boolean attributes
71
74 m_x = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_X).toDouble();
75 m_y = attributes.value(DOCUMENT_SERIALIZE_EDIT_GRAPH_Y).toDouble();
76
77 bool success = true;
78 while (loadNextFromReader (reader)) {
79
80 if (reader.atEnd() || reader.hasError ()) {
81 success = false;
82 break;
83 }
84
85 if ((reader.tokenType() == QXmlStreamReader::EndElement) &
86 (reader.name() == DOCUMENT_SERIALIZE_CMD)) {
87 break;
88 }
89
90 // Not done yet
91 if ((reader.tokenType() == QXmlStreamReader::StartElement) &&
92 (reader.name() == DOCUMENT_SERIALIZE_POINT)) {
93
94 // This is an entry that we need to add
96
97 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
98
99 m_pointIdentifiers << attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
100 }
101 }
102 }
103
104 if (!success) {
105 reader.raiseError (QObject::tr ("Cannot read graph points"));
106 }
107 }
108}
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 xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition Xml.cpp:25

◆ ~CmdEditPointGraph()

CmdEditPointGraph::~CmdEditPointGraph ( )
virtual

Definition at line 110 of file CmdEditPointGraph.cpp.

111{
112}

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 114 of file CmdEditPointGraph.cpp.

115{
116 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::cmdRedo";
117
120 document().editPointGraph (m_isX,
121 m_isY,
122 m_x,
123 m_y,
124 m_pointIdentifiers,
125 mainWindow().transformation());
126 document().updatePointOrdinals (mainWindow().transformation());
129}
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 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:377
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 131 of file CmdEditPointGraph.cpp.

132{
133 LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointGraph::cmdUndo";
134
139}
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 141 of file CmdEditPointGraph.cpp.

142{
143 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
145 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
146 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_X, m_isX ?
149 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_IS_Y, m_isY ?
152 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_X, QString::number (m_x));
153 writer.writeAttribute(DOCUMENT_SERIALIZE_EDIT_GRAPH_Y, QString::number (m_y));
154
155 for (int index = 0; index < m_pointIdentifiers.count(); index++) {
156
157 writer.writeStartElement (DOCUMENT_SERIALIZE_POINT);
158 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_pointIdentifiers.at (index));
159 writer.writeEndElement();
160 }
161 writer.writeEndElement();
162}
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

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