From 9d52cf70cebefe75cdca4976c7af30cf4d776d50 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 24 Aug 2015 21:12:32 +0100 Subject: [PATCH] Playing with a gap curve .. for power on allplot for now. --- .../qwtcurve/qwt_plot_gapped_curve.cpp | 34 +++++++------------ src/AllPlot.cpp | 7 ++-- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp b/qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp index 3c198b379..986d4a759 100644 --- a/qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp +++ b/qtsolutions/qwtcurve/qwt_plot_gapped_curve.cpp @@ -32,31 +32,23 @@ void QwtPlotGappedCurve::drawSeries(QPainter *painter, const QwtScaleMap &xMap, to = dataSize() - 1; int i = from; + double last = 0; while (i < to) { - // If data begins with missed values, - // we need to find first non-missed point. - double y = sample(i).y(); - while ((i < to) && (y == gapValue_)) - { - ++i; - y = sample(i).y(); - } // First non-missed point will be the start of curve section. - int start = i; - y = sample(i).y(); - // Find the last non-missed point, it will be the end of curve section. - while ((i < to) && (y != gapValue_)) - { - ++i; - y = sample(i).y(); - } - // Correct the end of the section if it is at missed point - int end = (y == gapValue_) ? i - 1 : i; + double x = sample(i).x(); + double y = sample(i).y(); + if ((y < -0.001 || y > 0.001) && x - last <= gapValue_) { - // Draw the curve section - if (start <= end) - QwtPlotCurve::drawSeries(painter, xMap, yMap, canvRect, start, end); + int start = i-1; + int end = i; + + // Draw the curve section + QwtPlotCurve::drawSeries(painter, xMap, yMap, canvRect, start, end); + } + + last = x; + i++; } } diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 9e37d7465..32a3d8fc3 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -46,6 +46,9 @@ #include #include #include + +#include "qwt_plot_gapped_curve.h" + #include #include // for memcpy @@ -279,7 +282,7 @@ AllPlotObject::AllPlotObject(AllPlot *plot) : plot(plot) { maxKM = maxSECS = 0; - wattsCurve = new QwtPlotCurve(tr("Power")); + wattsCurve = (QwtPlotCurve*)new QwtPlotGappedCurve(tr("Power"), 3); // > 3s is a power gap wattsCurve->setPaintAttribute(QwtPlotCurve::FilterPoints, true); wattsCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 0)); @@ -4202,7 +4205,7 @@ AllPlot::setDataFromPlots(QList plots) case RideFile::watts: { - ourCurve = new QwtPlotCurve(tr("Power")); + ourCurve = (QwtPlotCurve*)(new QwtPlotGappedCurve(tr("Power"), 3)); ourCurve->setPaintAttribute(QwtPlotCurve::FilterPoints, true); thereCurve = referencePlot->standard->wattsCurve; title = tr("Power");