Skip to content

Commit

Permalink
Merge pull request #1312 from kecnry/indicator-offscreen
Browse files Browse the repository at this point in the history
offscreen indicators in spectrum-viewer for lines and slice
  • Loading branch information
pllim authored May 17, 2022
2 parents ac48b5f + 8fe0330 commit 2a146dc
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 45 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ New Features
- Line list plugin now supports exact-text filtering on line names. [#1298]
- Added a Subset Tools plugin for viewing information about defined subsets. [#1292]

- Offscreen indication for spectral lines and slice indicator. [#1312]

Cubeviz
^^^^^^^

Expand Down
7 changes: 3 additions & 4 deletions jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import numpy as np

from jdaviz.configs.cubeviz.plugins.slice.slice import Slice
from jdaviz.core.marks import SliceIndicator


@pytest.mark.filterwarnings('ignore:No observer defined on WCS')
Expand Down Expand Up @@ -62,15 +61,15 @@ def test_indicator_settings(cubeviz_helper, spectrum1d_cube):
app.add_data_to_viewer("flux-viewer", "test")
sl = Slice(app=app)
sv = app.get_viewer('spectrum-viewer')
indicator = [m for m in sv.figure.marks if isinstance(m, SliceIndicator)][0]
indicator = sv.slice_indicator

assert sl.setting_show_indicator is True
assert indicator._show_if_inactive is True
assert sl.setting_show_wavelength is True
assert indicator.labels_visibility == 'label'
assert indicator.label.visible is True

sl.setting_show_indicator = False
assert indicator._show_if_inactive is False

sl.setting_show_wavelength = False
assert indicator.labels_visibility == 'none'
assert indicator.label.visible is False
10 changes: 5 additions & 5 deletions jdaviz/configs/cubeviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from glue_jupyter.bqplot.image import BqplotImageView

from jdaviz.core.registries import viewer_registry
from jdaviz.core.marks import SliceIndicator
from jdaviz.core.marks import SliceIndicatorMarks
from jdaviz.configs.default.plugins.viewers import JdavizViewerMixin
from jdaviz.configs.imviz.helper import data_has_valid_wcs
from jdaviz.configs.specviz.plugins.viewers import SpecvizProfileView
Expand Down Expand Up @@ -170,12 +170,12 @@ def __init__(self, *args, **kwargs):
@property
def slice_indicator(self):
for mark in self.figure.marks:
if isinstance(mark, SliceIndicator):
if isinstance(mark, SliceIndicatorMarks):
return mark

# SliceIndicator does not yet exist
slice_indicator = SliceIndicator(self)
self.figure.marks = self.figure.marks + [slice_indicator]
# SliceIndicatorMarks does not yet exist
slice_indicator = SliceIndicatorMarks(self)
self.figure.marks = self.figure.marks + slice_indicator.marks
return slice_indicator

def _update_slice_indicator(self, slice):
Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/specviz/plugins/line_analysis/line_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
LineAnalysisContinuumCenter,
LineAnalysisContinuumLeft,
LineAnalysisContinuumRight,
Shadow)
ShadowLine)
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import (PluginTemplateMixin,
DatasetSelectMixin,
Expand Down Expand Up @@ -149,7 +149,7 @@ def marks(self):
marks = {'left': LineAnalysisContinuumLeft(viewer, visible=self.plugin_opened),
'center': LineAnalysisContinuumCenter(viewer, visible=self.plugin_opened),
'right': LineAnalysisContinuumRight(viewer, visible=self.plugin_opened)}
shadows = [Shadow(mark, shadow_width=2) for mark in marks.values()]
shadows = [ShadowLine(mark, shadow_width=2) for mark in marks.values()]
# NOTE: += won't trigger the figure to notice new marks
viewer.figure.marks = viewer.figure.marks + shadows + list(marks.values())

Expand Down
4 changes: 3 additions & 1 deletion jdaviz/configs/specviz/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from jdaviz.core.events import SpectralMarksChangedMessage, LineIdentifyMessage
from jdaviz.core.registries import viewer_registry
from jdaviz.core.marks import SpectralLine, LineUncertainties, ScatterMask
from jdaviz.core.marks import SpectralLine, LineUncertainties, ScatterMask, OffscreenLinesMarks
from jdaviz.core.linelists import load_preset_linelist, get_available_linelists
from jdaviz.core.freezable_state import FreezableProfileViewerState
from jdaviz.configs.default.plugins.viewers import JdavizViewerMixin
Expand Down Expand Up @@ -53,6 +53,8 @@ class SpecvizProfileView(BqplotProfileView, JdavizViewerMixin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._initialize_toolbar_nested(default_tool_priority=['jdaviz:selectslice'])
self._offscreen_lines_marks = OffscreenLinesMarks(self)
self.figure.marks = self.figure.marks + self._offscreen_lines_marks.marks

self.display_uncertainties = False
self.display_mask = False
Expand Down
Loading

0 comments on commit 2a146dc

Please sign in to comment.