cabana: fix incorrect point size after adding new series to chart or changing series type (#27199)

* update pointers after create series

* cleanup
pull/27210/head
Dean Lee 2 years ago committed by GitHub
parent 29d9d03759
commit d6516059bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      tools/cabana/chartswidget.cc
  2. 1
      tools/cabana/chartswidget.h

@ -376,6 +376,7 @@ void ChartView::addSeries(const QString &msg_id, const Signal *sig) {
sigs.push_back({.msg_id = msg_id, .address = address, .source = source, .sig = sig, .series = series});
updateTitle();
updateSeries(sig);
updateSeriesPoints();
emit seriesAdded(msg_id, sig);
}
@ -482,7 +483,13 @@ void ChartView::updatePlot(double cur, double min, double max) {
if (min != axis_x->min() || max != axis_x->max()) {
axis_x->setRange(min, max);
updateAxisY();
updateSeriesPoints();
}
scene()->invalidate({}, QGraphicsScene::ForegroundLayer);
}
void ChartView::updateSeriesPoints() {
// 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; });
@ -514,9 +521,6 @@ void ChartView::updatePlot(double cur, double min, double max) {
}
}
scene()->invalidate({}, QGraphicsScene::ForegroundLayer);
}
void ChartView::updateSeries(const Signal *sig, const std::vector<Event *> *events, bool clear) {
events = events ? events : can->events();
for (auto &s : sigs) {
@ -783,6 +787,7 @@ void ChartView::setSeriesType(QAbstractSeries::SeriesType type) {
series->replace(s.vals);
s.series = series;
}
updateSeriesPoints();
updateTitle();
}
}

@ -73,6 +73,7 @@ private:
void applyNiceNumbers(qreal min, qreal max);
qreal niceNumber(qreal x, bool ceiling);
QXYSeries *createSeries(QAbstractSeries::SeriesType type);
void updateSeriesPoints();
QValueAxis *axis_x;
QValueAxis *axis_y;

Loading…
Cancel
Save