19 #include <QTextStream>
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,
88 void 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]);
143 destroy2DArray (xThetaYRadiusValuesOne);
149 outputXThetaYRadiusValues (modelExportOverride,
151 xThetaYRadiusValuesAll,
155 destroy2DArray (xThetaYRadiusValuesAll);
158 void 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,
189 destroy2DArray (xThetaYRadiusValues);
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
237 QStringList curvesIncluded = curvesToInclude (modelExportOverride,
249 exportAllPerLineXThetaValuesMerged (modelExportOverride,
260 exportOnePerLineXThetaValuesMerged (modelExportOverride,
273 void 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;
288 QPointF 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],
415 void 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;
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]),
469 void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight (
const DocumentModelCoords &modelCoords,
474 QVector<QString*> &xThetaValues,
475 QVector<QString*> &yRadiusValues,
478 LOG4CPP_INFO_S ((*
mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight";
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]),
503 void ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw (
const DocumentModelCoords &modelCoords,
507 QVector<QString*> &xThetaValues,
508 QVector<QString*> &yRadiusValues,
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;
582 ExportValuesOrdinal 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,
624 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothGraph (
double pointsIntervalRelations,
628 const Points &points)
const
635 if ((pointsIntervalRelations > 0) &&
636 (points.count() > 0)) {
639 vector<SplinePair> xy;
651 pointsIntervalRelations);
657 ExportValuesOrdinal 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;
680 pointsIntervalRelations);
686 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightGraph (
double pointsIntervalRelations,
688 const Points &points)
const
695 if ((pointsIntervalRelations > 0) &&
696 (points.count() > 0)) {
702 pointsIntervalRelations);
708 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightScreen (
double pointsIntervalRelations,
709 const Points &points)
const
712 <<
" pointCount=" << points.count();
718 if ((pointsIntervalRelations > 0) &&
719 (points.count() > 0)) {
724 pointsIntervalRelations);
731 const QStringList &curvesIncluded,
732 QVector<QVector<QString*> > &xThetaYRadiusValues,
733 const QString &delimiter,
735 unsigned int &numWritesSoFar)
const
741 insertLineSeparator (numWritesSoFar == 0,
742 modelExportOverride.
header (),
745 str << gnuplotComment();
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]);
765 str << delimiterForRow << wrapInDoubleQuotesIfNeeded (modelExportOverride,
767 delimiterForRow = delimiter;
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Cubic interpolation given independent and dependent value vectors.
const Points points() const
Return a shallow copy of the Points.
ExportPointsIntervalUnits
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
LineStyle lineStyle() const
Get method for LineStyle.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
double y() const
Get method for y.
#define LOG4CPP_INFO_S(logger)
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...
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
const LineStyle lineStyle(const QString &curveName) const
Get method for copying one line style in one step.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation(const Points &points, double pointsInterval) const
Compute ordinals, without any conversion to graph coordinates.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Model for DlgSettingsMainWindow.
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...
Utility class to interpolate points spaced evenly along a piecewise defined curve with fitted spline...
const int COLUMNS_PER_CURVE
Model for DlgSettingsCoords and CmdSettingsCoords.
Storage of one imported image and the data attached to that image.
Container for one set of digitized Points.
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.
Details for a specific Line.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Utility class to interpolate points spaced evenly along a piecewise defined curve with line segments ...
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.
log4cpp::Category * mainCat
double x() const
Get method for x.
QString exportDelimiterToText(ExportDelimiter exportDelimiter, bool isGnuplotDelimiter)
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
CurveStyle curveStyle() const
Return the curve style.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
ExportFileRelations()
Single constructor.
CurveConnectAs curveConnectAs() const
Get method for connect type.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation(const Points &points, const Transformation &transformation, double pointsInterval) const
Compute ordinals, converting screen coordinates to graph coordinates.
QList< double > ExportValuesOrdinal
Single X/Y pair for cubic spline interpolation initialization and calculations.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...