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

Command for moving all selected Points by a specified translation. More...

#include <CmdCopy.h>

Inheritance diagram for CmdCopy:
Inheritance graph
Collaboration diagram for CmdCopy:
Collaboration graph

Public Member Functions

 CmdCopy (MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
 Constructor for normal creation. More...
 
 CmdCopy (MainWindow &mainWindow, Document &document, const QString &cmdDescription, QXmlStreamReader &reader)
 Constructor for parsing error report file xml. More...
 
virtual ~CmdCopy ()
 
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 CmdAbstract
 CmdAbstract (MainWindow &mainWindow, Document &document, const QString &cmdDescription)
 Single constructor. More...
 
virtual ~CmdAbstract ()
 

Additional Inherited Members

- 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 moving all selected Points by a specified translation.

Definition at line 18 of file CmdCopy.h.

Constructor & Destructor Documentation

◆ CmdCopy() [1/2]

CmdCopy::CmdCopy ( MainWindow mainWindow,
Document document,
const QStringList &  selectedPointIdentifiers 
)

Constructor for normal creation.

Definition at line 27 of file CmdCopy.cpp.

29  :
31  document,
33  m_transformIsDefined (mainWindow.transformIsDefined())
34 {
35  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::CmdCopy"
36  << " selected=" << selectedPointIdentifiers.count ();
37 
38  ExportToClipboard exportStrategy;
39  QTextStream strCsv (&m_csv), strHtml (&m_html);
40  exportStrategy.exportToClipboard (selectedPointIdentifiers,
42  strCsv,
43  strHtml,
46  m_curvesGraphs);
47 }
const QString CMD_DESCRIPTION("Copy")
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:19
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Transformation transformation() const
Return read-only copy of transformation.
bool transformIsDefined() const
Return true if all three axis points have been defined.
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
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Definition: Document.cpp:342
const Curve & curveAxes() const
Get method for axis curve.
Definition: Document.cpp:321
void exportToClipboard(const QStringList &selected, const Transformation &transformation, QTextStream &strCsv, QTextStream &strHtml, const Curve &curveAxis, const CurvesGraphs &curvesGraphsAll, CurvesGraphs &curvesGraphsSelected) const
Export, curve-by-curve, raw data points to a string that will be copied to the clipboard.

◆ CmdCopy() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 49 of file CmdCopy.cpp.

52  :
54  document,
55  cmdDescription)
56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::CmdCopy";
58 
59  QXmlStreamAttributes attributes = reader.attributes();
60 
61  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
62  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
63  !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
64  xmlExitWithError (reader,
65  QString ("%1 %2, %3 %4 %5")
66  .arg (QObject::tr ("Missing attribute(s)"))
69  .arg (QObject::tr ("and/or"))
71  }
72 
73  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
74 
75  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
76  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
77  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
78  m_curvesGraphs.loadXml(reader);
79 }
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
const QString DOCUMENT_SERIALIZE_HTML
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Definition: CmdAbstract.h:19
const QString DOCUMENT_SERIALIZE_CSV
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
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_TRANSFORM_DEFINED
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
Document & document()
Return the Document that this command will modify during redo and undo.
Definition: CmdAbstract.cpp:35

◆ ~CmdCopy()

CmdCopy::~CmdCopy ( )
virtual

Definition at line 81 of file CmdCopy.cpp.

82 {
83 }

Member Function Documentation

◆ cmdRedo()

void CmdCopy::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 85 of file CmdCopy.cpp.

86 {
87  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdRedo";
88 
89  MimePointsExport *mimePointsExport;
90  if (m_transformIsDefined) {
91  mimePointsExport = new MimePointsExport (m_csv,
92  m_html);
93  } else {
94  mimePointsExport = new MimePointsExport (m_csv);
95  }
96 
97  QClipboard *clipboard = QApplication::clipboard();
98  clipboard->setMimeData (mimePointsExport, QClipboard::Clipboard);
99 
101  document().updatePointOrdinals (mainWindow().transformation());
104 }
#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.
Custom mime type for separate treatment of graph coordinates and, when there is no transform...
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

◆ cmdUndo()

void CmdCopy::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 106 of file CmdCopy.cpp.

107 {
108  LOG4CPP_INFO_S ((*mainCat)) << "CmdCopy::cmdUndo";
109 
111  document().updatePointOrdinals (mainWindow().transformation());
114 }
#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

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 116 of file CmdCopy.cpp.

117 {
118  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
120  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
121  writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
123  writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
124  writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
125  m_curvesGraphs.saveXml(writer);
126  writer.writeEndElement();
127 }
const QString DOCUMENT_SERIALIZE_HTML
const QString DOCUMENT_SERIALIZE_CSV
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
const QString DOCUMENT_SERIALIZE_CMD_TYPE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
const QString DOCUMENT_SERIALIZE_CMD_DESCRIPTION
const QString DOCUMENT_SERIALIZE_CMD_COPY
const QString DOCUMENT_SERIALIZE_TRANSFORM_DEFINED
const QString DOCUMENT_SERIALIZE_CMD

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