mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
bd252fc820
commit
21b8cded56
6 changed files with 44 additions and 14 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue