Allow selection after projection has been changed #2262
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, in the scatter viewer, as soon as one changes the projection of the viewer, the selection tools no longer work for that viewer. This effect is independent of both the initial and final projections in the change.
The reason for this is here. When the projection is updated, the
axes
property of the viewer is updated with the axes for the new projection. However, the toolbar items, and any associated ROI tools, are still referencing the original viewer axes. This stale reference causes the selection tools to no longer work.This PR fixes the issue by adding
remove_toolbar
andremove_all_toolbars
methods to the QtDataViewer
class, and using these to remove and recreate the toolbar when the scatter projection is changed. I don't believe there are any other viewers that can change axes, but if there are, they will require the same type of update.The alternative to this would be to update the reference to the axes in each toolbar item/ROI tool as appropriate, but this fix seems more straightforward to me.