cabana: fix chart glitches (#26928)

old-commit-hash: 97b931a12a
beeps
Dean Lee 2 years ago committed by GitHub
parent 28ceb52c33
commit 84b6e18b53
  1. 8
      tools/cabana/chartswidget.cc
  2. 2
      tools/cabana/chartswidget.h

@ -47,6 +47,10 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
QApplication::style()->standardPalette().color(QPalette::Background).value(); QApplication::style()->standardPalette().color(QPalette::Background).value();
updateToolBar(); updateToolBar();
align_charts_timer = new QTimer(this);
align_charts_timer->setSingleShot(true);
align_charts_timer->callOnTimeout(this, &ChartsWidget::alignCharts);
QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &ChartsWidget::removeAll); QObject::connect(dbc(), &DBCManager::DBCFileChanged, this, &ChartsWidget::removeAll);
QObject::connect(can, &CANMessages::eventsMerged, this, &ChartsWidget::eventsMerged); QObject::connect(can, &CANMessages::eventsMerged, this, &ChartsWidget::eventsMerged);
QObject::connect(can, &CANMessages::updated, this, &ChartsWidget::updateState); QObject::connect(can, &CANMessages::updated, this, &ChartsWidget::updateState);
@ -159,7 +163,7 @@ void ChartsWidget::showChart(const QString &id, const Signal *sig, bool show, bo
QObject::connect(chart, &ChartView::zoomReset, this, &ChartsWidget::zoomReset); QObject::connect(chart, &ChartView::zoomReset, this, &ChartsWidget::zoomReset);
QObject::connect(chart, &ChartView::seriesRemoved, this, &ChartsWidget::seriesChanged); QObject::connect(chart, &ChartView::seriesRemoved, this, &ChartsWidget::seriesChanged);
QObject::connect(chart, &ChartView::seriesAdded, this, &ChartsWidget::seriesChanged); QObject::connect(chart, &ChartView::seriesAdded, this, &ChartsWidget::seriesChanged);
QObject::connect(chart, &ChartView::axisYUpdated, this, &ChartsWidget::alignCharts); QObject::connect(chart, &ChartView::axisYUpdated, [this]() { align_charts_timer->start(100); });
charts_layout->insertWidget(0, chart); charts_layout->insertWidget(0, chart);
charts.push_back(chart); charts.push_back(chart);
} }
@ -453,7 +457,7 @@ void ChartView::updateAxisY() {
double range = max_y - min_y; double range = max_y - min_y;
applyNiceNumbers(min_y - range * 0.05, max_y + range * 0.05); applyNiceNumbers(min_y - range * 0.05, max_y + range * 0.05);
} }
QTimer::singleShot(0, this, &ChartView::axisYUpdated); emit axisYUpdated();
} }
void ChartView::applyNiceNumbers(qreal min, qreal max) { void ChartView::applyNiceNumbers(qreal min, qreal max) {

@ -5,6 +5,7 @@
#include <QLabel> #include <QLabel>
#include <QListWidget> #include <QListWidget>
#include <QGraphicsProxyWidget> #include <QGraphicsProxyWidget>
#include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QtCharts/QChartView> #include <QtCharts/QChartView>
#include <QtCharts/QLineSeries> #include <QtCharts/QLineSeries>
@ -111,6 +112,7 @@ private:
QAction *dock_btn; QAction *dock_btn;
QAction *reset_zoom_btn; QAction *reset_zoom_btn;
QAction *remove_all_btn; QAction *remove_all_btn;
QTimer *align_charts_timer;
QVBoxLayout *charts_layout; QVBoxLayout *charts_layout;
QList<ChartView *> charts; QList<ChartView *> charts;
uint32_t max_chart_range = 0; uint32_t max_chart_range = 0;

Loading…
Cancel
Save