From bcc19c94efa6f5c217a80d9fd8154792b32b1bb0 Mon Sep 17 00:00:00 2001 From: Keith Reynolds Date: Fri, 14 Nov 2014 00:45:28 -0500 Subject: [PATCH] In CriticalPowerWindow add a Percent of Best to the hover message for the current ride when not in "Percent of Best" mode. --- src/CPPlot.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/CPPlot.cpp b/src/CPPlot.cpp index 80bebf731..b5bc0e185 100644 --- a/src/CPPlot.cpp +++ b/src/CPPlot.cpp @@ -1256,6 +1256,7 @@ CPPlot::pointHover(QwtPlotCurve *curve, int index) double xvalue = curve->sample(index).x(); double yvalue = curve->sample(index).y(); QString text, dateStr; + QString currentRidePercentStr; QString units1; QString units2; @@ -1282,16 +1283,28 @@ CPPlot::pointHover(QwtPlotCurve *curve, int index) else units2 = RideFile::unitName(rideSeries, context); + // for the current ride curve, add a percent of rider's actual best. + if (!showPercent && curve == rideCurve && index >= 0 && getBests().count() > index) { + double bestY = getBests()[index]; + if (0 != bestY) { + // use 0 decimals for the percent. + currentRidePercentStr = QString("\n%1 %2") + .arg((yvalue *100)/ bestY, 0, 'f', 0) + .arg(tr("Percent of Best")); + } + } + // no units for Heat Curve if (curve == heatCurve) units2 = QString(tr("Rides")); // output the tooltip - text = QString("%1%2\n%3 %4%5") + text = QString("%1%2\n%3 %4%5%6") .arg(criticalSeries == CriticalPowerWindow::veloclinicplot?QString("%1").arg(xvalue, 0, 'f', RideFile::decimalsFor(rideSeries)):interval_to_str(60.0*xvalue)) .arg(units1) .arg(yvalue, 0, 'f', RideFile::decimalsFor(rideSeries)) .arg(units2) - .arg(dateStr); + .arg(dateStr) + .arg(currentRidePercentStr); // set that text up zoomer->setText(text);