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

Make sure we remove the right patch from the image viewer when removing the slit overlay #803

Merged
merged 2 commits into from
Sep 3, 2021
Merged
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
15 changes: 13 additions & 2 deletions jdaviz/configs/mosviz/plugins/slit_overlay/slit_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def __init__(self, *args, **kwargs):
table = self.app.get_viewer("table-viewer")
table.figure_widget.observe(self.place_slit_overlay, names=['highlighted'])

self._slit_overlay_mark = None

def vue_change_visible(self, *args, **kwargs):
if self.visible:
self.place_slit_overlay()
Expand Down Expand Up @@ -114,6 +116,8 @@ def place_slit_overlay(self, *args, **kwargs):
# Visualize slit on the figure
fig_image.marks = fig_image.marks + [patch2]

self._slit_overlay_mark = patch2

else:
self.visible = False
snackbar_message = SnackbarMessage(
Expand All @@ -126,5 +130,12 @@ def place_slit_overlay(self, *args, **kwargs):
self.hub.broadcast(snackbar_message)

def remove_slit_overlay(self):
image_figure = self.app.get_viewer("image-viewer").figure
image_figure.marks = [image_figure.marks[0]]
if self._slit_overlay_mark is not None:
image_figure = self.app.get_viewer("image-viewer").figure
# We need to do the following instead of just removing directly on
# the marks otherwise traitlets doesn't register a change in the
# marks.
marks = image_figure.marks.copy()
marks.remove(self._slit_overlay_mark)
image_figure.marks = marks
self._slit_overlay_mark = None