Skip to content
Open
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
14 changes: 6 additions & 8 deletions src/datasource/catmaid/spatial_skeleton_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,18 @@ import {
addSegmentToVisibleSets,
removeSegmentFromVisibleSets,
} from "#src/segmentation_display_state/base.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type {
SpatiallyIndexedSkeletonNode,
SpatialSkeletonSourceState,
SpatialSkeletonVector,
} from "#src/skeleton/api.js";
import type { SpatialSkeletonEditCommandFactory } from "#src/skeleton/command_factories.js";
import type {
SpatialSkeletonCommand,
SpatialSkeletonCommandContext,
} from "#src/skeleton/command_history.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
type SpatialSkeletonCommand,
type SpatialSkeletonCommandContext,
} from "#src/skeleton/command_protocol.js";
import type { SpatiallyIndexedSkeletonLayer } from "#src/skeleton/frontend.js";
import {
findSpatiallyIndexedSkeletonNode,
Expand Down
2 changes: 1 addition & 1 deletion src/layer/segmentation/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { describe, expect, it, vi } from "vitest";

import type { RenderLayerTransform } from "#src/render_coordinate_transform.js";
import { SpatialSkeletonActions } from "#src/skeleton/actions.js";
import { SpatialSkeletonActions } from "#src/skeleton/command_protocol.js";
import { WatchableValue } from "#src/trackable_value.js";

if (!("WebGL2RenderingContext" in globalThis)) {
Expand Down
28 changes: 14 additions & 14 deletions src/layer/segmentation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,26 @@ import type {
import { SegmentationGraphSourceTab } from "#src/segmentation_graph/source.js";
import { SharedDisjointUint64Sets } from "#src/shared_disjoint_sets.js";
import { SharedWatchableValue } from "#src/shared_watchable_value.js";
import type {
SpatiallyIndexedSkeletonNode,
SpatialSkeletonSourceState,
} from "#src/skeleton/api.js";
import {
DEFAULT_SPATIAL_SKELETON_EDIT_ACTIONS,
getSpatialSkeletonActionSupportLabel,
isSpatialSkeletonEditAction,
SpatialSkeletonActions,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type {
SpatiallyIndexedSkeletonNode,
SpatialSkeletonSourceState,
} from "#src/skeleton/api.js";
} from "#src/skeleton/command_protocol.js";
import {
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonNodeConfidenceUpdate,
executeSpatialSkeletonNodeDescriptionUpdate,
executeSpatialSkeletonNodeRadiusUpdate,
executeSpatialSkeletonReroot,
executeSpatialSkeletonNodeTrueEndUpdate,
showSpatialSkeletonActionError,
} from "#src/skeleton/commands.js";
import {
PerspectiveViewSkeletonLayer,
SkeletonLayer,
Expand All @@ -129,15 +138,6 @@ import {
SpatialSkeletonDisplayNodeType,
SpatialSkeletonNodeFilterType,
} from "#src/skeleton/node_types.js";
import {
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonNodeConfidenceUpdate,
executeSpatialSkeletonNodeDescriptionUpdate,
executeSpatialSkeletonNodeRadiusUpdate,
executeSpatialSkeletonReroot,
executeSpatialSkeletonNodeTrueEndUpdate,
showSpatialSkeletonActionError,
} from "#src/skeleton/spatial_skeleton_commands.js";
import {
editableSpatiallyIndexedSkeletonSourceSupportsAction,
getEditableSpatiallyIndexedSkeletonSource,
Expand Down
4 changes: 2 additions & 2 deletions src/skeleton/command_factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import type { SegmentationUserLayer } from "#src/layer/segmentation/index.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonCommand,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type { SpatialSkeletonCommand } from "#src/skeleton/command_history.js";
} from "#src/skeleton/command_protocol.js";

export type SpatialSkeletonCommandPayload = object;

Expand Down
6 changes: 2 additions & 4 deletions src/skeleton/command_history.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

import { describe, expect, it } from "vitest";

import {
SpatialSkeletonCommandHistory,
type SpatialSkeletonCommand,
} from "#src/skeleton/command_history.js";
import { SpatialSkeletonCommandHistory } from "#src/skeleton/command_history.js";
import { type SpatialSkeletonCommand } from "#src/skeleton/command_protocol.js";

function deferred() {
let resolve: (() => void) | undefined;
Expand Down
12 changes: 1 addition & 11 deletions src/skeleton/command_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@
* limitations under the License.
*/

import type { SpatialSkeletonCommand } from "#src/skeleton/command_protocol.js";
import { WatchableValue } from "#src/trackable_value.js";
import { RefCounted } from "#src/util/disposable.js";

export const SPATIAL_SKELETON_COMMAND_HISTORY_MAX_ENTRIES = 100;

export interface SpatialSkeletonCommandContext {
readonly mappings: SpatialSkeletonCommandMappings;
}

export interface SpatialSkeletonCommand {
readonly label: string;
execute(context: SpatialSkeletonCommandContext): Promise<void>;
undo(context: SpatialSkeletonCommandContext): Promise<void>;
redo?(context: SpatialSkeletonCommandContext): Promise<void>;
}

interface SpatialSkeletonCommandMappingSnapshot {
nodeIdMappings: Array<[number, number]>;
segmentIdMappings: Array<[number, number]>;
Expand Down
26 changes: 26 additions & 0 deletions src/skeleton/actions.ts → src/skeleton/command_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,29 @@ export function getSpatialSkeletonActionSupportLabel(
return "skeleton splitting";
}
}

export interface SpatialSkeletonCommandContext {
readonly mappings: {
resolveNodeId(nodeId: number | undefined): number | undefined;
resolveSegmentId(segmentId: number | undefined): number | undefined;
getStableNodeId(nodeId: number | undefined): number | undefined;
getStableSegmentId(segmentId: number | undefined): number | undefined;
getStableOrCurrentNodeId(nodeId: number | undefined): number | undefined;
getStableOrCurrentSegmentId(segmentId: number | undefined): number | undefined;
remapNodeId(
originalNodeId: number | undefined,
currentNodeId: number,
): boolean;
remapSegmentId(
originalSegmentId: number | undefined,
currentSegmentId: number,
): boolean;
};
}

export interface SpatialSkeletonCommand {
readonly label: string;
execute(context: SpatialSkeletonCommandContext): Promise<void>;
undo(context: SpatialSkeletonCommandContext): Promise<void>;
redo?(context: SpatialSkeletonCommandContext): Promise<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { makeCatmaidNodeSourceState } from "#src/datasource/catmaid/api.js";
import { buildCatmaidNeighborhoodEditContext } from "#src/datasource/catmaid/edit_state.js";
import { CatmaidSpatialSkeletonEditCommands } from "#src/datasource/catmaid/spatial_skeleton_commands.js";
import { SpatialSkeletonActions } from "#src/skeleton/actions.js";
import type { SpatiallyIndexedSkeletonNode } from "#src/skeleton/api.js";
import { SpatialSkeletonCommandHistory } from "#src/skeleton/command_history.js";
import {
findSpatiallyIndexedSkeletonNode,
getSpatiallyIndexedSkeletonDirectChildren,
getSpatiallyIndexedSkeletonNodeParent,
} from "#src/skeleton/node_traversal.js";
import { SpatialSkeletonActions } from "#src/skeleton/command_protocol.js";
import {
executeSpatialSkeletonAddNode,
executeSpatialSkeletonDeleteNode,
Expand All @@ -41,7 +36,12 @@ import {
executeSpatialSkeletonSplit,
redoSpatialSkeletonCommand,
undoSpatialSkeletonCommand,
} from "#src/skeleton/spatial_skeleton_commands.js";
} from "#src/skeleton/commands.js";
import {
findSpatiallyIndexedSkeletonNode,
getSpatiallyIndexedSkeletonDirectChildren,
getSpatiallyIndexedSkeletonNodeParent,
} from "#src/skeleton/node_traversal.js";
import { SpatialSkeletonState } from "#src/skeleton/spatial_skeleton_manager.js";
import { StatusMessage } from "#src/status.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
* limitations under the License.
*/

import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type {
EditableSpatiallyIndexedSkeletonSource,
SpatiallyIndexedSkeletonNode,
Expand All @@ -26,7 +22,11 @@ import type {
SpatialSkeletonCommandPayload,
SpatialSkeletonEditCommandFactory,
} from "#src/skeleton/command_factories.js";
import type { SpatialSkeletonCommand } from "#src/skeleton/command_history.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
type SpatialSkeletonCommand,
} from "#src/skeleton/command_protocol.js";
import { getSpatialSkeletonActionErrorMessage } from "#src/skeleton/edit_errors.js";
import {
getEditableSpatiallyIndexedSkeletonSource,
Expand Down Expand Up @@ -69,7 +69,7 @@ function executeCommand(
return layer.spatialSkeletonState.commandHistory.execute(command);
}

function executeCommandWithPendingMessage<T>(
async function executeCommandWithPendingMessage<T>(
promise: Promise<T>,
message: string,
) {
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/spatial_skeleton_manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { describe, expect, it, vi } from "vitest";

import { SpatialSkeletonActions } from "#src/skeleton/actions.js";
import { SpatialSkeletonActions } from "#src/skeleton/command_protocol.js";
import {
buildSpatiallyIndexedSkeletonNavigationGraph,
getFlatListNodeIds,
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/spatial_skeleton_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import type { SpatialSkeletonAction } from "#src/skeleton/actions.js";
import type {
EditableSpatiallyIndexedSkeletonSource,
SpatialSkeletonConfidenceConfiguration,
Expand All @@ -29,6 +28,7 @@ import {
SPATIAL_SKELETON_EDIT_COMMAND_METADATA,
} from "#src/skeleton/command_factories.js";
import { SpatialSkeletonCommandHistory } from "#src/skeleton/command_history.js";
import type { SpatialSkeletonAction } from "#src/skeleton/command_protocol.js";
import type { SpatiallyIndexedSkeletonLayer } from "#src/skeleton/frontend.js";
import { WatchableValue } from "#src/trackable_value.js";
import { RefCounted } from "#src/util/disposable.js";
Expand Down
8 changes: 4 additions & 4 deletions src/ui/skeleton_edit_tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import { afterEach, describe, expect, it, vi } from "vitest";

import { makeCatmaidNodeSourceState } from "#src/datasource/catmaid/api.js";
import { CatmaidSpatialSkeletonEditCommands } from "#src/datasource/catmaid/spatial_skeleton_commands.js";
import type { SpatiallyIndexedSkeletonNode } from "#src/skeleton/api.js";
import { SpatialSkeletonCommandHistory } from "#src/skeleton/command_history.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type { SpatiallyIndexedSkeletonNode } from "#src/skeleton/api.js";
import { SpatialSkeletonCommandHistory } from "#src/skeleton/command_history.js";
} from "#src/skeleton/command_protocol.js";
import {
executeSpatialSkeletonAddNode,
executeSpatialSkeletonMerge,
} from "#src/skeleton/spatial_skeleton_commands.js";
} from "#src/skeleton/commands.js";
import { StatusMessage } from "#src/status.js";

if (!("WebGL2RenderingContext" in globalThis)) {
Expand Down
18 changes: 9 additions & 9 deletions src/ui/skeleton_edit_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ import { PerspectivePanel } from "#src/perspective_view/panel.js";
import { getChunkPositionFromCombinedGlobalLocalPositions } from "#src/render_coordinate_transform.js";
import { RenderedDataPanel } from "#src/rendered_data_panel.js";
import { getVisibleSegments } from "#src/segmentation_display_state/base.js";
import { SpatialSkeletonActions } from "#src/skeleton/actions.js";
import type {
SpatialSkeletonSourceState,
SpatialSkeletonVector,
} from "#src/skeleton/api.js";
import { SpatialSkeletonActions } from "#src/skeleton/command_protocol.js";
import {
executeSpatialSkeletonAddNode,
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonMerge,
executeSpatialSkeletonMoveNode,
executeSpatialSkeletonSplit,
showSpatialSkeletonActionError,
} from "#src/skeleton/commands.js";
import {
type SpatiallyIndexedSkeletonLayer,
setSpatialSkeletonModesToLinesAndPoints,
Expand All @@ -38,14 +46,6 @@ import {
PerspectiveViewSpatiallyIndexedSkeletonLayer,
SliceViewPanelSpatiallyIndexedSkeletonLayer,
} from "#src/skeleton/frontend.js";
import {
executeSpatialSkeletonAddNode,
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonMerge,
executeSpatialSkeletonMoveNode,
executeSpatialSkeletonSplit,
showSpatialSkeletonActionError,
} from "#src/skeleton/spatial_skeleton_commands.js";
import { StatusMessage } from "#src/status.js";
import type { SpatialSkeletonToolPointInfo } from "#src/ui/skeleton_edit_tool_messages.js";
import {
Expand Down
18 changes: 9 additions & 9 deletions src/ui/skeleton_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ import {
getVisibleSegments,
} from "#src/segmentation_display_state/base.js";
import { getBaseObjectColor } from "#src/segmentation_display_state/frontend.js";
import type { SpatiallyIndexedSkeletonNode } from "#src/skeleton/api.js";
import {
SpatialSkeletonActions,
type SpatialSkeletonAction,
} from "#src/skeleton/actions.js";
import type { SpatiallyIndexedSkeletonNode } from "#src/skeleton/api.js";
} from "#src/skeleton/command_protocol.js";
import {
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonNodeTrueEndUpdate,
redoSpatialSkeletonCommand,
showSpatialSkeletonActionError,
undoSpatialSkeletonCommand,
} from "#src/skeleton/commands.js";
import {
buildSpatiallyIndexedSkeletonNavigationGraph,
getBranchEnd as getBranchEndFromGraph,
Expand All @@ -60,13 +67,6 @@ import {
SpatialSkeletonDisplayNodeType,
SpatialSkeletonNodeFilterType,
} from "#src/skeleton/node_types.js";
import {
executeSpatialSkeletonDeleteNode,
executeSpatialSkeletonNodeTrueEndUpdate,
redoSpatialSkeletonCommand,
showSpatialSkeletonActionError,
undoSpatialSkeletonCommand,
} from "#src/skeleton/spatial_skeleton_commands.js";
import { StatusMessage } from "#src/status.js";
import { observeWatchable, registerNested } from "#src/trackable_value.js";
import { SPATIAL_SKELETON_EDIT_MODE_TOOL_ID } from "#src/ui/skeleton_edit_tools.js";
Expand Down