1 #include "CmdMediator.h"
2 #include "DocumentModelExportFormat.h"
3 #include "DocumentSerialize.h"
7 #include <QXmlStreamWriter>
11 const QStringList DEFAULT_CURVE_NAMES_NOT_EXPORTED;
12 const double DEFAULT_POINTS_INTERVAL_FUNCTIONS = 10;
13 const double DEFAULT_POINTS_INTERVAL_RELATIONS = 10;
14 const QString DEFAULT_X_LABEL (
"x");
15 const ExportPointsIntervalUnits DEFAULT_POINTS_INTERVAL_UNITS_FUNCTIONS = EXPORT_POINTS_INTERVAL_UNITS_SCREEN;
16 const ExportPointsIntervalUnits DEFAULT_POINTS_INTERVAL_UNITS_RELATIONS = EXPORT_POINTS_INTERVAL_UNITS_SCREEN;
20 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
21 settings.beginGroup (SETTINGS_GROUP_EXPORT);
23 m_curveNamesNotExported = settings.value (SETTINGS_EXPORT_CURVE_NAMES_NOT_EXPORTED,
24 QVariant (DEFAULT_CURVE_NAMES_NOT_EXPORTED)).toStringList();
25 m_delimiter = (ExportDelimiter) settings.value (SETTINGS_EXPORT_DELIMITER,
26 QVariant (EXPORT_DELIMITER_COMMA)).toInt();
27 m_header = (ExportHeader) settings.value (SETTINGS_EXPORT_HEADER,
28 QVariant (EXPORT_HEADER_SIMPLE)).toInt();
29 m_layoutFunctions = (ExportLayoutFunctions) settings.value (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
30 QVariant (EXPORT_LAYOUT_ALL_PER_LINE)).toInt();
31 m_pointsIntervalFunctions = settings.value (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
32 QVariant (DEFAULT_POINTS_INTERVAL_FUNCTIONS)).toDouble();
33 m_pointsIntervalRelations = settings.value (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
34 QVariant (DEFAULT_POINTS_INTERVAL_RELATIONS)).toDouble();
35 m_pointsIntervalUnitsFunctions = (ExportPointsIntervalUnits) settings.value (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
36 QVariant (DEFAULT_POINTS_INTERVAL_UNITS_FUNCTIONS)).toInt();
37 m_pointsIntervalUnitsRelations = (ExportPointsIntervalUnits) settings.value (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
38 QVariant (DEFAULT_POINTS_INTERVAL_UNITS_RELATIONS)).toInt();
39 m_pointsSelectionFunctions = (ExportPointsSelectionFunctions) settings.value (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
40 QVariant (EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES)).toInt();
41 m_pointsSelectionRelations = (ExportPointsSelectionRelations) settings.value (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
42 QVariant (EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE)).toInt();
43 m_xLabel = settings.value (SETTINGS_EXPORT_X_LABEL,
44 QVariant (DEFAULT_X_LABEL)).toString();
48 m_curveNamesNotExported (document.modelExport().curveNamesNotExported()),
49 m_pointsSelectionFunctions (document.modelExport().pointsSelectionFunctions()),
50 m_pointsIntervalFunctions (document.modelExport().pointsIntervalFunctions()),
51 m_pointsIntervalUnitsFunctions (document.modelExport().pointsIntervalUnitsFunctions()),
52 m_pointsSelectionRelations (document.modelExport().pointsSelectionRelations()),
53 m_pointsIntervalRelations (document.modelExport().pointsIntervalRelations()),
54 m_pointsIntervalUnitsRelations (document.modelExport().pointsIntervalUnitsRelations()),
55 m_layoutFunctions (document.modelExport().layoutFunctions()),
56 m_delimiter (document.modelExport().delimiter()),
57 m_header (document.modelExport().header()),
58 m_xLabel (document.modelExport().xLabel())
63 m_curveNamesNotExported (other.curveNamesNotExported()),
64 m_pointsSelectionFunctions (other.pointsSelectionFunctions()),
65 m_pointsIntervalFunctions (other.pointsIntervalFunctions()),
66 m_pointsIntervalUnitsFunctions (other.pointsIntervalUnitsFunctions()),
67 m_pointsSelectionRelations (other.pointsSelectionRelations()),
68 m_pointsIntervalRelations (other.pointsIntervalRelations()),
69 m_pointsIntervalUnitsRelations (other.pointsIntervalUnitsRelations()),
70 m_layoutFunctions (other.layoutFunctions()),
71 m_delimiter (other.delimiter()),
72 m_header (other.header()),
73 m_xLabel (other.xLabel ())
97 return m_curveNamesNotExported;
112 return m_layoutFunctions;
117 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelExportFormat::loadXml";
121 QXmlStreamAttributes attributes = reader.attributes();
123 if (attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS) &&
124 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_FUNCTIONS) &&
125 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS) &&
126 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS) &&
127 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_RELATIONS) &&
128 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS) &&
129 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS) &&
130 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER) &&
131 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER) &&
132 attributes.hasAttribute(DOCUMENT_SERIALIZE_EXPORT_X_LABEL)) {
134 setPointsSelectionFunctions ((ExportPointsSelectionFunctions) attributes.value(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS).toInt());
140 setLayoutFunctions ((ExportLayoutFunctions) attributes.value(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS).toInt());
141 setDelimiter ((ExportDelimiter) attributes.value (DOCUMENT_SERIALIZE_EXPORT_DELIMITER).toInt());
142 setHeader ((ExportHeader) attributes.value(DOCUMENT_SERIALIZE_EXPORT_HEADER).toInt());
143 setXLabel (attributes.value(DOCUMENT_SERIALIZE_EXPORT_X_LABEL).toString());
146 while ((loadNextFromReader (reader) != QXmlStreamReader::StartElement) ||
147 (reader.name() != DOCUMENT_SERIALIZE_EXPORT_CURVE_NAMES_NOT_EXPORTED)) {
149 if (reader.atEnd()) {
159 QXmlStreamReader::TokenType tokenType = loadNextFromReader(reader);
160 while (tokenType == QXmlStreamReader::StartElement) {
162 if (reader.name() == DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED) {
163 curveNamesNotExported << reader.text().toString();
165 tokenType = loadNextFromReader(reader);
172 while ((reader.tokenType() != QXmlStreamReader::EndElement) ||
173 (reader.name() != DOCUMENT_SERIALIZE_EXPORT)){
174 loadNextFromReader(reader);
175 if (reader.atEnd()) {
184 reader.raiseError (
"Cannot read export data");
190 return m_pointsIntervalFunctions;
195 return m_pointsIntervalRelations;
200 return m_pointsIntervalUnitsFunctions;
205 return m_pointsIntervalUnitsRelations;
210 return m_pointsSelectionFunctions;
215 return m_pointsSelectionRelations;
219 QTextStream &str)
const
221 str << indentation <<
"DocumentModelExportFormat\n";
223 indentation += INDENTATION_DELTA;
225 str << indentation <<
"curveNamesNotExported=";
226 QStringList::const_iterator itr;
227 for (itr = m_curveNamesNotExported.begin (); itr != m_curveNamesNotExported.end(); itr++) {
228 QString curveName = *itr;
229 str << indentation << curveName <<
" ";
233 str << indentation <<
"exportPointsSelectionFunctions="
234 << exportPointsSelectionFunctionsToString (m_pointsSelectionFunctions) <<
"\n";
235 str << indentation <<
"pointsIntervalFunctions=" << m_pointsIntervalFunctions <<
"\n";
236 str << indentation <<
"pointsIntervalUnitsFunctions="
237 << exportPointsIntervalUnitsToString (m_pointsIntervalUnitsFunctions) <<
"\n";
238 str << indentation <<
"exportPointsSelectionRelations="
239 << exportPointsSelectionRelationsToString (m_pointsSelectionRelations) <<
"\n";
240 str << indentation <<
"pointsIntervalRelations=" << m_pointsIntervalRelations <<
"\n";
241 str << indentation <<
"pointsIntervalUnitsRelations="
242 << exportPointsIntervalUnitsToString (m_pointsIntervalUnitsRelations) <<
"\n";
243 str << indentation <<
"exportLayoutFunctions=" << exportLayoutFunctionsToString (m_layoutFunctions) <<
"\n";
244 str << indentation <<
"exportDelimiter=" << exportDelimiterToString (m_delimiter) <<
"\n";
245 str << indentation <<
"exportHeader=" << exportHeaderToString (m_header) <<
"\n";
246 str << indentation <<
"xLabel=" << m_xLabel <<
"\n";
251 LOG4CPP_INFO_S ((*mainCat)) <<
"DocumentModelExportFormat::saveXml";
253 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT);
254 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS, QString::number (m_pointsSelectionFunctions));
255 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_FUNCTIONS_STRING, exportPointsSelectionFunctionsToString (m_pointsSelectionFunctions));
256 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_FUNCTIONS, QString::number (m_pointsIntervalFunctions));
257 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS, QString::number (m_pointsIntervalUnitsFunctions));
258 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS, QString::number (m_pointsSelectionRelations));
259 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_SELECTION_RELATIONS_STRING, exportPointsSelectionRelationsToString (m_pointsSelectionRelations));
260 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS, QString::number (m_pointsIntervalUnitsRelations));
261 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_POINTS_INTERVAL_RELATIONS, QString::number (m_pointsIntervalRelations));
262 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS, QString::number (m_layoutFunctions));
263 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_LAYOUT_FUNCTIONS_STRING, exportLayoutFunctionsToString (m_layoutFunctions));
264 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER, QString::number (m_delimiter));
265 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_DELIMITER_STRING, exportDelimiterToString (m_delimiter));
266 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER, QString::number (m_header));
267 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_HEADER_STRING, exportHeaderToString (m_header));
268 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_X_LABEL, m_xLabel);
271 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAMES_NOT_EXPORTED);
272 QStringList::const_iterator itr;
273 for (itr = m_curveNamesNotExported.begin (); itr != m_curveNamesNotExported.end (); itr++) {
274 QString curveNameNotExported = *itr;
275 writer.writeStartElement(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED);
276 writer.writeAttribute(DOCUMENT_SERIALIZE_EXPORT_CURVE_NAME_NOT_EXPORTED_NAME, curveNameNotExported);
277 writer.writeEndElement();
279 writer.writeEndElement();
281 writer.writeEndElement();
Storage of one imported image and the data attached to that image.