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 #ifndef EXPORT_FILE_ABSTRACT_BASE_H 8 #define EXPORT_FILE_ABSTRACT_BASE_H 9 10 #include "CurveConnectAs.h" 11 #include "ExportHeader.h" 12 #include <QPointF> 13 #include <QStringList> 14 #include <QVector> 15 #include <vector> 16 17 class Document; 18 class DocumentModelCoords; 19 class DocumentModelExportFormat; 20 class QTextStream; 21 class SplinePair; 22 class Transformation; 23 24 /// Strategy base class for exporting to a file. This class provides common methods 25 class ExportFileAbstractBase 26 { 27 public: 28 /// Single constructor. 29 ExportFileAbstractBase(); 30 virtual ~ExportFileAbstractBase (); 31 32 protected: 33 34 /// Identify curves to include in export. The specified DocumentModelExportFormat overrides same data in Document for previewing window 35 QStringList curvesToInclude (const DocumentModelExportFormat &modelExportOverride, 36 const Document &document, 37 const QStringList &curvesGraphsNames, 38 CurveConnectAs curveConnectAs1, 39 CurveConnectAs curveConnectAs2) const; 40 41 /// Deallocate memory for array 42 void destroy2DArray (QVector<QVector<QString*> > &array) const; 43 44 /// Gnuplot comment delimiter 45 QString gnuplotComment() const; 46 47 /// Insert line(s) between successive sets of curves 48 void insertLineSeparator (bool isFirst, 49 ExportHeader exportHeader, 50 QTextStream &str) const; 51 52 /// Interpolate (if xThetaValue is between posGraphBefore.x() and posGraph.x()) or 53 /// extrapolate (if xThetaValue < posGraphBefore.x() or xThetaValue > posGraph.x()) 54 /// the given x/theta value using the two specified graph points 55 double linearlyInterpolateYRadiusFromTwoPoints (double xThetaValue, 56 const DocumentModelCoords &modelCoords, 57 const QPointF &posGraphBefore, 58 const QPointF &posGraph) const; 59 60 /// RFC 4180 says if values are delimited by a comma AND a value has commas in it (for locale like 61 /// English/Switzerland when dealing with numbers) then double quotes are required for the value. 62 /// In other cases this method is a noop 63 QString wrapInDoubleQuotesIfNeeded (const DocumentModelExportFormat &modelExportOverride, 64 const QString &valueString) const; 65 }; 66 67 #endif // EXPORT_FILE_ABSTRACT_BASE_H 68