mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-26 04:04:01 +08:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user