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 <noreply@anthropic.com>
This commit is contained in:
2026-05-26 16:56:02 +02:00
co-authored by Claude Sonnet 4.6
parent ad3cbf4859
commit d0e4ec374c
+11
View File
@@ -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")