Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
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. More...
 
 CmdAddPointAxis (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdAddPointAxis ()
 
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 adding one axis point.

Definition at line 16 of file CmdAddPointAxis.h.

Constructor & Destructor Documentation

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

Constructor for normal creation.

Definition at line 19 of file CmdAddPointAxis.cpp.

24  :
25  CmdPointChangeBase (mainWindow,
26  document,
28  m_posScreen (posScreen),
29  m_posGraph (posGraph),
30  m_ordinal (ordinal),
31  m_isXOnly (isXOnly)
32 {
33  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::CmdAddPointAxis"
34  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
35  << " posGraph=" << QPointFToString (posGraph).toLatin1 ().data ()
36  << " ordinal=" << ordinal;
37 }
const QString CMD_DESCRIPTION("Add axis point")
#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...
log4cpp::Category * mainCat
Definition: Logger.cpp:14
CmdAddPointAxis::CmdAddPointAxis ( MainWindow mainWindow,
Document document,
const QString &  cmdDescription,
QXmlStreamReader &  reader 
)

Constructor for parsing error report file xml.

Definition at line 39 of file CmdAddPointAxis.cpp.

42  :
43  CmdPointChangeBase (mainWindow,
44  document,
45  cmdDescription)
46 {
47  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::CmdAddPointAxis";
48 
49  QXmlStreamAttributes attributes = reader.attributes();
50 
51  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
52  !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
53  !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_X) ||
54  !attributes.hasAttribute(DOCUMENT_SERIALIZE_GRAPH_Y) ||
55  !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER) ||
56  !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
57  !attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY)) {
58  xmlExitWithError (reader,
59  QString ("Missing attribute(s) %1, %2, %3, %4, %5, %6 and/or %7")
67  }
68 
69  // Boolean values
70  QString isXOnlyValue = attributes.value(DOCUMENT_SERIALIZE_POINT_IS_X_ONLY).toString();
71 
72  m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
73  m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
74  m_posGraph.setX(attributes.value(DOCUMENT_SERIALIZE_GRAPH_X).toDouble());
75  m_posGraph.setY(attributes.value(DOCUMENT_SERIALIZE_GRAPH_Y).toDouble());
76  m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
77  m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
78  m_isXOnly = (isXOnlyValue == DOCUMENT_SERIALIZE_BOOL_TRUE);
79 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_GRAPH_X
const QString DOCUMENT_SERIALIZE_ORDINAL
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
const QString DOCUMENT_SERIALIZE_POINT_IS_X_ONLY
const QString DOCUMENT_SERIALIZE_GRAPH_Y
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_SCREEN_X
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void xmlExitWithError(QXmlStreamReader &reader, const QString &message)
Show specified message for an error while reading xml, then quit.
Definition: Xml.cpp:25
CmdAddPointAxis::~CmdAddPointAxis ( )
virtual

Definition at line 81 of file CmdAddPointAxis.cpp.

82 {
83 }

Member Function Documentation

void CmdAddPointAxis::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 85 of file CmdAddPointAxis.cpp.

86 {
87  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::cmdRedo";
88 
92  m_posGraph,
93  m_identifierAdded,
94  m_ordinal,
95  m_isXOnly);
96  document().updatePointOrdinals (mainWindow().transformation());
99 }
#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 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
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:165
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.
void CmdAddPointAxis::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 101 of file CmdAddPointAxis.cpp.

102 {
103  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointAxis::cmdUndo";
104 
109 }
#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 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
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
void CmdAddPointAxis::saveXml ( QXmlStreamWriter &  writer) const
virtual

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 111 of file CmdAddPointAxis.cpp.

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

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