From f06c5d0624bfd1d6b3bece98ae37f2d841d767da Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 16 Jan 2014 22:55:04 +0000 Subject: [PATCH] Histogram Compare Fixup .. remember we can plot for a season and recognise that when checking for isCompareIntervals in PowerHist. .. fixes a SEGV when looking at a histogram in the trends view whilst compare intervals is active in ride view. --- src/HistogramWindow.cpp | 2 +- src/PowerHist.cpp | 11 ++++++----- src/PowerHist.h | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/HistogramWindow.cpp b/src/HistogramWindow.cpp index d115ef267..432283582 100644 --- a/src/HistogramWindow.cpp +++ b/src/HistogramWindow.cpp @@ -82,7 +82,7 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind // plot QVBoxLayout *vlayout = new QVBoxLayout; vlayout->setSpacing(10); - powerHist = new PowerHist(context); + powerHist = new PowerHist(context, rangemode); vlayout->addWidget(powerHist); setChartLayout(vlayout); diff --git a/src/PowerHist.cpp b/src/PowerHist.cpp index d84c22015..8f1a0df15 100644 --- a/src/PowerHist.cpp +++ b/src/PowerHist.cpp @@ -45,9 +45,10 @@ #include "LTMCanvasPicker.h" // for tooltip -PowerHist::PowerHist(Context *context): +PowerHist::PowerHist(Context *context, bool rangemode) : minX(0), maxX(0), + rangemode(rangemode), rideItem(NULL), context(context), series(RideFile::watts), @@ -303,7 +304,7 @@ PowerHist::recalcCompareIntervals() // Set curves .. they will always have been created // in setDataFromCompareIntervals, but no samples set - if (!isVisible() && !context->isCompareIntervals) return; + if (!isVisible() && (rangemode || !context->isCompareIntervals)) return; double ncols = 0; foreach(CompareInterval x, context->compareIntervals) { @@ -540,7 +541,7 @@ PowerHist::recalcCompareIntervals() void PowerHist::recalc(bool force) { - if (context->isCompareIntervals) { //XXX bodge for now + if (!rangemode && context->isCompareIntervals) { recalcCompareIntervals(); return; } @@ -831,7 +832,7 @@ PowerHist::setYMax() { double MaxY=0; - if (context->isCompareIntervals) { + if (!rangemode && context->isCompareIntervals) { int i=0; foreach (QwtPlotCurve *p, compareCurves) { @@ -1034,7 +1035,7 @@ void PowerHist::setComparePens() { // no compare? don't bother - if (!context->isCompareIntervals) return; + if (rangemode || !context->isCompareIntervals) return; double width = appsettings->value(this, GC_LINEWIDTH, 2.0).toDouble(); for (int i=0; icompareIntervals.count(); i++) { diff --git a/src/PowerHist.h b/src/PowerHist.h index 076e4af38..0695e47fa 100644 --- a/src/PowerHist.h +++ b/src/PowerHist.h @@ -116,11 +116,12 @@ class PowerHist : public QwtPlot public: - PowerHist(Context *context); + PowerHist(Context *context, bool rangemode); ~PowerHist(); double minX; double maxX; + bool rangemode; public slots: