Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
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. More...
 
void exportToFile (const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str, unsigned int &numWritesSoFar) const
 Export Document points according to the settings. More...
 
- Public Member Functions inherited from ExportFileAbstractBase
 ExportFileAbstractBase ()
 Single constructor. More...
 
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. More...
 
void destroy2DArray (QVector< QVector< QString * > > &array) const
 Deallocate memory for array. More...
 
QString gnuplotComment () const
 Gnuplot comment delimiter. More...
 
void insertLineSeparator (bool isFirst, ExportHeader exportHeader, QTextStream &str) const
 Insert line(s) between successive sets of curves. More...
 
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 xThetaValue < posGraphBefore.x() or xThetaValue > posGraph.x()) the given x/theta value using the two specified graph points. More...
 
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. More...
 

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 27 of file ExportFileFunctions.h.

Constructor & Destructor Documentation

ExportFileFunctions::ExportFileFunctions ( )

Single constructor.

Definition at line 31 of file ExportFileFunctions.cpp.

32 {
33 }

Member Function Documentation

void ExportFileFunctions::exportToFile ( const DocumentModelExportFormat modelExportOverride,
const Document document,
const MainWindowModel modelMainWindow,
const Transformation transformation,
QTextStream &  str,
unsigned int &  numWritesSoFar 
) 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.

144 {
145  LOG4CPP_INFO_S ((*mainCat)) << "ExportFileFunctions::exportToFile";
146 
147  // Log coordinates must be temporarily transformed to linear coordinates
148  bool isLogXTheta = (document.modelCoords().coordScaleXTheta() == COORD_SCALE_LOG);
149  bool isLogYRadius = (document.modelCoords().coordScaleYRadius() == COORD_SCALE_LOG);
150 
151  // Identify curves to be included
152  QStringList curvesIncluded = curvesToInclude (modelExportOverride,
153  document,
154  document.curvesGraphsNames(),
157 
158  // Delimiter
159  const QString delimiter = exportDelimiterToText (modelExportOverride.delimiter(),
160  modelExportOverride.header() == EXPORT_HEADER_GNUPLOT);
161 
162  // Get x/theta values to be used. Also get the endpoint limits, if any
163  CurveLimits curveLimitsMin, curveLimitsMax;
164  ValuesVectorXOrY valuesVector;
166  CallbackGatherXThetasInGridLines ftor (modelMainWindow,
167  modelExportOverride,
168  curvesIncluded,
169  transformation,
170  document);
171  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
173  document.iterateThroughCurvesPointsGraphs(ftorWithCallback);
174  valuesVector = ftor.xThetaValuesRaw();
175  curveLimitsMin = ftor.curveLimitsMin();
176  curveLimitsMax = ftor.curveLimitsMax();
177  } else {
178  CallbackGatherXThetasInCurves ftor (modelExportOverride,
179  curvesIncluded,
180  transformation);
181  Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
183  document.iterateThroughCurvesPointsGraphs(ftorWithCallback);
184  valuesVector = ftor.xThetaValuesRaw();
185  curveLimitsMin = ftor.curveLimitsMin();
186  curveLimitsMax = ftor.curveLimitsMax();
187  }
188 
189  ExportXThetaValuesMergedFunctions exportXTheta (modelExportOverride,
190  valuesVector,
191  transformation);
192 
193  ExportValuesXOrY xThetaValuesMerged = exportXTheta.xThetaValues ();
194 
195  // Skip if every curve was a relation
196  if (xThetaValuesMerged.count() > 0) {
197 
198  // Export in one of two layouts
199  if (modelExportOverride.layoutFunctions() == EXPORT_LAYOUT_ALL_PER_LINE) {
200  exportAllPerLineXThetaValuesMerged (modelExportOverride,
201  document,
202  modelMainWindow,
203  curvesIncluded,
204  xThetaValuesMerged,
205  delimiter,
206  transformation,
207  isLogXTheta,
208  isLogYRadius,
209  curveLimitsMin,
210  curveLimitsMax,
211  str,
212  numWritesSoFar);
213  } else {
214  exportOnePerLineXThetaValuesMerged (modelExportOverride,
215  document,
216  modelMainWindow,
217  curvesIncluded,
218  xThetaValuesMerged,
219  delimiter,
220  transformation,
221  isLogXTheta,
222  isLogYRadius,
223  curveLimitsMin,
224  curveLimitsMax,
225  str,
226  numWritesSoFar);
227  }
228  }
229 }
ExportPointsSelectionFunctions pointsSelectionFunctions() const
Get method for point selection for functions.
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Creates the set of merged x/theta values for exporting functions, using interpolation.
ExportLayoutFunctions layoutFunctions() const
Get method for functions layout.
Callback for collecting X/Theta independent variables, for functions, in preparation for exporting...
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:695
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
QHash< QString, double > CurveLimits
Definition: CurveLimits.h:14
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 ...
ExportHeader header() const
Get method for header.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
QList< double > ExportValuesXOrY
ExportDelimiter delimiter() const
Get method for delimiter.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Definition: Document.cpp:349
virtual CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
QString exportDelimiterToText(ExportDelimiter exportDelimiter, bool isGnuplotDelimiter)
Callback for collecting X/Theta independent variables, for functions, in preparation for exporting...
void iterateThroughCurvesPointsGraphs(const Functor2wRet< const QString &, const Point &, CallbackSearchReturn > &ftorWithCallback)
See Curve::iterateThroughCurvePoints, for all the graphs curves.
Definition: Document.cpp:472
QMap< double, bool > ValuesVectorXOrY

Friends And Related Function Documentation

friend class TestExport
friend

Definition at line 30 of file ExportFileFunctions.h.


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