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

Show colormap previews in menu #2900

Merged
merged 5 commits into from
Jun 3, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 46 additions & 20 deletions jdaviz/configs/default/plugins/plot_options/plot_options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
v-model="image_color_mode_value"
label="Color Mode"
hint="Whether each layer gets a single color or colormap."
persistent-hint
dense
persistent-hint
dense
>
<template v-slot:selection="{ item }">
<span>
Expand Down Expand Up @@ -476,24 +476,33 @@
v-model="image_colormap_value"
label="Colormap"
dense
></v-select>
<v-alert v-if="image_colormap_value == 'Random' && (
stretch_function_value !== 'linear' || stretch_preset_value !== 100 ||
image_bias_value !== 0.5 || image_contrast_value !== 1.0
)" type='warning' style="margin-left: -12px; margin-right: -12px">
For image segmentation maps, "Random" gives unique colors
only when the stretch percentile is min/max, stretch function
is linear, contrast is 1.0, and bias is 0.5. Click below
to choose these settings.
<v-row justify='end'>
<plugin-action-button
:results_isolated_to_plugin="true"
@click="image_segmentation_map_presets"
>
Image segmentation map
</plugin-action-button>
</v-row>
</v-alert>
>
<template v-slot:selection="{ item, index }">
<span>{{ item.text }}</span>
</template>
<template v-slot:item="{ item }">
<v-card flat :style="'background: '+ colorStyle(item, cmap_samples)" width="150" class="d-flex justify-center align-center text-center">
rosteen marked this conversation as resolved.
Show resolved Hide resolved
<span style="color: white; font-weight: bold; text-shadow: 0px 0px 3px black">{{ item.text }}</span>
</v-card>
</template>
</v-select>
<v-alert v-if="image_colormap_value == 'Random' && (
stretch_function_value !== 'linear' || stretch_preset_value !== 100 ||
image_bias_value !== 0.5 || image_contrast_value !== 1.0
)" type='warning' style="margin-left: -12px; margin-right: -12px">
For image segmentation maps, "Random" gives unique colors
only when the stretch percentile is min/max, stretch function
is linear, contrast is 1.0, and bias is 0.5. Click below
to choose these settings.
<v-row justify='end'>
<plugin-action-button
:results_isolated_to_plugin="true"
@click="image_segmentation_map_presets"
>
Image segmentation map
</plugin-action-button>
</v-row>
</v-alert>

</glue-state-sync-wrapper>
<glue-state-sync-wrapper v-if="image_color_mode_value !== 'Colormaps' || image_color_mode_sync['mixed']" :sync="image_color_sync" :multiselect="layer_multiselect" @unmix-state="unmix_state('image_color')">
Expand Down Expand Up @@ -783,6 +792,23 @@ module.exports = {
contour_custom_levels_set_value(e) {
this.contour_custom_levels_txt = e
this.contour_custom_levels_value = e.split(',').filter(n => n.trim().length).map(n => Number(n)).filter(n => !isNaN(n))
},
colorStyle(item, cmap_samples) {
var cmap_strip_width = 3
rosteen marked this conversation as resolved.
Show resolved Hide resolved
var colors = []
var style = 'repeating-linear-gradient( 90deg, '
colors = cmap_samples[item.value]
for ([ci, color] of colors.entries()) {
var start = ci*cmap_strip_width
var end = (ci+1)*cmap_strip_width
style += color + ' '+start+'px, ' + color + ' '+end+'px'
rosteen marked this conversation as resolved.
Show resolved Hide resolved
if (ci !== colors.length-1) {
style += ', '
}
}
style += ')'
console.log(style)
return style
}
},
}
Expand Down
Loading