fix graph and white background added
This commit is contained in:
@@ -12,7 +12,6 @@ import threading
|
||||
import time
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pyqtgraph as pg
|
||||
from PyQt6.QtCore import QBuffer, QIODevice, QObject, pyqtSignal
|
||||
from PyQt6.QtWidgets import QLineEdit, QSpinBox, QWidget
|
||||
|
||||
@@ -100,20 +99,13 @@ class WebBridge(QObject):
|
||||
self._frame: dict | None = None
|
||||
self._pending_lock = threading.Lock()
|
||||
self._pending_calls: set[_WebActionCall] = set()
|
||||
self._closed = self._streaming = self._grabbing = False
|
||||
self._dirty = True
|
||||
self._closed = self._streaming = False
|
||||
self._grabbed_revision: int | None = None # plot revision shown by the last grab; None forces one
|
||||
self._last_png: str | None = None
|
||||
self._last_grab_s = 0.0
|
||||
self._frame_seq = self._snapshot_errors = 0
|
||||
self._action_requested.connect(self._run_action)
|
||||
self._streaming_changed.connect(self._set_streaming)
|
||||
plots = pipeline.plots
|
||||
plots.stack.currentChanged.connect(self._mark_dirty)
|
||||
for plot in plots.stack.findChildren(pg.PlotWidget):
|
||||
scene = plot.scene()
|
||||
assert scene is not None
|
||||
scene.changed.connect(self._mark_dirty)
|
||||
plot.sigDeviceRangeChanged.connect(self._mark_dirty)
|
||||
|
||||
def start_server(self) -> None:
|
||||
if self._closed or self._server is not None:
|
||||
@@ -295,26 +287,19 @@ class WebBridge(QObject):
|
||||
if not self._closed:
|
||||
self._streaming = enabled
|
||||
if enabled:
|
||||
self._dirty = True
|
||||
|
||||
def _mark_dirty(self, *_args: object) -> None:
|
||||
if not self._closed and not self._grabbing:
|
||||
self._dirty = True
|
||||
self._grabbed_revision = None
|
||||
|
||||
def _grab_frame_if_due(self) -> dict | None:
|
||||
if self._closed or not self._streaming or not self._dirty:
|
||||
plots = self._pipeline.plots
|
||||
if self._closed or not self._streaming or plots.revision == self._grabbed_revision:
|
||||
return None
|
||||
now = time.monotonic()
|
||||
if now - self._last_grab_s < _GRAB_INTERVAL_S:
|
||||
return None
|
||||
self._last_grab_s, self._dirty, self._grabbing = now, False, True
|
||||
try:
|
||||
png = self._grab_png()
|
||||
except Exception:
|
||||
self._dirty = True
|
||||
raise
|
||||
finally:
|
||||
self._grabbing = False
|
||||
self._last_grab_s = now
|
||||
png = self._grab_png()
|
||||
# Rendering applies pending resizes and lazy auto-ranges; this image already shows them.
|
||||
self._grabbed_revision = plots.revision
|
||||
if png is None or png == self._last_png:
|
||||
return None
|
||||
self._last_png = png
|
||||
|
||||
Reference in New Issue
Block a user