copper3d 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/ai-index/guides/mcp-server.md +16 -4
- package/ai-index/guides/nrrd-tools.md +103 -3
- package/ai-index/guides/segmentation-module.md +65 -2
- package/ai-index/manifest.json +6 -6
- package/ai-index/symbols.json +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +20 -0
- package/dist/Utils/segmentation/DrawToolCore.js +51 -7
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +17 -1
- package/dist/Utils/segmentation/NrrdTools.js +24 -1
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/UndoManager.d.ts +18 -0
- package/dist/Utils/segmentation/core/UndoManager.js +19 -3
- package/dist/Utils/segmentation/core/UndoManager.js.map +1 -1
- package/dist/Utils/segmentation/core/index.d.ts +3 -3
- package/dist/Utils/segmentation/core/index.js +1 -1
- package/dist/Utils/segmentation/core/index.js.map +1 -1
- package/dist/Utils/segmentation/core/types.d.ts +12 -2
- package/dist/bundle.esm.mjs +96 -13
- package/dist/bundle.umd.js +96 -13
- package/dist/index.d.ts +3 -3
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +20 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +17 -1
- package/dist/types/Utils/segmentation/core/UndoManager.d.ts +18 -0
- package/dist/types/Utils/segmentation/core/index.d.ts +3 -3
- package/dist/types/Utils/segmentation/core/types.d.ts +12 -2
- package/dist/types/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/bundle.umd.js
CHANGED
|
@@ -11240,6 +11240,11 @@
|
|
|
11240
11240
|
* - maxStackSize: 50 entries per layer.
|
|
11241
11241
|
* - Undo/redo operations also trigger backend sync via getMask callback.
|
|
11242
11242
|
*/
|
|
11243
|
+
/** The layer an entry belongs to. */
|
|
11244
|
+
function entryLayer(entry) {
|
|
11245
|
+
var _a;
|
|
11246
|
+
return Array.isArray(entry) ? (_a = entry[0]) === null || _a === void 0 ? void 0 : _a.layerId : entry.layerId;
|
|
11247
|
+
}
|
|
11243
11248
|
const MAX_STACK_SIZE = 50;
|
|
11244
11249
|
class UndoManager {
|
|
11245
11250
|
constructor() {
|
|
@@ -11312,13 +11317,24 @@
|
|
|
11312
11317
|
* @returns The delta(s) that were undone, or undefined if nothing to undo.
|
|
11313
11318
|
*/
|
|
11314
11319
|
undo() {
|
|
11315
|
-
|
|
11316
|
-
|
|
11320
|
+
return this.undoOn(this.activeLayer);
|
|
11321
|
+
}
|
|
11322
|
+
/**
|
|
11323
|
+
* Undo the last operation on `layerId`, whichever layer is active. The entry moves to that
|
|
11324
|
+
* layer's redo stack, exactly as `undo` does for the active one.
|
|
11325
|
+
*/
|
|
11326
|
+
undoOn(layerId) {
|
|
11327
|
+
const entry = this.stackFor(this.undoStacks, layerId).pop();
|
|
11317
11328
|
if (entry) {
|
|
11318
|
-
this.stackFor(this.redoStacks,
|
|
11329
|
+
this.stackFor(this.redoStacks, layerId).push(entry);
|
|
11319
11330
|
}
|
|
11320
11331
|
return entry;
|
|
11321
11332
|
}
|
|
11333
|
+
/** The entry an undo on `layerId` would take next, left in place. */
|
|
11334
|
+
peek(layerId) {
|
|
11335
|
+
const stack = this.undoStacks.get(layerId);
|
|
11336
|
+
return stack === null || stack === void 0 ? void 0 : stack[stack.length - 1];
|
|
11337
|
+
}
|
|
11322
11338
|
/**
|
|
11323
11339
|
* Redo the last undone operation on the active layer.
|
|
11324
11340
|
* @returns The delta(s) that were redone, or undefined if nothing to redo.
|
|
@@ -16786,6 +16802,29 @@
|
|
|
16786
16802
|
*
|
|
16787
16803
|
* Created by NrrdTools which passes in a shared CanvasState.
|
|
16788
16804
|
*/
|
|
16805
|
+
/**
|
|
16806
|
+
* The channels a slice delta changed: every label that differs between the slice before and
|
|
16807
|
+
* after, background (0) excluded, in ascending order.
|
|
16808
|
+
*
|
|
16809
|
+
* In a label volume a voxel's value is its channel, so this is exactly the set of channels an
|
|
16810
|
+
* undo or redo of the delta touches — which is what the host needs to know, not the channel
|
|
16811
|
+
* that happens to be active.
|
|
16812
|
+
*/
|
|
16813
|
+
function changedChannels(oldSlice, newSlice) {
|
|
16814
|
+
const seen = new Set();
|
|
16815
|
+
const n = Math.min(oldSlice.length, newSlice.length);
|
|
16816
|
+
for (let i = 0; i < n; i++) {
|
|
16817
|
+
const before = oldSlice[i];
|
|
16818
|
+
const after = newSlice[i];
|
|
16819
|
+
if (before === after)
|
|
16820
|
+
continue;
|
|
16821
|
+
if (before !== 0)
|
|
16822
|
+
seen.add(before);
|
|
16823
|
+
if (after !== 0)
|
|
16824
|
+
seen.add(after);
|
|
16825
|
+
}
|
|
16826
|
+
return [...seen].sort((a, b) => a - b);
|
|
16827
|
+
}
|
|
16789
16828
|
class DrawToolCore {
|
|
16790
16829
|
setAnnotationSuspended(suspended) {
|
|
16791
16830
|
this.annotationSuspended = suspended;
|
|
@@ -17089,15 +17128,18 @@
|
|
|
17089
17128
|
this.eventRouter.setKeydownHandler((ev) => {
|
|
17090
17129
|
if (this.state.configKeyBoard)
|
|
17091
17130
|
return;
|
|
17092
|
-
// Handle undo (Ctrl+Z)
|
|
17131
|
+
// Handle undo (Ctrl+Z). Cancelled so the browser does not also run its own page-level
|
|
17132
|
+
// undo, which reverts the last text typed anywhere on the page and moves focus there.
|
|
17093
17133
|
if ((ev.ctrlKey || ev.metaKey) && ev.key === this.state.keyboardSettings.undo) {
|
|
17134
|
+
ev.preventDefault();
|
|
17094
17135
|
undoFlag = true;
|
|
17095
17136
|
this.undoLastPainting();
|
|
17096
17137
|
}
|
|
17097
|
-
// Handle redo (Ctrl+<redo key> or Ctrl+Shift+<undo key>)
|
|
17138
|
+
// Handle redo (Ctrl+<redo key> or Ctrl+Shift+<undo key>), cancelled for the same reason
|
|
17098
17139
|
const redoKey = this.state.keyboardSettings.redo;
|
|
17099
17140
|
const undoKeyUpper = this.state.keyboardSettings.undo.toUpperCase();
|
|
17100
17141
|
if ((ev.ctrlKey || ev.metaKey) && (ev.key === redoKey || (ev.shiftKey && ev.key === undoKeyUpper))) {
|
|
17142
|
+
ev.preventDefault();
|
|
17101
17143
|
this.redoLastPainting();
|
|
17102
17144
|
}
|
|
17103
17145
|
// Handle mouse wheel mode toggle (Ctrl+1 = Scroll:Zoom, Ctrl+2 = Scroll:Slice)
|
|
@@ -17593,8 +17635,26 @@
|
|
|
17593
17635
|
*/
|
|
17594
17636
|
undoLastPainting() {
|
|
17595
17637
|
const entry = this.undoManager.undo();
|
|
17596
|
-
if (
|
|
17597
|
-
|
|
17638
|
+
if (entry)
|
|
17639
|
+
this.applyUndo(entry);
|
|
17640
|
+
}
|
|
17641
|
+
/**
|
|
17642
|
+
* Undo `entry` on its own layer if it is still that layer's latest operation, whichever
|
|
17643
|
+
* layer is active; otherwise change nothing.
|
|
17644
|
+
*
|
|
17645
|
+
* @returns Whether it was undone. False when a later operation is stacked on top of it, or
|
|
17646
|
+
* when it has already been undone.
|
|
17647
|
+
*/
|
|
17648
|
+
undoEntry(entry) {
|
|
17649
|
+
const layerId = entryLayer(entry);
|
|
17650
|
+
if (layerId === undefined || this.undoManager.peek(layerId) !== entry)
|
|
17651
|
+
return false;
|
|
17652
|
+
this.undoManager.undoOn(layerId);
|
|
17653
|
+
this.applyUndo(entry);
|
|
17654
|
+
return true;
|
|
17655
|
+
}
|
|
17656
|
+
/** Write an entry's "before" state back into its volume, repaint, and report the change. */
|
|
17657
|
+
applyUndo(entry) {
|
|
17598
17658
|
this.state.protectedData.isDrawing = true;
|
|
17599
17659
|
if (!Array.isArray(entry)) {
|
|
17600
17660
|
// VolumeSnapshot: restore the pre-replacement volume in one step.
|
|
@@ -17616,7 +17676,7 @@
|
|
|
17616
17676
|
if (!this.state.nrrd_states.flags.loadingMaskData) {
|
|
17617
17677
|
const { data: sliceData, width, height } = this.renderer.getVolumeForLayer(delta.layerId)
|
|
17618
17678
|
.getSliceUint8(delta.sliceIndex, delta.axis);
|
|
17619
|
-
this.state.annotationCallbacks.onMaskChanged(sliceData, delta.layerId, this.state.gui_states.layerChannel.activeChannel || 1, delta.sliceIndex, delta.axis, width, height, false);
|
|
17679
|
+
this.state.annotationCallbacks.onMaskChanged(sliceData, delta.layerId, this.state.gui_states.layerChannel.activeChannel || 1, delta.sliceIndex, delta.axis, width, height, false, { channels: changedChannels(delta.oldSlice, delta.newSlice) });
|
|
17620
17680
|
}
|
|
17621
17681
|
}
|
|
17622
17682
|
this.setIsDrawFalse(1000);
|
|
@@ -17649,7 +17709,7 @@
|
|
|
17649
17709
|
if (!this.state.nrrd_states.flags.loadingMaskData) {
|
|
17650
17710
|
const { data: sliceData, width, height } = this.renderer.getVolumeForLayer(delta.layerId)
|
|
17651
17711
|
.getSliceUint8(delta.sliceIndex, delta.axis);
|
|
17652
|
-
this.state.annotationCallbacks.onMaskChanged(sliceData, delta.layerId, this.state.gui_states.layerChannel.activeChannel || 1, delta.sliceIndex, delta.axis, width, height, false);
|
|
17712
|
+
this.state.annotationCallbacks.onMaskChanged(sliceData, delta.layerId, this.state.gui_states.layerChannel.activeChannel || 1, delta.sliceIndex, delta.axis, width, height, false, { channels: changedChannels(delta.oldSlice, delta.newSlice) });
|
|
17653
17713
|
}
|
|
17654
17714
|
}
|
|
17655
17715
|
this.setIsDrawFalse(1000);
|
|
@@ -19874,6 +19934,7 @@
|
|
|
19874
19934
|
*
|
|
19875
19935
|
* @param layerId Layer whose mask to edit.
|
|
19876
19936
|
* @param channel Label to erase, 1-255.
|
|
19937
|
+
* @returns The clear, for `undoChannelClear`; null when the channel held nothing.
|
|
19877
19938
|
* @throws {Error} If `layerId` names no layer. Deliberately NOT routed through
|
|
19878
19939
|
* `getVolumeForLayer`, which warns and falls back to the first layer — for a
|
|
19879
19940
|
* destructive call that would quietly erase a different layer's annotation.
|
|
@@ -19901,7 +19962,7 @@
|
|
|
19901
19962
|
});
|
|
19902
19963
|
}
|
|
19903
19964
|
if (deltas.length === 0)
|
|
19904
|
-
return; // nothing drawn on this channel
|
|
19965
|
+
return null; // nothing drawn on this channel
|
|
19905
19966
|
volume.clearChannel(channel);
|
|
19906
19967
|
for (const delta of deltas) {
|
|
19907
19968
|
delta.newSlice = volume.getSliceUint8(delta.sliceIndex, "z").data.slice();
|
|
@@ -19912,6 +19973,28 @@
|
|
|
19912
19973
|
this.state.annotationCallbacks.onMaskChanged(data, layerId, channel, delta.sliceIndex, "z", width, height, false);
|
|
19913
19974
|
}
|
|
19914
19975
|
this.reloadMasksFromVolume();
|
|
19976
|
+
return { layerId, channel, entry: deltas };
|
|
19977
|
+
}
|
|
19978
|
+
/**
|
|
19979
|
+
* Undo one `clearChannel`, on its own layer, whatever layer is active now.
|
|
19980
|
+
*
|
|
19981
|
+
* `undo()` acts on the active layer's latest operation, and by the time a caller offers to
|
|
19982
|
+
* reverse a clear the active layer may have changed. This names the clear instead, and
|
|
19983
|
+
* reverses it only while it is still the latest operation on its layer: a later edit there is
|
|
19984
|
+
* newer work, never undone in passing -- `undo()` steps back through it in order.
|
|
19985
|
+
*
|
|
19986
|
+
* Reported through `onMaskChanged` with the channels it restored, exactly as `undo()` reports.
|
|
19987
|
+
*
|
|
19988
|
+
* @returns Whether the clear was undone. False when a later operation is stacked on it, or
|
|
19989
|
+
* it has already been undone.
|
|
19990
|
+
*/
|
|
19991
|
+
undoChannelClear(clear) {
|
|
19992
|
+
if (!this.drawCore.undoEntry(clear.entry))
|
|
19993
|
+
return false;
|
|
19994
|
+
// `undo()` repaints only the slice on screen when it lies on the clear's axis; a clear
|
|
19995
|
+
// spans every slice of the label, so repaint them all, as the clear itself does.
|
|
19996
|
+
this.reloadMasksFromVolume();
|
|
19997
|
+
return true;
|
|
19915
19998
|
}
|
|
19916
19999
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
19917
20000
|
// 4. Public API — Keyboard & History
|
|
@@ -22117,15 +22200,15 @@
|
|
|
22117
22200
|
}
|
|
22118
22201
|
|
|
22119
22202
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
22120
|
-
// "v4.1.
|
|
22203
|
+
// "v4.1.4" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
|
|
22121
22204
|
// When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
|
|
22122
22205
|
// referencing it throws a ReferenceError — guard it so local loading still works.
|
|
22123
22206
|
let _revision = "unknown";
|
|
22124
22207
|
try {
|
|
22125
|
-
_revision = "v4.1.
|
|
22208
|
+
_revision = "v4.1.4";
|
|
22126
22209
|
}
|
|
22127
22210
|
catch (_a) {
|
|
22128
|
-
/* "v4.1.
|
|
22211
|
+
/* "v4.1.4" not injected (local source build) */
|
|
22129
22212
|
}
|
|
22130
22213
|
const REVISION = _revision;
|
|
22131
22214
|
// "186" is three's revision at build time, injected the same way.
|
package/dist/index.d.ts
CHANGED
|
@@ -56,9 +56,9 @@ import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadR
|
|
|
56
56
|
import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
|
|
57
57
|
import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
|
|
58
58
|
import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
|
|
59
|
-
import type { ToolMode, IAnnotationCallbacks, MaskRenderMode } from "./Utils/segmentation/core/types";
|
|
59
|
+
import type { ToolMode, IAnnotationCallbacks, IMaskHistoryChange, MaskRenderMode } from "./Utils/segmentation/core/types";
|
|
60
60
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
61
|
-
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
61
|
+
import type { LayerId, ChannelValue, ChannelClear } from "./Utils/segmentation/core/index";
|
|
62
62
|
import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
|
|
63
63
|
import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
|
|
64
64
|
import { OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels } from "./Utils/orientation";
|
|
@@ -66,5 +66,5 @@ import type { NrrdOrientationFields, OrientationErrorCode, OrientationTransform,
|
|
|
66
66
|
import "./css/style.css";
|
|
67
67
|
export declare const REVISION: string;
|
|
68
68
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, rasDimensions, DEFAULT_AXES, ensureAxisExtracted, prepareVolumeSlices, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels, };
|
|
69
|
-
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, MaskRenderMode, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation, };
|
|
69
|
+
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, IMaskHistoryChange, MaskRenderMode, LayerId, ChannelValue, ChannelClear, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation, };
|
|
70
70
|
export type { CameraViewPreset } from "./Controls/orbitFraming";
|
|
@@ -13,6 +13,7 @@ import { ImageStoreHelper } from "./tools/ImageStoreHelper";
|
|
|
13
13
|
import { SphereBrushTool } from "./tools/SphereBrushTool";
|
|
14
14
|
import { AiAssistTool } from "./tools/AiAssistTool";
|
|
15
15
|
import { UndoManager } from "./core";
|
|
16
|
+
import type { UndoEntry } from "./core";
|
|
16
17
|
/**
|
|
17
18
|
* DrawToolCore — Tool orchestration and event routing.
|
|
18
19
|
*
|
|
@@ -22,6 +23,15 @@ import { UndoManager } from "./core";
|
|
|
22
23
|
*
|
|
23
24
|
* Created by NrrdTools which passes in a shared CanvasState.
|
|
24
25
|
*/
|
|
26
|
+
/**
|
|
27
|
+
* The channels a slice delta changed: every label that differs between the slice before and
|
|
28
|
+
* after, background (0) excluded, in ascending order.
|
|
29
|
+
*
|
|
30
|
+
* In a label volume a voxel's value is its channel, so this is exactly the set of channels an
|
|
31
|
+
* undo or redo of the delta touches — which is what the host needs to know, not the channel
|
|
32
|
+
* that happens to be active.
|
|
33
|
+
*/
|
|
34
|
+
export declare function changedChannels(oldSlice: Uint8Array, newSlice: Uint8Array): number[];
|
|
25
35
|
export declare class DrawToolCore {
|
|
26
36
|
container: HTMLElement;
|
|
27
37
|
mainAreaContainer: HTMLDivElement;
|
|
@@ -179,6 +189,16 @@ export declare class DrawToolCore {
|
|
|
179
189
|
* Undo the last drawing operation on the active layer.
|
|
180
190
|
*/
|
|
181
191
|
undoLastPainting(): void;
|
|
192
|
+
/**
|
|
193
|
+
* Undo `entry` on its own layer if it is still that layer's latest operation, whichever
|
|
194
|
+
* layer is active; otherwise change nothing.
|
|
195
|
+
*
|
|
196
|
+
* @returns Whether it was undone. False when a later operation is stacked on top of it, or
|
|
197
|
+
* when it has already been undone.
|
|
198
|
+
*/
|
|
199
|
+
undoEntry(entry: UndoEntry): boolean;
|
|
200
|
+
/** Write an entry's "before" state back into its volume, repaint, and report the change. */
|
|
201
|
+
private applyUndo;
|
|
182
202
|
/**
|
|
183
203
|
* Redo the last undone operation on the active layer.
|
|
184
204
|
*/
|
|
@@ -2,6 +2,7 @@ import { nrrdSliceType, storeExportPaintImageType, loadingBarType } from "../../
|
|
|
2
2
|
import { GUI } from "dat.gui";
|
|
3
3
|
import { IMaskData, IDragOpts, IKeyBoardSettings, ToolMode, IGuiMeta, MaskRenderMode } from "./core/types";
|
|
4
4
|
import { DragOperator } from "./DragOperator";
|
|
5
|
+
import type { ChannelClear } from "./core/UndoManager";
|
|
5
6
|
import type { ChannelValue, RGBAColor, ChannelColorMap } from "./core";
|
|
6
7
|
import type { SphereType } from "./tools/SphereTool";
|
|
7
8
|
import type { AiPromptTool, AiPromptPayload, AiMaskResult } from "./tools/AiAssistTool";
|
|
@@ -129,12 +130,27 @@ export declare class NrrdTools {
|
|
|
129
130
|
*
|
|
130
131
|
* @param layerId Layer whose mask to edit.
|
|
131
132
|
* @param channel Label to erase, 1-255.
|
|
133
|
+
* @returns The clear, for `undoChannelClear`; null when the channel held nothing.
|
|
132
134
|
* @throws {Error} If `layerId` names no layer. Deliberately NOT routed through
|
|
133
135
|
* `getVolumeForLayer`, which warns and falls back to the first layer — for a
|
|
134
136
|
* destructive call that would quietly erase a different layer's annotation.
|
|
135
137
|
* @throws {RangeError} If `channel` is outside [1, 255] (from `MaskVolume`).
|
|
136
138
|
*/
|
|
137
|
-
clearChannel(layerId: string, channel: number):
|
|
139
|
+
clearChannel(layerId: string, channel: number): ChannelClear | null;
|
|
140
|
+
/**
|
|
141
|
+
* Undo one `clearChannel`, on its own layer, whatever layer is active now.
|
|
142
|
+
*
|
|
143
|
+
* `undo()` acts on the active layer's latest operation, and by the time a caller offers to
|
|
144
|
+
* reverse a clear the active layer may have changed. This names the clear instead, and
|
|
145
|
+
* reverses it only while it is still the latest operation on its layer: a later edit there is
|
|
146
|
+
* newer work, never undone in passing -- `undo()` steps back through it in order.
|
|
147
|
+
*
|
|
148
|
+
* Reported through `onMaskChanged` with the channels it restored, exactly as `undo()` reports.
|
|
149
|
+
*
|
|
150
|
+
* @returns Whether the clear was undone. False when a later operation is stacked on it, or
|
|
151
|
+
* it has already been undone.
|
|
152
|
+
*/
|
|
153
|
+
undoChannelClear(clear: ChannelClear): boolean;
|
|
138
154
|
undo(): void;
|
|
139
155
|
redo(): void;
|
|
140
156
|
enterKeyboardConfig(): void;
|
|
@@ -33,6 +33,17 @@ export interface VolumeSnapshot {
|
|
|
33
33
|
}
|
|
34
34
|
/** A slice-delta group or a whole-volume snapshot. `Array.isArray` discriminates. */
|
|
35
35
|
export type UndoEntry = MaskDelta[] | VolumeSnapshot;
|
|
36
|
+
/**
|
|
37
|
+
* One channel clear, as `NrrdTools.clearChannel` returns it, for `NrrdTools.undoChannelClear`.
|
|
38
|
+
* `entry` is the undo entry the clear pushed and is compared by identity.
|
|
39
|
+
*/
|
|
40
|
+
export interface ChannelClear {
|
|
41
|
+
readonly layerId: string;
|
|
42
|
+
readonly channel: number;
|
|
43
|
+
readonly entry: UndoEntry;
|
|
44
|
+
}
|
|
45
|
+
/** The layer an entry belongs to. */
|
|
46
|
+
export declare function entryLayer(entry: UndoEntry): string | undefined;
|
|
36
47
|
export declare class UndoManager {
|
|
37
48
|
private undoStacks;
|
|
38
49
|
private redoStacks;
|
|
@@ -67,6 +78,13 @@ export declare class UndoManager {
|
|
|
67
78
|
* @returns The delta(s) that were undone, or undefined if nothing to undo.
|
|
68
79
|
*/
|
|
69
80
|
undo(): UndoEntry | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Undo the last operation on `layerId`, whichever layer is active. The entry moves to that
|
|
83
|
+
* layer's redo stack, exactly as `undo` does for the active one.
|
|
84
|
+
*/
|
|
85
|
+
undoOn(layerId: string): UndoEntry | undefined;
|
|
86
|
+
/** The entry an undo on `layerId` would take next, left in place. */
|
|
87
|
+
peek(layerId: string): UndoEntry | undefined;
|
|
70
88
|
/**
|
|
71
89
|
* Redo the last undone operation on the active layer.
|
|
72
90
|
* @returns The delta(s) that were redone, or undefined if nothing to redo.
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
* const legacy = convertVolumeToIPaintImages(volume);
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
|
-
export type { Dimensions, RGBAColor, ChannelColorMap, SliceRenderOptions, LayerId, ChannelValue, ICommXYZ, ICommXY, ISkipSlicesDictType, ToolMode, IDragPrameters, IDrawingEvents, IContrastEvents, IPaintImages, IPaintImage, ILayerRenderTarget, IDownloadImageConfig, INewMaskData, IMaskData, IProtected, IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState, IGUIStates, IGuiMeta, IGuiParameterSettings, IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags, INrrdStates, IAnnotationCallbacks, IConvertObjType, ICursorPage, IDragOpts, IDrawOpts, IKeyBoardSettings, MaskRenderMode, } from './types';
|
|
70
|
+
export type { Dimensions, RGBAColor, ChannelColorMap, SliceRenderOptions, LayerId, ChannelValue, ICommXYZ, ICommXY, ISkipSlicesDictType, ToolMode, IDragPrameters, IDrawingEvents, IContrastEvents, IPaintImages, IPaintImage, ILayerRenderTarget, IDownloadImageConfig, INewMaskData, IMaskData, IProtected, IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState, IGUIStates, IGuiMeta, IGuiParameterSettings, IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags, INrrdStates, IAnnotationCallbacks, IMaskHistoryChange, IConvertObjType, ICursorPage, IDragOpts, IDrawOpts, IKeyBoardSettings, MaskRenderMode, } from './types';
|
|
71
71
|
export { RenderMode, MAX_ENGINE_CHANNEL, MASK_CHANNEL_COLORS, MASK_CHANNEL_CSS_COLORS, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, } from './types';
|
|
72
72
|
export { MaskVolume } from './MaskVolume';
|
|
73
|
-
export type { MaskDelta, UndoEntry } from './UndoManager';
|
|
74
|
-
export { UndoManager } from './UndoManager';
|
|
73
|
+
export type { MaskDelta, UndoEntry, ChannelClear } from './UndoManager';
|
|
74
|
+
export { UndoManager, entryLayer } from './UndoManager';
|
|
75
75
|
export type { ContourBBox, ContourPolygon } from './MarchingSquares';
|
|
76
76
|
export { extractLabelBoundarySegments, extractLabelContours, extractLabelOutline, extractLabelPolygons, findLabelsInSlice, } from './MarchingSquares';
|
|
@@ -459,8 +459,18 @@ export interface IInternalFlags {
|
|
|
459
459
|
export interface INrrdStates extends IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags {
|
|
460
460
|
}
|
|
461
461
|
/** Callbacks for external notification of annotation data changes */
|
|
462
|
+
/** What an undo or redo changed, passed with the slice it restored. */
|
|
463
|
+
export interface IMaskHistoryChange {
|
|
464
|
+
/** The channels whose voxels the undone or redone delta changed, ascending. */
|
|
465
|
+
channels: number[];
|
|
466
|
+
}
|
|
462
467
|
export interface IAnnotationCallbacks {
|
|
463
|
-
|
|
468
|
+
/**
|
|
469
|
+
* A slice of a layer changed. `channelId` is the active channel, which is the one a stroke
|
|
470
|
+
* paints. `history` is set only when the change was an undo or redo: it names the channels
|
|
471
|
+
* that change actually touched, which need not include the active one.
|
|
472
|
+
*/
|
|
473
|
+
onMaskChanged(sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag: boolean, history?: IMaskHistoryChange): void;
|
|
464
474
|
onSphereChanged(sphereOrigin: number[], sphereRadius: number): void;
|
|
465
475
|
onCalculatorPositionsChanged(tumour: ICommXYZ | null, skin: ICommXYZ | null, rib: ICommXYZ | null, nipple: ICommXYZ | null, axis: "x" | "y" | "z"): void;
|
|
466
476
|
onLayerVolumeCleared(layerId: string): void;
|
|
@@ -508,7 +518,7 @@ export interface IDragOpts {
|
|
|
508
518
|
getSliceNum?: (index: number, contrastNum: number) => void;
|
|
509
519
|
}
|
|
510
520
|
export interface IDrawOpts {
|
|
511
|
-
getMaskData?: (sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag?: boolean) => void;
|
|
521
|
+
getMaskData?: (sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag?: boolean, history?: IMaskHistoryChange) => void;
|
|
512
522
|
onClearLayerVolume?: (layerId: string) => void;
|
|
513
523
|
onLayerVolumeReplaced?: (layerId: string) => void;
|
|
514
524
|
getSphereData?: (sphereOrigin: number[], sphereRadius: number) => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -56,9 +56,9 @@ import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadR
|
|
|
56
56
|
import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
|
|
57
57
|
import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
|
|
58
58
|
import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
|
|
59
|
-
import type { ToolMode, IAnnotationCallbacks, MaskRenderMode } from "./Utils/segmentation/core/types";
|
|
59
|
+
import type { ToolMode, IAnnotationCallbacks, IMaskHistoryChange, MaskRenderMode } from "./Utils/segmentation/core/types";
|
|
60
60
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
61
|
-
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
61
|
+
import type { LayerId, ChannelValue, ChannelClear } from "./Utils/segmentation/core/index";
|
|
62
62
|
import { MAX_ENGINE_CHANNEL } from "./Utils/segmentation/core/index";
|
|
63
63
|
import type { AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult } from "./Utils/segmentation/tools/AiAssistTool";
|
|
64
64
|
import { OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels } from "./Utils/orientation";
|
|
@@ -66,5 +66,5 @@ import type { NrrdOrientationFields, OrientationErrorCode, OrientationTransform,
|
|
|
66
66
|
import "./css/style.css";
|
|
67
67
|
export declare const REVISION: string;
|
|
68
68
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, loadKiwrious, NrrdTools, registerNiftiMaskGrid, loading, Copper3dTrackballControls, Copper3dOrbitControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, MAX_ENGINE_CHANNEL, CHANNEL_COLORS, CHANNEL_HEX_COLORS, AI_MASK_CHANNEL_COLORS, AI_CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, SurfaceAnnotator, exposureExponent, DEFAULT_TARGET_GREY, disposeObject3D, disposeMaterial, collectFadeTargets, setFade, restoreFade, createSceneBudget, defaultBudgetBytes, disposeScene, removeSceneFromMap, fitDistance, fitView, isRotateEnabled, setRotateEnabled, isPanEnabled, setPanEnabled, isZoomEnabled, setZoomEnabled, beginGesture, isGestureActive, setCameraPose, addVolumeBoundingBox, VOLUME_BOUNDS_NAME, rasDimensions, DEFAULT_AXES, ensureAxisExtracted, prepareVolumeSlices, copperGltfLoader, setDracoDecoderPath, setKTX2TranscoderPath, easeInOutCubic, viewPointToPose, rotateAroundAxis, interpolateFlightPose, poseDistance, orbitStepPose, zoomPose, orbitSwingAngle, installFastSliceRepaint, OrientationError, canonicalTransform, geometryFromNrrd, readNrrdOrientationFields, reorientVoxels, reorientedGeometry, viewLabels, };
|
|
69
|
-
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, MaskRenderMode, LayerId, ChannelValue, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation, };
|
|
69
|
+
export type { positionType, screenPosType, optsType, NrrdHeaderLike, GltfLoadOpts, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, aligned4DSurfaceType, aligned4DOptsType, Aligned4DController, raw4DVolumeTransformType, raw4DVolumeOptsType, Raw4DVolumeController, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, IMaskHistoryChange, MaskRenderMode, LayerId, ChannelValue, ChannelClear, AiPromptTool, AiPromptPoint, AiPromptPayload, AiMaskResult, SurfaceAnnotatorOptions, Annotation, AnnotationMode, ExportOptions, ExposureVolume, DisposableObject3D, DisposableMaterial, FadeTarget, FadeableMaterial, SceneBudget, DisposableScene, SceneDisposalHost, FitBounds, FitViewScene, AxisGatedControls, GestureAxes, PosableScene, BoundingBoxHost, VolumeBoundingBoxOpts, NrrdAxis, Pose, NrrdOrientationFields, OrientationErrorCode, OrientationTransform, ViewAxis, ViewLabels, VolumeGeometry, VolumeOrientation, };
|
|
70
70
|
export type { CameraViewPreset } from "./Controls/orbitFraming";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copper3d",
|
|
3
3
|
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.4",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"module": "dist/bundle.esm.mjs",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|