Engauge Digitizer 2
Loading...
Searching...
No Matches
ExportFileAbstractBase Class Reference

Strategy base class for exporting to a file. This class provides common methods. More...

#include <ExportFileAbstractBase.h>

Inheritance diagram for ExportFileAbstractBase:
Inheritance graph
Collaboration diagram for ExportFileAbstractBase:
Collaboration graph

Public Member Functions

 ExportFileAbstractBase ()
 Single constructor.
virtual ~ExportFileAbstractBase ()

Protected Member Functions

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 Document for previewing window.
void destroy2DArray (QVector< QVector< QString * > > &array) const
 Deallocate memory for array.
QString gnuplotComment () const
 Gnuplot comment delimiter.
void insertLineSeparator (bool isFirst, ExportHeader exportHeader, QTextStream &str) const
 Insert line(s) between successive sets of curves.
double linearlyInterpolateYRadiusFromTwoPoints (double xThetaLinearized, const QPointF &posGraphBefore, const QPointF &posGraph) const
 Interpolate (if xThetaValue is between posGraphBefore.x() and posGraph.x()) or extrapolate (if xThetaValue < posGraphBefore.x() or xThetaValue > posGraph.x()) the given x/theta value using the two specified graph points.
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 English/Switzerland when dealing with numbers) then double quotes are required for the value.

Detailed Description

Strategy base class for exporting to a file. This class provides common methods.

Definition at line 25 of file ExportFileAbstractBase.h.

Constructor & Destructor Documentation

◆ ExportFileAbstractBase()

ExportFileAbstractBase::ExportFileAbstractBase ( )

Single constructor.

Definition at line 21 of file ExportFileAbstractBase.cpp.

22{
23}

◆ ~ExportFileAbstractBase()

ExportFileAbstractBase::~ExportFileAbstractBase ( )
virtual

Definition at line 25 of file ExportFileAbstractBase.cpp.

26{
27}

Member Function Documentation

◆ curvesToInclude()

QStringList ExportFileAbstractBase::curvesToInclude ( const DocumentModelExportFormat & modelExportOverride,
const Document & document,
const QStringList & curvesGraphsNames,
CurveConnectAs curveConnectAs1,
CurveConnectAs curveConnectAs2 ) const
protected

Identify curves to include in export. The specified DocumentModelExportFormat overrides same data in Document for previewing window.

Definition at line 29 of file ExportFileAbstractBase.cpp.

34{
35 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileAbstractBase::curvesToInclude";
36
37 QStringList curvesToInclude;
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
44 QString curvesGraphName = *itr;
45
46 if (!modelExportOverride.curveNamesNotExported().contains (curvesGraphName)) {
47
48 const Curve *curve = document.curveForCurveName(curvesGraphName);
49 ENGAUGE_CHECK_PTR (curve);
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
55 curvesToInclude.push_back (curvesGraphName);
56 }
57 }
58 }
59
60 return curvesToInclude;
61}
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
log4cpp::Category * mainCat
Definition Logger.cpp:14
LineStyle lineStyle() const
Get method for LineStyle.
CurveStyle curveStyle() const
Return the curve style.
Definition Curve.cpp:149
QStringList curveNamesNotExported() const
Get method for curve names not exported.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
Definition Document.cpp:341
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 ...
CurveConnectAs curveConnectAs() const
Get method for connect type.
Definition LineStyle.cpp:63
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ destroy2DArray()

void ExportFileAbstractBase::destroy2DArray ( QVector< QVector< QString * > > & array) const
protected

Deallocate memory for array.

Definition at line 63 of file ExportFileAbstractBase.cpp.

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}

◆ gnuplotComment()

QString ExportFileAbstractBase::gnuplotComment ( ) const
protected

Gnuplot comment delimiter.

Definition at line 76 of file ExportFileAbstractBase.cpp.

77{
78 return QString ("# ");
79}

◆ insertLineSeparator()

void ExportFileAbstractBase::insertLineSeparator ( bool isFirst,
ExportHeader exportHeader,
QTextStream & str ) const
protected

Insert line(s) between successive sets of curves.

Definition at line 81 of file ExportFileAbstractBase.cpp.

84{
85 // Insert line(s) between previous curve and this curve
86 if (!isFirst) {
87 if (exportHeader == EXPORT_HEADER_GNUPLOT) {
88 str << "\n\n"; // Gnuplot requires two blank lines between curves
89 } else {
90 str << "\n"; // Single blank line
91 }
92 }
93}
@ EXPORT_HEADER_GNUPLOT

◆ linearlyInterpolateYRadiusFromTwoPoints()

double ExportFileAbstractBase::linearlyInterpolateYRadiusFromTwoPoints ( double xThetaLinearized,
const QPointF & posGraphBefore,
const QPointF & posGraph ) const
protected

Interpolate (if xThetaValue is between posGraphBefore.x() and posGraph.x()) or extrapolate (if xThetaValue < posGraphBefore.x() or xThetaValue > posGraph.x()) the given x/theta value using the two specified graph points.

Definition at line 95 of file ExportFileAbstractBase.cpp.

98{
99 // Assumption is that inputs are linearized, so:
100 // - output will also be linearized
101 // - external code is responsible for linearizing and delinearizing
102 double s = (xThetaLinearized - posGraphBefore.x()) / (posGraph.x() - posGraphBefore.x());
103
104 double yRadiusLinearized = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
105
106 return yRadiusLinearized;
107}

◆ wrapInDoubleQuotesIfNeeded()

QString ExportFileAbstractBase::wrapInDoubleQuotesIfNeeded ( const DocumentModelExportFormat & modelExportOverride,
const QString & valueString ) const
protected

RFC 4180 says if values are delimited by a comma AND a value has commas in it (for locale like English/Switzerland when dealing with numbers) then double quotes are required for the value.

In other cases this method is a noop

Definition at line 109 of file ExportFileAbstractBase.cpp.

111{
112 QString newValueString = valueString;
113
114 if ((modelExportOverride.delimiter () == EXPORT_DELIMITER_COMMA) &&
115 (valueString.indexOf (",") >= 0)) {
116
117 // Eliminate ambiguities according to RFC 4180
118 newValueString = QString ("\"%1\"").arg (valueString);
119 }
120
121 return newValueString;
122}
@ EXPORT_DELIMITER_COMMA
ExportDelimiter delimiter() const
Get method for delimiter.

The documentation for this class was generated from the following files: