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

Command for adding one scale point. More...

#include <CmdAddScale.h>

Inheritance diagram for CmdAddScale:
Inheritance graph
Collaboration diagram for CmdAddScale:
Collaboration graph

Public Member Functions

 CmdAddScale (MainWindow &mainWindow, Document &document, const QPointF &posScreen0, const QPointF &posScreen1, double scaleLength, double ordinal0, double ordinal1)
 Constructor for normal creation.
 CmdAddScale (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml.
virtual ~CmdAddScale ()
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 scale point.

Definition at line 16 of file CmdAddScale.h.

Constructor & Destructor Documentation

◆ CmdAddScale() [1/2]

CmdAddScale::CmdAddScale ( MainWindow & mainWindow,
Document & document,
const QPointF & posScreen0,
const QPointF & posScreen1,
double scaleLength,
double ordinal0,
double ordinal1 )

Constructor for normal creation.

Definition at line 19 of file CmdAddScale.cpp.

25 :
29 m_posScreen0 (posScreen0),
30 m_posScreen1 (posScreen1),
31 m_scaleLength (scaleLength),
32 m_ordinal0 (ordinal0),
33 m_ordinal1 (ordinal1)
34{
35 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddScale::CmdAddScale"
36 << " posScreen0=" << QPointFToString (posScreen0).toLatin1 ().data ()
37 << " posScreen1=" << QPointFToString (posScreen1).toLatin1 ().data ()
38 << " scaleLength=" << scaleLength
39 << " ordinal0=" << ordinal0
40 << " ordinal1=" << ordinal1;
41}
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

◆ CmdAddScale() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 43 of file CmdAddScale.cpp.

46 :
49 cmdDescription)
50{
51 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddScale::CmdAddScale";
52
53 QXmlStreamAttributes attributes = reader.attributes();
54
55 QStringList requiredAttributesLeaf;
56 requiredAttributesLeaf << DOCUMENT_SERIALIZE_SCREEN_X
65 leafAndBaseAttributes (attributes,
66 requiredAttributesLeaf,
67 reader);
68
69 m_posScreen0.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
70 m_posScreen0.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
71 m_posScreen1.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X1).toDouble());
72 m_posScreen1.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y1).toDouble());
73 m_scaleLength = attributes.value(DOCUMENT_SERIALIZE_SCALE_LENGTH).toDouble();
74 m_identifierAdded0 = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
75 m_identifierAdded1 = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER1).toString();
76 m_ordinal0 = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
77 m_ordinal1 = attributes.value(DOCUMENT_SERIALIZE_ORDINAL1).toDouble();
78}
const QString DOCUMENT_SERIALIZE_SCREEN_X1
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_ORDINAL1
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_ORDINAL
const QString DOCUMENT_SERIALIZE_SCREEN_X
const QString DOCUMENT_SERIALIZE_SCALE_LENGTH
const QString DOCUMENT_SERIALIZE_SCREEN_Y1
const QString DOCUMENT_SERIALIZE_IDENTIFIER1
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...

◆ ~CmdAddScale()

CmdAddScale::~CmdAddScale ( )
virtual

Definition at line 80 of file CmdAddScale.cpp.

81{
82}

Member Function Documentation

◆ cmdRedo()

void CmdAddScale::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 84 of file CmdAddScale.cpp.

85{
86 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddScale::cmdRedo";
87
88 restoreState ();
92 m_posScreen1,
93 m_scaleLength,
94 m_identifierAdded0,
95 m_identifierAdded1,
96 m_ordinal0,
97 m_ordinal1);
98 document().updatePointOrdinals (mainWindow().transformation());
101}
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 addScaleWithGeneratedIdentifier(const QPointF &posScreen0, const QPointF &posScreen1, double scaleLength, QString &identifier0, QString &identifier1, double ordinal0, double ordinal1)
Add scale with a generated point identifier.
Definition Document.cpp:234
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.

◆ cmdUndo()

void CmdAddScale::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 103 of file CmdAddScale.cpp.

104{
105 LOG4CPP_INFO_S ((*mainCat)) << "CmdAddScale::cmdUndo";
106
107 restoreState ();
112}
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 114 of file CmdAddScale.cpp.

115{
116 // For time coordinates, many digits of precision are needed since a typical date is 1,246,870,000 = July 6, 2009
117 // and we want seconds of precision
118 const char FORMAT = 'g';
119 const int PRECISION = 16;
120
121 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
123 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
124 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen0.x()));
125 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen0.y()));
126 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X1, QString::number (m_posScreen1.x()));
127 writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y1, QString::number (m_posScreen1.y()));
128 writer.writeAttribute(DOCUMENT_SERIALIZE_SCALE_LENGTH, QString::number (m_scaleLength, FORMAT, PRECISION));
129 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded0);
130 writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER1, m_identifierAdded1);
131 writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal0));
132 writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL1, QString::number (m_ordinal1));
133 baseAttributes (writer);
134 writer.writeEndElement();
135}
const QString DOCUMENT_SERIALIZE_CMD_ADD_SCALE
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: