Skip to content

Commit

Permalink
Make sure we remove the right patch from the image viewer when removi…
Browse files Browse the repository at this point in the history
…ng the slit overlay
  • Loading branch information
astrofrog committed Sep 3, 2021
1 parent 4018090 commit 1b79541
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 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,7 @@ 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
image_figure.marks.remove(self._slit_overlay_mark)
self._slit_overlay_mark = None

0 comments on commit 1b79541

Please sign in to comment.