cabana: show dots when zoomed far into a signal (#27145)

* cabana: show dots when zoomed far into a signal

* review comments
This commit is contained in:
Willem Melching
2023-01-29 21:57:01 +01:00
committed by GitHub
parent bdb42f7f84
commit f038193f44

View File

@@ -469,6 +469,18 @@ void ChartView::updatePlot(double cur, double min, double max) {
axis_x->setRange(min, max);
updateAxisY();
}
// Show points when zoomed in enough
for (auto &s : sigs) {
auto begin = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), [](auto &p, double x) { return p.x() < x; });
auto end = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->max(), [](auto &p, double x) { return p.x() < x; });
int num_points = std::max<int>(end - begin, 1);
int pixels_per_point = width() / num_points;
s.series->setPointsVisible(pixels_per_point > 20);
}
scene()->invalidate({}, QGraphicsScene::ForegroundLayer);
}