From 085ce83bf59b56b53c02bfe6bcacbe9e8e2fa68d Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Wed, 21 May 2014 14:18:57 +0100 Subject: [PATCH] CPPlot Show Best Option .. sometimes its useful just to see the model and not the bests curve. So added an option to get rid of the bests curve and show the model on its own. --- src/CPPlot.cpp | 19 +++++++++++++++---- src/CPPlot.h | 2 ++ src/CriticalPowerWindow.cpp | 16 ++++++++++++++++ src/CriticalPowerWindow.h | 6 ++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/CPPlot.cpp b/src/CPPlot.cpp index 1f7e5c51a..aabd71a48 100644 --- a/src/CPPlot.cpp +++ b/src/CPPlot.cpp @@ -54,8 +54,10 @@ CPPlot::CPPlot(QWidget *parent, Context *context, bool rangemode) : QwtPlot(pare model(0), modelVariant(0), // state - context(context), rideCache(NULL), bestsCache(NULL), rideSeries(RideFile::watts), isFiltered(false), shadeMode(2), - shadeIntervals(true), rangemode(rangemode), showPercent(false), showHeat(false), showHeatByDate(false), + context(context), rideCache(NULL), bestsCache(NULL), rideSeries(RideFile::watts), + isFiltered(false), shadeMode(2), + shadeIntervals(true), rangemode(rangemode), + showBest(true), showPercent(false), showHeat(false), showHeatByDate(false), plotType(0), // curves and plot objects @@ -327,7 +329,7 @@ CPPlot::plotModel() QPen pen(GColor(CCP)); double width = appsettings->value(this, GC_LINEWIDTH, 1.0).toDouble(); pen.setWidth(width); - pen.setStyle(Qt::DashLine); + if (showBest) pen.setStyle(Qt::DashLine); modelCurve->setPen(pen); modelCurve->attach(this); @@ -575,6 +577,7 @@ CPPlot::plotBests() work[t] = values[t] * t / 1000; // kJ not Joules } + if (showBest) { if (shadingCP == 0) { // PLAIN CURVE @@ -758,6 +761,7 @@ CPPlot::plotBests() ++zone; } } + } // X-AXIS @@ -998,7 +1002,7 @@ CPPlot::setRide(RideItem *rideItem) void CPPlot::pointHover(QwtPlotCurve *curve, int index) { - if (curve == modelCurve) return; // ignore model curve hover + if (showBest && curve == modelCurve) return; // ignore model curve hover if (index >= 0) { @@ -1103,6 +1107,13 @@ CPPlot::setShowHeat(bool x) clearCurves(); } +void +CPPlot::setShowBest(bool x) +{ + showBest = x; + clearCurves(); +} + void CPPlot::setShowPercent(bool x) { diff --git a/src/CPPlot.h b/src/CPPlot.h index 7376be8a9..c289845db 100644 --- a/src/CPPlot.h +++ b/src/CPPlot.h @@ -65,6 +65,7 @@ class CPPlot : public QwtPlot void setRide(RideItem *rideItem); void setDateRange(const QDate &start, const QDate &end); void setShowPercent(bool x); + void setShowBest(bool x); void setShowHeat(bool x); void setShowHeatByDate(bool x); void setShadeMode(int x); @@ -140,6 +141,7 @@ class CPPlot : public QwtPlot int shadeMode; bool shadeIntervals; bool rangemode; + bool showBest; bool showPercent; bool showHeat; bool showHeatByDate; diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index b630a80b9..d21cc601f 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -161,6 +161,11 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, Context *context, boo QLabel *gridify = new QLabel(tr("Show grid")); cl->addRow(gridify, showGridCheck); + showBestCheck = new QCheckBox(this); + showBestCheck->setChecked(true); // default off + QLabel *bestify = new QLabel(tr("Show Bests")); + cl->addRow(bestify, showBestCheck); + showPercentCheck = new QCheckBox(this); showPercentCheck->setChecked(false); // default off QLabel *percentify = new QLabel(tr("Show as percentage")); @@ -446,6 +451,7 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, Context *context, boo connect(rHeat, SIGNAL(stateChanged(int)), this, SLOT(rHeatChanged(int))); connect(showHeatByDateCheck, SIGNAL(stateChanged(int)), this, SLOT(showHeatByDateChanged(int))); connect(showPercentCheck, SIGNAL(stateChanged(int)), this, SLOT(showPercentChanged(int))); + connect(showBestCheck, SIGNAL(stateChanged(int)), this, SLOT(showBestChanged(int))); connect(showGridCheck, SIGNAL(stateChanged(int)), this, SLOT(showGridChanged(int))); connect(rPercent, SIGNAL(stateChanged(int)), this, SLOT(rPercentChanged(int))); connect(dateSetting, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); @@ -1463,6 +1469,16 @@ CriticalPowerWindow::showGridChanged(int state) cpPlot->replot(); } +void +CriticalPowerWindow::showBestChanged(int state) +{ + cpPlot->setShowBest(state); + + // redraw + if (rangemode) dateRangeChanged(DateRange()); + else cpPlot->setRide(currentRide); +} + void CriticalPowerWindow::showPercentChanged(int state) { diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index 414010b50..e1ebd0627 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -51,6 +51,7 @@ class CriticalPowerWindow : public GcChartWindow Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) #endif Q_PROPERTY(int mode READ mode WRITE setMode USER true) + Q_PROPERTY(bool showBest READ showBest WRITE setShowBest USER true) Q_PROPERTY(bool showPercent READ showPercent WRITE setShowPercent USER true) Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid USER true) @@ -196,6 +197,9 @@ class CriticalPowerWindow : public GcChartWindow bool showGrid() { return showGridCheck->isChecked(); } void setShowGrid(bool x) { return showGridCheck->setChecked(x); } + bool showBest() { return showBestCheck->isChecked(); } + void setShowBest(bool x) { return showBestCheck->setChecked(x); } + bool showPercent() { return showPercentCheck->isChecked(); } void setShowPercent(bool x) { return showPercentCheck->setChecked(x); } @@ -212,6 +216,7 @@ class CriticalPowerWindow : public GcChartWindow void showHeatChanged(int check); void showHeatByDateChanged(int check); void showPercentChanged(int check); + void showBestChanged(int check); void showGridChanged(int check); void shadeIntervalsChanged(int state); void setPlotType(int index); @@ -268,6 +273,7 @@ class CriticalPowerWindow : public GcChartWindow QCheckBox *showHeatCheck; QCheckBox *showHeatByDateCheck; QCheckBox *showPercentCheck; + QCheckBox *showBestCheck; QCheckBox *showGridCheck; QCheckBox *rPercent, *rHeat; QwtPlotPicker *picker;