Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
CmdAddPointGraph Class Reference

Command for adding one graph point. More...

#include <CmdAddPointGraph.h>

Inheritance diagram for CmdAddPointGraph:
Inheritance graph
Collaboration diagram for CmdAddPointGraph:
Collaboration graph

Public Member Functions

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

Definition at line 17 of file CmdAddPointGraph.h.

Constructor & Destructor Documentation

CmdAddPointGraph::CmdAddPointGraph ( MainWindow mainWindow,
Document document,
const QString &  curveName,
const QPointF &  posScreen,
double  ordinal 
)

Constructor for normal creation.

Definition at line 19 of file CmdAddPointGraph.cpp.

23  :
24  CmdPointChangeBase (mainWindow,
25  document,
27  m_curveName (curveName),
28  m_posScreen (posScreen),
29  m_ordinal (ordinal)
30 {
31  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph"
32  << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ()
33  << " ordinal=" << m_ordinal;
34 }
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
CmdAddPointGraph::CmdAddPointGraph ( MainWindow mainWindow,
Document document,
const QString &  cmdDescription,
QXmlStreamReader &  reader 
)

Constructor for parsing error report file xml.

Definition at line 36 of file CmdAddPointGraph.cpp.

39  :
40  CmdPointChangeBase (mainWindow,
41  document,
42  cmdDescription)
43 {
44  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::CmdAddPointGraph";
45 
46  QXmlStreamAttributes attributes = reader.attributes();
47 
48  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_X) ||
49  !attributes.hasAttribute(DOCUMENT_SERIALIZE_SCREEN_Y) ||
50  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CURVE_NAME) ||
51  !attributes.hasAttribute(DOCUMENT_SERIALIZE_ORDINAL) ||
52  !attributes.hasAttribute(DOCUMENT_SERIALIZE_IDENTIFIER)) {
53  xmlExitWithError (reader,
54  QString ("Missing attribute(s) %1, %2, %3, %4 and/or %5")
60  }
61 
62  m_posScreen.setX(attributes.value(DOCUMENT_SERIALIZE_SCREEN_X).toDouble());
63  m_posScreen.setY(attributes.value(DOCUMENT_SERIALIZE_SCREEN_Y).toDouble());
64  m_curveName = attributes.value(DOCUMENT_SERIALIZE_CURVE_NAME).toString();
65  m_identifierAdded = attributes.value(DOCUMENT_SERIALIZE_IDENTIFIER).toString();
66  m_ordinal = attributes.value(DOCUMENT_SERIALIZE_ORDINAL).toDouble();
67 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_ORDINAL
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
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
const QString DOCUMENT_SERIALIZE_CURVE_NAME
CmdAddPointGraph::~CmdAddPointGraph ( )
virtual

Definition at line 69 of file CmdAddPointGraph.cpp.

70 {
71 }

Member Function Documentation

void CmdAddPointGraph::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 73 of file CmdAddPointGraph.cpp.

74 {
75  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::cmdRedo";
76 
80  m_posScreen,
81  m_identifierAdded,
82  m_ordinal);
83  document().updatePointOrdinals (mainWindow().transformation());
86 }
void addPointGraphWithGeneratedIdentifier(const QString &curveName, const QPointF &posScreen, QString &generatedIentifier, double ordinal)
Add a single graph point with a generated point identifier.
Definition: Document.cpp:195
#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
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 CmdAddPointGraph::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 88 of file CmdAddPointGraph.cpp.

89 {
90  LOG4CPP_INFO_S ((*mainCat)) << "CmdAddPointGraph::cmdUndo";
91 
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 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 CmdAddPointGraph::saveXml ( QXmlStreamWriter &  writer) const
virtual

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 98 of file CmdAddPointGraph.cpp.

99 {
100  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
102  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
103  writer.writeAttribute(DOCUMENT_SERIALIZE_CURVE_NAME, m_curveName);
104  writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_X, QString::number (m_posScreen.x()));
105  writer.writeAttribute(DOCUMENT_SERIALIZE_SCREEN_Y, QString::number (m_posScreen.y()));
106  writer.writeAttribute(DOCUMENT_SERIALIZE_IDENTIFIER, m_identifierAdded);
107  writer.writeAttribute(DOCUMENT_SERIALIZE_ORDINAL, QString::number (m_ordinal));
108  writer.writeEndElement();
109 }
const QString DOCUMENT_SERIALIZE_CMD_ADD_POINT_GRAPH
const QString DOCUMENT_SERIALIZE_SCREEN_Y
const QString DOCUMENT_SERIALIZE_ORDINAL
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_IDENTIFIER
const QString DOCUMENT_SERIALIZE_SCREEN_X
const QString DOCUMENT_SERIALIZE_CURVE_NAME
const QString DOCUMENT_SERIALIZE_CMD

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