Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable astrowidgets pixel marking when WCS linked (PR to PR 14 to PR 2179) #5

Closed
1 change: 1 addition & 0 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2391,6 +2391,7 @@ def _expose_meta(key):
'locked': False,
'ndims': data.ndim,
'type': typ,
'has_wcs': wcsaxes is not None,
'meta': {k: v for k, v in data.meta.items() if _expose_meta(k)},
'children': []}

Expand Down
19 changes: 2 additions & 17 deletions jdaviz/components/layer_viewer_icon.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
<template>
<span v-if="icon !== undefined">
<v-badge
dot
style="margin-right: 4px;"
color="accent"
:value="isRefData()">
<v-icon v-if="String(icon).startsWith('mdi-')" size="16">
<v-icon v-if="String(icon).startsWith('mdi-')" :size="icon_size || 16">
{{icon}}
</v-icon>
<span v-else :class="prevent_invert_if_dark ? 'layer-viewer-icon' : 'invert-if-dark layer-viewer-icon'" :style="span_style+'; color: '+color+'; '+borderStyle">
{{String(icon).toUpperCase()}}
</span>
</v-badge>
</span>
</template>

<script>
module.exports = {
props: ['span_style', 'color', 'icon', 'linewidth', 'linestyle', 'prevent_invert_if_dark', 'is_ref_data', 'linked_by_wcs'],
props: ['span_style', 'color', 'icon', 'icon_size', 'linewidth', 'linestyle', 'prevent_invert_if_dark'],
computed: {
borderStyle() {
if (this.$props.linewidth > 0) {
return 'border-bottom: '+this.$props.linewidth+'px '+this.$props.linestyle+' '+this.$props.color
}
return ''
},
},
methods: {
isRefData() {
if (!this.$props.linked_by_wcs || this.$props.is_ref_data === undefined) {
return false
} else {
return this.$props.is_ref_data
}
}
}
};
</script>
Expand Down
2 changes: 2 additions & 0 deletions jdaviz/components/tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ const tooltips = {
'viewer-data-radio': 'Switch visibility to layers associated with this data entry',
'viewer-data-enable': 'Load data entry into this viewer',
'viewer-data-disable': 'Disable data within this viewer (will be hidden and unavailable from plugins until re-enabled)',
'viewer-wcs-delete': 'Remove orientation option across entire app',
'viewer-data-delete': 'Remove data entry across entire app (might affect existing subsets)',
'viewer-data-nowcs': 'Data does not have WCS, cannot add unless link type changed to pixel',

'table-prev': 'Select previous row in table',
'table-next': 'Select next row in table',
Expand Down
59 changes: 18 additions & 41 deletions jdaviz/components/viewer_data_select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,77 +49,59 @@
:icon="layer_icons[item.name]"
:viewer="viewer"
:multi_select="multi_select"
:is_wcs_only="false"
:n_data_entries="nDataEntries"
:linked_by_wcs="linkedByWcs()"
@data-item-visibility="$emit('data-item-visibility', $event)"
@data-item-unload="$emit('data-item-unload', $event)"
@data-item-remove="$emit('data-item-remove', $event)"
@change-reference-data="$emit('change-reference-data', $event)"
></j-viewer-data-select-item>
</v-row>

<div v-if="extraDataItems.length" style="margin-bottom: -8px;">
<v-row key="extra-items-expand" style="padding-left: 25px; margin-right: 0px; padding-bottom: 4px; background-color: #E3F2FD">
<span
@click="toggleShowExtraItems"
class='text--primary'
style="overflow-wrap: anywhere; font-size: 12pt; padding-top: 6px; padding-left: 6px; cursor: pointer"
>
<v-icon class='invert-if-dark'>{{showExtraItems ? 'mdi-chevron-double-up' : 'mdi-chevron-double-down'}}</v-icon>
<span v-if="viewer.config === 'mosviz'">
{{showExtraItems ? 'hide other row data not in viewer' : 'show other row data not in viewer'}}
</span>
<span v-else>
{{showExtraItems ? 'hide data not in viewer' : 'show data not in viewer'}}
</span>
</span>
</v-row>

<v-row v-if="showExtraItems" v-for="item in extraDataItems" :key="item.id" style="padding-left: 25px; margin-right: 0px; margin-top: 4px; margin-bottom: 4px">
<div v-if="linkedByWcs()">
<div v-if="linkedByWcs()">
<j-plugin-section-header style="margin-top: 0px">Orientation</j-plugin-section-header>
<v-row v-for="item in wcsOnlyItems" :key="item.id" style="padding-left: 25px; margin-right: -8px; margin-top: 4px; margin-bottom: 4px">
<j-viewer-data-select-item
:item="item"
:icon="layer_icons[item.name]"
:viewer="viewer"
:multi_select="multi_select"
:n_data_entries="nDataEntries"
:linked_by_wcs="linkedByWcs()"
@data-item-visibility="$emit('data-item-visibility', $event)"
:is_wcs_only="true"
@data-item-remove="$emit('data-item-remove', $event)"
@change-reference-data="$emit('change-reference-data', $event)"
></j-viewer-data-select-item>
</div>
</v-row>
</div>

<div v-if="linkedByWcs()" style="margin-bottom: -8px;">
<v-row key="wcs-only-items-expand" style="padding-left: 25px; margin-right: 0px; padding-bottom: 4px; background-color: #E3F2FD">
<span
@click="toggleShowWcsOnlyItems"
<div v-if="extraDataItems.length > 0" style="margin-bottom: -8px;">
<v-row key="extra-items-expand" style="padding-left: 25px; margin-right: 0px; padding-bottom: 4px; background-color: #E3F2FD">
<span
@click="toggleShowExtraItems"
class='text--primary'
style="overflow-wrap: anywhere; font-size: 12pt; padding-top: 6px; padding-left: 6px; cursor: pointer"
>
<v-icon class='invert-if-dark'>{{showWcsOnlyItems ? 'mdi-chevron-double-up' : 'mdi-chevron-double-down'}}</v-icon>
<span>
{{showWcsOnlyItems ? 'hide orientation options' : 'show orientation options'}}
<v-icon class='invert-if-dark'>{{showExtraItems ? 'mdi-chevron-double-up' : 'mdi-chevron-double-down'}}</v-icon>
<span v-if="viewer.config === 'mosviz'">
{{showExtraItems ? 'hide other row data not in viewer' : 'show other row data not in viewer'}}
</span>
<span v-else>
{{showExtraItems ? 'hide data not in viewer' : 'show data not in viewer'}}
</span>
</span>
</v-row>

<v-row v-if="showWcsOnlyItems" v-for="item in wcsOnlyItems" :key="item.id" style="padding-left: 25px; margin-right: 0px; margin-top: 4px; margin-bottom: 4px">
<v-row v-if="showExtraItems" v-for="item in extraDataItems" :key="item.id" style="padding-left: 25px; margin-right: 0px; margin-top: 4px; margin-bottom: 4px">
<j-viewer-data-select-item
:item="item"
:icon="layer_icons[item.name]"
:viewer="viewer"
:multi_select="multi_select"
:linked_by_wcs="linkedByWcs()"
:is_wcs_only="false"
:n_data_entries="nDataEntries"
@data-item-visibility="$emit('data-item-visibility', $event)"
@data-item-remove="$emit('data-item-remove', $event)"
@change-reference-data="$emit('change-reference-data', $event)"
></j-viewer-data-select-item>
</v-row>
</div>

</v-list>
</v-menu>
</j-tooltip>
Expand Down Expand Up @@ -150,7 +132,6 @@ module.exports = {
showExtraItems: false,
valueTrunc: this.value,
uncertTrunc: this.uncertainty,
showWcsOnlyItems: false
}
},
methods: {
Expand Down Expand Up @@ -243,10 +224,6 @@ module.exports = {
}
}
},
toggleShowWcsOnlyItems() {
// toggle the visibility of the WCS-only items in the menu
this.showWcsOnlyItems = !this.showWcsOnlyItems
},
isRefData() {
return this.$props.item.viewer.reference_data_label === this.$props.item.name
},
Expand Down
64 changes: 37 additions & 27 deletions jdaviz/components/viewer_data_select_item.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<template>
<div style="display: contents">
<div v-if="isSelected">
<div v-if="is_wcs_only">
<j-tooltip
:tooltipcontent="isRefData() ? 'Current viewer orientation' : 'Set as viewer orientation'"
span_style="width: 36px"
>
<span @click="selectRefData">
<v-badge
dot
style="margin-right: 0px; margin-left: 8px; margin-top: 6px"
color="accent"
:value="isRefData()"
>
<j-layer-viewer-icon :icon="icon" icon_size="20" color="#000000DE"></j-layer-viewer-icon>
</v-badge>
</span>
</j-tooltip>
</div>
<div v-else-if="isSelected">
<j-tooltip :tipid="multi_select ? 'viewer-data-select' : 'viewer-data-radio'">
<v-btn
icon
Expand All @@ -11,7 +28,7 @@
</v-btn>
</j-tooltip>
</div>
<div v-else>
<div v-else-if="!linkedByWcs() || item.has_wcs">
<j-tooltip tipid="viewer-data-enable">
<v-btn
icon
Expand All @@ -21,15 +38,21 @@
</v-btn>
</j-tooltip>
</div>
<div v-else>
<j-tooltip tipid="viewer-data-nowcs">
<v-btn
icon
color="default"
disabled>
<v-icon>mdi-plus</v-icon>
</v-btn>
</j-tooltip>
</div>

