tweaked PyQT backend
This commit is contained in:
@ -1775,7 +1775,11 @@ def run_pyqtgraph(args):
|
|||||||
interval_ms = int(1000.0 / max_fps)
|
interval_ms = int(1000.0 / max_fps)
|
||||||
|
|
||||||
# PyQtGraph настройки
|
# PyQtGraph настройки
|
||||||
pg.setConfigOptions(useOpenGL=not peak_calibrate_mode, antialias=False)
|
pg.setConfigOptions(
|
||||||
|
useOpenGL=not peak_calibrate_mode,
|
||||||
|
antialias=False,
|
||||||
|
imageAxisOrder="row-major",
|
||||||
|
)
|
||||||
app = QtWidgets.QApplication.instance()
|
app = QtWidgets.QApplication.instance()
|
||||||
if app is None:
|
if app is None:
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
@ -1832,7 +1836,7 @@ def run_pyqtgraph(args):
|
|||||||
|
|
||||||
# Водопад спектров (справа-снизу)
|
# Водопад спектров (справа-снизу)
|
||||||
p_spec = win.addPlot(row=1, col=1, title="B-scan (дБ)")
|
p_spec = win.addPlot(row=1, col=1, title="B-scan (дБ)")
|
||||||
p_spec.invertY(True)
|
p_spec.invertY(False)
|
||||||
p_spec.showGrid(x=False, y=False)
|
p_spec.showGrid(x=False, y=False)
|
||||||
p_spec.setLabel("bottom", "Время, с (новое справа)")
|
p_spec.setLabel("bottom", "Время, с (новое справа)")
|
||||||
try:
|
try:
|
||||||
@ -1851,15 +1855,18 @@ def run_pyqtgraph(args):
|
|||||||
|
|
||||||
# Отдельное окно контролов: GraphicsLayoutWidget не принимает обычные QWidget через addItem.
|
# Отдельное окно контролов: GraphicsLayoutWidget не принимает обычные QWidget через addItem.
|
||||||
calib_cb = QtWidgets.QCheckBox("калибровка")
|
calib_cb = QtWidgets.QCheckBox("калибровка")
|
||||||
control_window = QtWidgets.QWidget()
|
control_window = None
|
||||||
try:
|
control_layout = None
|
||||||
control_window.setWindowTitle(f"{args.title} controls")
|
if peak_calibrate_mode:
|
||||||
except Exception:
|
control_window = QtWidgets.QWidget()
|
||||||
pass
|
try:
|
||||||
control_layout = QtWidgets.QVBoxLayout(control_window)
|
control_window.setWindowTitle(f"{args.title} controls")
|
||||||
control_layout.setContentsMargins(8, 8, 8, 8)
|
except Exception:
|
||||||
control_layout.setSpacing(6)
|
pass
|
||||||
control_layout.addWidget(calib_cb)
|
control_layout = QtWidgets.QVBoxLayout(control_window)
|
||||||
|
control_layout.setContentsMargins(8, 8, 8, 8)
|
||||||
|
control_layout.setSpacing(6)
|
||||||
|
control_layout.addWidget(calib_cb)
|
||||||
|
|
||||||
# Статусная строка (внизу окна)
|
# Статусная строка (внизу окна)
|
||||||
status = pg.LabelItem(justify="left")
|
status = pg.LabelItem(justify="left")
|
||||||
@ -1949,13 +1956,15 @@ def run_pyqtgraph(args):
|
|||||||
pass
|
pass
|
||||||
c_layout.addRow(f"C{idx}", edit)
|
c_layout.addRow(f"C{idx}", edit)
|
||||||
c_edits.append(edit)
|
c_edits.append(edit)
|
||||||
control_layout.addWidget(c_widget)
|
if control_layout is not None:
|
||||||
|
control_layout.addWidget(c_widget)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if control_window is not None:
|
||||||
|
try:
|
||||||
|
control_window.show()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
|
||||||
control_window.show()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def ensure_buffer(_w: int):
|
def ensure_buffer(_w: int):
|
||||||
nonlocal ring, ring_time, head, width, x_shared, ring_fft, distance_shared
|
nonlocal ring, ring_time, head, width, x_shared, ring_fft, distance_shared
|
||||||
@ -2102,7 +2111,9 @@ def run_pyqtgraph(args):
|
|||||||
cm_mod = getattr(pg, "colormap", None)
|
cm_mod = getattr(pg, "colormap", None)
|
||||||
if cm_mod is not None:
|
if cm_mod is not None:
|
||||||
cm = cm_mod.get(args.cmap)
|
cm = cm_mod.get(args.cmap)
|
||||||
img.setLookupTable(cm.getLookupTable(0.0, 1.0, 256))
|
lut = cm.getLookupTable(0.0, 1.0, 256)
|
||||||
|
img.setLookupTable(lut)
|
||||||
|
img_fft.setLookupTable(lut)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -2189,7 +2200,7 @@ def run_pyqtgraph(args):
|
|||||||
|
|
||||||
if changed and ring is not None:
|
if changed and ring is not None:
|
||||||
disp = ring if head == 0 else np.roll(ring, -head, axis=0)
|
disp = ring if head == 0 else np.roll(ring, -head, axis=0)
|
||||||
disp = disp.T[:, ::-1] # (width, time with newest at left)
|
disp = disp.T # (width, time with newest at right)
|
||||||
levels = _visible_levels_pyqtgraph(disp)
|
levels = _visible_levels_pyqtgraph(disp)
|
||||||
if levels is not None:
|
if levels is not None:
|
||||||
img.setImage(disp, autoLevels=False, levels=levels)
|
img.setImage(disp, autoLevels=False, levels=levels)
|
||||||
@ -2226,10 +2237,9 @@ def run_pyqtgraph(args):
|
|||||||
|
|
||||||
if changed and ring_fft is not None:
|
if changed and ring_fft is not None:
|
||||||
disp_fft = ring_fft if head == 0 else np.roll(ring_fft, -head, axis=0)
|
disp_fft = ring_fft if head == 0 else np.roll(ring_fft, -head, axis=0)
|
||||||
disp_fft = disp_fft.T[:, ::-1]
|
disp_fft = disp_fft.T
|
||||||
if spec_mean_sec > 0.0 and ring_time is not None:
|
if spec_mean_sec > 0.0 and ring_time is not None:
|
||||||
disp_times = ring_time if head == 0 else np.roll(ring_time, -head)
|
disp_times = ring_time if head == 0 else np.roll(ring_time, -head)
|
||||||
disp_times = disp_times[::-1]
|
|
||||||
now_t = time.time()
|
now_t = time.time()
|
||||||
mask = np.isfinite(disp_times) & (disp_times >= (now_t - spec_mean_sec))
|
mask = np.isfinite(disp_times) & (disp_times >= (now_t - spec_mean_sec))
|
||||||
if np.any(mask):
|
if np.any(mask):
|
||||||
@ -2273,10 +2283,11 @@ def run_pyqtgraph(args):
|
|||||||
def on_quit():
|
def on_quit():
|
||||||
stop_event.set()
|
stop_event.set()
|
||||||
reader.join(timeout=1.0)
|
reader.join(timeout=1.0)
|
||||||
try:
|
if control_window is not None:
|
||||||
control_window.close()
|
try:
|
||||||
except Exception:
|
control_window.close()
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
app.aboutToQuit.connect(on_quit)
|
app.aboutToQuit.connect(on_quit)
|
||||||
win.show()
|
win.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user