mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Playing with a gap curve
.. for power on allplot for now.
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user