Skip to content

Commit 3b58f37

Browse files
committed
fix(datasource/graphene) make all segments aside from the focus segment (including segment id 0) hidden (same as off color) as well as making them appear to have no highlight effect by setting the highlight color to be the same as the off color (other than the focus segment)
1 parent a709235 commit 3b58f37

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/datasource/graphene/frontend.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,12 +2767,13 @@ class MulticutSegmentsTool extends LayerTool<SegmentationUserLayer> {
27672767
const priorBaseSegmentHighlighting =
27682768
displayState.baseSegmentHighlighting.value;
27692769
const priorHighlightColor = displayState.highlightColor.value;
2770-
2770+
const priorHideSegmentZero = displayState.hideSegmentZero.value;
27712771
activation.bindInputEventMap(MULTICUT_SEGMENTS_INPUT_EVENT_MAP);
27722772
activation.registerDisposer(() => {
27732773
resetMulticutDisplay();
27742774
displayState.baseSegmentHighlighting.value = priorBaseSegmentHighlighting;
27752775
displayState.highlightColor.value = priorHighlightColor;
2776+
displayState.hideSegmentZero.value = priorHideSegmentZero;
27762777
});
27772778
const resetMulticutDisplay = () => {
27782779
resetTemporaryVisibleSegmentsState(segmentationGroupState);
@@ -2781,6 +2782,23 @@ class MulticutSegmentsTool extends LayerTool<SegmentationUserLayer> {
27812782
displayState.tempSegmentDefaultColor2d.value = undefined;
27822783
displayState.highlightColor.value = undefined;
27832784
};
2785+
const { segmentSelectionState } = layer.displayState;
2786+
const updateHighlightColor = () => {
2787+
const focusSegment = multicutState.focusSegment.value;
2788+
if (focusSegment === undefined) {
2789+
displayState.highlightColor.value = undefined;
2790+
return;
2791+
}
2792+
const { value } = segmentSelectionState;
2793+
if (value === multicutState.focusSegment.value) {
2794+
displayState.highlightColor.value = multicutState.blueGroup.value
2795+
? BLUE_COLOR_HIGHTLIGHT
2796+
: RED_COLOR_HIGHLIGHT;
2797+
} else {
2798+
// set hightlight to off color for all other segments to ignore them
2799+
displayState.highlightColor.value = MULTICUT_OFF_COLOR;
2800+
}
2801+
};
27842802
const updateMulticutDisplay = () => {
27852803
resetMulticutDisplay();
27862804
activeGroupIndicator.classList.toggle(
@@ -2790,9 +2808,8 @@ class MulticutSegmentsTool extends LayerTool<SegmentationUserLayer> {
27902808
const focusSegment = multicutState.focusSegment.value;
27912809
if (focusSegment === undefined) return;
27922810
displayState.baseSegmentHighlighting.value = true;
2793-
displayState.highlightColor.value = multicutState.blueGroup.value
2794-
? BLUE_COLOR_HIGHTLIGHT
2795-
: RED_COLOR_HIGHLIGHT;
2811+
displayState.hideSegmentZero.value = false;
2812+
updateHighlightColor();
27962813
segmentsState.useTemporaryVisibleSegments.value = true;
27972814
segmentsState.useTemporarySegmentEquivalences.value = true;
27982815
// add focus segment and red/blue segments
@@ -2833,6 +2850,11 @@ class MulticutSegmentsTool extends LayerTool<SegmentationUserLayer> {
28332850
displayState.useTempSegmentStatedColors2d.value = true;
28342851
};
28352852
updateMulticutDisplay();
2853+
activation.registerDisposer(
2854+
layer.displayState.segmentSelectionState.changed.add(
2855+
updateHighlightColor,
2856+
),
2857+
);
28362858
activation.registerDisposer(
28372859
multicutState.changed.add(updateMulticutDisplay),
28382860
);

0 commit comments

Comments
 (0)