works fine. Save
This commit is contained in:
@ -415,6 +415,7 @@ def main():
|
|||||||
import matplotlib
|
import matplotlib
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib.animation import FuncAnimation
|
from matplotlib.animation import FuncAnimation
|
||||||
|
from matplotlib.widgets import Slider
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write(f"[error] Нужны matplotlib и ее зависимости: {e}\n")
|
sys.stderr.write(f"[error] Нужны matplotlib и ее зависимости: {e}\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -429,8 +430,8 @@ def main():
|
|||||||
fig, axs = plt.subplots(2, 2, figsize=(12, 8))
|
fig, axs = plt.subplots(2, 2, figsize=(12, 8))
|
||||||
(ax_line, ax_img), (ax_fft, ax_spec) = axs
|
(ax_line, ax_img), (ax_fft, ax_spec) = axs
|
||||||
fig.canvas.manager.set_window_title(args.title) if hasattr(fig.canvas.manager, "set_window_title") else None
|
fig.canvas.manager.set_window_title(args.title) if hasattr(fig.canvas.manager, "set_window_title") else None
|
||||||
# Увеличим расстояния между графиками, чтобы избежать наложения подписей
|
# Увеличим расстояния и оставим место справа под ползунки оси Y B-scan
|
||||||
fig.subplots_adjust(wspace=0.2, hspace=0.3, left=0.07, right=0.98, top=0.92, bottom=0.08)
|
fig.subplots_adjust(wspace=0.25, hspace=0.35, left=0.07, right=0.90, top=0.92, bottom=0.08)
|
||||||
|
|
||||||
# Состояние для отображения
|
# Состояние для отображения
|
||||||
current_sweep: Optional[np.ndarray] = None
|
current_sweep: Optional[np.ndarray] = None
|
||||||
@ -448,6 +449,9 @@ def main():
|
|||||||
freq_shared: Optional[np.ndarray] = None
|
freq_shared: Optional[np.ndarray] = None
|
||||||
# Параметры контраста водопада спектров
|
# Параметры контраста водопада спектров
|
||||||
spec_clip = _parse_spec_clip(getattr(args, "spec_clip", None))
|
spec_clip = _parse_spec_clip(getattr(args, "spec_clip", None))
|
||||||
|
# Ползунки управления Y для B-scan
|
||||||
|
ymin_slider = None
|
||||||
|
ymax_slider = None
|
||||||
|
|
||||||
# Линейный график последнего свипа
|
# Линейный график последнего свипа
|
||||||
line_obj, = ax_line.plot([], [], lw=1)
|
line_obj, = ax_line.plot([], [], lw=1)
|
||||||
@ -506,6 +510,26 @@ def main():
|
|||||||
ax_spec.tick_params(axis="x", labelbottom=False)
|
ax_spec.tick_params(axis="x", labelbottom=False)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
# Слайдеры для управления осью Y B-scan (мин/макс)
|
||||||
|
try:
|
||||||
|
ax_smin = fig.add_axes([0.92, 0.55, 0.02, 0.35])
|
||||||
|
ax_smax = fig.add_axes([0.95, 0.55, 0.02, 0.35])
|
||||||
|
ymin_slider = Slider(ax_smin, "Y min", 0, max(1, fft_bins - 1), valinit=0, valstep=1, orientation="vertical")
|
||||||
|
ymax_slider = Slider(ax_smax, "Y max", 0, max(1, fft_bins - 1), valinit=max(1, fft_bins - 1), valstep=1, orientation="vertical")
|
||||||
|
|
||||||
|
def _on_ylim_change(_val):
|
||||||
|
try:
|
||||||
|
y0 = int(min(ymin_slider.val, ymax_slider.val))
|
||||||
|
y1 = int(max(ymin_slider.val, ymax_slider.val))
|
||||||
|
ax_spec.set_ylim(y0, y1)
|
||||||
|
fig.canvas.draw_idle()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
ymin_slider.on_changed(_on_ylim_change)
|
||||||
|
ymax_slider.on_changed(_on_ylim_change)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# Для контроля частоты обновления
|
# Для контроля частоты обновления
|
||||||
max_fps = max(1.0, float(args.max_fps))
|
max_fps = max(1.0, float(args.max_fps))
|
||||||
|
|||||||
Reference in New Issue
Block a user