Permalink
Browse files

Merge branch 'Walibu-master'

  • Loading branch information...
amtriathlon committed Jan 12, 2018
2 parents b65dfc9 + 6b1f3f4 commit ced9eba3606995726a4bd19953fd8a313f0a6279
Showing with 75 additions and 10 deletions.
  1. +28 −4 src/Charts/CPPlot.cpp
  2. +2 −0 src/Charts/CPPlot.h
  3. +37 −6 src/Charts/CriticalPowerWindow.cpp
  4. +8 −0 src/Charts/CriticalPowerWindow.h
View
@@ -64,6 +64,7 @@ CPPlot::CPPlot(QWidget *parent, Context *context, bool rangemode) : QwtPlot(pare
shadeIntervals(true), rangemode(rangemode),
showBest(true), filterBest(false), showPercent(false), showHeat(false), showHeatByDate(false), showDelta(false), showDeltaPercent(false),
plotType(0),
xAxisLinearOnSpeed(true),
// curves and plot objects
rideCurve(NULL), modelCurve(NULL), effortCurve(NULL), heatCurve(NULL), heatAgeCurve(NULL), pdModel(NULL)
@@ -235,7 +236,11 @@ CPPlot::setSeries(CriticalPowerWindow::CriticalSeriesType criticalSeries)
case CriticalPowerWindow::kph:
series = tr("Speed");
units = tr("kph");
scale = linear;
if (xAxisLinearOnSpeed == true) {
scale = linear;
} else {
scale = log;
}
break;
case CriticalPowerWindow::nm:
@@ -1411,8 +1416,9 @@ CPPlot::plotBests(RideItem *rideItem)
// now set the scale
QwtScaleDiv div((double)xmin, (double)xmax);
if (criticalSeries == CriticalPowerWindow::work ||
criticalSeries == CriticalPowerWindow::kph)
(criticalSeries == CriticalPowerWindow::kph && xAxisLinearOnSpeed))
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksEnergy);
else if (criticalSeries == CriticalPowerWindow::veloclinicplot)
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksVeloclinic);
@@ -2044,6 +2050,22 @@ CPPlot::setShadeIntervals(int x)
clearCurves();
}
void
CPPlot::showXAxisLinear(bool x)
{
xAxisLinearOnSpeed = x;
// change to linear/log on critical speed chart only
if (this->criticalSeries == CriticalPowerWindow::kph) {
lastupdate = QTime::currentTime();
clearCurves();
// redraw
setSeries(this->criticalSeries);
setRide(const_cast<RideItem*>(context->currentRideItem()));
calculateForDateRanges(context->compareDateRanges);
}
}
// model parameters!
void
CPPlot::setModel(int sanI1, int sanI2, int anI1, int anI2, int aeI1, int aeI2, int laeI1, int laeI2, int model, int variant)
@@ -2578,8 +2600,9 @@ CPPlot::calculateForDateRanges(QList<CompareDateRange> compareDateRanges)
// now set the scale
QwtScaleDiv div((double)xmin, (double)xmax);
if (criticalSeries == CriticalPowerWindow::work ||
criticalSeries == CriticalPowerWindow::kph)
(criticalSeries == CriticalPowerWindow::kph && xAxisLinearOnSpeed))
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksEnergy);
else if (criticalSeries == CriticalPowerWindow::veloclinicplot)
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksVeloclinic);
@@ -2721,8 +2744,9 @@ CPPlot::calculateForIntervals(QList<CompareInterval> compareIntervals)
// now set the scale
QwtScaleDiv div((double)xmin, (double)xmax);
if (criticalSeries == CriticalPowerWindow::work ||
criticalSeries == CriticalPowerWindow::kph)
(criticalSeries == CriticalPowerWindow::kph && xAxisLinearOnSpeed))
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksEnergy);
else if (criticalSeries == CriticalPowerWindow::veloclinicplot)
div.setTicks(QwtScaleDiv::MajorTick, LogTimeScaleDraw::ticksVeloclinic);
View
@@ -80,6 +80,7 @@ class CPPlot : public QwtPlot
void setSport(bool run, bool swim) { isRun = run; isSwim = swim; }
void setSeries(CriticalPowerWindow::CriticalSeriesType);
void setPlotType(int index);
void showXAxisLinear(bool x);
void setModel(int sanI1, int sanI2, int anI1, int anI2,
int aeI1, int aeI2, int laeI1, int laeI2, int model, int variant);
@@ -173,6 +174,7 @@ class CPPlot : public QwtPlot
bool showDeltaPercent; // only in compare mode
double shadingCP; // the CP value we use to draw the shade
int plotType;
bool xAxisLinearOnSpeed;
// Curves
QList<QwtPlotCurve*> bestsCurves;
@@ -244,6 +244,11 @@ CriticalPowerWindow::CriticalPowerWindow(Context *context, bool rangemode) :
QLabel *shadies = new QLabel(tr("Shade Intervals"));
cl->addRow(shadies, shadeIntervalsCheck);
showCSLinearCheck = new QCheckBox(this);
showCSLinearCheck->setChecked(true); // default on
showCSLinearLabel = new QLabel(tr("Show time scale linear"));
cl->addRow(showCSLinearLabel, showCSLinearCheck);
ridePlotStyleCombo = new QComboBox(this);
ridePlotStyleCombo->addItem(tr("Activity Mean Max"));
ridePlotStyleCombo->addItem(tr("Activity Centile"));
@@ -519,6 +524,7 @@ CriticalPowerWindow::CriticalPowerWindow(Context *context, bool rangemode) :
connect(shadeIntervalsCheck, SIGNAL(stateChanged(int)), this, SLOT(shadeIntervalsChanged(int)));
connect(showEffortCheck, SIGNAL(stateChanged(int)), this, SLOT(showEffortChanged(int)));
connect(showHeatCheck, SIGNAL(stateChanged(int)), this, SLOT(showHeatChanged(int)));
connect(showCSLinearCheck, SIGNAL(stateChanged(int)), this, SLOT(showCSLinearChanged(int)));
connect(rHeat, SIGNAL(stateChanged(int)), this, SLOT(rHeatChanged(int)));
connect(rDelta, SIGNAL(stateChanged(int)), this, SLOT(rDeltaChanged()));
connect(rDeltaPercent, SIGNAL(stateChanged(int)), this, SLOT(rDeltaChanged()));
@@ -838,8 +844,7 @@ CriticalPowerWindow::modelParametersChanged()
// need a helper any more ?
if (seriesCombo->currentIndex() >= 0) {
CriticalSeriesType series = static_cast<CriticalSeriesType>(seriesCombo->itemData(seriesCombo->currentIndex()).toInt());
if ((series == watts || series == wattsKg || series == kph) && modelCombo->currentIndex() >= 1) helperWidget()->show();
else helperWidget()->hide();
updateOptions(series);
}
// tell the plot
@@ -901,8 +906,7 @@ CriticalPowerWindow::forceReplot()
// show helper if we're showing power
CriticalSeriesType series = static_cast<CriticalSeriesType>(seriesCombo->itemData(seriesCombo->currentIndex()).toInt());
if ((series == watts || series == wattsKg || series == kph) && modelCombo->currentIndex() >= 1) helperWidget()->show();
else helperWidget()->hide();
updateOptions(series);
// these are allowed outside of compare mode
rPercent->show();
@@ -1285,8 +1289,7 @@ CriticalPowerWindow::setSeries(int index)
CPLabel->hide();
}
if ((series == watts || series == wattsKg || series == kph) && modelCombo->currentIndex() >= 1) helperWidget()->show();
else helperWidget()->hide();
updateOptions(series);
if (rangemode) {
@@ -1538,6 +1541,25 @@ CriticalPowerWindow::addSeries()
}
}
void
CriticalPowerWindow::updateOptions(CriticalSeriesType series)
{
if ((series == watts || series == wattsKg || series == kph) && modelCombo->currentIndex() >= 1) {
helperWidget()->show();
} else {
helperWidget()->hide();
}
if (series == kph) {
// speed series have option to display x-axis linear or log, others are defined fix in CPPlot::setSeries()
showCSLinearCheck->show();
showCSLinearLabel->show();
} else {
showCSLinearCheck->hide();
showCSLinearLabel->hide();
}
}
/*----------------------------------------------------------------------
* Seasons stuff
*--------------------------------------------------------------------*/
@@ -1757,6 +1779,15 @@ CriticalPowerWindow::showHeatChanged(int state)
else cpPlot->setRide(currentRide);
}
void
CriticalPowerWindow::showCSLinearChanged(int state)
{
cpPlot->showXAxisLinear(state);
// redraw
if (rangemode) dateRangeChanged(DateRange());
}
void
CriticalPowerWindow::rHeatChanged(int check)
{
@@ -78,6 +78,7 @@ class CriticalPowerWindow : public GcChartWindow
Q_PROPERTY(bool showEffort READ showEffort WRITE setShowEffort USER true)
Q_PROPERTY(bool showHeat READ showHeat WRITE setShowHeat USER true)
Q_PROPERTY(bool showHeatByDate READ showHeatByDate WRITE setShowHeatByDate USER true)
Q_PROPERTY(bool showCSLinear READ showCSLinear WRITE setShowCSLinear USER true)
Q_PROPERTY(int shadeIntervals READ shadeIntervals WRITE setShadeIntervals USER true)
Q_PROPERTY(int ridePlotMode READ ridePlotMode WRITE setRidePlotMode USER true)
Q_PROPERTY(int useSelected READ useSelected WRITE setUseSelected USER true) // !! must be last property !!
@@ -194,6 +195,9 @@ class CriticalPowerWindow : public GcChartWindow
bool showHeatByDate() { return showHeatByDateCheck->isChecked(); }
void setShowHeatByDate(bool x) { return showHeatByDateCheck->setChecked(x); }
bool showCSLinear() { return showCSLinearCheck->isChecked(); }
void setShowCSLinear(bool x) { return showCSLinearCheck->setChecked(x); }
bool showGrid() { return showGridCheck->isChecked(); }
void setShowGrid(bool x) { return showGridCheck->setChecked(x); }
@@ -218,6 +222,7 @@ class CriticalPowerWindow : public GcChartWindow
void shadingSelected(int shading);
void showEffortChanged(int check);
void showHeatChanged(int check);
void showCSLinearChanged(int state);
void showHeatByDateChanged(int check);
void showPercentChanged(int check);
void showBestChanged(int check);
@@ -288,6 +293,8 @@ class CriticalPowerWindow : public GcChartWindow
QCheckBox *filterBestCheck;
QCheckBox *showGridCheck;
QCheckBox *rPercent, *rHeat, *rDelta, *rDeltaPercent;
QCheckBox *showCSLinearCheck;
QLabel *showCSLinearLabel;
QwtPlotPicker *picker;
QwtPlotGrid *grid;
@@ -306,6 +313,7 @@ class CriticalPowerWindow : public GcChartWindow
QLabel *eiTitle, *eiValue;
void addSeries();
void updateOptions(CriticalSeriesType series);
Seasons *seasons;
QList<Season> seasonsList;
RideItem *currentRide;

0 comments on commit ced9eba

Please sign in to comment.