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,
229 bool &isOverrun)
const
254 exportAllPerLineXThetaValuesMerged (modelExportOverride,
265 exportOnePerLineXThetaValuesMerged (modelExportOverride,
278void ExportFileRelations::initializeXThetaYRadiusValues (
const QStringList &curvesIncluded,
279 QVector<QVector<QString*> > &xThetaYRadiusValues)
const
284 int curveCount = curvesIncluded.count();
285 int xThetaCount = xThetaYRadiusValues [0].count();
286 for (
int row = 0; row < xThetaCount; row++) {
288 xThetaYRadiusValues [col] [row] =
new QString;
293QPointF ExportFileRelations::linearlyInterpolate (
const Points &points,
299 double xTheta = 0, yRadius = 0;
300 double ordinalBefore = 0;
301 QPointF posGraphBefore;
302 bool foundIt =
false;
303 for (
int ip = 0; ip < points.count(); ip++) {
305 const Point &point = points.at (ip);
310 if (ordinal <= point.
ordinal()) {
316 xTheta = posGraph.x();
317 yRadius = posGraph.y();
323 double s = (ordinal - ordinalBefore) / (point.
ordinal() - ordinalBefore);
324 xTheta = (1.0 - s) * posGraphBefore.x() + s * posGraph.x();
325 yRadius = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
331 ordinalBefore = point.
ordinal();
332 posGraphBefore = posGraph;
338 xTheta = posGraphBefore.x();
339 yRadius = posGraphBefore.y();
343 return QPointF (xTheta,
350 const QStringList &curvesIncluded,
354 QVector<QVector<QString*> > &xThetaYRadiusValues)
const
359 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
361 int colXTheta = 2 * ic;
362 int colYRadius = 2 * ic + 1;
364 const QString curveName = curvesIncluded.at (ic);
372 loadXThetaYRadiusValuesForCurveRaw (document.
modelCoords(),
376 xThetaYRadiusValues [colXTheta],
377 xThetaYRadiusValues [colYRadius],
394 loadXThetaYRadiusValuesForCurveInterpolatedSmooth (document.
modelCoords(),
399 xThetaYRadiusValues [colXTheta],
400 xThetaYRadiusValues [colYRadius],
407 loadXThetaYRadiusValuesForCurveInterpolatedStraight (document.
modelCoords(),
412 xThetaYRadiusValues [colXTheta],
413 xThetaYRadiusValues [colYRadius],
420void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth (
const DocumentModelCoords &modelCoords,
425 QVector<QString*> &xThetaValues,
426 QVector<QString*> &yRadiusValues,
429 bool isLogYRadius)
const
431 LOG4CPP_INFO_S ((*
mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth";
434 vector<SplinePair> xy;
435 ExportOrdinalsSmooth ordinalsSmooth;
451 FormatCoordsUnits format;
454 for (
int row = 0; row < ordinals.count(); row++) {
456 double ordinal = ordinals.at (row);
457 SplinePair splinePairFound = spline.interpolateCoeff(ordinal);
458 double xTheta = splinePairFound.
x ();
459 double yRadius = splinePairFound.
y ();
467 *(xThetaValues [row]),
468 *(yRadiusValues [row]),
474void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight (
const DocumentModelCoords &modelCoords,
479 QVector<QString*> &xThetaValues,
480 QVector<QString*> &yRadiusValues,
483 LOG4CPP_INFO_S ((*
mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight";
485 FormatCoordsUnits format;
488 for (
int row = 0; row < ordinals.count(); row++) {
490 double ordinal = ordinals.at (row);
492 QPointF pointInterpolated = linearlyInterpolate (points,
498 pointInterpolated.y(),
502 *(xThetaValues [row]),
503 *(yRadiusValues [row]),
508void ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw (
const DocumentModelCoords &modelCoords,
512 QVector<QString*> &xThetaValues,
513 QVector<QString*> &yRadiusValues,
518 FormatCoordsUnits format;
520 for (
int pt = 0; pt < points.count(); pt++) {
522 const Point &point = points.at (pt);
534 *(xThetaValues [pt]),
535 *(yRadiusValues [pt]),
545 const QStringList &curvesIncluded)
const
549 int maxColumnSize = 0;
552 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
554 const QString curveName = curvesIncluded.at (ic);
562 maxColumnSize = qMax (maxColumnSize,
579 maxColumnSize = qMax (maxColumnSize,
584 return maxColumnSize;
587ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervals (
double pointsIntervalRelations,
593 const Points &points)
const
600 return ordinalsAtIntervalsSmoothGraph (pointsIntervalRelations,
608 return ordinalsAtIntervalsStraightGraph (pointsIntervalRelations,
617 return ordinalsAtIntervalsSmoothScreen (pointsIntervalRelations,
622 return ordinalsAtIntervalsStraightScreen (pointsIntervalRelations,
629ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothGraph (
double pointsIntervalRelations,
633 const Points &points)
const
640 if ((pointsIntervalRelations > 0) &&
641 (points.count() > 0)) {
644 vector<SplinePair> xy;
645 ExportOrdinalsSmooth ordinalsSmooth;
656 pointsIntervalRelations);
662ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothScreen (
double pointsIntervalRelations,
663 const Points &points)
const
666 <<
" pointCount=" << points.count();
672 if ((pointsIntervalRelations > 0) &&
673 (points.count() > 0)) {
676 vector<SplinePair> xy;
677 ExportOrdinalsSmooth ordinalsSmooth;
685 pointsIntervalRelations);
691ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightGraph (
double pointsIntervalRelations,
693 const Points &points)
const
700 if ((pointsIntervalRelations > 0) &&
701 (points.count() > 0)) {
703 ExportOrdinalsStraight ordinalsStraight;
707 pointsIntervalRelations);
713ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightScreen (
double pointsIntervalRelations,
714 const Points &points)
const
717 <<
" pointCount=" << points.count();
723 if ((pointsIntervalRelations > 0) &&
724 (points.count() > 0)) {
726 ExportOrdinalsStraight ordinalsStraight;
729 pointsIntervalRelations);
736 const QStringList &curvesIncluded,
737 QVector<QVector<QString*> > &xThetaYRadiusValues,
738 const QString &delimiter,
740 unsigned int &numWritesSoFar)
const
747 modelExportOverride.
header (),
752 QString delimiterForRow;
753 QStringList::const_iterator itr;
754 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
755 QString curveName = *itr;
756 str << delimiterForRow << modelExportOverride.
xLabel();
757 delimiterForRow = delimiter;
758 str << delimiterForRow << curveName;
764 for (
int row = 0; row < xThetaYRadiusValues [0].count(); row++) {
766 QString delimiterForRow;
767 for (
int col = 0; col < xThetaYRadiusValues.count(); col++) {
769 QString xThetaString = *(xThetaYRadiusValues [col] [row]);
772 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, bool &isOverrun) 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)