The Ride Plot currently displays the activity's speed in MPH,

regardless of the Units preference.  This patch checks the preference
and displays it in the appropriate units.

Unlike some of the other cases, I'm checking the value of the Units
setting each time the plot/panel is displayed.  

The patch also pulls the 0.62137119 magic constant into a #define
MILES_PER_KM.  This constant (and it's inverse, KMS_PER_MILE), occurs
in several files, and (IMHO) really deserves to be pulled into a
separate header, but again, that's work for another day.

   --jtc
This commit is contained in:
Justin F. Knotzke
2009-01-02 20:58:06 +00:00
parent f2187c6965
commit d5997b9fee
2 changed files with 16 additions and 3 deletions

View File

@@ -31,10 +31,14 @@
static const inline double
max(double a, double b) { if (a > b) return a; else return b; }
#define MILES_PER_KM 0.62137119
AllPlot::AllPlot() :
d_mrk(NULL), hrArray(NULL), wattsArray(NULL),
speedArray(NULL), cadArray(NULL),
timeArray(NULL), interArray(NULL), smooth(30)
timeArray(NULL), interArray(NULL), smooth(30),
settings(GC_SETTINGS_CO, GC_SETTINGS_APP),
unit(settings.value(GC_UNIT))
{
insertLegend(new QwtLegend(), QwtPlot::BottomLegend);
setCanvasBackground(Qt::white);
@@ -207,7 +211,8 @@ AllPlot::setYMax()
}
if (speedCurve->isVisible()) {
ymax = max(ymax, speedCurve->maxYValue());
ylabel += QString((ylabel == "") ? "" : " / ") + "MPH";
ylabel += QString((ylabel == "") ? "" : " / ") +
QString((unit.toString() == "Metric") ? "KPH" : "MPH");
}
if (cadCurve->isVisible()) {
ymax = max(ymax, cadCurve->maxYValue());
@@ -241,7 +246,10 @@ AllPlot::setData(RideFile *ride)
timeArray[arrayLength] = point->secs;
wattsArray[arrayLength] = max(0, point->watts);
hrArray[arrayLength] = max(0, point->hr);
speedArray[arrayLength] = max(0, point->kph * 0.62137119);
speedArray[arrayLength] = max(0,
((unit.toString() == "Metric")
? point->kph
: point->kph * MILES_PER_KM));
cadArray[arrayLength] = max(0, point->cad);
interArray[arrayLength] = point->interval;
++arrayLength;

View File

@@ -20,6 +20,7 @@
#define _GC_AllPlot_h 1
#include <qwt_plot.h>
#include <QtGui>
class QwtPlotCurve;
class QwtPlotGrid;
@@ -70,6 +71,10 @@ class AllPlot : public QwtPlot
void recalc();
void setYMax();
private:
QSettings settings;
QVariant unit;
};
#endif // _GC_AllPlot_h