From 033d704e48ef5872b72d63dae7f03dba9529bef1 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 19 May 2014 20:11:45 +0100 Subject: [PATCH] Add Model Data to CP export .. if a model is active we can get the model values now using PDModel::y() which is kinda neat ! --- src/CPPlot.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/CPPlot.cpp b/src/CPPlot.cpp index 2e46e9ddb..1f7e5c51a 100644 --- a/src/CPPlot.cpp +++ b/src/CPPlot.cpp @@ -494,9 +494,8 @@ CPPlot::clearCurves() } // rainbow curve - if (bestsCurves.size()) { - foreach (QwtPlotCurve *curve, bestsCurves) - delete curve; + if (bestsCurves.count()) { + foreach (QwtPlotCurve *curve, bestsCurves) delete curve; bestsCurves.clear(); } @@ -1043,9 +1042,12 @@ CPPlot::exportBests(QString filename) if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) return; // couldn't open file + // do we want to export the model estimate too ? + bool model = (pdModel && (rideSeries == RideFile::wattsKg || rideSeries == RideFile::watts)); + // open stream and write header QTextStream stream(&f); - stream << "seconds, value, date" << endl; + stream << "seconds, value," << (model ? " model, date" : " date") << endl; // output a row for each second foreach(QwtPlotCurve *bestsCurve, bestsCurves) { @@ -1054,14 +1056,17 @@ CPPlot::exportBests(QString filename) for (size_t i=0; idata()->size(); i++) { double xvalue = bestsCurve->sample(i).x(); double yvalue = bestsCurve->sample(i).y(); + double modelvalue = model ? pdModel->y(xvalue) : 0; - int index = xvalue * 60; + int index = xvalue * 60.00f; QDate date; if (index >= 0 && bestsCache && getBests().count() > index) { date = getBestDates()[index]; } - stream << int(xvalue * 60.00f) << "," << yvalue << "," << date.toString() << endl; + // values + if (model) stream << int(xvalue * 60.00f) << "," << yvalue << "," << modelvalue << "," << date.toString() << endl; + else stream << int(xvalue * 60.00f) << "," << yvalue << "," << date.toString() << endl; } }