Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoomable spectrum plot in the Spectrum Viewer #2133

Merged
merged 7 commits into from
May 9, 2024

Conversation

MikeSullivan7
Copy link
Collaborator

Issue

Closes #2132

Description

The SpectrumPlotWidget in spectrum_widget.py now uses a custom viewbox which overrides the mouse events of the standard ViewBox class. The custom viewbox uses the RectMode mouse mode which uses a built-in zoom drag box. Now to pan the data, the middle mouse button can be used (by temporary using the PanMode mouse mode). The right mouse button can be clicked to reset the zoom to its default. The right click menu for this plot has been disabled as it is not useful for this plot.

Testing

make check

Acceptance Criteria

  • Load data into MI and use the Spectrum Viewer.

  • Click and drag a zoom box over the data to check the data is zoomed in as expected.

  • NOTE: the ToF range box has to be moved to zoom as clicking and dragging this box will move the box instead of creating a zoom box, e.g. below:
    image

  • Use the middle and right mouse buttons to check they have the behaviour as mentioned above.

Documentation

will add release note

@MikeSullivan7 MikeSullivan7 self-assigned this Mar 13, 2024
@coveralls
Copy link

coveralls commented Mar 13, 2024

Coverage Status

coverage: 74.196% (-0.09%) from 74.281%
when pulling 6a76deb on 2132_spectrum_plot_zoom
into 4b0e89d on main.

@samtygier-stfc
Copy link
Collaborator

I'd like to find a way to do this that can be consistent across all our image views and plots. So maybe holding down Ctrl and dragging a box. Or a magnifying glass icon, that you can click on and then zoom, like in matplotlib.

E.g.

python -c "from matplotlib import pyplot; pyplot.plot([1,2,3,2,1]); pyplot.show()"

@MikeSullivan7
Copy link
Collaborator Author

I could see if I can make the zoom box activate upon holding down the ctrl key, but this behaviour should be able to to made consistent with all plots etc by setting the viewbox as CustomViewBox or perhaps could be renamed to ZoomViewBox.

I thought I would apply this behaviour to the Spectrum Viewer plot only at first to test and see if the scientists like the functionality of it, etc

@MikeSullivan7
Copy link
Collaborator Author

Note:
We need to make sure that the ZoomBox plays well with other things in the image views, i.e. the ROIs and the Range Controls in the spectrum viewer. This could perhaps be done by making it such that when Ctrl is held done, the mouse interaction is disabled for other objects in the image view. This might have to be done on a case by case basis but it would be good to have this generalised

@MikeSullivan7 MikeSullivan7 marked this pull request as draft April 25, 2024 10:41
@MikeSullivan7 MikeSullivan7 marked this pull request as ready for review April 25, 2024 16:40
Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

Mostly working well. A couple of code comments.

When I first open the spectum window, I am unable to move the ends of the range in the spectrum view. After pressing and releasing ctrl I can.

Also, does it work to make this work with the ROIs in the keyPressEvent and keyReleaseEvents.

mantidimaging/gui/widgets/mi_mini_image_view/view.py Outdated Show resolved Hide resolved
mantidimaging/gui/widgets/mi_mini_image_view/view.py Outdated Show resolved Hide resolved
@samtygier-stfc samtygier-stfc added this pull request to the merge queue May 9, 2024
Merged via the queue into main with commit a9fbdbb May 9, 2024
8 checks passed
@samtygier-stfc samtygier-stfc deleted the 2132_spectrum_plot_zoom branch May 9, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spectrum Viewer: add draggable zoom box to spectrum plot
3 participants