7 #include "CurveConnectAs.h" 9 #include "DocumentModelGeneral.h" 10 #include "EngaugeAssert.h" 11 #include "ExportFileRelations.h" 12 #include "ExportLayoutFunctions.h" 13 #include "ExportOrdinalsSmooth.h" 14 #include "ExportOrdinalsStraight.h" 15 #include "FormatCoordsUnits.h" 19 #include <QTextStream> 22 #include "SplinePair.h" 23 #include "Transformation.h" 28 const int COLUMNS_PER_CURVE = 2;
37 const QStringList &curvesIncluded,
38 const QString &delimiter,
42 QTextStream &str)
const 44 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportAllPerLineXThetaValuesMerged";
46 int curveCount = curvesIncluded.count();
47 int maxColumnSize = maxColumnSizeAllocation (modelExportOverride,
55 if (maxColumnSize > 0) {
57 QVector<QVector<QString*> > xThetaYRadiusValues (COLUMNS_PER_CURVE * curveCount, QVector<QString*> (maxColumnSize));
58 initializeXThetaYRadiusValues (curvesIncluded,
60 loadXThetaYRadiusValues (modelExportOverride,
68 outputXThetaYRadiusValues (modelExportOverride,
73 destroy2DArray (xThetaYRadiusValues);
80 const QStringList &curvesIncluded,
81 const QString &delimiter,
85 QTextStream &str)
const 87 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportOnePerLineXThetaValuesMerged";
89 QStringList::const_iterator itr;
90 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
92 QString curveIncluded = *itr;
94 exportAllPerLineXThetaValuesMerged (modelExportOverride,
97 QStringList (curveIncluded),
110 QTextStream &str)
const 112 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportToFile";
119 QStringList curvesIncluded = curvesToInclude (modelExportOverride,
122 CONNECT_AS_RELATION_SMOOTH,
123 CONNECT_AS_RELATION_STRAIGHT);
126 const QString delimiter = exportDelimiterToText (modelExportOverride.
delimiter(),
127 modelExportOverride.
header() == EXPORT_HEADER_GNUPLOT);
130 if (modelExportOverride.
layoutFunctions() == EXPORT_LAYOUT_ALL_PER_LINE) {
131 exportAllPerLineXThetaValuesMerged (modelExportOverride,
141 exportOnePerLineXThetaValuesMerged (modelExportOverride,
153 void ExportFileRelations::initializeXThetaYRadiusValues (
const QStringList &curvesIncluded,
154 QVector<QVector<QString*> > &xThetaYRadiusValues)
const 156 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::initializeXThetaYRadiusValues";
159 int curveCount = curvesIncluded.count();
160 int xThetaCount = xThetaYRadiusValues [0].count();
161 for (
int row = 0; row < xThetaCount; row++) {
162 for (
int col = 0; col < COLUMNS_PER_CURVE * curveCount; col++) {
163 xThetaYRadiusValues [col] [row] =
new QString;
168 QPointF ExportFileRelations::linearlyInterpolate (
const Points &points,
174 double xTheta = 0, yRadius = 0;
175 double ordinalBefore = 0;
176 QPointF posGraphBefore;
177 bool foundIt =
false;
178 for (
int ip = 0; ip < points.count(); ip++) {
180 const Point &point = points.at (ip);
185 if (ordinal <= point.
ordinal()) {
191 xTheta = posGraph.x();
192 yRadius = posGraph.y();
198 double s = (ordinal - ordinalBefore) / (point.
ordinal() - ordinalBefore);
199 xTheta = (1.0 - s) * posGraphBefore.x() + s * posGraph.x();
200 yRadius = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
206 ordinalBefore = point.
ordinal();
207 posGraphBefore = posGraph;
213 xTheta = posGraphBefore.x();
214 yRadius = posGraphBefore.y();
218 return QPointF (xTheta,
225 const QStringList &curvesIncluded,
229 QVector<QVector<QString*> > &xThetaYRadiusValues)
const 231 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValues";
234 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
236 int colXTheta = 2 * ic;
237 int colYRadius = 2 * ic + 1;
239 const QString curveName = curvesIncluded.at (ic);
242 const Points points = curve->
points ();
247 loadXThetaYRadiusValuesForCurveRaw (document.
modelCoords(),
251 xThetaYRadiusValues [colXTheta],
252 xThetaYRadiusValues [colYRadius],
269 loadXThetaYRadiusValuesForCurveInterpolatedSmooth (document.
modelCoords(),
274 xThetaYRadiusValues [colXTheta],
275 xThetaYRadiusValues [colYRadius],
282 loadXThetaYRadiusValuesForCurveInterpolatedStraight (document.
modelCoords(),
287 xThetaYRadiusValues [colXTheta],
288 xThetaYRadiusValues [colYRadius],
295 void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth (
const DocumentModelCoords &modelCoords,
298 const Points &points,
299 const ExportValuesOrdinal &ordinals,
300 QVector<QString*> &xThetaValues,
301 QVector<QString*> &yRadiusValues,
304 bool isLogYRadius)
const 306 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth";
309 vector<SplinePair> xy;
329 for (
int row = 0; row < ordinals.count(); row++) {
331 double ordinal = ordinals.at (row);
333 double xTheta = splinePairFound.
x ();
334 double yRadius = splinePairFound.
y ();
342 *(xThetaValues [row]),
343 *(yRadiusValues [row]),
349 void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight (
const DocumentModelCoords &modelCoords,
352 const Points &points,
353 const ExportValuesOrdinal &ordinals,
354 QVector<QString*> &xThetaValues,
355 QVector<QString*> &yRadiusValues,
358 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight";
363 for (
int row = 0; row < ordinals.count(); row++) {
365 double ordinal = ordinals.at (row);
367 QPointF pointInterpolated = linearlyInterpolate (points,
373 pointInterpolated.y(),
377 *(xThetaValues [row]),
378 *(yRadiusValues [row]),
383 void ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw (
const DocumentModelCoords &modelCoords,
386 const Points &points,
387 QVector<QString*> &xThetaValues,
388 QVector<QString*> &yRadiusValues,
391 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw";
395 for (
int pt = 0; pt < points.count(); pt++) {
397 const Point &point = points.at (pt);
409 *(xThetaValues [pt]),
410 *(yRadiusValues [pt]),
420 const QStringList &curvesIncluded)
const 422 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::maxColumnSizeAllocation";
424 int maxColumnSize = 0;
427 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
429 const QString curveName = curvesIncluded.at (ic);
432 const Points points = curve->
points ();
437 maxColumnSize = qMax (maxColumnSize,
454 maxColumnSize = qMax (maxColumnSize,
459 return maxColumnSize;
462 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervals (
double pointsIntervalRelations,
463 ExportPointsIntervalUnits pointsIntervalUnits,
464 CurveConnectAs curveConnectAs,
468 const Points &points)
const 470 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervals";
472 if (pointsIntervalUnits == EXPORT_POINTS_INTERVAL_UNITS_GRAPH) {
473 if (curveConnectAs == CONNECT_AS_RELATION_SMOOTH) {
475 return ordinalsAtIntervalsSmoothGraph (pointsIntervalRelations,
483 return ordinalsAtIntervalsStraightGraph (pointsIntervalRelations,
490 if (curveConnectAs == CONNECT_AS_RELATION_SMOOTH) {
492 return ordinalsAtIntervalsSmoothScreen (pointsIntervalRelations,
497 return ordinalsAtIntervalsStraightScreen (pointsIntervalRelations,
504 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothGraph (
double pointsIntervalRelations,
508 const Points &points)
const 510 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsSmoothGraph";
512 ExportValuesOrdinal ordinals;
515 if ((pointsIntervalRelations > 0) &&
516 (points.count() > 0)) {
519 vector<SplinePair> xy;
531 pointsIntervalRelations);
537 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothScreen (
double pointsIntervalRelations,
538 const Points &points)
const 540 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsSmoothScreen" 541 <<
" pointCount=" << points.count();
544 ExportValuesOrdinal ordinals;
547 if ((pointsIntervalRelations > 0) &&
548 (points.count() > 0)) {
551 vector<SplinePair> xy;
560 pointsIntervalRelations);
566 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightGraph (
double pointsIntervalRelations,
568 const Points &points)
const 570 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsStraightGraph";
572 ExportValuesOrdinal ordinals;
575 if ((pointsIntervalRelations > 0) &&
576 (points.count() > 0)) {
582 pointsIntervalRelations);
588 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightScreen (
double pointsIntervalRelations,
589 const Points &points)
const 591 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsStraightScreen" 592 <<
" pointCount=" << points.count();
595 ExportValuesOrdinal ordinals;
598 if ((pointsIntervalRelations > 0) &&
599 (points.count() > 0)) {
604 pointsIntervalRelations);
611 const QStringList &curvesIncluded,
612 QVector<QVector<QString*> > &xThetaYRadiusValues,
613 const QString &delimiter,
614 QTextStream &str)
const 616 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::outputXThetaYRadiusValues";
619 if (modelExportOverride.
header() != EXPORT_HEADER_NONE) {
620 if (modelExportOverride.
header() == EXPORT_HEADER_GNUPLOT) {
621 str << curveSeparator(str.string());
622 str << gnuplotComment();
624 QString delimiterForRow;
625 QStringList::const_iterator itr;
626 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
627 QString curveName = *itr;
628 str << delimiterForRow << modelExportOverride.
xLabel();
629 delimiterForRow = delimiter;
630 str << delimiterForRow << curveName;
635 for (
int row = 0; row < xThetaYRadiusValues [0].count(); row++) {
637 QString delimiterForRow;
638 for (
int col = 0; col < xThetaYRadiusValues.count(); col++) {
640 str << delimiterForRow << *(xThetaYRadiusValues [col] [row]);
641 delimiterForRow = delimiter;
Model for DlgSettingsGeneral and CmdSettingsGeneral.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Cubic interpolation given independent and dependent value vectors.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithTransformation(const Points &points, const Transformation &transformation, double pointsInterval) const
Compute ordinals, converting screen coordinates to graph coordinates.
SplinePair interpolateCoeff(double t) const
Return interpolated y for specified x.
double y() const
Get method for y.
const Curve * curveForCurveName(const QString &curveName) const
See CurvesGraphs::curveForCurveNames, although this also works for AXIS_CURVE_NAME.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
QPointF posScreen() const
Accessor for screen position.
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.
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
const Points points() const
Return a shallow copy of the Points.
Model for DlgSettingsMainWindow.
const LineStyle lineStyle(const QString &curveName) const
Get method for copying one line style in one step.
LineStyle lineStyle() const
Get method for LineStyle.
Utility class to interpolate points spaced evenly along a piecewise defined curve with fitted spline...
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsCoords and CmdSettingsCoords.
Storage of one imported image and the data attached to that image.
Container for one set of digitized Points.
Details for a specific Line.
Utility class to interpolate points spaced evenly along a piecewise defined curve with line segments ...
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...
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CurveStyle curveStyle() const
Return the curve style.
ExportFileRelations()
Single constructor.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
double x() const
Get method for x.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Single X/Y pair for cubic spline interpolation initialization and calculations.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
ExportValuesOrdinal ordinalsAtIntervalsGraphWithoutTransformation(const Points &points, double pointsInterval) const
Compute ordinals, without any conversion to graph coordinates.
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...