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

* cabana: show dots when zoomed far into a signal

* review comments
pull/27146/head
Willem Melching 2 years ago committed by GitHub
parent bdb42f7f84
commit f038193f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      tools/cabana/chartswidget.cc

@ -469,6 +469,18 @@ void ChartView::updatePlot(double cur, double min, double max) {
axis_x->setRange(min, max); axis_x->setRange(min, max);
updateAxisY(); 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); scene()->invalidate({}, QGraphicsScene::ForegroundLayer);
} }

Loading…
Cancel
Save