Engauge Digitizer 2
Loading...
Searching...
No Matches
ExportFileAbstractBase.cpp
Go to the documentation of this file.
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 "CoordScale.h"
8#include "CurveConnectAs.h"
9#include "Document.h"
10#include "DocumentModelCoords.h"
11#include "EngaugeAssert.h"
13#include "Logger.h"
14#include <qdebug.h>
15#include <qmath.h>
16#include <QTextStream>
17#include "Transformation.h"
18
19using namespace std;
20
24
28
30 const Document &document,
31 const QStringList &curvesGraphsNames,
34{
35 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileAbstractBase::curvesToInclude";
36
38
39 // Build a list of curves to include by subtracting the excluded curves from the the complete list.
40 // Special case is to use only first included curve if appropriate flag is set
41 QStringList::const_iterator itr;
42 for (itr = curvesGraphsNames.begin(); itr != curvesGraphsNames.end(); itr++) {
43
45
46 if (!modelExportOverride.curveNamesNotExported().contains (curvesGraphName)) {
47
50
51 // Not excluded which means it gets included, but only if it is a function
52 if (curve->curveStyle().lineStyle().curveConnectAs() == curveConnectAs1 ||
53 curve->curveStyle().lineStyle().curveConnectAs() == curveConnectAs2) {
54
56 }
57 }
58 }
59
60 return curvesToInclude;
61}
62
64{
65 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileAbstractBase::destroy2DArray";
66
67 int colCount = array.count();
68 int rowCount = array [0].count();
69 for (int row = 0; row < rowCount; row++) {
70 for (int col = 0; col < colCount; col++) {
71 delete array [col] [row];
72 }
73 }
74}
75
77{
78 return QString ("# ");
79}
80
83 QTextStream &str) const
84{
85 // Insert line(s) between previous curve and this curve
86 if (!isFirst) {
88 str << "\n\n"; // Gnuplot requires two blank lines between curves
89 } else {
90 str << "\n"; // Single blank line
91 }
92 }
93}
94
96 const DocumentModelCoords &modelCoords,
98 const QPointF &posGraph) const
99{
100 // X coordinate scaling is linear or log
101 double s;
102 if (modelCoords.coordScaleXTheta() == COORD_SCALE_LINEAR) {
103 s = (xThetaValue - posGraphBefore.x()) / (posGraph.x() - posGraphBefore.x());
104 } else {
105 s = (qLn (xThetaValue) - qLn (posGraphBefore.x())) / (qLn (posGraph.x()) - qLn (posGraphBefore.x()));
106 }
107
108 // Y coordinate scaling is linear or log
109 double yRadius;
110 if (modelCoords.coordScaleYRadius() == COORD_SCALE_LINEAR) {
111 yRadius = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
112 } else {
113 yRadius = qExp ((1.0 - s) * qLn (posGraphBefore.y()) + s * qLn (posGraph.y()));
114 }
115
116 return yRadius;
117}
118
120 const QString &valueString) const
121{
123
124 if ((modelExportOverride.delimiter () == EXPORT_DELIMITER_COMMA) &&
125 (valueString.indexOf (",") >= 0)) {
126
127 // Eliminate ambiguities according to RFC 4180
128 newValueString = QString ("\"%1\"").arg (valueString);
129 }
130
131 return newValueString;
132}
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
CurveConnectAs
const int INNER_RADIUS_MIN
#define ENGAUGE_CHECK_PTR(ptr)
#endif
@ EXPORT_DELIMITER_COMMA
ExportHeader
@ EXPORT_HEADER_GNUPLOT
log4cpp::Category * mainCat
Definition Logger.cpp:14
Container for one set of digitized Points.
Definition Curve.h:34
Model for DlgSettingsCoords and CmdSettingsCoords.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsExportFormat and CmdSettingsExportFormat.
QStringList curveNamesNotExported() const
Get method for curve names not exported.
ExportDelimiter delimiter() const
Get method for delimiter.
Storage of one imported image and the data attached to that image.
Definition Document.h:42
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition Document.cpp:335
void destroy2DArray(QVector< QVector< QString * > > &array) const
Deallocate memory for array.
double linearlyInterpolateYRadiusFromTwoPoints(double xThetaValue, const DocumentModelCoords &modelCoords, const QPointF &posGraphBefore, const QPointF &posGraph) const
Interpolate (if xThetaValue is between posGraphBefore.x() and posGraph.x()) or extrapolate (if xTheta...
QString wrapInDoubleQuotesIfNeeded(const DocumentModelExportFormat &modelExportOverride, const QString &valueString) const
RFC 4180 says if values are delimited by a comma AND a value has commas in it (for locale like Englis...
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 ...
ExportFileAbstractBase()
Single constructor.
void insertLineSeparator(bool isFirst, ExportHeader exportHeader, QTextStream &str) const
Insert line(s) between successive sets of curves.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18