copper3d 3.3.3 → 3.4.1
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/dist/Utils/segmentation/DrawToolCore.js +20 -3
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.js +4 -0
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/RenderingUtils.d.ts +9 -3
- package/dist/Utils/segmentation/RenderingUtils.js +35 -15
- package/dist/Utils/segmentation/RenderingUtils.js.map +1 -1
- package/dist/Utils/segmentation/core/MarchingSquares.d.ts +72 -0
- package/dist/Utils/segmentation/core/MarchingSquares.js +169 -0
- package/dist/Utils/segmentation/core/MarchingSquares.js.map +1 -0
- package/dist/Utils/segmentation/core/index.d.ts +2 -0
- package/dist/Utils/segmentation/core/index.js +1 -0
- package/dist/Utils/segmentation/core/index.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +9 -0
- package/dist/Utils/segmentation/eventRouter/EventRouter.js +36 -8
- package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -1
- package/dist/Utils/segmentation/tools/DrawingTool.d.ts +35 -10
- package/dist/Utils/segmentation/tools/DrawingTool.js +247 -36
- package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/SphereBrushTool.d.ts +83 -6
- package/dist/Utils/segmentation/tools/SphereBrushTool.js +283 -68
- package/dist/Utils/segmentation/tools/SphereBrushTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ToolHost.d.ts +1 -1
- package/dist/bundle.esm.js +794 -131
- package/dist/bundle.umd.js +794 -131
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/types/Utils/segmentation/RenderingUtils.d.ts +9 -3
- package/dist/types/Utils/segmentation/core/MarchingSquares.d.ts +72 -0
- package/dist/types/Utils/segmentation/core/index.d.ts +2 -0
- package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +9 -0
- package/dist/types/Utils/segmentation/tools/DrawingTool.d.ts +35 -10
- package/dist/types/Utils/segmentation/tools/SphereBrushTool.d.ts +83 -6
- package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/t
|
|
|
25
25
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
26
26
|
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
27
27
|
import "./css/style.css";
|
|
28
|
-
export declare const REVISION = "v3.
|
|
28
|
+
export declare const REVISION = "v3.4.1-beta";
|
|
29
29
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, };
|
|
30
30
|
export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, };
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import { MeshNodeTool } from "./Utils/MeshNodeTool";
|
|
|
21
21
|
import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
22
22
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
23
23
|
import "./css/style.css";
|
|
24
|
-
export const REVISION = "v3.
|
|
24
|
+
export const REVISION = "v3.4.1-beta";
|
|
25
25
|
console.log(`%cCopper3D Visualisation %cBeta:${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
26
26
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, };
|
|
27
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -51,11 +51,17 @@ export declare class RenderingUtils {
|
|
|
51
51
|
*/
|
|
52
52
|
getOrCreateSliceBuffer(axis: "x" | "y" | "z"): ImageData | null;
|
|
53
53
|
/**
|
|
54
|
-
* Render a layer's slice
|
|
54
|
+
* Render a layer's slice onto the target canvas as vector contours.
|
|
55
55
|
*
|
|
56
|
-
* Uses
|
|
56
|
+
* Uses marching-squares to extract voxel-truthful Path2D contours per
|
|
57
|
+
* label, then `ctx.fill()` them at the display canvas resolution. This
|
|
58
|
+
* eliminates the bilinear-upscale blur and zoom-dependent shape drift
|
|
59
|
+
* that plagued the old putImageData → drawImage pipeline.
|
|
60
|
+
*
|
|
61
|
+
* The `buffer` parameter is kept for backward-compatible signature but
|
|
62
|
+
* is no longer used on this path — callers may pass any valid ImageData.
|
|
57
63
|
*/
|
|
58
|
-
renderSliceToCanvas(layer: string, axis: "x" | "y" | "z", sliceIndex: number,
|
|
64
|
+
renderSliceToCanvas(layer: string, axis: "x" | "y" | "z", sliceIndex: number, _buffer: ImageData, targetCtx: CanvasRenderingContext2D, scaledWidth: number, scaledHeight: number): void;
|
|
59
65
|
/**
|
|
60
66
|
* Invalidate the reusable buffer (e.g. when switching datasets).
|
|
61
67
|
*/
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarchingSquares — Extract vector contours from a 2D voxel label grid.
|
|
3
|
+
*
|
|
4
|
+
* For each label, produces a `Path2D` whose subpaths are small per-cell
|
|
5
|
+
* polygons. The polygons tile the region occupied by the target label; the
|
|
6
|
+
* union (via `ctx.fill(path, 'nonzero')`) is the label's silhouette on the
|
|
7
|
+
* voxel grid.
|
|
8
|
+
*
|
|
9
|
+
* Coordinate convention:
|
|
10
|
+
* - Voxel (i, j) occupies the unit square [i, i+1] × [j, j+1] in render
|
|
11
|
+
* space, with its center at (i+0.5, j+0.5). This matches ITK-SNAP /
|
|
12
|
+
* standard imaging viewers and the existing `renderSliceToCanvas`
|
|
13
|
+
* `scale(scaledW / W, scaledH / H)` mapping.
|
|
14
|
+
* - Marching squares treats voxels as point samples at their centers:
|
|
15
|
+
* cell (i, j) has corners at voxel centers (i+0.5, j+0.5),
|
|
16
|
+
* (i+1.5, j+0.5), (i+1.5, j+1.5), (i+0.5, j+1.5).
|
|
17
|
+
* - This produces 45°-cut contours (diamonds for isolated voxels, rounded
|
|
18
|
+
* corners for connected regions) that stay within the voxel-square
|
|
19
|
+
* bounds, so the rendered silhouette is a slightly-inset version of the
|
|
20
|
+
* ITK-SNAP silhouette with smooth diagonals.
|
|
21
|
+
*
|
|
22
|
+
* Saddle cases (5 and 10) use a fixed convention: the two in-corners are
|
|
23
|
+
* treated as disconnected within the cell (4-connectivity interpretation).
|
|
24
|
+
*/
|
|
25
|
+
export interface ContourBBox {
|
|
26
|
+
/** Inclusive left voxel (0 ≤ x0 ≤ width). */
|
|
27
|
+
x0: number;
|
|
28
|
+
/** Inclusive top voxel (0 ≤ y0 ≤ height). */
|
|
29
|
+
y0: number;
|
|
30
|
+
/** Exclusive right voxel (x1 > x0). */
|
|
31
|
+
x1: number;
|
|
32
|
+
/** Exclusive bottom voxel (y1 > y0). */
|
|
33
|
+
y1: number;
|
|
34
|
+
}
|
|
35
|
+
/** A single polygon's vertices in voxel-space coordinates. */
|
|
36
|
+
export type ContourPolygon = ReadonlyArray<readonly [number, number]>;
|
|
37
|
+
/**
|
|
38
|
+
* Emit all per-cell polygons covering the voxels where `labels === targetLabel`.
|
|
39
|
+
* Pure geometry function — no Canvas dependency. Consumers can build a Path2D
|
|
40
|
+
* (see {@link extractLabelContours}) or walk the vertex arrays directly
|
|
41
|
+
* (tests, export, stroke rendering).
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractLabelPolygons(labels: Uint8Array, width: number, height: number, targetLabel: number, stride?: number, channelOffset?: number, bbox?: ContourBBox): ContourPolygon[];
|
|
44
|
+
/**
|
|
45
|
+
* Extract a `Path2D` covering all voxels equal to `targetLabel`.
|
|
46
|
+
*
|
|
47
|
+
* @param labels Flat label array. Addressed as
|
|
48
|
+
* `labels[(y * width + x) * stride + channelOffset]`.
|
|
49
|
+
* @param width Grid width in voxels.
|
|
50
|
+
* @param height Grid height in voxels.
|
|
51
|
+
* @param targetLabel Label value to extract (1..255; 0 is background).
|
|
52
|
+
* @param stride Bytes per voxel (default 1). Use MaskVolume.numChannels
|
|
53
|
+
* when reading interleaved slices.
|
|
54
|
+
* @param channelOffset Offset within each voxel's channels to sample.
|
|
55
|
+
* Default 0 (first channel = label id).
|
|
56
|
+
* @param bbox Optional voxel-space bbox to limit extraction.
|
|
57
|
+
* Cells in a 1-voxel halo around the bbox are still
|
|
58
|
+
* visited so the contour closes correctly at the bbox edges.
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractLabelContours(labels: Uint8Array, width: number, height: number, targetLabel: number, stride?: number, channelOffset?: number, bbox?: ContourBBox): Path2D;
|
|
61
|
+
/**
|
|
62
|
+
* Detect the distinct non-zero labels present in a slice region.
|
|
63
|
+
*
|
|
64
|
+
* @param labels Flat label array (see {@link extractLabelContours}).
|
|
65
|
+
* @param width Grid width.
|
|
66
|
+
* @param height Grid height.
|
|
67
|
+
* @param stride Bytes per voxel.
|
|
68
|
+
* @param channelOffset Offset within each voxel.
|
|
69
|
+
* @param bbox Optional region to scan (defaults to full grid).
|
|
70
|
+
* @returns Sorted array of distinct label values (0 omitted).
|
|
71
|
+
*/
|
|
72
|
+
export declare function findLabelsInSlice(labels: Uint8Array, width: number, height: number, stride?: number, channelOffset?: number, bbox?: ContourBBox): number[];
|
|
@@ -72,3 +72,5 @@ export { RenderMode, MASK_CHANNEL_COLORS, MASK_CHANNEL_CSS_COLORS, CHANNEL_COLOR
|
|
|
72
72
|
export { MaskVolume } from './MaskVolume';
|
|
73
73
|
export type { MaskDelta, UndoEntry } from './UndoManager';
|
|
74
74
|
export { UndoManager } from './UndoManager';
|
|
75
|
+
export type { ContourBBox, ContourPolygon } from './MarchingSquares';
|
|
76
|
+
export { extractLabelContours, extractLabelPolygons, findLabelsInSlice, } from './MarchingSquares';
|
|
@@ -88,6 +88,15 @@ export declare class EventRouter {
|
|
|
88
88
|
isCtrlHeld(): boolean;
|
|
89
89
|
isLeftButtonDown(): boolean;
|
|
90
90
|
isRightButtonDown(): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the user is currently performing a slice-drag (left-button held
|
|
93
|
+
* in idle mode with a non-sphere tool). In this state the mouse wheel is
|
|
94
|
+
* suppressed so that slice switching via drag and slice/zoom via wheel
|
|
95
|
+
* cannot fight each other. Draw / contrast / crosshair set `mode` away
|
|
96
|
+
* from 'idle', and sphere-family tools use left-drag for their own
|
|
97
|
+
* purposes, so both are correctly excluded.
|
|
98
|
+
*/
|
|
99
|
+
isDragSliceActive(): boolean;
|
|
91
100
|
/**
|
|
92
101
|
* Update keyboard settings.
|
|
93
102
|
*/
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* Extracted from DrawToolCore.paintOnCanvas() closure (Phase 3).
|
|
5
5
|
* Handles left-click drawing operations: pencil stroke + fill, brush strokes,
|
|
6
6
|
* eraser, and undo snapshot capture/push.
|
|
7
|
+
*
|
|
8
|
+
* Phase B: Brush mode now writes voxels directly during mousemove and
|
|
9
|
+
* re-renders via marching squares, eliminating the visual "snap" between
|
|
10
|
+
* the smooth canvas stroke and the voxel-based post-release render.
|
|
7
11
|
*/
|
|
8
12
|
import { BaseTool } from "./BaseTool";
|
|
9
13
|
import type { ToolContext } from "./BaseTool";
|
|
@@ -21,6 +25,8 @@ export declare class DrawingTool extends BaseTool {
|
|
|
21
25
|
private preDrawSlice;
|
|
22
26
|
private preDrawAxis;
|
|
23
27
|
private preDrawSliceIndex;
|
|
28
|
+
/** Previous voxel-space position for Bresenham interpolation (brush mode) */
|
|
29
|
+
private prevVoxel;
|
|
24
30
|
private callbacks;
|
|
25
31
|
constructor(ctx: ToolContext, callbacks: DrawingHostDeps);
|
|
26
32
|
/** Whether a draw operation is currently active */
|
|
@@ -56,30 +62,49 @@ export declare class DrawingTool extends BaseTool {
|
|
|
56
62
|
/**
|
|
57
63
|
* Create a self-managing mouseover/mouseout/mousemove handler
|
|
58
64
|
* that tracks brush hover position for the preview circle.
|
|
59
|
-
*
|
|
60
|
-
* The returned function should be registered on drawingCanvas for
|
|
61
|
-
* "mouseover" and "mouseout" events. It adds/removes a "mousemove"
|
|
62
|
-
* listener on itself to keep mouseOverX/Y up-to-date while the
|
|
63
|
-
* cursor is inside the canvas.
|
|
64
65
|
*/
|
|
65
66
|
createBrushTrackingHandler(): (e: MouseEvent) => void;
|
|
66
67
|
/**
|
|
67
68
|
* Render brush circle preview on the drawing context.
|
|
68
|
-
* Called from the start() render loop when in draw mode and not
|
|
69
|
-
* actively painting. Skipped in pencil/eraser mode.
|
|
70
69
|
*/
|
|
71
70
|
renderBrushPreview(ctx: CanvasRenderingContext2D, width: number, height: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Convert display (zoomed) coordinates to 3D voxel coordinates.
|
|
73
|
+
* Same logic as SphereBrushTool.canvasToVoxelCenter.
|
|
74
|
+
*/
|
|
75
|
+
private canvasToVoxel3D;
|
|
76
|
+
/**
|
|
77
|
+
* Get voxel-space brush radius for visible axes.
|
|
78
|
+
* Converts display-pixel brush size to voxel units.
|
|
79
|
+
*/
|
|
80
|
+
private getVoxelBrushRadius;
|
|
81
|
+
/**
|
|
82
|
+
* Paint a 2D ellipse of voxels on the current slice.
|
|
83
|
+
* Only the two visible axes are iterated; the slice-direction axis is fixed.
|
|
84
|
+
*/
|
|
85
|
+
private paintVoxelEllipse;
|
|
86
|
+
/**
|
|
87
|
+
* Brush mode mousemove: write voxels along stroke segment, then re-render.
|
|
88
|
+
* Uses linear interpolation between prev and current positions to ensure
|
|
89
|
+
* no gaps when the mouse moves fast.
|
|
90
|
+
*/
|
|
91
|
+
private paintBrushVoxelMove;
|
|
92
|
+
/**
|
|
93
|
+
* Re-render the active layer's canvas from MaskVolume via marching squares,
|
|
94
|
+
* then composite all layers to master.
|
|
95
|
+
*/
|
|
96
|
+
private refreshLayerFromVolume;
|
|
72
97
|
/** Capture pre-draw slice snapshot for undo */
|
|
73
98
|
private capturePreDrawSnapshot;
|
|
74
99
|
/** Push delta to UndoManager after drawing completes */
|
|
75
100
|
private pushUndoDelta;
|
|
76
101
|
/**
|
|
77
102
|
* Redraws persisted layer data onto ctx before new pencil fill.
|
|
78
|
-
*
|
|
103
|
+
* Delegates to the host's vector renderSliceToCanvas for consistency.
|
|
79
104
|
*/
|
|
80
105
|
private redrawPreviousImageToLayerCtx;
|
|
81
|
-
/** Draw a line segment on a layer canvas */
|
|
106
|
+
/** Draw a line segment on a layer canvas (pencil mode only) */
|
|
82
107
|
private drawLinesOnLayer;
|
|
83
|
-
/** Paint a segment on the current layer canvas and composite to master */
|
|
108
|
+
/** Paint a segment on the current layer canvas and composite to master (pencil mode) */
|
|
84
109
|
private paintOnCanvasLayer;
|
|
85
110
|
}
|
|
@@ -19,7 +19,11 @@ import type { ToolContext } from "./BaseTool";
|
|
|
19
19
|
import type { SphereBrushHostDeps } from "./ToolHost";
|
|
20
20
|
export declare class SphereBrushTool extends BaseTool {
|
|
21
21
|
private callbacks;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Recorded sphere center in display (zoomed) coordinates.
|
|
24
|
+
* Used for both preview redraw and voxel calculation — the voxel conversion
|
|
25
|
+
* uses `changedWidth/Height` as the display scale, so no mm detour is needed.
|
|
26
|
+
*/
|
|
23
27
|
private centerX;
|
|
24
28
|
private centerY;
|
|
25
29
|
private centerSlice;
|
|
@@ -27,18 +31,42 @@ export declare class SphereBrushTool extends BaseTool {
|
|
|
27
31
|
private active;
|
|
28
32
|
/** Current operation mode for the active placement */
|
|
29
33
|
private mode;
|
|
30
|
-
/** Cumulative "before" snapshots for drag
|
|
34
|
+
/** Cumulative "before" snapshots for drag undo (z-index → slice data) — used by both brush and eraser drag */
|
|
31
35
|
private dragBeforeSnapshots;
|
|
32
|
-
/** Whether a drag
|
|
36
|
+
/** Whether a drag has actually moved (vs. simple click-release) */
|
|
33
37
|
private dragMoved;
|
|
38
|
+
/**
|
|
39
|
+
* Latest cursor position in display (zoomed) coords. Used by the wheel
|
|
40
|
+
* handler to redraw the preview at the cursor, not the original mousedown
|
|
41
|
+
* point, during mid-drag radius changes.
|
|
42
|
+
*/
|
|
43
|
+
private lastDisplayX;
|
|
44
|
+
private lastDisplayY;
|
|
45
|
+
private lastSliceIndex;
|
|
46
|
+
/**
|
|
47
|
+
* All sphere centers written during the current stroke. The wheel handler
|
|
48
|
+
* retroactively re-renders the entire stroke at the new radius by restoring
|
|
49
|
+
* `dragBeforeSnapshots` and replaying every entry here.
|
|
50
|
+
*/
|
|
51
|
+
private strokeCenters;
|
|
34
52
|
constructor(ctx: ToolContext, callbacks: SphereBrushHostDeps);
|
|
35
53
|
setCallbacks(callbacks: SphereBrushHostDeps): void;
|
|
36
54
|
/**
|
|
37
|
-
* Convert
|
|
55
|
+
* Convert display (zoomed) coordinates to 3D voxel coordinates.
|
|
56
|
+
*
|
|
57
|
+
* Uses `changedWidth/Height` as the display scale directly (instead of
|
|
58
|
+
* going through mm via `/sizeFactor`). This keeps the write pixel-exact
|
|
59
|
+
* with the preview circle, which is drawn on a `changedWidth x changedHeight`
|
|
60
|
+
* sized sphere canvas — avoiding floating-point drift at high zoom levels.
|
|
38
61
|
*/
|
|
39
62
|
private canvasToVoxelCenter;
|
|
40
63
|
/**
|
|
41
64
|
* Convert mm radius to per-axis voxel radii.
|
|
65
|
+
*
|
|
66
|
+
* For the two axes visible in the current view, scale via
|
|
67
|
+
* `changedWidth/Height` so the rendered ellipsoid cross-section matches
|
|
68
|
+
* the preview pixel radius exactly. The third (slice-direction) axis is
|
|
69
|
+
* not visible, so it uses the plain mm-based ratio.
|
|
42
70
|
*/
|
|
43
71
|
private getVoxelRadii;
|
|
44
72
|
/**
|
|
@@ -83,11 +111,41 @@ export declare class SphereBrushTool extends BaseTool {
|
|
|
83
111
|
*/
|
|
84
112
|
configSphereBrushWheel(): (e: WheelEvent) => void;
|
|
85
113
|
/**
|
|
86
|
-
*
|
|
114
|
+
* Retroactively re-render the current stroke at the current radius.
|
|
115
|
+
*
|
|
116
|
+
* Step 1: walk every recorded stroke center and expand
|
|
117
|
+
* `dragBeforeSnapshots` to cover the new (larger) bounding box. Slices
|
|
118
|
+
* newly included here are still pristine because the original stroke
|
|
119
|
+
* never touched them.
|
|
120
|
+
* Step 2: restore every snapshotted slice from its pristine backup.
|
|
121
|
+
* Step 3: replay every stroke center at the new radius.
|
|
122
|
+
*
|
|
123
|
+
* Step 3 produces the same final state as if the user had used the new
|
|
124
|
+
* radius from the start. Undo still captures the full stroke as one group
|
|
125
|
+
* at pointerup.
|
|
126
|
+
*/
|
|
127
|
+
private replayStrokeWithCurrentRadius;
|
|
128
|
+
/**
|
|
129
|
+
* Handle pointer-down in sphereBrush mode (3D Slicer-style).
|
|
130
|
+
*
|
|
131
|
+
* Captures pristine snapshots at the mousedown location but does NOT
|
|
132
|
+
* write any voxels yet — the user may wheel-adjust the radius before
|
|
133
|
+
* dragging. The first sphere is written either by the first pointermove
|
|
134
|
+
* or by pointerup (single-click fallback).
|
|
87
135
|
*/
|
|
88
136
|
onSphereBrushClick(e: MouseEvent): void;
|
|
89
137
|
/**
|
|
90
|
-
* Handle pointer-
|
|
138
|
+
* Handle pointer-move in sphereBrush mode — drag to continuously paint.
|
|
139
|
+
*
|
|
140
|
+
* Mirrors sphereEraser drag: writes a new sphere at each move position,
|
|
141
|
+
* extends the cumulative before-snapshot to cover any newly-touched Z
|
|
142
|
+
* slices, and repaints the preview. Never notifies the backend; pointerup
|
|
143
|
+
* does that once for the whole stroke.
|
|
144
|
+
*/
|
|
145
|
+
onSphereBrushMove(e: MouseEvent): void;
|
|
146
|
+
/**
|
|
147
|
+
* Handle pointer-up in sphereBrush mode — finalize stroke + push undo group
|
|
148
|
+
* + single batched backend notify for all Z slices touched during the drag.
|
|
91
149
|
*/
|
|
92
150
|
onSphereBrushPointerUp(): void;
|
|
93
151
|
/**
|
|
@@ -104,6 +162,12 @@ export declare class SphereBrushTool extends BaseTool {
|
|
|
104
162
|
* Works for both click-release and drag-release.
|
|
105
163
|
*/
|
|
106
164
|
onSphereEraserPointerUp(): void;
|
|
165
|
+
/**
|
|
166
|
+
* Clear per-stroke state after pointerup or cancel. Kept as a helper so
|
|
167
|
+
* brush/eraser pointerup and cancelActivePlacement all reset the same set
|
|
168
|
+
* of fields — if a new drag-state field is added, only one place to update.
|
|
169
|
+
*/
|
|
170
|
+
private finalizeStrokeState;
|
|
107
171
|
/**
|
|
108
172
|
* Expand cumulative "before" snapshots to cover z range [minZ, maxZ].
|
|
109
173
|
* Only captures slices not yet in the map (preserves original state).
|
|
@@ -120,8 +184,21 @@ export declare class SphereBrushTool extends BaseTool {
|
|
|
120
184
|
* @param changedDeltas - If provided, fire onMaskChanged for ALL changed
|
|
121
185
|
* slices (not just the current view slice) so the backend receives the
|
|
122
186
|
* full 3D sphere data for NII/GLTF export.
|
|
187
|
+
* @param notifyBackend - When false, only refresh the local canvas and skip
|
|
188
|
+
* the onMaskChanged callback. Used during drag to avoid per-frame HTTP;
|
|
189
|
+
* pointerup then calls with `true` to send a single batched update.
|
|
123
190
|
*/
|
|
124
191
|
private refreshDisplay;
|
|
125
192
|
/** Whether a sphere placement is currently in progress */
|
|
126
193
|
get isActive(): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Defensively cancel any in-progress sphere placement and clear the preview.
|
|
196
|
+
*
|
|
197
|
+
* Called when crosshair mode is entered so any lingering sphere preview
|
|
198
|
+
* (e.g. red dashed eraser outline) is wiped immediately. In normal flow
|
|
199
|
+
* `leftButtonDown === true` blocks crosshair toggle, so this shouldn't
|
|
200
|
+
* fire mid-stroke — but if it ever does, we drop the drag snapshot
|
|
201
|
+
* rather than committing a partial undo entry.
|
|
202
|
+
*/
|
|
203
|
+
cancelActivePlacement(): void;
|
|
127
204
|
}
|
|
@@ -64,7 +64,7 @@ export type ZoomHostDeps = Pick<ToolHost, 'resetPaintAreaUIPosition' | 'resizePa
|
|
|
64
64
|
/** SphereTool host dependencies */
|
|
65
65
|
export type SphereHostDeps = Pick<ToolHost, 'setEmptyCanvasSize' | 'drawImageOnEmptyImage' | 'enableCrosshair' | 'setUpSphereOrigins'>;
|
|
66
66
|
/** DrawingTool host dependencies */
|
|
67
|
-
export type DrawingHostDeps = Pick<ToolHost, 'setCurrentLayer' | 'compositeAllLayers' | 'syncLayerSliceData' | 'filterDrawedImage' | 'getVolumeForLayer' | 'pushUndoDelta' | 'getEraserUrls'>;
|
|
67
|
+
export type DrawingHostDeps = Pick<ToolHost, 'setCurrentLayer' | 'compositeAllLayers' | 'syncLayerSliceData' | 'filterDrawedImage' | 'getVolumeForLayer' | 'pushUndoDelta' | 'getEraserUrls' | 'renderSliceToCanvas' | 'getOrCreateSliceBuffer'>;
|
|
68
68
|
/** DragSliceTool host dependencies */
|
|
69
69
|
export type DragSliceHostDeps = Pick<ToolHost, 'setSyncsliceNum' | 'setIsDrawFalse' | 'flipDisplayImageByAxis' | 'setEmptyCanvasSize' | 'getOrCreateSliceBuffer' | 'renderSliceToCanvas' | 'refreshSphereOverlay' | 'compositeAllLayers'>;
|
|
70
70
|
/** LayerChannelManager host dependencies */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/t
|
|
|
25
25
|
import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
|
|
26
26
|
import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
|
|
27
27
|
import "./css/style.css";
|
|
28
|
-
export declare const REVISION = "v3.
|
|
28
|
+
export declare const REVISION = "v3.4.1-beta";
|
|
29
29
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, GaussianSmoother, };
|
|
30
30
|
export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, };
|
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": "3.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"moudle": "dist/bundle.esm.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|