gui_client: debounce plot redraws to speed up initial record import
Replace direct _redraw() calls in PlotTab.update() with a 100 ms single-shot QTimer. During a burst of incoming records (e.g. 500 history records on connect) only the data is accumulated; a single redraw fires 100 ms after the last record arrives instead of once per record (~4000 pyqtgraph redraws avoided). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -20,7 +20,7 @@ from collections import deque
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from PyQt5.QtCore import QObject, Qt, pyqtSignal
|
||||
from PyQt5.QtCore import QObject, QTimer, Qt, pyqtSignal
|
||||
from PyQt5.QtGui import QColor, QFont
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QComboBox, QFormLayout, QGridLayout, QGroupBox,
|
||||
@@ -382,6 +382,11 @@ class PlotTab(QWidget):
|
||||
self._series: dict[str, deque] = {}
|
||||
self._units: dict[str, str] = {}
|
||||
|
||||
self._redraw_timer = QTimer(self)
|
||||
self._redraw_timer.setSingleShot(True)
|
||||
self._redraw_timer.setInterval(100)
|
||||
self._redraw_timer.timeout.connect(self._redraw)
|
||||
|
||||
# ── 4×2 scrollable plot grid (each cell: control bar + plot) ─────────
|
||||
plot_container = QWidget()
|
||||
plot_grid = QGridLayout(plot_container)
|
||||
@@ -521,6 +526,7 @@ class PlotTab(QWidget):
|
||||
# ── public API ────────────────────────────────────────────────────────────
|
||||
|
||||
def clear_data(self):
|
||||
self._redraw_timer.stop()
|
||||
self._series.clear()
|
||||
self._units.clear()
|
||||
self._redraw()
|
||||
@@ -550,7 +556,7 @@ class PlotTab(QWidget):
|
||||
if new_keys:
|
||||
self._refresh_combos()
|
||||
|
||||
self._redraw()
|
||||
self._redraw_timer.start()
|
||||
|
||||
# ── combo refresh + saved-trace restore ──────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user