diff --git a/src/LTMPlot.cpp b/src/LTMPlot.cpp index c6b8c6c68..bdb51b521 100644 --- a/src/LTMPlot.cpp +++ b/src/LTMPlot.cpp @@ -63,6 +63,7 @@ LTMPlot::LTMPlot(LTMWindow *parent, Context *context) : grid->attach(this); settings = NULL; + cogganPMC = skibaPMC = NULL; // cache when replotting a PMC configUpdate(); // set basic colors @@ -100,6 +101,15 @@ LTMPlot::setAxisTitle(int axis, QString label) void LTMPlot::setData(LTMSettings *set) { + QTime timer; + timer.start(); + + //qDebug()<<"Starting.."<value(this, GC_LINEWIDTH, 2.0).toDouble(); bool donestack = false; @@ -391,6 +405,7 @@ LTMPlot::setData(LTMSettings *set) } // end of reverse for stacked plots + //qDebug()<<"First plotting iteration.."<setData(xdata.data(),ydata.data(), count + 1); current->setBaseline(metricDetail.baseline); + //qDebug()<<"Set Curve Data.."<maxYValue() > maxY[axisid]) maxY[axisid] = current->maxYValue(); if (current->minYValue() < minY[axisid]) minY[axisid] = current->minYValue(); @@ -717,6 +736,9 @@ LTMPlot::setData(LTMSettings *set) } + //qDebug()<<"Second plotting iteration.."<groupBy != LTM_TOD) { // make start date always fall on a Monday @@ -774,8 +796,13 @@ LTMPlot::setData(LTMSettings *set) if (settings->groupBy != LTM_TOD) refreshMarkers(settings->start.date(), settings->end.date(), settings->groupBy); + //qDebug()<<"Final tidy.."<athlete->cyclist, - settings->start, - settings->end, - (appsettings->value(this, GC_STS_DAYS,7)).toInt(), - (appsettings->value(this, GC_LTS_DAYS,42)).toInt()); + StressCalculator *sc ; - sc->calculateStress(context, context->athlete->home.absolutePath(), scoreType, settings->ltmTool->isFiltered(), settings->ltmTool->filters()); + if (scoreType == "coggan_tss" && cogganPMC) { + sc = cogganPMC; + } else if (scoreType == "skiba_bike_score" && skibaPMC) { + sc = skibaPMC; + } else { + sc = new StressCalculator( + context->athlete->cyclist, + settings->start, + settings->end, + (appsettings->value(this, GC_STS_DAYS,7)).toInt(), + (appsettings->value(this, GC_LTS_DAYS,42)).toInt()); + + sc->calculateStress(context, context->athlete->home.absolutePath(), scoreType, settings->ltmTool->isFiltered(), settings->ltmTool->filters()); + + } // pick out any data that is in the date range selected // convert to SummaryMetric Format used on the plot @@ -1037,7 +1073,14 @@ LTMPlot::createPMCCurveData(LTMSettings *settings, MetricDetail metricDetail, customData << add; } - delete sc; + + if (scoreType == "coggan_tss") { + cogganPMC = sc; + } else if (scoreType == "skiba_bike_score") { + skibaPMC = sc; + } else { + delete sc; + } } int diff --git a/src/LTMPlot.h b/src/LTMPlot.h index d79d14a20..2d7bca62b 100644 --- a/src/LTMPlot.h +++ b/src/LTMPlot.h @@ -37,6 +37,7 @@ class LTMPlotBackground; class LTMWindow; class LTMPlotZoneLabel; class LTMScaleDraw; +class StressCalculator; class LTMPlot : public QwtPlot { @@ -97,6 +98,10 @@ class LTMPlot : public QwtPlot int chooseYAxis(QString); void refreshZoneLabels(int); void refreshMarkers(QDate from, QDate to, int groupby); + + // remember the coggan or skiba stress calculators + // so it isn't recalculated for each data series! + StressCalculator *cogganPMC, *skibaPMC; }; // Produce Labels for X-Axis