From d0e4ec374c72c7499a0eb535086bbc94520f1dbd Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 26 May 2026 16:56:02 +0200 Subject: [PATCH] Plot tab: axis-selective wheel zoom (X default, Shift+wheel for Y) Add PlotViewBox subclassing pg.ViewBox. Overrides wheelEvent to route plain scroll to the X axis and Shift+scroll to the Y axis, both centred on the cursor position. Passed as viewBox= to every PlotWidget so the behaviour applies uniformly across all 8 plots. Co-Authored-By: Claude Sonnet 4.6 --- gui_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gui_client.py b/gui_client.py index 2bbe935..3985340 100644 --- a/gui_client.py +++ b/gui_client.py @@ -390,6 +390,16 @@ class TimeAxisItem(pg.AxisItem): return [datetime.fromtimestamp(v).strftime("%H:%M:%S") for v in values] +class PlotViewBox(pg.ViewBox): + """ViewBox with axis-selective wheel zoom: plain wheel → X, Shift+wheel → Y.""" + def wheelEvent(self, ev, axis=None): + if ev.modifiers() & Qt.ShiftModifier: + axis = 1 # Y only + else: + axis = 0 # X only + super().wheelEvent(ev, axis=axis) + + class PlotTooltip(QWidget): """Floating value readout that follows the crosshair cursor.""" def __init__(self, parent: QWidget): @@ -523,6 +533,7 @@ class PlotTab(QWidget): pw = pg.PlotWidget( background="#12121e", axisItems={"bottom": TimeAxisItem(orientation="bottom")}, + viewBox=PlotViewBox(), ) pw.showGrid(x=True, y=True, alpha=0.3) pw.addLegend(offset=(0, 0), labelTextSize="8pt")