7 #include "CurveConnectAs.h" 9 #include "EngaugeAssert.h" 10 #include "ExportFileRelations.h" 11 #include "ExportLayoutFunctions.h" 12 #include "ExportOrdinalsSmooth.h" 13 #include "ExportOrdinalsStraight.h" 14 #include "FormatCoordsUnits.h" 18 #include <QTextStream> 21 #include "SplinePair.h" 22 #include "Transformation.h" 27 const int COLUMNS_PER_CURVE = 2;
36 const QStringList &curvesIncluded,
37 const QString &delimiter,
39 QTextStream &str)
const 41 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportAllPerLineXThetaValuesMerged";
43 int curveCount = curvesIncluded.count();
44 int maxColumnSize = maxColumnSizeAllocation (modelExportOverride,
50 if (maxColumnSize > 0) {
52 QVector<QVector<QString*> > xThetaYRadiusValues (COLUMNS_PER_CURVE * curveCount, QVector<QString*> (maxColumnSize));
53 initializeXThetaYRadiusValues (curvesIncluded,
55 loadXThetaYRadiusValues (modelExportOverride,
61 outputXThetaYRadiusValues (modelExportOverride,
66 destroy2DArray (xThetaYRadiusValues);
73 const QStringList &curvesIncluded,
74 const QString &delimiter,
76 QTextStream &str)
const 78 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportOnePerLineXThetaValuesMerged";
80 QStringList::const_iterator itr;
81 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
83 QString curveIncluded = *itr;
85 exportAllPerLineXThetaValuesMerged (modelExportOverride,
88 QStringList (curveIncluded),
99 QTextStream &str)
const 101 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::exportToFile";
104 QStringList curvesIncluded = curvesToInclude (modelExportOverride,
107 CONNECT_AS_RELATION_SMOOTH,
108 CONNECT_AS_RELATION_STRAIGHT);
111 const QString delimiter = exportDelimiterToText (modelExportOverride.
delimiter(),
112 modelExportOverride.
header() == EXPORT_HEADER_GNUPLOT);
115 if (modelExportOverride.
layoutFunctions() == EXPORT_LAYOUT_ALL_PER_LINE) {
116 exportAllPerLineXThetaValuesMerged (modelExportOverride,
124 exportOnePerLineXThetaValuesMerged (modelExportOverride,
134 void ExportFileRelations::initializeXThetaYRadiusValues (
const QStringList &curvesIncluded,
135 QVector<QVector<QString*> > &xThetaYRadiusValues)
const 137 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::initializeXThetaYRadiusValues";
140 int curveCount = curvesIncluded.count();
141 int xThetaCount = xThetaYRadiusValues [0].count();
142 for (
int row = 0; row < xThetaCount; row++) {
143 for (
int col = 0; col < COLUMNS_PER_CURVE * curveCount; col++) {
144 xThetaYRadiusValues [col] [row] =
new QString;
149 QPointF ExportFileRelations::linearlyInterpolate (
const Points &points,
155 double xTheta = 0, yRadius = 0;
156 double ordinalBefore = 0;
157 QPointF posGraphBefore;
158 bool foundIt =
false;
159 for (
int ip = 0; ip < points.count(); ip++) {
161 const Point &point = points.at (ip);
166 if (ordinal <= point.
ordinal()) {
172 xTheta = posGraph.x();
173 yRadius = posGraph.y();
179 double s = (ordinal - ordinalBefore) / (point.
ordinal() - ordinalBefore);
180 xTheta = (1.0 - s) * posGraphBefore.x() + s * posGraph.x();
181 yRadius = (1.0 - s) * posGraphBefore.y() + s * posGraph.y();
187 ordinalBefore = point.
ordinal();
188 posGraphBefore = posGraph;
194 xTheta = posGraphBefore.x();
195 yRadius = posGraphBefore.y();
199 return QPointF (xTheta,
206 const QStringList &curvesIncluded,
208 QVector<QVector<QString*> > &xThetaYRadiusValues)
const 210 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValues";
213 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
215 int colXTheta = 2 * ic;
216 int colYRadius = 2 * ic + 1;
218 const QString curveName = curvesIncluded.at (ic);
221 const Points points = curve->
points ();
226 loadXThetaYRadiusValuesForCurveRaw (document.
modelCoords(),
229 xThetaYRadiusValues [colXTheta],
230 xThetaYRadiusValues [colYRadius],
245 loadXThetaYRadiusValuesForCurveInterpolatedSmooth (document.
modelCoords(),
249 xThetaYRadiusValues [colXTheta],
250 xThetaYRadiusValues [colYRadius],
255 loadXThetaYRadiusValuesForCurveInterpolatedStraight (document.
modelCoords(),
259 xThetaYRadiusValues [colXTheta],
260 xThetaYRadiusValues [colYRadius],
267 void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth (
const DocumentModelCoords &modelCoords,
269 const Points &points,
270 const ExportValuesOrdinal &ordinals,
271 QVector<QString*> &xThetaValues,
272 QVector<QString*> &yRadiusValues,
275 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedSmooth";
278 vector<SplinePair> xy;
296 for (
int row = 0; row < ordinals.count(); row++) {
298 double ordinal = ordinals.at (row);
300 double xTheta = splinePairFound.
x ();
301 double yRadius = splinePairFound.
y ();
308 *(xThetaValues [row]),
309 *(yRadiusValues [row]),
315 void ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight (
const DocumentModelCoords &modelCoords,
317 const Points &points,
318 const ExportValuesOrdinal &ordinals,
319 QVector<QString*> &xThetaValues,
320 QVector<QString*> &yRadiusValues,
323 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveInterpolatedStraight";
328 for (
int row = 0; row < ordinals.count(); row++) {
330 double ordinal = ordinals.at (row);
332 QPointF pointInterpolated = linearlyInterpolate (points,
338 pointInterpolated.y(),
341 *(xThetaValues [row]),
342 *(yRadiusValues [row]),
347 void ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw (
const DocumentModelCoords &modelCoords,
349 const Points &points,
350 QVector<QString*> &xThetaValues,
351 QVector<QString*> &yRadiusValues,
354 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::loadXThetaYRadiusValuesForCurveRaw";
358 for (
int pt = 0; pt < points.count(); pt++) {
360 const Point &point = points.at (pt);
371 *(xThetaValues [pt]),
372 *(yRadiusValues [pt]),
380 const QStringList &curvesIncluded)
const 382 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::maxColumnSizeAllocation";
384 int maxColumnSize = 0;
387 for (
int ic = 0; ic < curvesIncluded.count(); ic++) {
389 const QString curveName = curvesIncluded.at (ic);
392 const Points points = curve->
points ();
397 maxColumnSize = qMax (maxColumnSize,
411 maxColumnSize = qMax (maxColumnSize,
416 return maxColumnSize;
419 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervals (
double pointsIntervalRelations,
420 ExportPointsIntervalUnits pointsIntervalUnits,
421 CurveConnectAs curveConnectAs,
423 const Points &points)
const 425 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervals";
427 if (pointsIntervalUnits == EXPORT_POINTS_INTERVAL_UNITS_GRAPH) {
428 if (curveConnectAs == CONNECT_AS_RELATION_SMOOTH) {
430 return ordinalsAtIntervalsSmoothGraph (pointsIntervalRelations,
436 return ordinalsAtIntervalsStraightGraph (pointsIntervalRelations,
443 if (curveConnectAs == CONNECT_AS_RELATION_SMOOTH) {
445 return ordinalsAtIntervalsSmoothScreen (pointsIntervalRelations,
450 return ordinalsAtIntervalsStraightScreen (pointsIntervalRelations,
457 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothGraph (
double pointsIntervalRelations,
459 const Points &points)
const 461 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsSmoothGraph";
463 ExportValuesOrdinal ordinals;
466 if ((pointsIntervalRelations > 0) &&
467 (points.count() > 0)) {
470 vector<SplinePair> xy;
480 pointsIntervalRelations);
486 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsSmoothScreen (
double pointsIntervalRelations,
487 const Points &points)
const 489 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsSmoothScreen" 490 <<
" pointCount=" << points.count();
493 ExportValuesOrdinal ordinals;
496 if ((pointsIntervalRelations > 0) &&
497 (points.count() > 0)) {
500 vector<SplinePair> xy;
509 pointsIntervalRelations);
515 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightGraph (
double pointsIntervalRelations,
517 const Points &points)
const 519 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsStraightGraph";
521 ExportValuesOrdinal ordinals;
524 if ((pointsIntervalRelations > 0) &&
525 (points.count() > 0)) {
531 pointsIntervalRelations);
537 ExportValuesOrdinal ExportFileRelations::ordinalsAtIntervalsStraightScreen (
double pointsIntervalRelations,
538 const Points &points)
const 540 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::ordinalsAtIntervalsStraightScreen" 541 <<
" pointCount=" << points.count();
544 ExportValuesOrdinal ordinals;
547 if ((pointsIntervalRelations > 0) &&
548 (points.count() > 0)) {
553 pointsIntervalRelations);
560 const QStringList &curvesIncluded,
561 QVector<QVector<QString*> > &xThetaYRadiusValues,
562 const QString &delimiter,
563 QTextStream &str)
const 565 LOG4CPP_INFO_S ((*mainCat)) <<
"ExportFileRelations::outputXThetaYRadiusValues";
568 if (modelExportOverride.
header() != EXPORT_HEADER_NONE) {
569 if (modelExportOverride.
header() == EXPORT_HEADER_GNUPLOT) {
570 str << curveSeparator(str.string());
571 str << gnuplotComment();
573 QString delimiterForRow;
574 QStringList::const_iterator itr;
575 for (itr = curvesIncluded.begin(); itr != curvesIncluded.end(); itr++) {
576 QString curveName = *itr;
577 str << delimiterForRow << modelExportOverride.
xLabel();
578 delimiterForRow = delimiter;
579 str << delimiterForRow << curveName;
584 for (
int row = 0; row < xThetaYRadiusValues [0].count(); row++) {
586 QString delimiterForRow;
587 for (
int col = 0; col < xThetaYRadiusValues.count(); col++) {
589 str << delimiterForRow << *(xThetaYRadiusValues [col] [row]);
590 delimiterForRow = delimiter;
SplinePair interpolateCoeff(double t) const
Return interpolated y for specified x.
Cubic interpolation given independent and dependent value vectors.
const Points points() const
Return a shallow copy of the Points.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
LineStyle lineStyle() const
Get method for LineStyle.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
double y() const
Get method for y.
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.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
void loadSplinePairsWithTransformation(const Points &points, const Transformation &transformation, std::vector< double > &t, std::vector< SplinePair > &xy) const
Load t (=ordinal) and xy (=screen position) spline pairs, converting screen coordinates to graph coor...
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...
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 ...
double x() const
Get method for x.
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.
Single X/Y pair for cubic spline interpolation initialization and calculations.