Skip to content

Commit 7dab7e0

Browse files
pd0wmtwilsonco
authored andcommitted
cabana: show dots when zoomed far into a signal (commaai#27145)
* cabana: show dots when zoomed far into a signal * review comments
1 parent b6d8cc6 commit 7dab7e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/cabana/chartswidget.cc

+12
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,18 @@ void ChartView::updatePlot(double cur, double min, double max) {
469469
axis_x->setRange(min, max);
470470
updateAxisY();
471471
}
472+
473+
// Show points when zoomed in enough
474+
for (auto &s : sigs) {
475+
auto begin = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->min(), [](auto &p, double x) { return p.x() < x; });
476+
auto end = std::lower_bound(s.vals.begin(), s.vals.end(), axis_x->max(), [](auto &p, double x) { return p.x() < x; });
477+
478+
int num_points = std::max<int>(end - begin, 1);
479+
int pixels_per_point = width() / num_points;
480+
481+
s.series->setPointsVisible(pixels_per_point > 20);
482+
}
483+
472484
scene()->invalidate({}, QGraphicsScene::ForegroundLayer);
473485
}
474486

0 commit comments

Comments
 (0)