AllPlot: Add secondary Scope to plot speed and headwind in the same together

This commit is contained in:
Damien
2013-12-26 15:39:47 +01:00
parent 7d00cba9df
commit 0fa9aec9cd
3 changed files with 11 additions and 4 deletions

View File

@@ -228,7 +228,7 @@ class TimeScaleDraw: public QwtScaleDraw
static inline double
max(double a, double b) { if (a > b) return a; else return b; }
AllPlot::AllPlot(AllPlotWindow *parent, Context *context, RideFile::SeriesType scope, bool wanttext):
AllPlot::AllPlot(AllPlotWindow *parent, Context *context, RideFile::SeriesType scope, RideFile::SeriesType secScope, bool wanttext):
QwtPlot(parent),
rideItem(NULL),
shade_zones(true),
@@ -246,6 +246,7 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context, RideFile::SeriesType s
showBalance(true),
bydist(false),
scope(scope),
secondaryScope(secScope),
context(context),
parent(parent),
wanttext(wanttext)
@@ -1762,6 +1763,10 @@ AllPlot::setDataFromPlot(AllPlot *plot)
{
ourCurve = speedCurve;
thereCurve = referencePlot->speedCurve;
if (secondaryScope == RideFile::headwind) {
ourICurve = windCurve;
thereICurve = referencePlot->windCurve;
}
title = tr("Speed");
}
break;

View File

@@ -63,7 +63,7 @@ class AllPlot : public QwtPlot
// you can declare which series to plot, none means do them all
// wanttext is to say if plot markers should have text
AllPlot(AllPlotWindow *parent, Context *context,
RideFile::SeriesType series = RideFile::none, bool wanttext = true);
RideFile::SeriesType series = RideFile::none, RideFile::SeriesType secSeries = RideFile::none, bool wanttext = true);
bool eventFilter(QObject *object, QEvent *e);
@@ -216,6 +216,7 @@ class AllPlot : public QwtPlot
// scope of plot (none means all, or just for a specific series
RideFile::SeriesType scope;
RideFile::SeriesType secondaryScope;
private:
Context *context;

View File

@@ -1804,6 +1804,7 @@ AllPlotWindow::setupSeriesStackPlots()
// this is NOT a memory leak (see ZZZ below)
seriesPlots.clear();
bool addHeadwind = false;
RideItem* rideItem = current;
if (!rideItem || !rideItem->ride() || rideItem->ride()->dataPoints().isEmpty()) return;
@@ -1819,7 +1820,7 @@ AllPlotWindow::setupSeriesStackPlots()
if (showCad->isChecked() && rideItem->ride()->areDataPresent()->cad) serieslist << RideFile::cad;
if (showAlt->isChecked() && rideItem->ride()->areDataPresent()->alt) serieslist << RideFile::alt;
if (showTemp->isChecked() && rideItem->ride()->areDataPresent()->temp) serieslist << RideFile::temp;
if (showWind->isChecked() && rideItem->ride()->areDataPresent()->headwind) serieslist << RideFile::headwind;
if (showWind->isChecked() && rideItem->ride()->areDataPresent()->headwind) addHeadwind=true; //serieslist << RideFile::headwind;
if (showTorque->isChecked() && rideItem->ride()->areDataPresent()->nm) serieslist << RideFile::nm;
if (showNP->isChecked() && rideItem->ride()->areDataPresent()->watts) serieslist << RideFile::NP;
if (showXP->isChecked() && rideItem->ride()->areDataPresent()->watts) serieslist << RideFile::xPower;
@@ -1831,7 +1832,7 @@ AllPlotWindow::setupSeriesStackPlots()
foreach(RideFile::SeriesType x, serieslist) {
// create that plot
AllPlot *_allPlot = new AllPlot(this, context, x, first);
AllPlot *_allPlot = new AllPlot(this, context, x, (addHeadwind && x == RideFile::kph ? RideFile::headwind : RideFile::none), first);
_allPlot->setAutoFillBackground(false);
_allPlot->setPalette(palette);
_allPlot->setDataFromPlot(allPlot); // will clone all settings and data for the series