1 #include "CmdMediator.h"
2 #include "DocumentModelExportFormat.h"
3 #include "DocumentSerialize.h"
6 #include <QXmlStreamWriter>
9 const QStringList DEFAULT_CURVE_NAMES_NOT_EXPORTED;
10 const double DEFAULT_POINTS_INTERVAL_FUNCTIONS = 10;
11 const double DEFAULT_POINTS_INTERVAL_RELATIONS = 10;
12 const QString DEFAULT_X_LABEL (
"x");
13 const ExportPointsIntervalUnits DEFAULT_POINTS_INTERVAL_UNITS_FUNCTIONS = EXPORT_POINTS_INTERVAL_UNITS_SCREEN;
14 const ExportPointsIntervalUnits DEFAULT_POINTS_INTERVAL_UNITS_RELATIONS = EXPORT_POINTS_INTERVAL_UNITS_SCREEN;
17 m_curveNamesNotExported (DEFAULT_CURVE_NAMES_NOT_EXPORTED),
18 m_pointsSelectionFunctions (EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES),
19 m_pointsIntervalFunctions (DEFAULT_POINTS_INTERVAL_FUNCTIONS),
20 m_pointsIntervalUnitsFunctions (DEFAULT_POINTS_INTERVAL_UNITS_FUNCTIONS),
21 m_pointsSelectionRelations (EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE),
22 m_pointsIntervalRelations (DEFAULT_POINTS_INTERVAL_RELATIONS),
23 m_pointsIntervalUnitsRelations (DEFAULT_POINTS_INTERVAL_UNITS_RELATIONS),
24 m_layoutFunctions (EXPORT_LAYOUT_ALL_PER_LINE),
25 m_delimiter (EXPORT_DELIMITER_COMMA),
26 m_header (EXPORT_HEADER_SIMPLE),
27 m_xLabel (DEFAULT_X_LABEL)
32 m_curveNamesNotExported (document.modelExport().curveNamesNotExported()),
33 m_pointsSelectionFunctions (document.modelExport().pointsSelectionFunctions()),
34 m_pointsIntervalFunctions (document.modelExport().pointsIntervalFunctions()),
35 m_pointsIntervalUnitsFunctions (document.modelExport().pointsIntervalUnitsFunctions()),
36 m_pointsSelectionRelations (document.modelExport().pointsSelectionRelations()),
37 m_pointsIntervalRelations (document.modelExport().pointsIntervalRelations()),
38 m_pointsIntervalUnitsRelations (document.modelExport().pointsIntervalUnitsRelations()),
39 m_layoutFunctions (document.modelExport().layoutFunctions()),
40 m_delimiter (document.modelExport().delimiter()),
41 m_header (document.modelExport().header()),
42 m_xLabel (document.modelExport().xLabel())
47 m_curveNamesNotExported (other.curveNamesNotExported()),
48 m_pointsSelectionFunctions (other.pointsSelectionFunctions()),
49 m_pointsIntervalFunctions (other.pointsIntervalFunctions()),
50 m_pointsIntervalUnitsFunctions (other.pointsIntervalUnitsFunctions()),
51 m_pointsSelectionRelations (other.pointsSelectionRelations()),
52 m_pointsIntervalRelations (other.pointsIntervalRelations()),
53 m_pointsIntervalUnitsRelations (other.pointsIntervalUnitsRelations()),
54 m_layoutFunctions (other.layoutFunctions()),
55 m_delimiter (other.delimiter()),
56 m_header (other.header()),
57 m_xLabel (other.xLabel ())
81 return m_curveNamesNotExported;
96 return m_layoutFunctions;
101 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelExportFormat::loadXml";
105 QXmlStreamAttributes attributes = reader.attributes();
107 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS) &&
108 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_FUNCTIONS) &&
109 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS) &&
110 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS) &&
111 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_RELATIONS) &&
112 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS) &&
113 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS) &&
114 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER) &&
115 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER) &&
116 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_X_LABEL)) {
118 setPointsSelectionFunctions ((ExportPointsSelectionFunctions) attributes.value(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS).toInt());
124 setLayoutFunctions ((ExportLayoutFunctions) attributes.value(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS).toInt());
125 setDelimiter ((ExportDelimiter) attributes.value (DOCUMENT_SERIALIZE_EXPORT_DELIMITER).toInt());
126 setHeader ((ExportHeader) attributes.value(DOCUMENT_SERIALIZE_EXPORT_HEADER).toInt());
127 setXLabel (attributes.value(DOCUMENT_SERIALIZE_EXPORT_X_LABEL).toString());
130 while ((loadNextFromReader (reader) != QXmlStreamReader::StartElement) ||
131 (reader.name() != DOCUMENT_SERIALIZE_EXPORT_CURVE_NAMES_NOT_EXPORTED)) {
133 if (reader.atEnd()) {
143 QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
144 while (tokenType == QXmlStreamReader::StartElement) {
146 if (reader.name() == DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED) {
147 curveNamesNotExported << reader.text().toString();
149 tokenType = loadNextFromReader(reader);
156 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
157 (reader.name() != DOCUMENT_SERIALIZE_EXPORT)){
158 loadNextFromReader(reader);
159 if (reader.atEnd()) {
168 reader.raiseError (
"Cannot read export data");
174 return m_pointsIntervalFunctions;
179 return m_pointsIntervalRelations;
184 return m_pointsIntervalUnitsFunctions;
189 return m_pointsIntervalUnitsRelations;
194 return m_pointsSelectionFunctions;
199 return m_pointsSelectionRelations;
203 QTextStream &str)
const
205 str << indentation <<
"DocumentModelExportFormat\n";
207 indentation += INDENTATION_DELTA;
209 str << indentation <<
"curveNamesNotExported=";
210 QStringList::const_iterator itr;
211 for (itr = m_curveNamesNotExported.begin (); itr != m_curveNamesNotExported.end(); itr++) {
212 QString curveName = *itr;
213 str << indentation << curveName <<
" ";
217 str << indentation <<
"exportPointsSelectionFunctions="
218 << exportPointsSelectionFunctionsToString (m_pointsSelectionFunctions) <<
"\n";
219 str << indentation <<
"pointsIntervalFunctions=" << m_pointsIntervalFunctions <<
"\n";
220 str << indentation <<
"pointsIntervalUnitsFunctions="
221 << exportPointsIntervalUnitsToString (m_pointsIntervalUnitsFunctions) <<
"\n";
222 str << indentation <<
"exportPointsSelectionRelations="
223 << exportPointsSelectionRelationsToString (m_pointsSelectionRelations) <<
"\n";
224 str << indentation <<
"pointsIntervalRelations=" << m_pointsIntervalRelations <<
"\n";
225 str << indentation <<
"pointsIntervalUnitsRelations="
226 << exportPointsIntervalUnitsToString (m_pointsIntervalUnitsRelations) <<
"\n";
227 str << indentation <<
"exportLayoutFunctions=" << exportLayoutFunctionsToString (m_layoutFunctions) <<
"\n";
228 str << indentation <<
"exportDelimiter=" << exportDelimiterToString (m_delimiter) <<
"\n";
229 str << indentation <<
"exportHeader=" << exportHeaderToString (m_header) <<
"\n";
230 str << indentation <<
"xLabel=" << m_xLabel <<
"\n";
235 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelExportFormat::saveXml";
237 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT);
238 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS, QString::number (m_pointsSelectionFunctions));
239 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS_STRING, exportPointsSelectionFunctionsToString (m_pointsSelectionFunctions));
240 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_FUNCTIONS, QString::number (m_pointsIntervalFunctions));
241 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS, QString::number (m_pointsIntervalUnitsFunctions));
242 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS, QString::number (m_pointsSelectionRelations));
243 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS_STRING, exportPointsSelectionRelationsToString (m_pointsSelectionRelations));
244 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS, QString::number (m_pointsIntervalUnitsRelations));
245 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_RELATIONS, QString::number (m_pointsIntervalRelations));
246 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS, QString::number (m_layoutFunctions));
247 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS_STRING, exportLayoutFunctionsToString (m_layoutFunctions));
248 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER, QString::number (m_delimiter));
249 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER_STRING, exportDelimiterToString (m_delimiter));
250 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER, QString::number (m_header));
251 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER_STRING, exportHeaderToString (m_header));
252 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_X_LABEL, m_xLabel);
255 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAMES_NOT_EXPORTED);
256 QStringList::const_iterator itr;
257 for (itr = m_curveNamesNotExported.begin (); itr != m_curveNamesNotExported.end (); itr++) {
258 QString curveNameNotExported = *itr;
259 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED);
260 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED_NAME, curveNameNotExported);
261 writer.writeEndElement();
263 writer.writeEndElement();
265 writer.writeEndElement();
Storage of one imported image and the data attached to that image.