Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/silx/gui/plot/PlotInteraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,18 +1867,28 @@ def _onWheel(self, x: float, y: float, angle: float):
if not self.isZoomOnWheelEnabled():
return

if angle == 0:
return
plotWidget = self.parent()
if plotWidget is None:
return

# All axes are enabled if keep aspect ratio is on
enabledAxes = (
EnabledAxes()
if plotWidget.isKeepDataAspectRatio()
else self.getZoomEnabledAxes()
)
if plotWidget.isKeepDataAspectRatio():
enabledAxes = EnabledAxes()
else:
modifiers = qt.QApplication.keyboardModifiers()
shiftPressed = modifiers & qt.Qt.ShiftModifier
altPressed = modifiers & qt.Qt.AltModifier
if shiftPressed or altPressed:
enabledAxes = EnabledAxes(
xaxis=altPressed, yaxis=shiftPressed, y2axis=shiftPressed
)
else:
enabledAxes = self.getZoomEnabledAxes()
if enabledAxes.isDisabled():
return

scale = 1.1 if angle > 0 else 1.0 / 1.1

applyZoomToPlot(plotWidget, scale, (x, y), enabledAxes)
2 changes: 1 addition & 1 deletion src/silx/gui/plot/backends/BackendOpenGL.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def mouseReleaseEvent(self, event):
event.accept()

def wheelEvent(self, event):
delta = event.angleDelta().y()
delta = event.angleDelta().x() + event.angleDelta().y()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when alt is pressed in opengl, event.angleDelta().y() has a value and event.angleDelta().x() is 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect x to always be 0 except for fancy mouses no ? According to the doc

And even if x is not zero I am not sure we want to take it into account.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry my comment was wrong when alt is pressend in open gl x value is set else y

that's why. DO you want me to be more specific like really use x when alt is pressed ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior is hard-coded in qt xcb plugin: https://github.com/qt/qtbase/blob/120883a028a59864dc7691dd1efa318bd602755d/src/plugins/platforms/xcb/qxcbwindow.cpp#L1955-L1956

Rather than summing, it's also possible to use x() only when y() == 0

Since this is not documented in qt doc, it's worth a comment to explain!

angleInDegrees = delta / 8.0
x, y = qt.getMouseEventPosition(event)
self._plot.onMouseWheel(x, y, angleInDegrees)
Expand Down
6 changes: 3 additions & 3 deletions src/silx/gui/plot/tools/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def __init__(self, plot: PlotWidget, parent: qt.QWidget | None = None):
self.__plotRef = weakref.ref(plot)

self.addSection("Enabled axes")
self.__xAxisAction = qt.QAction("X axis", parent=self)
self.__yAxisAction = qt.QAction("Y left axis", parent=self)
self.__y2AxisAction = qt.QAction("Y right axis", parent=self)
self.__xAxisAction = qt.QAction("X axis (alt)", parent=self)
self.__yAxisAction = qt.QAction("Y left axis (shift)", parent=self)
self.__y2AxisAction = qt.QAction("Y right axis (shift)", parent=self)
Comment on lines +55 to +57

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me here there is clear need to clarify the policy we want to have.
I think this is not something we want to "impose" at the library side but to have at silx view side right @t20100 ?

So from my understanding either this is added at the silx view application level and/or this should be optional at the lib side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think if we add this shortcut it can benefit to library too ?

@loichuder loichuder Jun 18, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not something we want to "impose" at the library side but to have at silx view side right @t20100 ?

Agreed. It should not enabled by default in the lib but be in opt-in. And silx view would opt-in.

i think if we add this shortcut it can benefit to library too ?

Yes, it would be good to still have in the library so that other consumer apps can enable it. But not enabled by default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, plot interactions are mostly wired in PlotWidget in Plotinteraction and associated tools through PlotWidget.setInteractiveMode.
It's possible to add an API to toggle use of modifer keys, but I'm not sure it is worth it here.

I agree silx should leave it up to the application to choose it's keyboard short-cuts (unless they are standard ones). However here it is about modifier keys for the mouse wheel which is a behavior I don't think one cannot infer with from the API.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(alt) -> (Alt+Wheel)
(shift) -> (Shift+Wheel)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i m not sure i understand the final decision @t20100 . So i can keep thit like that and let it in silx core ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless someone disagree, I would leave it as it is in silx core.


for action in (self.__xAxisAction, self.__yAxisAction, self.__y2AxisAction):
action.setCheckable(True)
Expand Down
Loading