Skip to content

Commit

Permalink
imviz matched zoom: use center & radius instead of corners
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Oct 8, 2024
1 parent 99baa91 commit c15feea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion jdaviz/configs/imviz/plugins/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@


class _ImvizMatchedZoomMixin(_MatchedZoomMixin):
match_keys = ('x_min', 'x_max', 'y_min', 'y_max')
match_axes = []
disable_matched_zoom_in_other_viewer = True

@property
def match_keys(self):
return ('zoom_center_x', 'zoom_center_y', 'zoom_radius')

def _is_matched_viewer(self, viewer):
return isinstance(viewer, BqplotImageView)

Expand Down
9 changes: 8 additions & 1 deletion jdaviz/core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def on_limits_change(self, *args):
viewer.zoom_level = old_level * float(to_fov_sky / orig_fov_sky)
viewer.center_on(sky_cen)

else:
elif len(self.match_axes):
with delay_callback(viewer.state, *self.match_keys):
for ax in self.match_axes:
if None in orig_lims.values():
Expand All @@ -134,6 +134,13 @@ def on_limits_change(self, *args):
if not np.isnan(value) and (orig_value is None or
abs(value-orig_lims.get(k, np.inf)) > tol):
setattr(viewer.state, k, value)
else:
# match keys, but not match axes (e.g., zoom_center and zoom_radius)
with delay_callback(viewer.state, *self.match_keys):
for k in self.match_keys:
value = to_lims.get(k)
if not np.isnan(value):
setattr(viewer.state, k, value)

def is_visible(self):
return len(self.viewer.jdaviz_app._viewer_store) > 1
Expand Down

0 comments on commit c15feea

Please sign in to comment.