Plot Predicted W'bal in Train mode

.. only plots predicted W'bal for the workout but at least that
   means you can see if the workout is even possible.
This commit is contained in:
Mark Liversedge
2014-01-28 18:32:26 +00:00
parent 0df5bf8646
commit 2877ddd6c5
5 changed files with 222 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
#include "ErgFilePlot.h"
#include "WPrime.h"
#include "Context.h"
// Bridge between QwtPlot and ErgFile to avoid having to
@@ -89,6 +90,8 @@ ErgFilePlot::ErgFilePlot(Context *context) : context(context)
setCanvasBackground(GColor(CRIDEPLOTBACKGROUND));
static_cast<QwtPlotCanvas*>(canvas())->setFrameStyle(QFrame::NoFrame);
//courseData = data; // what we plot
setAutoDelete(false);
setAxesCount(QwtAxis::yRight, 4);
// Setup the left axis (Power)
setAxisTitle(yLeft, "Watts");
@@ -158,6 +161,31 @@ ErgFilePlot::ErgFilePlot(Context *context) : context(context)
QPen Lodpen = QPen(Qt::blue, 1.0);
LodCurve->setPen(Lodpen);
wbalCurvePredict = new QwtPlotCurve("W'bal Predict");
wbalCurvePredict->attach(this);
wbalCurvePredict->setYAxis(QwtAxisId(QwtAxis::yRight, 3));
QColor predict = GColor(CWBAL).darker();
predict.setAlpha(200);
QPen wbalPen = QPen(predict, 2.0); // predict darker...
wbalCurvePredict->setPen(wbalPen);
wbalCurvePredict->setVisible(true);
wbalCurveActual = new QwtPlotCurve("W'bal Actual");
wbalCurveActual->attach(this);
wbalCurveActual->setYAxis(QwtAxisId(QwtAxis::yRight, 3));
QPen wbalPenA = QPen(GColor(CWBAL), 1.0); // actual lighter
wbalCurveActual->setPen(wbalPenA);
sd = new QwtScaleDraw;
sd->enableComponent(QwtScaleDraw::Ticks, false);
sd->enableComponent(QwtScaleDraw::Backbone, false);
sd->setLabelRotation(90);// in the 000s
sd->setTickLength(QwtScaleDiv::MajorTick, 3);
setAxisScaleDraw(QwtAxisId(QwtAxis::yRight, 3), sd);
pal.setColor(QPalette::WindowText, GColor(CWBAL));
pal.setColor(QPalette::Text, GColor(CWBAL));
axisWidget(QwtAxisId(QwtAxis::yRight, 3))->setPalette(pal);
// telemetry history
wattsCurve = new QwtPlotCurve("Power");
QPen wattspen = QPen(GColor(CPOWER));
@@ -339,6 +367,21 @@ ErgFilePlot::setData(ErgFile *ergfile)
}
}
// wbal predict curve and clear actual curve
QVector<double> empty;
wbalCurveActual->setSamples(empty, empty);
// compute wbal curve for the erg file
calculator;
calculator.setErg(ergfile);
setAxisTitle(QwtAxisId(QwtAxis::yRight, 3), tr("W' Balance (j)"));
setAxisScale(QwtAxisId(QwtAxis::yRight, 3),calculator.minY-1000,calculator.maxY+1000);
setAxisLabelAlignment(QwtAxisId(QwtAxis::yRight, 3),Qt::AlignVCenter);
// and the values ... but avoid sharing!
wbalCurvePredict->setSamples(calculator.xdata(), calculator.ydata());
} else {
// clear the plot we have nothing selected