diff --git a/CHANGES.rst b/CHANGES.rst index cf5e968799..ec9728b153 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -75,6 +75,8 @@ Bug Fixes Cubeviz ^^^^^^^ +- Re-enable support for exporting spectrum-viewer. [#2825] + Imviz ^^^^^ diff --git a/jdaviz/configs/default/plugins/export/export.py b/jdaviz/configs/default/plugins/export/export.py index 4c798dcda6..b1aa8b0abf 100644 --- a/jdaviz/configs/default/plugins/export/export.py +++ b/jdaviz/configs/default/plugins/export/export.py @@ -5,6 +5,7 @@ from glue_jupyter.bqplot.image import BqplotImageView from jdaviz.core.custom_traitlets import FloatHandleEmpty, IntHandleEmpty +from jdaviz.core.marks import ShadowMixin from jdaviz.core.registries import tray_registry from jdaviz.core.template_mixin import (PluginTemplateMixin, SelectPluginComponent, ViewerSelectMixin, DatasetMultiSelectMixin, @@ -330,11 +331,31 @@ def export(self, filename=None, show_dialog=None, overwrite=False, raise FileExistsError(f"{filename} exists but overwrite=False") return + # temporarily "clean" incompatible marks of unicode characters, etc + restores = [] + for i, mark in enumerate(viewer.figure.marks): + restores.append({}) + if len(getattr(mark, 'text', [])): + if not isinstance(mark, ShadowMixin): + # if it is shadowing another mark, that will automatically get updated + # when the other mark is restored, but we'll still ensure that the mark + # is clean of unicode before exporting. + restores[i]['text'] = [t for t in mark.text] + mark.text = [t.strip() for t in mark.text] + if len(getattr(mark, 'labels', [])): + restores[i]['labels'] = mark.labels[:] + mark.labels = [lbl.strip() for lbl in mark.labels] + if filetype == "mp4": self.save_movie(viewer, filename, filetype) else: self.save_figure(viewer, filename, filetype, show_dialog=show_dialog) + # restore marks to their original state + for restore, mark in zip(restores, viewer.figure.marks): + for k, v in restore.items(): + setattr(mark, k, v) + elif len(self.plugin_plot.selected): plot = self.plugin_plot.selected_obj._obj filetype = self.plugin_plot_format.selected