10#include "DocumentSerialize.h"
11#include "EngaugeAssert.h"
12#include "ExportToClipboard.h"
13#include "GraphicsItemType.h"
14#include "GraphicsView.h"
16#include "MainWindow.h"
17#include "MimePoints.h"
18#include <QApplication>
21#include "QtToString.h"
22#include <QXmlStreamReader>
25const QString CMD_DESCRIPTION (
"Cut");
29 const QStringList &selectedPointIdentifiers) :
33 m_transformIsDefined (mainWindow.transformIsDefined())
35 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::CmdCut"
36 <<
" selected=(" << selectedPointIdentifiers.join (
", ").toLatin1 ().data () <<
")";
40 QTextStream strCsv (&m_csv), strHtml (&m_html);
47 m_curvesGraphsRemoved);
52 const QString &cmdDescription,
53 QXmlStreamReader &reader) :
58 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::CmdCut";
60 QXmlStreamAttributes attributes = reader.attributes();
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)"))
68 .arg (DOCUMENT_SERIALIZE_TRANSFORM_DEFINED)
69 .arg (DOCUMENT_SERIALIZE_CSV)
70 .arg (QObject::tr (
"and/or"))
71 .arg (DOCUMENT_SERIALIZE_HTML));
74 QString defined = attributes.value(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED).toString();
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);
88 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::cmdRedo";
91 if (m_transformIsDefined) {
98 QClipboard *clipboard = QApplication::clipboard();
99 clipboard->setMimeData (mimePoints, QClipboard::Clipboard);
109 LOG4CPP_INFO_S ((*mainCat)) <<
"CmdCut::cmdUndo";
119 writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
120 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_CUT);
121 writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
122 writer.writeAttribute(DOCUMENT_SERIALIZE_TRANSFORM_DEFINED,
123 m_transformIsDefined ? DOCUMENT_SERIALIZE_BOOL_TRUE: DOCUMENT_SERIALIZE_BOOL_FALSE);
124 writer.writeAttribute(DOCUMENT_SERIALIZE_CSV, m_csv);
125 writer.writeAttribute(DOCUMENT_SERIALIZE_HTML, m_html);
126 m_curvesGraphsRemoved.
saveXml(writer);
127 writer.writeEndElement();
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Document & document()
Return the Document that this command will modify during redo and undo.
MainWindow & mainWindow()
Return the MainWindow so it can be updated by this command as a last step.
virtual void cmdRedo()
Redo method that is called when QUndoStack is moved one command forward.
CmdCut(MainWindow &mainWindow, Document &document, const QStringList &selectedPointIdentifiers)
Constructor for normal creation.
virtual void cmdUndo()
Undo method that is called when QUndoStack is moved one command backward.
virtual void saveXml(QXmlStreamWriter &writer) const
Save commands as xml for later uploading.
void saveXml(QXmlStreamWriter &writer) const
Serialize curves.
void loadXml(QXmlStreamReader &reader)
Load from serialized xml post-version 5 file.
Storage of one imported image and the data attached to that image.
void updatePointOrdinals(const Transformation &transformation)
Update point ordinals after point addition/removal or dragging.
const Curve & curveAxes() const
Get method for axis curve.
void removePointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Remove all points identified in the specified CurvesGraphs. See also addPointsInCurvesGraphs.
const CurvesGraphs & curvesGraphs() const
Make all Curves available, read only, for CmdAbstract classes only.
void addPointsInCurvesGraphs(CurvesGraphs &curvesGraphs)
Add all points identified in the specified CurvesGraphs. See also removePointsInCurvesGraphs.
Strategy class for exporting to the clipboard. This strategy is external to the Document class so tha...
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.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
Transformation transformation() const
Return read-only copy of transformation.
Custom mime type for separate treatment of graph coordinates and, when there is no transform,...