Engauge Digitizer 2
Loading...
Searching...
No Matches
ExportFileAbstractBase.cpp
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "CurveConnectAs.h"
8#include "Document.h"
9#include "EngaugeAssert.h"
10#include "ExportFileAbstractBase.h"
11#include "Logger.h"
12#include <qdebug.h>
13#include <QTextStream>
14#include "SplinePair.h"
15#include "Transformation.h"
16
17using namespace std;
18
22
23QString ExportFileAbstractBase::curveSeparator (const QString *string) const
24{
25 QString separator = "";
26
27 if (string != 0) {
28
29 if (!string->trimmed().isEmpty()) {
30 return "\n";
31 }
32 }
33
34 return separator;
35}
36
38 const Document &document,
39 const QStringList &curvesGraphsNames,
40 CurveConnectAs curveConnectAs1,
41 CurveConnectAs curveConnectAs2) const
42{
43 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileAbstractBase::curvesToInclude";
44
45 QStringList curvesToInclude;
46
47 // Build a list of curves to include by subtracting the excluded curves from the the complete list.
48 // Special case is to use only first included curve if appropriate flag is set
49 QStringList::const_iterator itr;
50 for (itr = curvesGraphsNames.begin(); itr != curvesGraphsNames.end(); itr++) {
51
52 QString curvesGraphName = *itr;
53
54 if (!modelExportOverride.curveNamesNotExported().contains (curvesGraphName)) {
55
56 const Curve *curve = document.curveForCurveName(curvesGraphName);
57 ENGAUGE_CHECK_PTR (curve);
58
59 // Not excluded which means it gets included, but only if it is a function
60 if (curve->curveStyle().lineStyle().curveConnectAs() == curveConnectAs1 ||
61 curve->curveStyle().lineStyle().curveConnectAs() == curveConnectAs2) {
62
63 curvesToInclude.push_back (curvesGraphName);
64 }
65 }
66 }
67
68 return curvesToInclude;
69}
70
71void ExportFileAbstractBase::destroy2DArray (QVector<QVector<QString*> > &array) const
72{
73 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileAbstractBase::destroy2DArray";
74
75 int colCount = array.count();
76 int rowCount = array [0].count();
77 for (int row = 0; row < rowCount; row++) {
78 for (int col = 0; col < colCount; col++) {
79 delete array [col] [row];
80 }
81 }
82}
83
85{
86 return QString ("# ");
87}
88
90 ExportHeader exportHeader,
91 QTextStream &str) const
92{
93 // Insert line(s) between previous curve and this curve
94 if (isFirst) {
95 isFirst = false;
96 } else {
97 if (exportHeader == EXPORT_HEADER_GNUPLOT) {
98 str << "\n\n"; // Gnuplot requires two blank lines between curves
99 } else {
100 str << "\n"; // Single blank line
101 }
102 }
103}
LineStyle lineStyle() const
Get method for LineStyle.
Container for one set of digitized Points.
Definition Curve.h:33
CurveStyle curveStyle() const
Return the curve style.
Definition Curve.cpp:138
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
QStringList curveNamesNotExported() const
Get method for curve names not exported.
Storage of one imported image and the data attached to that image.
Definition Document.h:41
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition Document.cpp:298
void destroy2DArray(QVector< QVector< QString * > > &array) const
Deallocate memory for array.
QString curveSeparator(const QString *string) const
Gnuplot requires, and other graphing tools probably prefer, blank lines between successive curves.
QString gnuplotComment() const
Gnuplot comment delimiter.
QStringList curvesToInclude(const DocumentModelExportFormat &modelExportOverride, const Document &document, const QStringList &curvesGraphsNames, CurveConnectAs curveConnectAs1, CurveConnectAs curveConnectAs2) const
Identify curves to include in export. The specified DocumentModelExportFormat overrides same data in ...
void insertLineSeparator(bool &isFirst, ExportHeader exportHeader, QTextStream &str) const
Insert line(s) between successive sets of curves.
ExportFileAbstractBase()
Single constructor.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Definition LineStyle.cpp:63