Skip to content

Commit

Permalink
show label of selected line at top of line list plugin
Browse files Browse the repository at this point in the history
* click un-identifies it
  • Loading branch information
kecnry committed Mar 18, 2022
1 parent 2112a44 commit eb597c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jdaviz/configs/default/plugins/line_lists/line_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class LineListTool(PluginTemplateMixin):
custom_unit_choices = List([]).tag(sync=True)
custom_unit = Unicode().tag(sync=True)

identify_label = Unicode().tag(sync=True)
identify_line_icon = Unicode(read_icon(os.path.join(ICON_DIR, 'line_select.svg'), 'svg+xml')).tag(sync=True) # noqa

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -693,6 +694,7 @@ def _update_identify_to_line(self, name_rest, listname=None, identify=True):

self.list_contents = {}
self.list_contents = list_contents
self.identify_label = name_rest if identify else ""

def _process_identify_change(self, msg):
if msg.sender == self:
Expand All @@ -703,10 +705,17 @@ def _process_identify_change(self, msg):
# then line mark themselves will also respond to the same event, so there is
# no need to broadcast another

def vue_set_identify(self, data):
def vue_set_identify(self, data=None):
"""
Set the selected line as "identified"
"""
if data is None:
# then default to the currently identified (which will unidentify it)
for listname, this_list in self.list_contents.items():
for line_ind, line in enumerate(this_list['lines']):
if line['identify']:
return self.vue_set_identify((listname, line, line_ind))

listname, line, line_ind = data
identify = not line.get('identify', False)
if identify and not line['show']:
Expand Down
7 changes: 7 additions & 0 deletions jdaviz/configs/default/plugins/line_lists/line_lists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<j-docs-link :link="'https://jdaviz.readthedocs.io/en/'+vdocs+'/'+config+'/plugins.html#line-lists'">Plot lines from preset or custom line lists.</j-docs-link>
</v-row>

<v-row v-if="identify_label">
<v-chip
label=true
@click="set_identify(null)"
><img class="color-to-accent" :src="identify_line_icon" width="20"/> {{ identify_label }}</v-chip>
</v-row>

<j-plugin-section-header>Redshift</j-plugin-section-header>
<v-row>
<j-docs-link>Shift spectral lines according to a specific redshift. Only enabled if at least one line is plotted.</j-docs-link>
Expand Down

0 comments on commit eb597c9

Please # to comment.