Add reveal control for data series to Histogram chart

Similar to Scatter chart, to avoid the need to have several instances
for different data series sparing tabbar space.
Fixes #2039
This commit is contained in:
Ale Martinez
2020-11-29 14:26:38 -03:00
parent cb37db2281
commit 1b61f076ca
2 changed files with 40 additions and 11 deletions

View File

@@ -64,6 +64,8 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind
//
// reveal controls
QLabel *rSeriesLabel = new QLabel(tr("Data Series"), this);
rSeriesSelector = new QxtStringSpinBox();
rWidth = new QLabel(tr("Bin Width"));
rBinEdit = new QLineEdit();
rBinEdit->setFixedWidth(40);
@@ -79,14 +81,22 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind
QHBoxLayout *r = new QHBoxLayout;
r->setContentsMargins(0,0,0,0);
r->addStretch();
r->addWidget(rWidth);
r->addWidget(rBinEdit);
r->addWidget(rBinSlider);
QVBoxLayout *v = new QVBoxLayout;
v->addWidget(rShade);
v->addWidget(rZones);
QVBoxLayout *v1 = new QVBoxLayout;
QHBoxLayout *h1 = new QHBoxLayout;
h1->addWidget(rSeriesLabel);
h1->addWidget(rSeriesSelector);
v1->addLayout(h1);
QHBoxLayout *h2 = new QHBoxLayout;
h2->addWidget(rWidth);
h2->addWidget(rBinEdit);
h2->addWidget(rBinSlider);
v1->addLayout(h2);
r->addLayout(v1);
QVBoxLayout *v2 = new QVBoxLayout;
v2->addWidget(rShade);
v2->addWidget(rZones);
r->addSpacing(20);
r->addLayout(v);
r->addLayout(v2);
r->addStretch();
setRevealLayout(r);
@@ -327,6 +337,7 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind
connect(showLnY, SIGNAL(stateChanged(int)), this, SLOT(forceReplot()));
connect(showZeroes, SIGNAL(stateChanged(int)), this, SLOT(forceReplot()));
connect(seriesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged()));
connect(rSeriesSelector, SIGNAL(valueChanged(int)), this, SLOT(rSeriesSelectorChanged(int)));
connect(showInCPZones, SIGNAL(stateChanged(int)), this, SLOT(setCPZoned(int)));
connect(showInCPZones, SIGNAL(stateChanged(int)), this, SLOT(forceReplot()));
connect(showInZones, SIGNAL(stateChanged(int)), this, SLOT(setZoned(int)));
@@ -693,6 +704,9 @@ HistogramWindow::treeSelectionChanged()
void
HistogramWindow::seriesChanged()
{
// update reveal control
rSeriesSelector->setValue(seriesCombo->currentIndex());
// series changed so tell power hist
powerHist->setSeries(static_cast<RideFile::SeriesType>(seriesCombo->itemData(seriesCombo->currentIndex()).toInt()));
powerHist->setDelta(getDelta());
@@ -709,6 +723,13 @@ HistogramWindow::seriesChanged()
updateChart();
}
void
HistogramWindow::rSeriesSelectorChanged(int value)
{
seriesCombo->setCurrentIndex(value);
seriesChanged();
}
//
// We need to config / update the controls when data series/metrics change
//
@@ -852,8 +873,14 @@ void HistogramWindow::addSeries()
<< RideFile::smo2
<< RideFile::wbal;
foreach (RideFile::SeriesType x, seriesList)
QStringList seriesNames;
foreach (RideFile::SeriesType x, seriesList) {
seriesCombo->addItem(RideFile::seriesName(x), static_cast<int>(x));
seriesNames << RideFile::seriesName(x);
}
rSeriesSelector->setStrings(seriesNames);
}
void
@@ -945,8 +972,7 @@ HistogramWindow::updateChart()
// If no data present show the blank state page
if (!rangemode) {
RideFile::SeriesType baseSeries = (series == RideFile::wattsKg || series == RideFile::wbal) ? RideFile::watts : series;
if (rideItem() != NULL && rideItem()->ride()->isDataPresent(baseSeries))
if (rideItem() != NULL)
setIsBlank(false);
else
setIsBlank(true);

View File

@@ -40,6 +40,7 @@
#include "SearchFilterBox.h"
#include "qxtstringspinbox.h"
#include <QtGui>
#include <QCheckBox>
#include <QFormLayout>
@@ -89,7 +90,7 @@ class HistogramWindow : public GcChartWindow
// get/set properties
int series() const { return seriesCombo->currentIndex(); }
void setSeries(int x) { seriesCombo->setCurrentIndex(x); }
void setSeries(int x) { seriesCombo->setCurrentIndex(x); rSeriesSelector->setValue(x); }
int percent() const { return showSumY->currentIndex(); }
void setPercent(int x) { showSumY->setCurrentIndex(x); }
double bin() const { return binWidthLineEdit->text().toDouble(); }
@@ -161,6 +162,7 @@ class HistogramWindow : public GcChartWindow
// we changed the series to plot
void seriesChanged();
void rSeriesSelectorChanged(int);
// in rangemode we choose data series or metric
void metricToggled(bool);
@@ -208,6 +210,7 @@ class HistogramWindow : public GcChartWindow
QLineEdit *rBinEdit; // set Bin Width from the line edit
QSlider *rBinSlider; // seet Bin Width from a slider
QCheckBox *rShade, *rZones;
QxtStringSpinBox *rSeriesSelector;
QList<RideFile::SeriesType> seriesList;
void addSeries();