Skip to content

Commit f0c6541

Browse files
committed
fix(datasource/graphene) swap selected layer when activating merge tool to allow place line tool to function. Swap back when tool is unloaded. Also swapping back to the merge tool layer's legacy tool
1 parent bac1d63 commit f0c6541

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/datasource/graphene/frontend.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ class GraphConnection extends SegmentationGraphSourceConnection {
13631363
annotationLayerStates.push(redGroup, blueGroup);
13641364

13651365
if (layer.tool.value instanceof MergeSegmentsPlaceLineTool) {
1366-
layer.tool.value = undefined;
1366+
layer.tool.value = undefined; // unset the line tool if it is active when page is loaded
13671367
}
13681368

13691369
this.mergeAnnotationState = makeColoredAnnotationState(
@@ -3044,15 +3044,25 @@ class MergeSegmentsTool extends LayerTool<SegmentationUserLayer> {
30443044
if (checkSegmentationOld(timestamp, activation)) {
30453045
return;
30463046
}
3047-
const { merges, autoSubmit } = mergeState;
30483047
const lineTool = new MergeSegmentsPlaceLineTool(
30493048
this.layer,
30503049
mergeAnnotationState,
30513050
);
3051+
// Switch selected layer to the layer associated with the tool
3052+
// to enable to place line tool. Swap back when deactivating.
3053+
const { selectedLayer } = this.layer.manager.root;
3054+
const previousSelectedLayer = selectedLayer.layer;
3055+
const previousSelectedLayerVisible = selectedLayer.visible;
3056+
const previousTool = tool.value;
3057+
selectedLayer.layer = this.layer.managedLayer;
3058+
selectedLayer.visible = true;
30523059
tool.value = lineTool;
30533060
activation.registerDisposer(() => {
3054-
tool.value = undefined;
3061+
selectedLayer.layer = previousSelectedLayer;
3062+
selectedLayer.visible = previousSelectedLayerVisible;
3063+
tool.value = previousTool;
30553064
});
3065+
const { merges, autoSubmit } = mergeState;
30563066
const { body, header } =
30573067
makeToolActivationStatusMessageWithHeader(activation);
30583068
header.textContent = "Merge segments";

0 commit comments

Comments
 (0)