Playing with a gap curve

.. for power on allplot for now.
This commit is contained in:
Mark Liversedge
2015-08-24 21:12:32 +01:00
parent da34d9524d
commit 9d52cf70ce
2 changed files with 18 additions and 23 deletions

View File

@@ -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++;
}
}

View File

@@ -46,6 +46,9 @@
#include <qwt_text.h>
#include <qwt_legend.h>
#include <qwt_series_data.h>
#include "qwt_plot_gapped_curve.h"
#include <QMultiMap>
#include <string.h> // 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<AllPlot *> 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");