aboutsummaryrefslogtreecommitdiffstats
path: root/stats/pieseries.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-02-07 20:48:43 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-02-13 13:02:54 -0800
commit21b8cded56854f81327f4f553e32a15ffe5c7b82 (patch)
tree354194513eed9bdb69d31f1855edbade60bb0ad5 /stats/pieseries.cpp
parentbd252fc8201c7e77882ac95ef90ddbf4a16356d3 (diff)
downloadsubsurface-21b8cded56854f81327f4f553e32a15ffe5c7b82.tar.gz
statistics: highlight selected pie slices
In analogy to the other charts, highlight selected pie slices. Overlay them with a checkerboard pattern, like in the bar charts. Since all charts now support highlighting, the divesSelected() virtual function now doesn't need a default implementation anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/pieseries.cpp')
-rw-r--r--stats/pieseries.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/stats/pieseries.cpp b/stats/pieseries.cpp
index 61579df74..5d940c2b2 100644
--- a/stats/pieseries.cpp
+++ b/stats/pieseries.cpp
@@ -20,7 +20,8 @@ static const double outerLabelRadius = 1.01; // 1.0 = at outer border of pie
PieSeries::Item::Item(StatsView &view, const QString &name, int from, std::vector<dive *> divesIn, int totalCount,
int bin_nr, int numBins) :
name(name),
- dives(std::move(divesIn))
+ dives(std::move(divesIn)),
+ selected(allDivesSelected(dives))
{
QFont f; // make configurable
QLocale loc;
@@ -72,7 +73,7 @@ void PieSeries::Item::highlight(ChartPieItem &item, int bin_nr, bool highlight,
QColor border = highlight ? highlightedBorderColor : ::borderColor;
if (innerLabel)
innerLabel->setColor(highlight ? darkLabelColor : labelColor(bin_nr, numBins), fill);
- item.drawSegment(angleFrom, angleTo, fill, border);
+ item.drawSegment(angleFrom, angleTo, fill, border, selected);
}
PieSeries::PieSeries(StatsView &view, StatsAxis *xAxis, StatsAxis *yAxis, const QString &categoryName,
@@ -277,3 +278,16 @@ bool PieSeries::selectItemsUnderMouse(const QPointF &pos, bool)
setSelection(dives, dives.empty() ? nullptr : dives.front());
return true;
}
+
+void PieSeries::divesSelected(const QVector<dive *> &)
+{
+ for (Item &segment: items) {
+ bool selected = allDivesSelected(segment.dives);
+ if (segment.selected != selected) {
+ segment.selected = selected;
+
+ int idx = &segment - &items[0];
+ segment.highlight(*item, idx, idx == highlighted, (int)items.size());
+ }
+ }
+}