Skip to content
Open
Changes from all 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
23 changes: 17 additions & 6 deletions src/datasource/graphene/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ class GraphConnection extends SegmentationGraphSourceConnection {
annotationLayerStates.push(redGroup, blueGroup);

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

this.mergeAnnotationState = makeColoredAnnotationState(
Expand Down Expand Up @@ -2394,18 +2394,29 @@ class MergeSegmentsTool extends LayerTool<SegmentationUserLayer> {
return;
const {
state: { mergeState },
mergeAnnotationState,
} = graphConnection;
if (mergeState === undefined) return;
const { merges, autoSubmit } = mergeState;

const lineTool = new MergeSegmentsPlaceLineTool(
this.layer,
graphConnection.mergeAnnotationState,
mergeAnnotationState,
);
// Switch selected layer to the layer associated with the tool
// to enable to place line tool. Swap back when deactivating.
const { selectedLayer, selectionState } = this.layer.manager.root;
const previousSelectedLayer = selectedLayer.layer;
const previousSelectedLayerVisible = selectedLayer.visible;
const previousTool = tool.value;
selectedLayer.layer = this.layer.managedLayer;
selectedLayer.visible = true;
tool.value = lineTool;
const prevousSelectionState = selectionState.toJSON();
activation.registerDisposer(() => {
tool.value = undefined;
selectedLayer.layer = previousSelectedLayer;
selectedLayer.visible = previousSelectedLayerVisible;
tool.value = previousTool;
selectionState.restoreState(prevousSelectionState);
});
const { merges, autoSubmit } = mergeState;
const { body, header } =
makeToolActivationStatusMessageWithHeader(activation);
header.textContent = "Merge segments";
Expand Down
Loading