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

* cabana: show dots when zoomed far into a signal

* review comments
old-commit-hash: f038193f4447afc8ae7b6034dec430d08f6da331
This commit is contained in:
Willem Melching
2023-01-29 21:57:01 +01:00
committed by GitHub
parent d24fb585b5
commit 423f22b51c
+12
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);
}