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

DM-14763 Improve region ID handling in display_firefly #14

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions python/lsst/display/firefly/firefly.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, display, verbose=False, url=None,

self._isBuffered = False
self._regions = []
self._regionLayerId = None
self._regionLayerId = self._getRegionLayerId()
self._fireflyFitsID = None
self._fireflyMaskOnServer = None
self._client = _fireflyClient
Expand Down Expand Up @@ -140,6 +140,8 @@ def _mtv(self, image, mask=None, wcs=None, title=""):
if title == "":
title = str(self.display.frame)
if image:
if self.verbose:
print('displaying image')
self._erase()

with tempfile.NamedTemporaryFile() as fd:
Expand All @@ -165,6 +167,8 @@ def _mtv(self, image, mask=None, wcs=None, title=""):
raise RuntimeError("Display of image failed")

if mask:
if self.verbose:
print('displaying mask')
with tempfile.NamedTemporaryFile() as fdm:
displayLib.writeFitsImage(fdm.name, mask, wcs, title)
fdm.flush()
Expand Down Expand Up @@ -249,9 +253,10 @@ def _drawLines(self, points, ctype):

def _erase(self):
"""Erase all overlays on the image"""
if self.verbose:
print('region layer id is {}'.format(self._regionLayerId))
if self._regionLayerId:
_fireflyClient.delete_region_layer(self._regionLayerId, plot_id=str(self.display.frame))
self._regionLayerId = None

def _setCallback(self, what, func):
if func != interface.noop_callback:
Expand Down