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

Command for adding one axis point. More...

#include <CmdAddPointAxis.h>

Inheritance diagram for CmdAddPointAxis:
Inheritance graph
Collaboration diagram for CmdAddPointAxis:
Collaboration graph

Public Member Functions

 CmdAddPointAxis (MainWindow &mainWindow, Document &document, const QPointF &posScreen, const QPointF &posGraph, double ordinal, bool isXOnly)
 Constructor for normal creation.
 CmdAddPointAxis (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdAddPointAxis ()
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 axis point.

Definition at line 16 of file CmdAddPointAxis.h.

Constructor & Destructor Documentation

◆ CmdAddPointAxis() [1/2]

CmdAddPointAxis::CmdAddPointAxis ( MainWindow & mainWindow,
Document & document,
const QPointF & posScreen,
const QPointF & posGraph,
double ordinal,
bool isXOnly )

Constructor for normal creation.

Definition at line 20 of file CmdAddPointAxis.cpp.

25 :
29 m_posScreen (posScreen),
30 m_posGraph (posGraph),
31 m_ordinal (ordinal),
32 m_isXOnly (isXOnly)
33{
34 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::CmdAddPointAxis"
35 << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
36 << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ()
37 << " ordinal=" << ordinal;
38}
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

◆ CmdAddPointAxis() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 40 of file CmdAddPointAxis.cpp.

43 :
46 cmdDescription)
47{
48 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::CmdAddPointAxis";
49
50 QXmlStreamAttributes attributes = reader.attributes();
51
52 // Base attributes are handled by CmdPointChangeBase
53 QStringList requiredAttributesLeaf;
54 requiredAttributesLeaf << DOCUMENT_SERIALIZE_SCREEN_X
61 leafAttributes (attributes,
62 requiredAttributesLeaf,
63 reader);
64
65 // Boolean values
66 QString isXOnlyValue = attributes.value(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY).toString();
67
68 m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
69 m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
70 m_posGraph.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X).toDouble());
71 m_posGraph.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y).toDouble());
72 m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
73 m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
74 m_isXOnly = (isXOnlyValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
75}
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_GRAPH_X
const QString DOCUMENT_SERIALIZE_GRAPH_Y
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_ORDINAL
const QString DOCUMENT_SERIALIZE_SCREEN_X
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
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...

◆ ~CmdAddPointAxis()

CmdAddPointAxis::~CmdAddPointAxis ( )
virtual

Definition at line 77 of file CmdAddPointAxis.cpp.

78{
79}

Member Function Documentation

◆ cmdRedo()

void CmdAddPointAxis::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 81 of file CmdAddPointAxis.cpp.

82{
83 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::cmdRedo";
84
85 restoreState ();
89 m_posGraph,
90 m_identifierAdded,
91 m_ordinal,
92 m_isXOnly);
93 document().updatePointOrdinals (mainWindow().transformation());
95 selectAddedPointForMoving (m_identifierAdded);
97}
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 addPointAxisWithGeneratedIdentifier(const QPointF &posScreen, const QPointF &posGraph, QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with a generated point identifier.
Definition Document.cpp:171
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdAddPointAxis::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 99 of file CmdAddPointAxis.cpp.

100{
101 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::cmdUndo";
102
103 restoreState ();
108}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 110 of file CmdAddPointAxis.cpp.

111{
112 // For time coordinates, many digits of precision are needed since a typical date is 1,246,870,000 = July 6, 2009
113 // and we want seconds of precision
114 const char FORMAT = 'g';
115 const int PRECISION = 16;
116
117 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
119 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
120 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen.x()));
121 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen.y()));
122 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_X, QString::number (m_posGraph.x(), FORMAT, PRECISION));
123 writer.writeAttribute(DOCUMENT_SERIALIZE_GRAPH_Y, QString::number (m_posGraph.y(), FORMAT, PRECISION));
124 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded);
125 writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal));
126 writer.writeAttribute(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY, m_isXOnly ?
129 baseAttributes (writer);
130 writer.writeEndElement();
131}
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_AXIS
const QString DOCUMENT_SERIALIZE_CMD
const QString DOCUMENT_SERIALIZE_CMD_TYPE
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: