diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 47a3ad0e7..9bb12009e 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -297,6 +297,9 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context): wCurve = new QwtPlotCurve(tr("W' Balance (j)")); wCurve->setYAxis(yRight3); + curveTitle.attach(this); + curveTitle.setLabelAlignment(Qt::AlignRight); + intervalHighlighterCurve = new QwtPlotCurve(); intervalHighlighterCurve->setYAxis(yLeft); intervalHighlighterCurve->setData(new IntervalPlotData(this, context)); @@ -1176,6 +1179,10 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) stopidx = plot->timeIndex(plot->timeArray[(stopidx>=plot->timeArray.size()?plot->timeArray.size()-1:stopidx)]/60)-1; } + // center the curve title + curveTitle.setYValue(30); + curveTitle.setXValue(2); + // make sure indexes are still valid if (startidx > stopidx || startidx < 0 || stopidx < 0) return; @@ -1198,6 +1205,14 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) // attach appropriate curves //if (this->legend()) this->legend()->hide(); + if (showW && parent->wpData->TAU > 0) { + QwtText text(QString("tau=%1").arg(parent->wpData->TAU)); + text.setFont(QFont("Helvetica", 10, QFont::Bold)); + text.setColor(Qt::red); + curveTitle.setLabel(text); + } else { + curveTitle.setLabel(QwtText("")); + } wCurve->detach(); wattsCurve->detach(); @@ -1330,6 +1345,7 @@ AllPlot::setDataFromRide(RideItem *_rideItem) if (_rideItem == NULL) return; wattsArray.clear(); + curveTitle.setLabel(QwtText(QString(""), QwtText::PlainText)); // default to no title RideFile *ride = rideItem->ride(); if (ride && ride->dataPoints().size()) { @@ -1550,6 +1566,14 @@ AllPlot::setShowW(bool show) { showW = show; wCurve->setVisible(show); + if (showW && parent->wpData->TAU > 0) { + QwtText text(QString("tau=%1").arg(parent->wpData->TAU)); + text.setFont(QFont("Helvetica", 10, QFont::Bold)); + text.setColor(Qt::red); + curveTitle.setLabel(text); + } else { + curveTitle.setLabel(QwtText("")); + } setYMax(); replot(); } diff --git a/src/AllPlot.h b/src/AllPlot.h index 816eb97e8..85f264ea0 100644 --- a/src/AllPlot.h +++ b/src/AllPlot.h @@ -22,6 +22,10 @@ #include #include +#include +#include +#include +#include #include class QwtPlotCurve; @@ -121,6 +125,7 @@ class AllPlot : public QwtPlot QwtPlotGrid *grid; QVector d_mrk; QVector cal_mrk; + QwtPlotMarker curveTitle; QwtPlotMarker *allMarker1; QwtPlotMarker *allMarker2; QwtPlotCurve *wattsCurve; diff --git a/src/WPrime.cpp b/src/WPrime.cpp index 8b3f0a5d8..fa8b0c36a 100644 --- a/src/WPrime.cpp +++ b/src/WPrime.cpp @@ -36,12 +36,9 @@ #include "WPrime.h" const double WprimeMultConst = -1.0; -const double WprimeDecayConst = 336; const int WprimeDecayPeriod = 1200; // 1200 seconds or 20 minutes const double E = 2.71828183; -inline double decaySchedule(double sec) { return pow(E, -(sec/WprimeDecayConst)); } - WPrime::WPrime() { // XXX will need to reset metrics when they are added @@ -64,6 +61,7 @@ WPrime::setRide(RideFile *input) //XXX will need to reset metrics when they are added minY = maxY = 0; + TAU=0; //qDebug()<<"now work to do"< inputArray(last+1); for (int i=0; i CP ? value-CP : 0; + + if (value < CP) { + totalBelowCP += value; + countBelowCP++; + } } + TAU = 546.00f * pow(E,-0.01*(CP - (totalBelowCP/countBelowCP))) + 316.00f; + TAU = int(TAU); // round it down + //qDebug()<<"data preparation took"< 0; j++) { - sumproduct += inputArray.at(i-j) * pow(E, -(j/WprimeDecayConst)); + sumproduct += inputArray.at(i-j) * pow(E, -(double(j)/TAU)); } values[i] = sumproduct * WprimeMultConst; diff --git a/src/WPrime.h b/src/WPrime.h index 4df5256ba..9289047a7 100644 --- a/src/WPrime.h +++ b/src/WPrime.h @@ -45,6 +45,7 @@ class WPrime { QVector &xdata() { return xvalues; } double minY, maxY; + double TAU; private: