From b5411a3ed839648b8bd8bca210fcbe2969b496ee Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 8 Dec 2022 11:39:01 +0000 Subject: [PATCH 1/4] Improve default viewer name --- glue/viewers/common/viewer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glue/viewers/common/viewer.py b/glue/viewers/common/viewer.py index 86bee0391..abf48320a 100644 --- a/glue/viewers/common/viewer.py +++ b/glue/viewers/common/viewer.py @@ -39,12 +39,14 @@ class BaseViewer(HubListener): The base class for all viewers. """ - LABEL = 'Override this' + LABEL = None def __init__(self, session): self._session = session self._data = session.data_collection self._hub = None + if self.LABEL is None: + self.LABEL = str(self.__class__) def register_to_hub(self, hub): self._hub = hub From f013a85ef208fafa568ed04fd202685de9b82872 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 8 Dec 2022 11:39:25 +0000 Subject: [PATCH 2/4] Make sure that BaseCartesianData instances can be assigned via key to DataCollection --- glue/core/data_collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue/core/data_collection.py b/glue/core/data_collection.py index 753b18e74..863a7baa8 100644 --- a/glue/core/data_collection.py +++ b/glue/core/data_collection.py @@ -424,7 +424,7 @@ def __setitem__(self, key, data): if not isinstance(key, str): raise TypeError("item key should be a string, but got {0}".format(type(key))) - if not isinstance(data, Data): + if not isinstance(data, BaseCartesianData): handler, preferred = data_translator.get_handler_for(data) From eb8f3c37364a9fed849005842814ff1689e5ab8c Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 8 Dec 2022 11:40:02 +0000 Subject: [PATCH 3/4] Allow _reference_data_changed call to be forced --- glue/viewers/image/state.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glue/viewers/image/state.py b/glue/viewers/image/state.py index 762676aa0..0c6ae51b3 100644 --- a/glue/viewers/image/state.py +++ b/glue/viewers/image/state.py @@ -149,11 +149,11 @@ def reset_limits(self): def _display_world(self): return getattr(self.reference_data, 'coords', None) is not None - def _reference_data_changed(self, *args): + def _reference_data_changed(self, *args, force=False): # This signal can get emitted if just the choices but not the actual # reference data change, so we check here that the reference data has # actually changed - if self.reference_data is not getattr(self, '_last_reference_data', None): + if self.reference_data is not getattr(self, '_last_reference_data', None) or force: self._last_reference_data = self.reference_data # Note that we deliberately use nested delay_callback here, because # we want to make sure that x_att_world and y_att_world both get From 59e76ed2c5b05249b7a18cb4970d18f2d2842b6c Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 8 Dec 2022 11:40:36 +0000 Subject: [PATCH 4/4] Make sure that changes in externally defined links triggers an update of the reference data in the image viewer --- glue/viewers/image/viewer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glue/viewers/image/viewer.py b/glue/viewers/image/viewer.py index c4ffb3b0f..142cd09ef 100644 --- a/glue/viewers/image/viewer.py +++ b/glue/viewers/image/viewer.py @@ -86,6 +86,10 @@ def add_data(self, data): self._set_wcs() return result + def _update_data(self, *args, **kwargs): + super()._update_data(*args, **kwargs) + self.state._reference_data_changed(force=True) + def _on_slice_change(self, event=None): if self._changing_slice_requires_wcs_update: self._set_wcs(relim=False)