<j-tooltip :tooltipcontent="is_wcs_only ? '' : 'data label: '+item.name" span_style="font-size: 12pt; padding-top: 6px; padding-left: 4px; padding-right: 16px; width: calc(100% - 80px); white-space: nowrap; cursor: default;">
<j-layer-viewer-icon v-if="!is_wcs_only" span_style="margin-left: 4px;" :icon="icon" color="#000000DE"></j-layer-viewer-icon>
<span v-else style="padding-right: 24px"></span>

<j-tooltip
:tooltipcontent=dataMenuTooltip
span_style="font-size: 12pt; padding-top: 6px; padding-left: 4px; padding-right: 16px; width: calc(100% - 80px); white-space: nowrap; cursor: default;">
<span
:style="dataMenuTooltip !== null ? 'cursor: pointer;' : 'cursor: default;'"
@click="selectRefData"
>
<j-layer-viewer-icon span_style="margin-left: 4px;" :icon="icon" color="#000000DE" :is_ref_data="isRefData()" :linked_by_wcs="linkedByWcs()"></j-layer-viewer-icon>
<div class="text-ellipsis-middle" style="font-weight: 500;">
<span>
{{itemNamePrefix}}
Expand All @@ -38,7 +61,6 @@
{{itemNameExtension}}
</span>
</div>
</span>
</j-tooltip>

