statistics: highlight selected boxes in box plot

In analogy to bar plots, highlight selected boxes in box plots.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-07 18:10:08 +01:00 committed by Dirk Hohndel
parent 91d371374b
commit bd252fc820
5 changed files with 37 additions and 5 deletions

View file

@ -27,9 +27,10 @@ BoxSeries::~BoxSeries()
}
BoxSeries::Item::Item(StatsView &view, BoxSeries *series, double lowerBound, double upperBound,
const StatsQuartiles &q, const QString &binName) :
lowerBound(lowerBound), upperBound(upperBound), q(q),
binName(binName)
const StatsQuartiles &qIn, const QString &binName) :
lowerBound(lowerBound), upperBound(upperBound), q(qIn),
binName(binName),
selected(allDivesSelected(q.dives))
{
item = view.createChartItem<ChartBoxItem>(ChartZValue::Series, boxBorderWidth);
highlight(false);
@ -44,6 +45,8 @@ void BoxSeries::Item::highlight(bool highlight)
{
if (highlight)
item->setColor(highlightedColor, highlightedBorderColor);
else if (selected)
item->setColor(selectedColor, selectedBorderColor);
else
item->setColor(fillColor, ::borderColor);
}
@ -155,3 +158,17 @@ bool BoxSeries::selectItemsUnderMouse(const QPointF &pos, bool)
setSelection(dives, dives.empty() ? nullptr : dives.front());
return true;
}
void BoxSeries::divesSelected(const QVector<dive *> &)
{
for (auto &item: items) {
bool selected = allDivesSelected(item->q.dives);
if (item->selected != selected) {
item->selected = selected;
int idx = &item - &items[0];
bool highlight = idx == highlighted;
item->highlight(highlight);
}
}
}