Skip to content
Draft
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/datasource/catmaid/spatial_skeleton_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,9 @@ function applyDeleteNodeToCache(
if (remainingSegmentNodes.length === 0) {
removeVisibleSegment(layer, node.segmentId, { deselect: true });
}
layer
.getSpatiallyIndexedSkeletonLayer()
?.removeRetainedOverlaySegmentIfEmpty(node.segmentId);
layer.markSpatialSkeletonNodeDataChanged({
invalidateFullSkeletonCache: false,
});
Expand Down
11 changes: 7 additions & 4 deletions src/layer/segmentation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ export class SegmentationUserLayer extends Base {
readonly spatialSkeletonState = this.registerDisposer(
new SpatialSkeletonState(),
);
private _currentSpatialSkeletonSource:
SpatiallyIndexedSkeletonSource | undefined = undefined;
readonly selectedSpatialSkeletonNodeId = new WatchableValue<
number | undefined
>(undefined);
Expand Down Expand Up @@ -1563,12 +1565,13 @@ export class SegmentationUserLayer extends Base {
break;
}
}
if (!hasSpatialSkeletonLayer) {
const newSource = this.getSpatialSkeletonCommandHistorySource();
const sourceChanged = newSource !== this._currentSpatialSkeletonSource;
this._currentSpatialSkeletonSource = newSource;
if (!hasSpatialSkeletonLayer || sourceChanged) {
this.spatialSkeletonState.clearInspectedSkeletonCache();
}
this.spatialSkeletonState.updateCommandHistorySource(
this.getSpatialSkeletonCommandHistorySource(),
);
this.spatialSkeletonState.updateCommandHistorySource(newSource);
}

private getSpatialSkeletonCommandHistorySource() {
Expand Down
11 changes: 11 additions & 0 deletions src/skeleton/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2222,6 +2222,17 @@ export class SpatiallyIndexedSkeletonLayer
return true;
}

removeRetainedOverlaySegmentIfEmpty(segmentId: number) {
const nodes = this.inspectionState?.getCachedSegmentNodes(segmentId);
if (nodes === undefined || nodes.length > 0) return;
const next = this.retainedOverlaySegmentIds.filter(
(id) => id !== segmentId,
);
if (next.length === this.retainedOverlaySegmentIds.length) return;
this.retainedOverlaySegmentIds = next;
this.redrawNeeded.dispatch();
}

suppressBrowseSegment(segmentId: number) {
const normalizedSegmentId = Math.round(Number(segmentId));
if (
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/segment_overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function buildSpatiallyIndexedSkeletonOverlayGeometry(
};
}

export const DEFAULT_MAX_RETAINED_OVERLAY_SEGMENTS = 4;
export const DEFAULT_MAX_RETAINED_OVERLAY_SEGMENTS = 16;

function normalizeSegmentId(segmentId: number) {
const normalizedSegmentId = Math.round(Number(segmentId));
Expand Down
Loading