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

Channel colors & sliders #1222

Merged
merged 14 commits into from
Jun 29, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ export default {
autoRange: undefined
}
})
Object.entries(CHANNEL_COLORS).forEach(([channelName, color]) => {
if(this.layers.includes(channelName)){
this.compositeLayerInfo[channelName].palette = color
usedColors.push(color)
// Assign colors
this.layers.forEach((layerName) => {
if (!this.compositeLayerInfo[layerName].palette) {
// Search for case-insensitive regex match among known channel-colors
Object.entries(CHANNEL_COLORS).forEach(([channelPattern, color]) => {
if (layerName.match(new RegExp(channelPattern, 'i')) && !usedColors.includes(color)) {
this.compositeLayerInfo[layerName].palette = color
usedColors.push(color)
}
})

manthey marked this conversation as resolved.
Show resolved Hide resolved
}
})
this.layers.forEach((layerName) => {
Expand Down Expand Up @@ -193,7 +200,7 @@ export default {
</script>

<template>
<div class="table-container">
<div :class="colorPickerShown ? 'table-container tall' : 'table-container'">
<table id="composite-layer-table" class="table table-condensed">
<thead class="table-header">
<tr>
Expand Down Expand Up @@ -341,7 +348,8 @@ export default {
width: 10%;
}
.name-col {
width: 40%;
max-width: 40%;
word-break: break-all;
}
.color-col {
width: 25%;
Expand Down Expand Up @@ -408,6 +416,9 @@ export default {
position: relative;
max-height: 300px;
}
.table-container.tall {
height: 300px;
}
.table-container td {
padding: 0 5px;
}
Expand Down
62 changes: 52 additions & 10 deletions girder/girder_large_image/web_client/vue/components/DualInput.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script>
export default {
props: ['label', 'currentValue', 'valueMax'],
props: ['label', 'currentValue', 'valueMax', 'sliderLabels'],
emits: ['updateValue'],
data() {
return {
value: this.currentValue
value: this.currentValue,
}
},
watch: {
Expand All @@ -16,7 +16,7 @@ export default {
</script>

<template>
<tr class="dual-controls">
<tr :class="this.sliderLabels && this.sliderLabels.length ? 'dual-controls tall' : 'dual-controls'">
<td><label for="numberControl">{{ label }}: </label></td>
<td><input
type="number"
Expand All @@ -25,18 +25,60 @@ export default {
:max="valueMax"
v-model="value"
></td>
<td style="width:90%"><input
type="range"
name="sliderControl"
min="0"
:max="valueMax"
v-model="value"
></td>
<td style="width:90%">
<input
type="range"
name="sliderControl"
min="0"
:max="valueMax"
v-model="value"
>
<div class="bubble-wrap">
<output
v-if="this.sliderLabels && this.sliderLabels.length > value"
:style="'left:'+value/valueMax*100+'%; transform:translateX(-'+value/valueMax*100+'%)'"
class="bubble"
>
{{ this.sliderLabels[value] }}
</output>
<span v-if="this.sliderLabels && this.sliderLabels.length > value"
:style="'left:'+value/valueMax*100+'%; transform:translateX(-'+value/valueMax*100+'%)'"
class="bubble-after"></span>
</div>
</td>
</tr>
</template>

<style scoped>
.dual-controls > * > * {
margin-right: 15px;
}
.dual-controls.tall {
height: 40px;
vertical-align: top;
}
.bubble-wrap {
position: relative;
width: calc(100% - 20px);
left: 10px;
}
.bubble {
background: rgb(120, 120, 120);
font-size: 10px;
color: white;
padding: 4px 12px;
position: absolute;
border-radius: 4px;
transform: translateX(-50%);
z-index: 10;
white-space: nowrap;
}
.bubble-after {
position: absolute;
width: 4px;
height: 4px;
background: rgb(120, 120, 120);
top: -1px;
left: 50%;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default Vue.extend({
:currentValue="indexInfo[index].current"
:valueMax="indexInfo[index].range"
:label="index.replace('Index', '')"
:sliderLabels="index === 'IndexC' ? imageMetadata.channels : []"
manthey marked this conversation as resolved.
Show resolved Hide resolved
@updateValue="(v) => updateAxisSlider({index, frame: v})"
/>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export default {
this.fetchHistogram()
},
watch: {
currentFrame() {
this.fetchHistogram()
},
histogram() {
// allow rerender to occur first
nextTick().then(() => {
Expand Down
14 changes: 7 additions & 7 deletions girder/girder_large_image/web_client/vue/utils/colors.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const CHANNEL_COLORS = {
BRIGHTFIELD: '#FFFFFF',
DAPI: '#0000FF',
A594: '#FF0000',
CY3: '#FF8000',
CY5: '#FF00FF',
YFP: '#00FF00',
GFP: '#00FF00'
'^BRIGHTFIELD.*$': '#FFFFFF',
'^DAPI.*$': '#0000FF',
'^A594(|[^\d].*)$': '#FF0000', // eslint-disable-line
'^CY3(|[^\d].*)$': '#FF8000', // eslint-disable-line
'^CY5(|[^\d].*)$': '#FF00FF', // eslint-disable-line
'^YFP.*$': '#00FF00',
'^GFP.*$': '#00FF00'
};

export const OTHER_COLORS = [
Expand Down