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-14734 Allow zoom to be set before mtv in afw Displays for Firefly backend #13

Merged
merged 1 commit into from
Jun 8, 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
33 changes: 28 additions & 5 deletions python/lsst/display/firefly/firefly.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def __init__(self, display, verbose=False, url=None,
self._localbrowser = localbrowser
self._maskIds = []
self._maskDict = {}
self._lastZoom = None
self._lastPan = None

def _getRegionLayerId(self):
return "lsstRegions%s" % self.display.frame if self.display else "None"
Expand All @@ -146,11 +148,18 @@ def _mtv(self, image, mask=None, wcs=None, title=""):
fd.seek(0,0)
self._fireflyFitsID = _fireflyClient.upload_data(fd, 'FITS')

extraParams = dict(Title=title,
MultiImageIdx=0,
PredefinedOvelayIds=' ')
# Firefly's Javascript API requires a space for parameters;
# otherwise the parameter will be ignored

if self._lastZoom:
extraParams['InitZoomLevel'] = self._lastZoom
extraParams['ZoomType'] = 'LEVEL'
Copy link
Member

Choose a reason for hiding this comment

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

Should there be a similar block for panning here, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were some concerns about that leaving an overlay at that position...however let me give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have the right API right now so it will be added once we have that on the Firefly end.


ret = _fireflyClient.show_fits(self._fireflyFitsID, plot_id=str(self.display.frame),
Title=title, MultiImageIdx=0,
PredefinedOverlayIds=' ')
# Firefly's Javascript API requires a space for parameters; otherwise
# the parameter will be ignored
**extraParams)

if not ret["success"]:
raise RuntimeError("Display of image failed")
Expand Down Expand Up @@ -375,9 +384,23 @@ def _show(self):
#

def _zoom(self, zoomfac):
"""Zoom frame by specified amount"""
"""Zoom display by specified amount

Parameters:
-----------
zoomfac: `float`
zoom level in screen pixels per image pixel
"""
self._lastZoom = zoomfac
_fireflyClient.set_zoom(plot_id=str(self.display.frame), factor=zoomfac)

def _pan(self, colc, rowc):
"""Pan to specified pixel coordinates

Parameters:
-----------
colc, rowc : `float`
column and row in units of pixels
"""
self._lastPan = [colc, rowc] # saved for future use in _mtv
_fireflyClient.set_pan(plot_id=str(self.display.frame), x=colc, y=rowc)