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

Command for cutting all selected Points. More...

#include <CmdCut.h>

Inheritance diagram for CmdCut:
Inheritance graph
Collaboration diagram for CmdCut:
Collaboration graph

Public Member Functions

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

Definition at line 18 of file CmdCut.h.

Constructor & Destructor Documentation

◆ CmdCut() [1/2]

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

Constructor for normal creation.

Definition at line 27 of file CmdCut.cpp.

29  :
31  document,
33  m_transformIsDefined (mainWindow.transformIsDefined())
34 {
35  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::CmdCut"
36  << " selected=" << selectedPointIdentifiers.count ();
37 
38  // Export to clipboard
39  ExportToClipboard exportStrategy;
40  QTextStream strCsv (&m_csv), strHtml (&m_html);
41  exportStrategy.exportToClipboard (selectedPointIdentifiers,
43  strCsv,
44  strHtml,
47  m_curvesGraphsRemoved);
48 }
#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.
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
const QString CMD_DESCRIPTION("Cut")
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.

◆ CmdCut() [2/2]

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

Constructor for parsing error report file xml.

Definition at line 50 of file CmdCut.cpp.

53  :
55  document,
56  cmdDescription)
57 {
58  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::CmdCut";
59 
60  QXmlStreamAttributes attributes = reader.attributes();
61 
62  if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
63  !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
64  !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
65  xmlExitWithError (reader,
66  QString ("%1 %2, %3 %4 %5")
67  .arg (QObject::tr ("Missing argument(s)"))
70  .arg (QObject::tr ("and/or"))
72  }
73 
74  QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
75 
76  m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
77  m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
78  m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
79  m_curvesGraphsRemoved.loadXml(reader);
80 }
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
const QString DOCUMENT_SERIALIZE_HTML
const QString DOCUMENT_SERIALIZE_CSV
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
Base class for CmdBase leaf subclasses that involve point additions, deletions and/or modifications...
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

◆ ~CmdCut()

CmdCut::~CmdCut ( )
virtual

Definition at line 82 of file CmdCut.cpp.

83 {
84 }

Member Function Documentation

◆ cmdRedo()

void CmdCut::cmdRedo ( )
virtual

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

Implements CmdAbstract.

Definition at line 86 of file CmdCut.cpp.

87 {
88  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::cmdRedo";
89 
90  MimePointsExport *mimePointsExport;
91  if (m_transformIsDefined) {
92  mimePointsExport = new MimePointsExport (m_csv,
93  m_html);
94  } else {
95  mimePointsExport = new MimePointsExport (m_csv);
96  }
97 
98  QClipboard *clipboard = QApplication::clipboard();
99  clipboard->setMimeData (mimePointsExport, QClipboard::Clipboard);
100 
103  document().removePointsInCurvesGraphs (m_curvesGraphsRemoved);
104 
105  document().updatePointOrdinals (mainWindow().transformation());
108 }
#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...
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
Definition: Document.cpp:877
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.

◆ cmdUndo()

void CmdCut::cmdUndo ( )
virtual

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

Implements CmdAbstract.

Definition at line 110 of file CmdCut.cpp.

111 {
112  LOG4CPP_INFO_S ((*mainCat)) << "CmdCut::cmdUndo";
113 
118 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void restoreDocumentState(Document &document) const
Restore the document previously saved by saveDocumentState.
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

◆ saveXml()

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

Save commands as xml for later uploading.

Implements CmdAbstract.

Definition at line 120 of file CmdCut.cpp.

121 {
122  writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
124  writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
125  writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
127  writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
128  writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
129  m_curvesGraphsRemoved.saveXml(writer);
130  writer.writeEndElement();
131 }
const QString DOCUMENT_SERIALIZE_CMD_CUT
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_TRANSFORM_DEFINED
const QString DOCUMENT_SERIALIZE_CMD

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