<div v-if="isSelected && isUnloadable" style="padding-left: 2px; right: 2px">
Expand All @@ -54,7 +76,7 @@
</div>

<div v-if="isDeletable" style="padding-left: 2px; right: 2px">
<j-tooltip tipid='viewer-data-delete'>
<j-tooltip :tipid="is_wcs_only ? 'viewer-wcs-delete' : 'viewer-data-delete'">
<v-btn
icon
@click="$emit('data-item-remove', {item_name: item.name, viewer_id: viewer.id})"
Expand All @@ -67,7 +89,7 @@
<script>

module.exports = {
props: ['item', 'icon', 'multi_select', 'viewer', 'n_data_entries'],
props: ['item', 'icon', 'multi_select', 'viewer', 'n_data_entries', 'is_wcs_only'],
methods: {
selectClicked() {
prevVisibleState = this.visibleState
Expand All @@ -83,7 +105,7 @@ module.exports = {
})
},
selectRefData() {
if (this.linkedByWcs() && !this.isRefData() && this.isWCSOnly()) {
if (this.linkedByWcs() && !this.isRefData() && this.is_wcs_only) {
this.$emit('change-reference-data', {
id: this.$props.viewer.id,
item_id: this.$props.item.id
Expand All @@ -95,9 +117,6 @@ module.exports = {
},
linkedByWcs() {
return this.$props.viewer.linked_by_wcs
},
isWCSOnly() {
return this.$props.item.type === 'wcs-only'
}
},
computed: {
Expand Down Expand Up @@ -162,7 +181,7 @@ module.exports = {
isMosviz = this.$props.viewer.config === 'mosviz'
isCubeviz = this.$props.viewer.config === 'cubeviz'
isPluginData = !(this.$props.item.meta.Plugin === undefined)
return notSelected && (isPluginData || (!isLastDataset && !isMosviz && !isCubeviz))
return notSelected && (isPluginData || (!isLastDataset && !isMosviz && !isCubeviz)) && (this.$props.item.name !== 'Default orientation')
},
selectTipId() {
if (this.multi_select) {
Expand All @@ -177,15 +196,6 @@ module.exports = {
} else {
return 'gray'
}
},
dataMenuTooltip() {
if (this.linkedByWcs() && this.$props.viewer.config === 'imviz' && this.isRefData()) {
return 'Current viewer orientation'
} else if (this.linkedByWcs() && this.$props.viewer.config === 'imviz' && this.$props.item.type === 'wcs-only') {
return 'Set viewer orientation'
} else {
return null
}
}
}
};
Expand Down
39 changes: 19 additions & 20 deletions jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ def link_image_data(app, link_type='pixels', wcs_fallback_scheme=None, wcs_use_a
Invalid inputs or reference data.

"""
# to avoid any confusion with the capitalized-versions in the links control plugin, let's
# just always compare against lowercase here.
link_type = link_type.lower()
if len(app.data_collection) <= 1 and link_type != 'wcs': # No need to link, we are done.
return

Expand Down Expand Up @@ -653,34 +656,30 @@ def link_image_data(app, link_type='pixels', wcs_fallback_scheme=None, wcs_use_a

app._link_type = link_type
app._wcs_use_affine = wcs_use_affine
viewer_ref = app._jdaviz_helper.default_viewer.reference
viewer_item = app._get_viewer_item(viewer_ref)

viewer_item['reference_data_label'] = refdata.label

if link_plugin is not None:
# Only broadcast after success.
app.hub.broadcast(LinkUpdatedMessage(link_type,
wcs_fallback_scheme == 'pixels',
wcs_use_affine,
sender=app))

if insert_base_wcs_layer:
# update all viewer items with reference data:
for viewer_id in app.get_viewer_ids():
viewer_item = app._get_viewer_item(viewer_id)
viewer_item['reference_data_label'] = refdata.label

# reset the progress spinner
link_plugin.linking_in_progress = False

for viewer in app._viewer_store.values():
wcs_linked = link_type == 'wcs'
# viewer-state needs to know link type for reset_limits behavior
viewer.state.linked_by_wcs = wcs_linked
# also need to store a copy in the viewer item for the data dropdown to access
viewer_item = app._get_viewer_item(viewer.reference)

viewer_item['reference_data_label'] = refdata.label
viewer_item['linked_by_wcs'] = wcs_linked

if insert_base_wcs_layer:
viewer_item['reference_data_label'] = refdata.label

# if changing from one link type to another, reset the limits:
if link_type != old_link_type:
viewer.state.reset_limits()

if link_plugin is not None:
# Only broadcast after success.
app.hub.broadcast(LinkUpdatedMessage(link_type,
wcs_fallback_scheme == 'pixels',
wcs_use_affine,
sender=app))

# reset the progress spinner
link_plugin.linking_in_progress = False
Loading