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

Command for editing the graph coordinates one axis point. More...

#include <CmdEditPointAxis.h>

Inheritance diagram for CmdEditPointAxis:
Inheritance graph
Collaboration diagram for CmdEditPointAxis:
Collaboration graph

Public Member Functions

 CmdEditPointAxis (MainWindow &mainWindow, Document &document, const QString &pointIdentifier, const QPointF &posGraphBefore, const QPointF &posGraphAfter, bool isXOnly)
 Constructor for normal creation. More...
 
 CmdEditPointAxis (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdEditPointAxis ()
 
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 editing the graph coordinates one axis point.

The screen coordinates are handled by another command

Definition at line 18 of file CmdEditPointAxis.h.

Constructor & Destructor Documentation

◆ CmdEditPointAxis() [1/2]

CmdEditPointAxis::CmdEditPointAxis ( MainWindow mainWindow,
Document document,
const QString &  pointIdentifier,
const QPointF &  posGraphBefore,
const QPointF &  posGraphAfter,
bool  isXOnly 
)

Constructor for normal creation.

Definition at line 20 of file CmdEditPointAxis.cpp.

25  :
27  document,
29  m_pointIdentifier (pointIdentifier),
30  m_posGraphBefore (posGraphBefore),
31  m_posGraphAfter (posGraphAfter),
32  m_isXOnly (isXOnly)
33 {
34  LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::CmdEditPointAxis point="
35  << pointIdentifier.toLatin1 ().data ()
36  << " posGraphBefore=" << QPointFToString (posGraphBefore).toLatin1 ().data ()
37  << " posGraphAfter=" << QPointFToString (posGraphAfter).toLatin1 ().data ();
38 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
QString QPointFToString(const QPointF &pos)
Definition: QtToString.cpp:17
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
const QString CMD_DESCRIPTION("Edit axis point")
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35

◆ CmdEditPointAxis() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 40 of file CmdEditPointAxis.cpp.

43  :
45  document,
46  cmdDescription)
47 {
48  LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::CmdEditPointAxis";
49 
50  QXmlStreamAttributes attributes = reader.attributes();
51 
52  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE) ||
53  !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE) ||
54  !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X_AFTER) ||
55  !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER) ||
56  !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER) ||
57  !attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY)) {
58  xmlExitWithError (reader,
59  QString ("%1 %2, %3, %4, %5, %6 %7 %8")
60  .arg (QObject::tr ("Missing attribute(s)"))
66  .arg (QObject::tr ("and/or"))
68  }
69 
70  // Boolean values
71  QString isXOnlyValue = attributes.value(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY).toString();
72 
73  m_posGraphBefore.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE).toDouble());
74  m_posGraphBefore.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE).toDouble());
75  m_posGraphAfter.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X_AFTER).toDouble());
76  m_posGraphAfter.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER).toDouble());
77  m_pointIdentifier = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
78  m_isXOnly = (isXOnlyValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
79 }
const QString DOCUMENT_SERIALIZE_GRAPH_Y_AFTER
const QString DOCUMENT_SERIALIZE_GRAPH_X_BEFORE
const QString DOCUMENT_SERIALIZE_GRAPH_X_AFTER
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_IDENTIFIER
log4cpp::Category * mainCat
Definition: Logger.cpp:14
const QString DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition: Xml.cpp:25
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35

◆ ~CmdEditPointAxis()

CmdEditPointAxis::~CmdEditPointAxis ( )
virtual

Definition at line 81 of file CmdEditPointAxis.cpp.

82 {
83 }

Member Function Documentation

◆ cmdRedo()

void CmdEditPointAxis::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 85 of file CmdEditPointAxis.cpp.

86 {
87  LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::cmdRedo";
88 
91  document().editPointAxis (m_posGraphAfter,
92  m_pointIdentifier);
93  document().updatePointOrdinals (mainWindow().transformation());
96 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void saveOrCheckPostCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
void editPointAxis(const QPointF &posGraph, const QString &identifier)
Edit the graph coordinates of a single axis point. Call this after checkAddPointAxis to guarantee suc...
Definition: Document.cpp:368
void saveOrCheckPreCommandDocumentStateHash(const Document &document)
Save, when called the first time, a hash value representing the state of the Document.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
Definition: Document.cpp:1066
void saveDocumentState(const Document &document)
Save the document state for restoration by restoreDocumentState.

◆ cmdUndo()

void CmdEditPointAxis::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 98 of file CmdEditPointAxis.cpp.

99 {
100  LOG4CPP_INFO_S ((*mainCat)) << "CmdEditPointAxis::cmdUndo";
101 
106 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
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.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
Definition: CmdAbstract.cpp:45
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 108 of file CmdEditPointAxis.cpp.

109 {
110  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
112  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
113  writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_pointIdentifier);
114  writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_BEFORE, QString::number (m_posGraphBefore.x()));
115  writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE, QString::number (m_posGraphBefore.y()));
116  writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X_AFTER, QString::number (m_posGraphAfter.x()));
117  writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y_AFTER, QString::number (m_posGraphAfter.y()));
118  writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY, m_isXOnly ?
121  writer.writeEndElement();
122 }
const QString DOCUMENT_SERIALIZE_GRAPH_Y_AFTER
const QString DOCUMENT_SERIALIZE_GRAPH_X_BEFORE
const QString DOCUMENT_SERIALIZE_GRAPH_X_AFTER
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_CMD_EDIT_POINT_AXIS
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_GRAPH_Y_BEFORE
const QString DOCUMENT_SERIALIZE_CMD

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