4 #include "DocumentSerialize.h"
5 #include "EngaugeAssert.h"
6 #include "ExportToClipboard.h"
7 #include "GraphicsItemType.h"
8 #include "GraphicsView.h"
10 #include "MainWindow.h"
11 #include "MimePoints.h"
12 #include <QApplication>
14 #include <QTextStream>
15 #include "QtToString.h"
16 #include <QXmlStreamReader>
18 const QString CMD_DESCRIPTION (
"Cut");
22 const QStringList &selectedPointIdentifiers) :
26 m_transformIsDefined (mainWindow.transformIsDefined())
28 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::CmdCut"
29 <<
" selected=(" << selectedPointIdentifiers.join (
", ").toLatin1 ().data () <<
")";
33 QTextStream strCsv (&m_csv), strHtml (&m_html);
40 m_curvesGraphsRemoved);
45 const QString &cmdDescription,
46 QXmlStreamReader &reader) :
51 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::CmdCut";
53 QXmlStreamAttributes attributes = reader.attributes();
55 if (!attributes.hasAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED) ||
56 !attributes.hasAttribute(DOCUMENT_SERIALIZE_CSV) ||
57 !attributes.hasAttribute(DOCUMENT_SERIALIZE_HTML)) {
58 ENGAUGE_ASSERT (
false);
61 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
63 m_transformIsDefined = (defined == DOCUMENT_SERIALIZE_BOOL_TRUE);
64 m_csv = attributes.value(DOCUMENT_SERIALIZE_CSV).toString();
65 m_html = attributes.value(DOCUMENT_SERIALIZE_HTML).toString();
66 m_curvesGraphsRemoved.
loadXml(reader);
75 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::cmdRedo";
78 if (m_transformIsDefined) {
85 QClipboard *clipboard = QApplication::clipboard();
86 clipboard->setMimeData (mimePoints, QClipboard::Clipboard);
96 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::cmdUndo";
106 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
107 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_CUT);
108 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
109 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
110 m_transformIsDefined ? DOCUMENT_SERIALIZE_BOOL_TRUE: DOCUMENT_SERIALIZE_BOOL_FALSE);
111 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
112 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
113 m_curvesGraphsRemoved.
saveXml(writer);
114 writer.writeEndElement();
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
CmdCut(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
Transformation transformation() const
Return read-only copy of transformation.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
const Curve & curveAxes() const
Get method for axis curve.
Custom mime type for separate treatment of graph coordinates and, when there is no transform...
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.
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Storage of one imported image and the data attached to that image.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
Document & document()
Return the Document that this command will modify during redo and undo.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.