mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 00:43:54 +08:00
@@ -47,6 +47,10 @@ ChartsWidget::ChartsWidget(QWidget *parent) : QWidget(parent) {
|
||||
QApplication::style()->standardPalette().color(QPalette::Background).value();
|
||||
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(can, &CANMessages::eventsMerged, this, &ChartsWidget::eventsMerged);
|
||||
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::seriesRemoved, 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.push_back(chart);
|
||||
}
|
||||
@@ -453,7 +457,7 @@ void ChartView::updateAxisY() {
|
||||
double range = max_y - min_y;
|
||||
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) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtCharts/QChartView>
|
||||
#include <QtCharts/QLineSeries>
|
||||
@@ -111,6 +112,7 @@ private:
|
||||
QAction *dock_btn;
|
||||
QAction *reset_zoom_btn;
|
||||
QAction *remove_all_btn;
|
||||
QTimer *align_charts_timer;
|
||||
QVBoxLayout *charts_layout;
|
||||
QList<ChartView *> charts;
|
||||
uint32_t max_chart_range = 0;
|
||||
|
||||
Reference in New Issue
Block a user