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

Strategy class for exporting to a file. This strategy is external to the Document class so that class is simpler. More...

#include <ExportFileFunctions.h>

Inheritance diagram for ExportFileFunctions:
Inheritance graph
Collaboration diagram for ExportFileFunctions:
Collaboration graph

Public Member Functions

 ExportFileFunctions ()
 Single constructor.
void exportToFile (const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str, unsigned int &numWritesSoFar, bool &isOverrun) const
 Export Document points according to the settings.
Public Member Functions inherited from ExportFileAbstractBase
 ExportFileAbstractBase ()
 Single constructor.
virtual ~ExportFileAbstractBase ()

Friends

class TestExport

Additional Inherited Members

Protected Member Functions inherited from ExportFileAbstractBase
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 class for exporting to a file. This strategy is external to the Document class so that class is simpler.

Definition at line 28 of file ExportFileFunctions.h.

Constructor & Destructor Documentation

◆ ExportFileFunctions()

ExportFileFunctions::ExportFileFunctions ( )

Single constructor.

Definition at line 31 of file ExportFileFunctions.cpp.

32{
33}

Member Function Documentation

◆ exportToFile()

void ExportFileFunctions::exportToFile ( const DocumentModelExportFormat & modelExportOverride,
const Document & document,
const MainWindowModel & modelMainWindow,
const Transformation & transformation,
QTextStream & str,
unsigned int & numWritesSoFar,
bool & isOverrun ) const

Export Document points according to the settings.

The DocumentModelExportFormat inside the Document is ignored so DlgSettingsExport can supply its own DocumentModelExportFormat when previewing what would be exported.

Definition at line 138 of file ExportFileFunctions.cpp.

145{
146 LOG4CPP_INFO_S ((*mainCat)) << "ExportFileFunctions::exportToFile";
147
148 isOverrun = false;
149
150 // Log coordinates must be temporarily transformed to linear coordinates
151 bool isLogXTheta = (document.modelCoords().coordScaleXTheta() == COORD_SCALE_LOG);
152 bool isLogYRadius = (document.modelCoords().coordScaleYRadius() == COORD_SCALE_LOG);
153
154 // Identify curves to be included
155 QStringList curvesIncluded = curvesToInclude (modelExportOverride,
156 document,
157 document.curvesGraphsNames(),
160
161 // Delimiter
162 const QString delimiter = exportDelimiterToText (modelExportOverride.delimiter(),
163 modelExportOverride.header() == EXPORT_HEADER_GNUPLOT);
164
165 // Get x/theta values to be used. Also get the endpoint limits, if any
166 CurveLimits curveLimitsMin, curveLimitsMax;
167 ValuesVectorXOrY valuesVector;
169 CallbackGatherXThetasInGridLines ftor (modelMainWindow,
170 modelExportOverride,
171 curvesIncluded,
172 transformation,
173 document);
174 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
176 document.iterateThroughCurvesPointsGraphs(ftorWithCallback);
177 valuesVector = ftor.xThetaValuesRaw();
178 curveLimitsMin = ftor.curveLimitsMin();
179 curveLimitsMax = ftor.curveLimitsMax();
180 } else {
181 CallbackGatherXThetasInCurves ftor (modelExportOverride,
182 curvesIncluded,
183 transformation);
184 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
186 document.iterateThroughCurvesPointsGraphs(ftorWithCallback);
187 valuesVector = ftor.xThetaValuesRaw();
188 curveLimitsMin = ftor.curveLimitsMin();
189 curveLimitsMax = ftor.curveLimitsMax();
190 }
191
192 ExportXThetaValuesMergedFunctions exportXTheta (modelExportOverride,
193 modelMainWindow,
194 valuesVector,
195 transformation);
196
197 ExportValuesXOrY xThetaValuesMerged = exportXTheta.xThetaValues (isOverrun);
198
199 if (isOverrun) {
200
201 // Put note in output to explain why there are no points
202 str << QObject::tr ("Too many points");
203
204 } else {
205
206 // Skip if every curve was a relation
207 if (xThetaValuesMerged.count() > 0) {
208
209 // Export in one of two layouts
210 if (modelExportOverride.layoutFunctions() == EXPORT_LAYOUT_ALL_PER_LINE) {
211 exportAllPerLineXThetaValuesMerged (modelExportOverride,
212 document,
213 modelMainWindow,
214 curvesIncluded,
215 xThetaValuesMerged,
216 delimiter,
217 transformation,
218 isLogXTheta,
219 isLogYRadius,
220 curveLimitsMin,
221 curveLimitsMax,
222 str,
223 numWritesSoFar);
224 } else {
225 exportOnePerLineXThetaValuesMerged (modelExportOverride,
226 document,
227 modelMainWindow,
228 curvesIncluded,
229 xThetaValuesMerged,
230 delimiter,
231 transformation,
232 isLogXTheta,
233 isLogYRadius,
234 curveLimitsMin,
235 curveLimitsMax,
236 str,
237 numWritesSoFar);
238 }
239 }
240 }
241}
@ COORD_SCALE_LOG
Definition CoordScale.h:14
@ CONNECT_AS_FUNCTION_STRAIGHT
@ CONNECT_AS_FUNCTION_SMOOTH
QHash< QString, double > CurveLimits
Definition CurveLimits.h:14
QString exportDelimiterToText(ExportDelimiter exportDelimiter, bool isGnuplotDelimiter)
@ EXPORT_HEADER_GNUPLOT
@ EXPORT_LAYOUT_ALL_PER_LINE
@ EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_GRID_LINES
QList< double > ExportValuesXOrY
log4cpp::Category * mainCat
Definition Logger.cpp:14
QMap< double, bool > ValuesVectorXOrY
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
ExportHeader header() const
Get method for header.
ExportPointsSelectionFunctions pointsSelectionFunctions() const
Get method for point selection for functions.
ExportDelimiter delimiter() const
Get method for delimiter.
ExportLayoutFunctions layoutFunctions() const
Get method for functions layout.
void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
Definition Document.cpp:478
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Definition Document.cpp:355
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:707
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 ...
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ TestExport

friend class TestExport
friend

Definition at line 31 of file ExportFileFunctions.h.


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