37 const QStringList &curvesIncluded,
38 const QString &delimiter,
43 unsigned int &numWritesSoFar)
const
47 int maxColumnSize = maxColumnSizeAllocation (modelExportOverride,
55 if (maxColumnSize > 0) {
59 exportAllPerLineXThetaValuesMergedMultiplePass (maxColumnSize,
73 exportAllPerLineXThetaValuesMergedOnePass (maxColumnSize,
88void ExportFileRelations::exportAllPerLineXThetaValuesMergedMultiplePass (
int maxColumnSize,
92 const QStringList &curvesIncluded,
93 const QString &delimiter,
98 unsigned int &numWritesSoFar)
const
106 const int CURVE_COUNT_PER_PASS = 1;
108 int curveCount = curvesIncluded.count ();
110 QVector<QVector<QString*> > xThetaYRadiusValuesAll (
COLUMNS_PER_CURVE * curveCount, QVector<QString*> (maxColumnSize));
112 initializeXThetaYRadiusValues (curvesIncluded,
113 xThetaYRadiusValuesAll);
116 int colX = 0, colY = colX + 1;
117 for (
int c = 0; c < curvesIncluded.count (); c++) {
118 QString curve = curvesIncluded [c];
120 QStringList curvesIncludedInPass;
121 curvesIncludedInPass << curve;
122 ENGAUGE_ASSERT (curvesIncludedInPass.count () == CURVE_COUNT_PER_PASS);
124 QVector<QVector<QString*> > xThetaYRadiusValuesOne (
COLUMNS_PER_CURVE * CURVE_COUNT_PER_PASS, QVector<QString*> (maxColumnSize));
126 initializeXThetaYRadiusValues (curvesIncludedInPass,
127 xThetaYRadiusValuesOne);
128 loadXThetaYRadiusValues (modelExportOverride,
131 curvesIncludedInPass,
135 xThetaYRadiusValuesOne);
138 for (
int row = 0; row < maxColumnSize; row++) {
139 *(xThetaYRadiusValuesAll [colX] [row]) = *(xThetaYRadiusValuesOne [0] [row]);
140 *(xThetaYRadiusValuesAll [colY] [row]) = *(xThetaYRadiusValuesOne [1] [row]);
149 outputXThetaYRadiusValues (modelExportOverride,
151 xThetaYRadiusValuesAll,
158void ExportFileRelations::exportAllPerLineXThetaValuesMergedOnePass (
int maxColumnSize,
162 const QStringList &curvesIncluded,
163 const QString &delimiter,
168 unsigned int &numWritesSoFar)
const
170 int curveCount = curvesIncluded.count ();
172 QVector<QVector<QString*> > xThetaYRadiusValues (
COLUMNS_PER_CURVE * curveCount, QVector<QString*> (maxColumnSize));
173 initializeXThetaYRadiusValues (curvesIncluded,
174 xThetaYRadiusValues);
175 loadXThetaYRadiusValues (modelExportOverride,
182 xThetaYRadiusValues);
183 outputXThetaYRadiusValues (modelExportOverride,
195 const QStringList &curvesIncluded,
196 const QString &delimiter,
201 unsigned int &numWritesSoFar)
const
205 QStringList::const_iterator itr;
206 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
208 QString curveIncluded = *itr;
210 exportAllPerLineXThetaValuesMerged (modelExportOverride,
213 QStringList (curveIncluded),
228 unsigned int &numWritesSoFar)
const
249 exportAllPerLineXThetaValuesMerged (modelExportOverride,
260 exportOnePerLineXThetaValuesMerged (modelExportOverride,
273void ExportFileRelations::initializeXThetaYRadiusValues (
const QStringList &curvesIncluded,
274 QVector<QVector<QString*> > &xThetaYRadiusValues)
const
279 int curveCount = curvesIncluded.count();
280 int xThetaCount = xThetaYRadiusValues [0].count();
281 for (
int row = 0; row < xThetaCount; row++) {
283 xThetaYRadiusValues [col] [row] =
new QString;
288QPointF ExportFileRelations::linearlyInterpolate (
const Points &points,
294 double xTheta = 0, yRadius = 0;
295 double ordinalBefore = 0;
296 QPointF posGraphBefore;
297 bool foundIt =
false;
298 for (
int ip = 0; ip < points.count(); ip++) {
300 const Point &point = points.at (ip);
305 if (ordinal <= point.
ordinal()) {
311 xTheta = posGraph.x();
312 yRadius = posGraph.y();
318 double s = (ordinal - ordinalBefore) / (point.
ordinal() - ordinalBefore);
319 xTheta = (1.0 - s) * posGraphBefore.x() + s * posGraph.x();
320 yRadius = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
326 ordinalBefore = point.
ordinal();
327 posGraphBefore = posGraph;
333 xTheta = posGraphBefore.x();
334 yRadius = posGraphBefore.y();
338 return QPointF (xTheta,
345 const QStringList &curvesIncluded,
349 QVector<QVector<QString*> > &xThetaYRadiusValues)
const
354 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
356 int colXTheta = 2 * ic;
357 int colYRadius = 2 * ic + 1;
359 const QString curveName = curvesIncluded.at (ic);
367 loadXThetaYRadiusValuesForCurveRaw (document.
modelCoords(),
371 xThetaYRadiusValues [colXTheta],
372 xThetaYRadiusValues [colYRadius],
389 loadXThetaYRadiusValuesForCurveInterpolatedSmooth (document.
modelCoords(),
394 xThetaYRadiusValues [colXTheta],
395 xThetaYRadiusValues [colYRadius],
402 loadXThetaYRadiusValuesForCurveInterpolatedStraight (document.
modelCoords(),
407 xThetaYRadiusValues [colXTheta],
408 xThetaYRadiusValues [colYRadius],
415void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth (
const DocumentModelCoords &modelCoords,
420 QVector<QString*> &xThetaValues,
421 QVector<QString*> &yRadiusValues,
424 bool isLogYRadius)
const
426 LOG4CPP_INFO_S ((*
mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth";
429 vector<SplinePair> xy;
430 ExportOrdinalsSmooth ordinalsSmooth;
446 FormatCoordsUnits format;
449 for (
int row = 0; row < ordinals.count(); row++) {
451 double ordinal = ordinals.at (row);
452 SplinePair splinePairFound = spline.interpolateCoeff(ordinal);
453 double xTheta = splinePairFound.
x ();
454 double yRadius = splinePairFound.
y ();
462 *(xThetaValues [row]),
463 *(yRadiusValues [row]),
469void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight (
const DocumentModelCoords &modelCoords,
474 QVector<QString*> &xThetaValues,
475 QVector<QString*> &yRadiusValues,
478 LOG4CPP_INFO_S ((*
mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight";
480 FormatCoordsUnits format;
483 for (
int row = 0; row < ordinals.count(); row++) {
485 double ordinal = ordinals.at (row);
487 QPointF pointInterpolated = linearlyInterpolate (points,
493 pointInterpolated.y(),
497 *(xThetaValues [row]),
498 *(yRadiusValues [row]),
503void ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw (
const DocumentModelCoords &modelCoords,
507 QVector<QString*> &xThetaValues,
508 QVector<QString*> &yRadiusValues,
513 FormatCoordsUnits format;
515 for (
int pt = 0; pt < points.count(); pt++) {
517 const Point &point = points.at (pt);
529 *(xThetaValues [pt]),
530 *(yRadiusValues [pt]),
540 const QStringList &curvesIncluded)
const
544 int maxColumnSize = 0;
547 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
549 const QString curveName = curvesIncluded.at (ic);
557 maxColumnSize = qMax (maxColumnSize,
574 maxColumnSize = qMax (maxColumnSize,
579 return maxColumnSize;
582ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervals (
double pointsIntervalRelations,
588 const Points &points)
const
595 return ordinalsAtIntervalsSmoothGraph (pointsIntervalRelations,
603 return ordinalsAtIntervalsStraightGraph (pointsIntervalRelations,
612 return ordinalsAtIntervalsSmoothScreen (pointsIntervalRelations,
617 return ordinalsAtIntervalsStraightScreen (pointsIntervalRelations,
624ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothGraph (
double pointsIntervalRelations,
628 const Points &points)
const
635 if ((pointsIntervalRelations > 0) &&
636 (points.count() > 0)) {
639 vector<SplinePair> xy;
640 ExportOrdinalsSmooth ordinalsSmooth;
651 pointsIntervalRelations);
657ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothScreen (
double pointsIntervalRelations,
658 const Points &points)
const
661 <<
" pointCount=" << points.count();
667 if ((pointsIntervalRelations > 0) &&
668 (points.count() > 0)) {
671 vector<SplinePair> xy;
672 ExportOrdinalsSmooth ordinalsSmooth;
680 pointsIntervalRelations);
686ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightGraph (
double pointsIntervalRelations,
688 const Points &points)
const
695 if ((pointsIntervalRelations > 0) &&
696 (points.count() > 0)) {
698 ExportOrdinalsStraight ordinalsStraight;
702 pointsIntervalRelations);
708ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightScreen (
double pointsIntervalRelations,
709 const Points &points)
const
712 <<
" pointCount=" << points.count();
718 if ((pointsIntervalRelations > 0) &&
719 (points.count() > 0)) {
721 ExportOrdinalsStraight ordinalsStraight;
724 pointsIntervalRelations);
731 const QStringList &curvesIncluded,
732 QVector<QVector<QString*> > &xThetaYRadiusValues,
733 const QString &delimiter,
735 unsigned int &numWritesSoFar)
const
742 modelExportOverride.
header (),
747 QString delimiterForRow;
748 QStringList::const_iterator itr;
749 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
750 QString curveName = *itr;
751 str << delimiterForRow << modelExportOverride.
xLabel();
752 delimiterForRow = delimiter;
753 str << delimiterForRow << curveName;
759 for (
int row = 0; row < xThetaYRadiusValues [0].count(); row++) {
761 QString delimiterForRow;
762 for (
int col = 0; col < xThetaYRadiusValues.count(); col++) {
764 QString xThetaString = *(xThetaYRadiusValues [col] [row]);
767 delimiterForRow = delimiter;
@ CONNECT_AS_RELATION_STRAIGHT
@ CONNECT_AS_RELATION_SMOOTH
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
QString exportDelimiterToText(ExportDelimiter exportDelimiter, bool isGnuplotDelimiter)
const int COLUMNS_PER_CURVE
@ EXPORT_LAYOUT_ALL_PER_LINE
ExportPointsIntervalUnits
@ EXPORT_POINTS_INTERVAL_UNITS_GRAPH
@ EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE
@ EXPORT_POINTS_SELECTION_RELATIONS_RAW
QList< double > ExportValuesOrdinal
log4cpp::Category * mainCat
LineStyle lineStyle() const
Get method for LineStyle.
const LineStyle lineStyle(const QString &curveName) const
Get method for copying one line style in one step.
CurveStyle curveStyle() const
Return the curve style.
const Points points() const
Return a shallow copy of the Points.
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Storage of one imported image and the data attached to that image.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
void destroy2DArray(QVector< QVector< QString * > > &array) const
Deallocate memory for array.
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 ...
void insertLineSeparator(bool isFirst, ExportHeader exportHeader, QTextStream &str) const
Insert line(s) between successive sets of curves.
ExportFileRelations()
Single constructor.
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.
void loadSplinePairsWithTransformation(const Points &points, const Transformation &transformation, bool isLogXTheta, bool isLogYRadius, std::vector< double > &t, std::vector< SplinePair > &xy) const
Load t (=ordinal) and xy (=screen position) spline pairs, converting screen coordinates to graph coor...
ExportValuesOrdinal ordinalsAtIntervalsGraph(const std::vector< double > &t, const std::vector< SplinePair > &xy, double pointsInterval) const
Perform the interpolation on the arrays loaded by the other methods.
void loadSplinePairsWithoutTransformation(const Points &points, std::vector< double > &t, std::vector< SplinePair > &xy) const
Load t (=ordinal) and xy (=screen position) spline pairs, without any conversion to graph coordinates...
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation(const Points &points, double pointsInterval) const
Compute ordinals, without any conversion to graph coordinates.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation(const Points &points, const Transformation &transformation, double pointsInterval) const
Compute ordinals, converting screen coordinates to graph coordinates.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Model for DlgSettingsMainWindow.
QPointF posScreen() const
Accessor for screen position.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
double y() const
Get method for y.
double x() const
Get method for x.
#define LOG4CPP_INFO_S(logger)