copper3d 2.2.3 → 3.0.0
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 +1056 -5
- package/dist/Scene/copperScene.d.ts +3 -0
- package/dist/Scene/copperScene.js +13 -0
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/segmentation/CommToolsData.d.ts +109 -6
- package/dist/Utils/segmentation/CommToolsData.js +314 -50
- package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
- package/dist/Utils/segmentation/DragOperator.d.ts +13 -7
- package/dist/Utils/segmentation/DragOperator.js +51 -165
- package/dist/Utils/segmentation/DragOperator.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +57 -76
- package/dist/Utils/segmentation/DrawToolCore.js +368 -878
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +277 -15
- package/dist/Utils/segmentation/NrrdTools.js +594 -232
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.d.ts +477 -0
- package/dist/Utils/segmentation/core/MaskVolume.js +1238 -0
- package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -0
- package/dist/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
- package/dist/Utils/segmentation/core/MigrationUtils.js +163 -0
- package/dist/Utils/segmentation/core/MigrationUtils.js.map +1 -0
- package/dist/Utils/segmentation/core/UndoManager.d.ts +47 -0
- package/dist/Utils/segmentation/core/UndoManager.js +86 -0
- package/dist/Utils/segmentation/core/UndoManager.js.map +1 -0
- package/dist/Utils/segmentation/core/index.d.ts +76 -0
- package/dist/Utils/segmentation/core/index.js +75 -0
- package/dist/Utils/segmentation/core/index.js.map +1 -0
- package/dist/Utils/segmentation/core/types.d.ts +106 -0
- package/dist/Utils/segmentation/core/types.js +98 -0
- package/dist/Utils/segmentation/core/types.js.map +1 -0
- package/dist/Utils/segmentation/coreTools/coreType.d.ts +55 -36
- package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/gui.d.ts +6 -16
- package/dist/Utils/segmentation/coreTools/gui.js +23 -27
- package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +144 -0
- package/dist/Utils/segmentation/eventRouter/EventRouter.js +369 -0
- package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -0
- package/dist/Utils/segmentation/eventRouter/index.d.ts +7 -0
- package/dist/Utils/segmentation/eventRouter/index.js +7 -0
- package/dist/Utils/segmentation/eventRouter/index.js.map +1 -0
- package/dist/Utils/segmentation/eventRouter/types.d.ts +70 -0
- package/dist/Utils/segmentation/eventRouter/types.js +7 -0
- package/dist/Utils/segmentation/eventRouter/types.js.map +1 -0
- package/dist/Utils/segmentation/tools/BaseTool.d.ts +25 -0
- package/dist/Utils/segmentation/tools/BaseTool.js +18 -0
- package/dist/Utils/segmentation/tools/BaseTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
- package/dist/Utils/segmentation/tools/ContrastTool.js +118 -0
- package/dist/Utils/segmentation/tools/ContrastTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
- package/dist/Utils/segmentation/tools/CrosshairTool.js +157 -0
- package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.js +170 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/EraserTool.d.ts +16 -0
- package/dist/Utils/segmentation/tools/EraserTool.js +92 -0
- package/dist/Utils/segmentation/tools/EraserTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +65 -0
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js +174 -0
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -0
- package/dist/Utils/segmentation/tools/SphereTool.d.ts +38 -0
- package/dist/Utils/segmentation/tools/SphereTool.js +193 -0
- package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
- package/dist/Utils/segmentation/tools/ZoomTool.js +59 -0
- package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/index.d.ts +22 -0
- package/dist/Utils/segmentation/tools/index.js +23 -0
- package/dist/Utils/segmentation/tools/index.js.map +1 -0
- package/dist/bundle.esm.js +4740 -1979
- package/dist/bundle.umd.js +4743 -1978
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/types/Renderer/copperRenderer.d.ts +1 -1
- package/dist/types/Renderer/copperRendererOnDemond.d.ts +1 -1
- package/dist/types/Scene/copperScene.d.ts +3 -0
- package/dist/types/Utils/segmentation/CommToolsData.d.ts +109 -6
- package/dist/types/Utils/segmentation/DragOperator.d.ts +13 -7
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +57 -76
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +277 -15
- package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +477 -0
- package/dist/types/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
- package/dist/types/Utils/segmentation/core/UndoManager.d.ts +47 -0
- package/dist/types/Utils/segmentation/core/index.d.ts +76 -0
- package/dist/types/Utils/segmentation/core/types.d.ts +106 -0
- package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +55 -36
- package/dist/types/Utils/segmentation/coreTools/gui.d.ts +6 -16
- package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +144 -0
- package/dist/types/Utils/segmentation/eventRouter/index.d.ts +7 -0
- package/dist/types/Utils/segmentation/eventRouter/types.d.ts +70 -0
- package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +25 -0
- package/dist/types/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
- package/dist/types/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
- package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
- package/dist/types/Utils/segmentation/tools/EraserTool.d.ts +16 -0
- package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +65 -0
- package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +38 -0
- package/dist/types/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
- package/dist/types/Utils/segmentation/tools/index.d.ts +22 -0
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/types.d.ts +3 -3
- package/dist/types/types.d.ts +3 -3
- package/package.json +1 -1
- package/dist/Utils/segmentation/coreTools/archive.d.ts +0 -1
- package/dist/Utils/segmentation/coreTools/archive.js +0 -23
- package/dist/Utils/segmentation/coreTools/archive.js.map +0 -1
- package/dist/types/Utils/segmentation/coreTools/archive.d.ts +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EraserTool - Channel-aware circular eraser implementation
|
|
3
|
+
*
|
|
4
|
+
* Phase 3.5: Updated to only erase pixels matching the active channel color
|
|
5
|
+
* on the current layer canvas. Other channels/layers are untouched.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseTool } from "./BaseTool";
|
|
8
|
+
import { MASK_CHANNEL_COLORS } from "../core";
|
|
9
|
+
export class EraserTool extends BaseTool {
|
|
10
|
+
/**
|
|
11
|
+
* Create the circular eraser function.
|
|
12
|
+
*
|
|
13
|
+
* Channel-aware: only erases pixels whose RGB matches the active channel's color.
|
|
14
|
+
* Only operates on the current layer canvas + master canvas.
|
|
15
|
+
*/
|
|
16
|
+
createClearArc() {
|
|
17
|
+
const clearArc = (x, y, radius) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const activeChannel = this.ctx.gui_states.activeChannel || 1;
|
|
20
|
+
// Get color from current layer's volume (respects custom per-layer colors)
|
|
21
|
+
const layer = this.ctx.gui_states.layer;
|
|
22
|
+
const volume = this.ctx.protectedData.maskData.volumes[layer];
|
|
23
|
+
const channelColor = volume
|
|
24
|
+
? volume.getChannelColor(activeChannel)
|
|
25
|
+
: ((_a = MASK_CHANNEL_COLORS[activeChannel]) !== null && _a !== void 0 ? _a : MASK_CHANNEL_COLORS[1]);
|
|
26
|
+
// Determine current layer context via layerTargets Map
|
|
27
|
+
const target = this.ctx.protectedData.layerTargets.get(layer);
|
|
28
|
+
if (!target)
|
|
29
|
+
return; // Unknown layer, safe exit
|
|
30
|
+
const layerCtx = target.ctx;
|
|
31
|
+
// Calculate bounding box of the eraser circle
|
|
32
|
+
const x0 = Math.max(0, Math.floor(x - radius));
|
|
33
|
+
const y0 = Math.max(0, Math.floor(y - radius));
|
|
34
|
+
const x1 = Math.min(this.ctx.nrrd_states.changedWidth, Math.ceil(x + radius));
|
|
35
|
+
const y1 = Math.min(this.ctx.nrrd_states.changedHeight, Math.ceil(y + radius));
|
|
36
|
+
const w = x1 - x0;
|
|
37
|
+
const h = y1 - y0;
|
|
38
|
+
if (w <= 0 || h <= 0)
|
|
39
|
+
return;
|
|
40
|
+
// Read current layer pixels in the bounding box
|
|
41
|
+
const imageData = layerCtx.getImageData(x0, y0, w, h);
|
|
42
|
+
const pixels = imageData.data;
|
|
43
|
+
const r2 = radius * radius;
|
|
44
|
+
// Erase pixels matching the active channel color within the circle.
|
|
45
|
+
// Uses tolerance (±30) to handle anti-aliased edges from canvas path rendering.
|
|
46
|
+
const TOL = 30;
|
|
47
|
+
const cr = channelColor.r, cg = channelColor.g, cb = channelColor.b;
|
|
48
|
+
for (let py = 0; py < h; py++) {
|
|
49
|
+
for (let px = 0; px < w; px++) {
|
|
50
|
+
const dx = (x0 + px) - x;
|
|
51
|
+
const dy = (y0 + py) - y;
|
|
52
|
+
if (dx * dx + dy * dy > r2)
|
|
53
|
+
continue; // Outside circle
|
|
54
|
+
const idx = (py * w + px) * 4;
|
|
55
|
+
const pa = pixels[idx + 3];
|
|
56
|
+
// Skip transparent pixels
|
|
57
|
+
if (pa === 0)
|
|
58
|
+
continue;
|
|
59
|
+
// Match if RGB is within tolerance of the active channel color
|
|
60
|
+
const pr = pixels[idx];
|
|
61
|
+
const pg = pixels[idx + 1];
|
|
62
|
+
const pb = pixels[idx + 2];
|
|
63
|
+
if (Math.abs(pr - cr) <= TOL &&
|
|
64
|
+
Math.abs(pg - cg) <= TOL &&
|
|
65
|
+
Math.abs(pb - cb) <= TOL) {
|
|
66
|
+
pixels[idx] = 0;
|
|
67
|
+
pixels[idx + 1] = 0;
|
|
68
|
+
pixels[idx + 2] = 0;
|
|
69
|
+
pixels[idx + 3] = 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Write modified pixels back to layer canvas
|
|
74
|
+
layerCtx.putImageData(imageData, x0, y0);
|
|
75
|
+
// Recomposite master from all layer canvases (full alpha;
|
|
76
|
+
// globalAlpha applied in start() render loop).
|
|
77
|
+
const masterCtx = this.ctx.protectedData.ctxes.drawingLayerMasterCtx;
|
|
78
|
+
const fullW = this.ctx.nrrd_states.changedWidth;
|
|
79
|
+
const fullH = this.ctx.nrrd_states.changedHeight;
|
|
80
|
+
masterCtx.clearRect(0, 0, fullW, fullH);
|
|
81
|
+
for (const layerId of this.ctx.nrrd_states.layers) {
|
|
82
|
+
if (!this.ctx.gui_states.layerVisibility[layerId])
|
|
83
|
+
continue;
|
|
84
|
+
const lt = this.ctx.protectedData.layerTargets.get(layerId);
|
|
85
|
+
if (lt)
|
|
86
|
+
masterCtx.drawImage(lt.canvas, 0, 0, fullW, fullH);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return clearArc;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=EraserTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EraserTool.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/EraserTool.ts"],"names":[],"mappings":"AA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I,CAAC,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC;YACjD,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YAExC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE;gBACjD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC;oBAAE,SAAS;gBAC5D,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC5D,IAAI,EAAE;oBAAE,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;aAC5D;QACH,CAAC,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageStoreHelper - Cross-axis image storage
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.ts:
|
|
5
|
+
* - storeAllImages / storeImageToAxis / storeImageToLayer / storeEachLayerImage
|
|
6
|
+
*
|
|
7
|
+
* Phase 2 Day 7: Updated to write/read MaskVolume alongside legacy IPaintImages.
|
|
8
|
+
* Volume is the primary storage; IPaintImages kept for backward compatibility.
|
|
9
|
+
*/
|
|
10
|
+
import { BaseTool } from "./BaseTool";
|
|
11
|
+
import type { ToolContext } from "./BaseTool";
|
|
12
|
+
import type { IPaintImage, IPaintImages } from "../coreTools/coreType";
|
|
13
|
+
export interface ImageStoreCallbacks {
|
|
14
|
+
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
15
|
+
drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare class ImageStoreHelper extends BaseTool {
|
|
18
|
+
private callbacks;
|
|
19
|
+
constructor(ctx: ToolContext, callbacks: ImageStoreCallbacks);
|
|
20
|
+
/**
|
|
21
|
+
* Get MaskVolume for a specific layer.
|
|
22
|
+
* Delegates to the volumes stored in protectedData.maskData.
|
|
23
|
+
*
|
|
24
|
+
* @param layer - "layer1", "layer2", or "layer3"
|
|
25
|
+
* @returns MaskVolume for the given layer, or layer1 as fallback
|
|
26
|
+
*/
|
|
27
|
+
private getVolumeForLayer;
|
|
28
|
+
/**
|
|
29
|
+
* Get MaskVolume for the currently active layer.
|
|
30
|
+
*/
|
|
31
|
+
private getCurrentVolume;
|
|
32
|
+
/**
|
|
33
|
+
* Get the canvas element for a specific layer.
|
|
34
|
+
*/
|
|
35
|
+
private getCanvasForLayer;
|
|
36
|
+
/**
|
|
37
|
+
* Phase 3: Simplified to be a no-op.
|
|
38
|
+
* MaskVolume storage happens in storeAllImages via setSliceFromImageData.
|
|
39
|
+
* This method kept for backward compatibility with existing call sites.
|
|
40
|
+
*/
|
|
41
|
+
storeImageToAxis(_index: number, _paintedImages: IPaintImages, _imageData: ImageData, _axis?: "x" | "y" | "z"): void;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve the drawn image for a given axis and slice.
|
|
44
|
+
*
|
|
45
|
+
* Phase 3: Reads exclusively from MaskVolume (no legacy fallback).
|
|
46
|
+
*/
|
|
47
|
+
filterDrawedImage(axis: "x" | "y" | "z", sliceIndex: number, _paintedImages: IPaintImages): IPaintImage | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Store all layer images for the current slice (cross-axis sync).
|
|
50
|
+
*
|
|
51
|
+
* Phase 2: Also writes into the current layer's MaskVolume.
|
|
52
|
+
*/
|
|
53
|
+
storeAllImages(index: number, layer: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Store a single layer's canvas data to its MaskVolume.
|
|
56
|
+
* Reads from the individual layer canvas (not master) and uses RGB→channel reverse lookup.
|
|
57
|
+
*/
|
|
58
|
+
storeEachLayerImage(index: number, layer: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Phase 3: Simplified - extracts ImageData from canvas but no longer stores to paintImages.
|
|
61
|
+
* Kept for backward compatibility with existing call sites.
|
|
62
|
+
*/
|
|
63
|
+
storeImageToLayer(_index: number, canvas: HTMLCanvasElement, _paintedImages: IPaintImages): ImageData;
|
|
64
|
+
private hasNonZeroPixels;
|
|
65
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImageStoreHelper - Cross-axis image storage
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.ts:
|
|
5
|
+
* - storeAllImages / storeImageToAxis / storeImageToLayer / storeEachLayerImage
|
|
6
|
+
*
|
|
7
|
+
* Phase 2 Day 7: Updated to write/read MaskVolume alongside legacy IPaintImages.
|
|
8
|
+
* Volume is the primary storage; IPaintImages kept for backward compatibility.
|
|
9
|
+
*/
|
|
10
|
+
import { BaseTool } from "./BaseTool";
|
|
11
|
+
export class ImageStoreHelper extends BaseTool {
|
|
12
|
+
constructor(ctx, callbacks) {
|
|
13
|
+
super(ctx);
|
|
14
|
+
this.callbacks = callbacks;
|
|
15
|
+
}
|
|
16
|
+
// ===== Volume Accessor Helpers (Phase 2) =====
|
|
17
|
+
/**
|
|
18
|
+
* Get MaskVolume for a specific layer.
|
|
19
|
+
* Delegates to the volumes stored in protectedData.maskData.
|
|
20
|
+
*
|
|
21
|
+
* @param layer - "layer1", "layer2", or "layer3"
|
|
22
|
+
* @returns MaskVolume for the given layer, or layer1 as fallback
|
|
23
|
+
*/
|
|
24
|
+
getVolumeForLayer(layer) {
|
|
25
|
+
const { volumes } = this.ctx.protectedData.maskData;
|
|
26
|
+
switch (layer) {
|
|
27
|
+
case "layer1": return volumes.layer1;
|
|
28
|
+
case "layer2": return volumes.layer2;
|
|
29
|
+
case "layer3": return volumes.layer3;
|
|
30
|
+
default: return volumes.layer1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get MaskVolume for the currently active layer.
|
|
35
|
+
*/
|
|
36
|
+
getCurrentVolume() {
|
|
37
|
+
return this.getVolumeForLayer(this.ctx.gui_states.layer);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the canvas element for a specific layer.
|
|
41
|
+
*/
|
|
42
|
+
getCanvasForLayer(layer) {
|
|
43
|
+
const target = this.ctx.protectedData.layerTargets.get(layer);
|
|
44
|
+
if (target)
|
|
45
|
+
return target.canvas;
|
|
46
|
+
return this.ctx.protectedData.canvases.drawingCanvasLayerMaster;
|
|
47
|
+
}
|
|
48
|
+
// ===== Store Image To Axis =====
|
|
49
|
+
/**
|
|
50
|
+
* Phase 3: Simplified to be a no-op.
|
|
51
|
+
* MaskVolume storage happens in storeAllImages via setSliceFromImageData.
|
|
52
|
+
* This method kept for backward compatibility with existing call sites.
|
|
53
|
+
*/
|
|
54
|
+
storeImageToAxis(_index, _paintedImages, _imageData, _axis) {
|
|
55
|
+
// No-op: MaskVolume is the primary storage, updated in storeAllImages
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve the drawn image for a given axis and slice.
|
|
59
|
+
*
|
|
60
|
+
* Phase 3: Reads exclusively from MaskVolume (no legacy fallback).
|
|
61
|
+
*/
|
|
62
|
+
filterDrawedImage(axis, sliceIndex, _paintedImages) {
|
|
63
|
+
try {
|
|
64
|
+
const volume = this.getCurrentVolume();
|
|
65
|
+
if (volume) {
|
|
66
|
+
const dims = volume.getDimensions();
|
|
67
|
+
const [w, h] = axis === 'z' ? [dims.width, dims.height]
|
|
68
|
+
: axis === 'y' ? [dims.width, dims.depth]
|
|
69
|
+
// Sagittal: width = depth (Z), height = height (Y)
|
|
70
|
+
: [dims.depth, dims.height];
|
|
71
|
+
const imageData = new ImageData(w, h);
|
|
72
|
+
const channelVis = this.ctx.gui_states.channelVisibility[this.ctx.gui_states.layer];
|
|
73
|
+
volume.renderLabelSliceInto(sliceIndex, axis, imageData, channelVis);
|
|
74
|
+
return { index: sliceIndex, image: imageData };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
console.warn(`filterDrawedImage: Failed to read slice ${sliceIndex} on ${axis}:`, err);
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
// ===== Store All Images (cross-axis sync) =====
|
|
83
|
+
/**
|
|
84
|
+
* Store all layer images for the current slice (cross-axis sync).
|
|
85
|
+
*
|
|
86
|
+
* Phase 2: Also writes into the current layer's MaskVolume.
|
|
87
|
+
*/
|
|
88
|
+
storeAllImages(index, layer) {
|
|
89
|
+
const nrrd = this.ctx.nrrd_states;
|
|
90
|
+
// Read from the individual layer canvas (NOT master) to preserve layer isolation
|
|
91
|
+
const layerCanvas = this.getCanvasForLayer(layer);
|
|
92
|
+
if (!nrrd.loadMaskJson && !this.ctx.gui_states.sphere && !this.ctx.gui_states.calculator) {
|
|
93
|
+
this.callbacks.setEmptyCanvasSize();
|
|
94
|
+
this.callbacks.drawImageOnEmptyImage(layerCanvas);
|
|
95
|
+
}
|
|
96
|
+
const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
|
|
97
|
+
// Write label data into 1-channel MaskVolume with RGB→channel reverse lookup
|
|
98
|
+
try {
|
|
99
|
+
const volume = this.getVolumeForLayer(layer);
|
|
100
|
+
if (volume) {
|
|
101
|
+
const activeChannel = this.ctx.gui_states.activeChannel || 1;
|
|
102
|
+
// Phase 4 Fix: Pass channel visibility map to preserve hidden channels
|
|
103
|
+
const channelVis = this.ctx.gui_states.channelVisibility[layer];
|
|
104
|
+
volume.setSliceLabelsFromImageData(index, imageData, this.ctx.protectedData.axis, activeChannel, channelVis);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
// Volume not ready — skip
|
|
109
|
+
}
|
|
110
|
+
if (!nrrd.loadMaskJson && !this.ctx.gui_states.sphere && !this.ctx.gui_states.calculator) {
|
|
111
|
+
// Extract raw slice data from MaskVolume and notify parent
|
|
112
|
+
try {
|
|
113
|
+
const volume = this.getVolumeForLayer(layer);
|
|
114
|
+
if (volume) {
|
|
115
|
+
const axis = this.ctx.protectedData.axis;
|
|
116
|
+
const sliceIndex = this.ctx.nrrd_states.currentIndex;
|
|
117
|
+
const { data: sliceData, width, height } = volume.getSliceUint8(sliceIndex, axis);
|
|
118
|
+
const activeChannel = this.ctx.gui_states.activeChannel || 1;
|
|
119
|
+
this.ctx.nrrd_states.getMask(sliceData, layer, activeChannel, sliceIndex, axis, width, height, this.ctx.nrrd_states.clearAllFlag);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
// Volume not ready — skip notification
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// ===== Store Per-Layer Images =====
|
|
128
|
+
/**
|
|
129
|
+
* Store a single layer's canvas data to its MaskVolume.
|
|
130
|
+
* Reads from the individual layer canvas (not master) and uses RGB→channel reverse lookup.
|
|
131
|
+
*/
|
|
132
|
+
storeEachLayerImage(index, layer) {
|
|
133
|
+
const layerCanvas = this.getCanvasForLayer(layer);
|
|
134
|
+
this.callbacks.setEmptyCanvasSize();
|
|
135
|
+
this.callbacks.drawImageOnEmptyImage(layerCanvas);
|
|
136
|
+
const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
|
|
137
|
+
try {
|
|
138
|
+
const volume = this.getVolumeForLayer(layer);
|
|
139
|
+
if (volume) {
|
|
140
|
+
const activeChannel = this.ctx.gui_states.activeChannel || 1;
|
|
141
|
+
// Phase 4 Fix: Pass channel visibility map to preserve hidden channels
|
|
142
|
+
const channelVis = this.ctx.gui_states.channelVisibility[layer];
|
|
143
|
+
volume.setSliceLabelsFromImageData(index, imageData, this.ctx.protectedData.axis, activeChannel, channelVis);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (_a) {
|
|
147
|
+
// Volume not ready — skip
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Phase 3: Simplified - extracts ImageData from canvas but no longer stores to paintImages.
|
|
152
|
+
* Kept for backward compatibility with existing call sites.
|
|
153
|
+
*/
|
|
154
|
+
storeImageToLayer(_index, canvas, _paintedImages) {
|
|
155
|
+
if (!this.ctx.nrrd_states.loadMaskJson) {
|
|
156
|
+
this.callbacks.setEmptyCanvasSize();
|
|
157
|
+
this.callbacks.drawImageOnEmptyImage(canvas);
|
|
158
|
+
}
|
|
159
|
+
const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
|
|
160
|
+
// No longer stores to paintedImages - MaskVolume is primary storage
|
|
161
|
+
return imageData;
|
|
162
|
+
}
|
|
163
|
+
// ===== Helper Methods =====
|
|
164
|
+
hasNonZeroPixels(imageData) {
|
|
165
|
+
const data = imageData.data;
|
|
166
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
167
|
+
if (data[i] !== 0 || data[i + 1] !== 0 || data[i + 2] !== 0 || data[i + 3] !== 0) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=ImageStoreHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageStoreHelper.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/ImageStoreHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAG5C,YAAY,GAAgB,EAA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AI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE;gBAChF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SphereTool - Sphere drawing and calculator sphere operations
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.ts:
|
|
5
|
+
* - drawSphere / drawSphereCore / clearSphereCanvas
|
|
6
|
+
* - drawSphereOnEachViews / drawCalculatorSphereOnEachViews
|
|
7
|
+
* - storeSphereImages / setSphereCanvasSize
|
|
8
|
+
* - drawCalculatorSphere / configMouseSphereWheel
|
|
9
|
+
* - getSpherePosition / clearSpherePrintStoreImages
|
|
10
|
+
*/
|
|
11
|
+
import { BaseTool } from "./BaseTool";
|
|
12
|
+
import type { ToolContext } from "./BaseTool";
|
|
13
|
+
import type { IPaintImages } from "../coreTools/coreType";
|
|
14
|
+
/**
|
|
15
|
+
* Callbacks that DrawToolCore must provide for sphere operations.
|
|
16
|
+
*/
|
|
17
|
+
export interface SphereCallbacks {
|
|
18
|
+
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
19
|
+
drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
|
|
20
|
+
storeImageToAxis: (index: number, paintedImages: IPaintImages, imageData: ImageData, axis?: "x" | "y" | "z") => void;
|
|
21
|
+
createEmptyPaintImage: (dimensions: number[], paintImages: IPaintImages) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare class SphereTool extends BaseTool {
|
|
24
|
+
private callbacks;
|
|
25
|
+
constructor(ctx: ToolContext, callbacks: SphereCallbacks);
|
|
26
|
+
setCallbacks(callbacks: SphereCallbacks): void;
|
|
27
|
+
setSphereCanvasSize(axis?: "x" | "y" | "z"): void;
|
|
28
|
+
drawSphereCore(ctx: CanvasRenderingContext2D, x: number, y: number, radius: number, color: string): void;
|
|
29
|
+
clearSphereCanvas(): [HTMLCanvasElement, CanvasRenderingContext2D];
|
|
30
|
+
drawSphere(mouseX: number, mouseY: number, radius: number): void;
|
|
31
|
+
configMouseSphereWheel(): (e: WheelEvent) => void;
|
|
32
|
+
private storeSphereImages;
|
|
33
|
+
drawSphereOnEachViews(decay: number, axis: "x" | "y" | "z"): void;
|
|
34
|
+
private getSpherePosition;
|
|
35
|
+
drawCalculatorSphereOnEachViews(axis: "x" | "y" | "z"): void;
|
|
36
|
+
drawCalculatorSphere(radius: number): void;
|
|
37
|
+
clearSpherePrintStoreImages(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SphereTool - Sphere drawing and calculator sphere operations
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.ts:
|
|
5
|
+
* - drawSphere / drawSphereCore / clearSphereCanvas
|
|
6
|
+
* - drawSphereOnEachViews / drawCalculatorSphereOnEachViews
|
|
7
|
+
* - storeSphereImages / setSphereCanvasSize
|
|
8
|
+
* - drawCalculatorSphere / configMouseSphereWheel
|
|
9
|
+
* - getSpherePosition / clearSpherePrintStoreImages
|
|
10
|
+
*/
|
|
11
|
+
import { BaseTool } from "./BaseTool";
|
|
12
|
+
export class SphereTool extends BaseTool {
|
|
13
|
+
constructor(ctx, callbacks) {
|
|
14
|
+
super(ctx);
|
|
15
|
+
this.callbacks = callbacks;
|
|
16
|
+
}
|
|
17
|
+
setCallbacks(callbacks) {
|
|
18
|
+
this.callbacks = callbacks;
|
|
19
|
+
}
|
|
20
|
+
// ===== Sphere Canvas Size =====
|
|
21
|
+
setSphereCanvasSize(axis) {
|
|
22
|
+
const nrrd = this.ctx.nrrd_states;
|
|
23
|
+
switch (axis !== null && axis !== void 0 ? axis : this.ctx.protectedData.axis) {
|
|
24
|
+
case "x":
|
|
25
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.width = nrrd.nrrd_z_mm;
|
|
26
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.height = nrrd.nrrd_y_mm;
|
|
27
|
+
break;
|
|
28
|
+
case "y":
|
|
29
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.width = nrrd.nrrd_x_mm;
|
|
30
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.height = nrrd.nrrd_z_mm;
|
|
31
|
+
break;
|
|
32
|
+
case "z":
|
|
33
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.width = nrrd.nrrd_x_mm;
|
|
34
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.height = nrrd.nrrd_y_mm;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// ===== Core Sphere Drawing =====
|
|
39
|
+
drawSphereCore(ctx, x, y, radius, color) {
|
|
40
|
+
ctx.beginPath();
|
|
41
|
+
ctx.arc(x, y, radius, 0, 2 * Math.PI);
|
|
42
|
+
ctx.fillStyle = color;
|
|
43
|
+
ctx.fill();
|
|
44
|
+
ctx.closePath();
|
|
45
|
+
}
|
|
46
|
+
clearSphereCanvas() {
|
|
47
|
+
// clear drawingCanvasLayerMaster
|
|
48
|
+
this.ctx.protectedData.canvases.drawingCanvasLayerMaster.width =
|
|
49
|
+
this.ctx.protectedData.canvases.drawingCanvasLayerMaster.width;
|
|
50
|
+
// resize sphere canvas to original size
|
|
51
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.width =
|
|
52
|
+
this.ctx.protectedData.canvases.originCanvas.width;
|
|
53
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas.height =
|
|
54
|
+
this.ctx.protectedData.canvases.originCanvas.height;
|
|
55
|
+
return [
|
|
56
|
+
this.ctx.protectedData.canvases.drawingSphereCanvas,
|
|
57
|
+
this.ctx.protectedData.ctxes.drawingSphereCtx,
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
drawSphere(mouseX, mouseY, radius) {
|
|
61
|
+
const [canvas, ctx] = this.clearSphereCanvas();
|
|
62
|
+
this.drawSphereCore(ctx, mouseX, mouseY, radius, this.ctx.gui_states.fillColor);
|
|
63
|
+
this.ctx.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.ctx.nrrd_states.changedWidth, this.ctx.nrrd_states.changedHeight);
|
|
64
|
+
}
|
|
65
|
+
// ===== Sphere Wheel =====
|
|
66
|
+
configMouseSphereWheel() {
|
|
67
|
+
return (e) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
if (e.deltaY < 0) {
|
|
70
|
+
this.ctx.nrrd_states.sphereRadius += 1;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.ctx.nrrd_states.sphereRadius -= 1;
|
|
74
|
+
}
|
|
75
|
+
this.ctx.nrrd_states.sphereRadius = Math.max(1, Math.min(this.ctx.nrrd_states.sphereRadius, 50));
|
|
76
|
+
const mouseX = this.ctx.nrrd_states.sphereOrigin[this.ctx.protectedData.axis][0];
|
|
77
|
+
const mouseY = this.ctx.nrrd_states.sphereOrigin[this.ctx.protectedData.axis][1];
|
|
78
|
+
this.drawSphere(mouseX, mouseY, this.ctx.nrrd_states.sphereRadius);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// ===== Store Sphere Images =====
|
|
82
|
+
storeSphereImages(index, axis) {
|
|
83
|
+
this.callbacks.setEmptyCanvasSize(axis);
|
|
84
|
+
this.callbacks.drawImageOnEmptyImage(this.ctx.protectedData.canvases.drawingSphereCanvas);
|
|
85
|
+
const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
|
|
86
|
+
this.callbacks.storeImageToAxis(index, { x: [], y: [], z: [] }, imageData, axis);
|
|
87
|
+
}
|
|
88
|
+
// ===== Multi-View Sphere =====
|
|
89
|
+
drawSphereOnEachViews(decay, axis) {
|
|
90
|
+
this.setSphereCanvasSize(axis);
|
|
91
|
+
const mouseX = this.ctx.nrrd_states.sphereOrigin[axis][0];
|
|
92
|
+
const mouseY = this.ctx.nrrd_states.sphereOrigin[axis][1];
|
|
93
|
+
const originIndex = this.ctx.nrrd_states.sphereOrigin[axis][2];
|
|
94
|
+
const preIndex = originIndex - decay;
|
|
95
|
+
const nextIndex = originIndex + decay;
|
|
96
|
+
const ctx = this.ctx.protectedData.ctxes.drawingSphereCtx;
|
|
97
|
+
const canvas = this.ctx.protectedData.canvases.drawingSphereCanvas;
|
|
98
|
+
if (preIndex === nextIndex) {
|
|
99
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.ctx.nrrd_states.sphereRadius, this.ctx.gui_states.fillColor);
|
|
100
|
+
this.storeSphereImages(preIndex, axis);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.ctx.nrrd_states.sphereRadius - decay, this.ctx.gui_states.fillColor);
|
|
104
|
+
this.callbacks.drawImageOnEmptyImage(canvas);
|
|
105
|
+
this.storeSphereImages(preIndex, axis);
|
|
106
|
+
this.storeSphereImages(nextIndex, axis);
|
|
107
|
+
}
|
|
108
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
109
|
+
}
|
|
110
|
+
// ===== Calculator Sphere =====
|
|
111
|
+
getSpherePosition(position, axis) {
|
|
112
|
+
return {
|
|
113
|
+
x: position[axis][0],
|
|
114
|
+
y: position[axis][1],
|
|
115
|
+
z: position[axis][2],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
drawCalculatorSphereOnEachViews(axis) {
|
|
119
|
+
this.setSphereCanvasSize(axis);
|
|
120
|
+
const ctx = this.ctx.protectedData.ctxes.drawingSphereCtx;
|
|
121
|
+
const canvas = this.ctx.protectedData.canvases.drawingSphereCanvas;
|
|
122
|
+
const nrrd = this.ctx.nrrd_states;
|
|
123
|
+
const tumourPosition = nrrd.tumourSphereOrigin
|
|
124
|
+
? Object.assign(this.getSpherePosition(nrrd.tumourSphereOrigin, axis), { color: nrrd.tumourColor })
|
|
125
|
+
: null;
|
|
126
|
+
const skinPosition = nrrd.skinSphereOrigin
|
|
127
|
+
? Object.assign(this.getSpherePosition(nrrd.skinSphereOrigin, axis), { color: nrrd.skinColor })
|
|
128
|
+
: null;
|
|
129
|
+
const ribcagePosition = nrrd.ribSphereOrigin
|
|
130
|
+
? Object.assign(this.getSpherePosition(nrrd.ribSphereOrigin, axis), { color: nrrd.ribcageColor })
|
|
131
|
+
: null;
|
|
132
|
+
const nipplePosition = nrrd.nippleSphereOrigin
|
|
133
|
+
? Object.assign(this.getSpherePosition(nrrd.nippleSphereOrigin, axis), { color: nrrd.nippleColor })
|
|
134
|
+
: null;
|
|
135
|
+
const positionGroup = [];
|
|
136
|
+
if (tumourPosition)
|
|
137
|
+
positionGroup.push(tumourPosition);
|
|
138
|
+
if (skinPosition)
|
|
139
|
+
positionGroup.push(skinPosition);
|
|
140
|
+
if (ribcagePosition)
|
|
141
|
+
positionGroup.push(ribcagePosition);
|
|
142
|
+
if (nipplePosition)
|
|
143
|
+
positionGroup.push(nipplePosition);
|
|
144
|
+
const copyPosition = JSON.parse(JSON.stringify(positionGroup));
|
|
145
|
+
const rePositionGroup = [];
|
|
146
|
+
positionGroup.forEach((p) => {
|
|
147
|
+
const temp = [];
|
|
148
|
+
const sameIndex = [];
|
|
149
|
+
for (let i = 0; i < copyPosition.length; i++) {
|
|
150
|
+
if (p.z == copyPosition[i].z) {
|
|
151
|
+
temp.push(copyPosition[i]);
|
|
152
|
+
sameIndex.push(i);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
sameIndex.reverse();
|
|
156
|
+
sameIndex.forEach((i) => copyPosition.splice(i, 1));
|
|
157
|
+
if (temp.length > 0)
|
|
158
|
+
rePositionGroup.push(temp);
|
|
159
|
+
if (copyPosition.length == 0) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
rePositionGroup.forEach((group) => {
|
|
164
|
+
group.forEach((p) => {
|
|
165
|
+
this.drawSphereCore(ctx, p.x, p.y, nrrd.sphereRadius, p.color);
|
|
166
|
+
});
|
|
167
|
+
this.storeSphereImages(group[0].z, axis);
|
|
168
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
drawCalculatorSphere(radius) {
|
|
172
|
+
const [canvas, ctx] = this.clearSphereCanvas();
|
|
173
|
+
const nrrd = this.ctx.nrrd_states;
|
|
174
|
+
const axis = this.ctx.protectedData.axis;
|
|
175
|
+
if (nrrd.tumourSphereOrigin && nrrd.tumourSphereOrigin[axis][2] === nrrd.currentIndex) {
|
|
176
|
+
this.drawSphereCore(ctx, nrrd.tumourSphereOrigin[axis][0], nrrd.tumourSphereOrigin[axis][1], radius, nrrd.tumourColor);
|
|
177
|
+
}
|
|
178
|
+
if (nrrd.skinSphereOrigin && nrrd.skinSphereOrigin[axis][2] === nrrd.currentIndex) {
|
|
179
|
+
this.drawSphereCore(ctx, nrrd.skinSphereOrigin[axis][0], nrrd.skinSphereOrigin[axis][1], radius, nrrd.skinColor);
|
|
180
|
+
}
|
|
181
|
+
if (nrrd.ribSphereOrigin && nrrd.ribSphereOrigin[axis][2] === nrrd.currentIndex) {
|
|
182
|
+
this.drawSphereCore(ctx, nrrd.ribSphereOrigin[axis][0], nrrd.ribSphereOrigin[axis][1], radius, nrrd.ribcageColor);
|
|
183
|
+
}
|
|
184
|
+
if (nrrd.nippleSphereOrigin && nrrd.nippleSphereOrigin[axis][2] === nrrd.currentIndex) {
|
|
185
|
+
this.drawSphereCore(ctx, nrrd.nippleSphereOrigin[axis][0], nrrd.nippleSphereOrigin[axis][1], radius, nrrd.nippleColor);
|
|
186
|
+
}
|
|
187
|
+
this.ctx.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, nrrd.changedWidth, nrrd.changedHeight);
|
|
188
|
+
}
|
|
189
|
+
clearSpherePrintStoreImages() {
|
|
190
|
+
// No-op: sphere images are no longer stored in Phase 3 volumetric model
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=SphereTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SphereTool.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/SphereTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAsBtC,MAAM,OAAO,UAAW,SAAQ,QAAQ;IAGtC,YAAY,GAAgB,EAAE,SAA0B;QACtD,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,YAAY,CAAC,SAA0B;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,iCAAiC;IAEjC,mBAAmB,CAAC,IAAsB;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;QAClC,QAAQ,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE;YAC3C,KAAK,GAAG;gBACN,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC3E,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC5E,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC3E,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC5E,MAAM;YACR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C,aAAa,CACnB,CAAC;IACJ,CAAC;IAED,2BAA2B;QACzB,wEAAwE;IAC1E,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZoomTool - Mouse wheel zoom configuration
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.ts:
|
|
5
|
+
* - configMouseZoomWheel
|
|
6
|
+
*/
|
|
7
|
+
import { BaseTool } from "./BaseTool";
|
|
8
|
+
import type { ToolContext } from "./BaseTool";
|
|
9
|
+
export interface ZoomCallbacks {
|
|
10
|
+
resetPaintAreaUIPosition: (l?: number, t?: number) => void;
|
|
11
|
+
resizePaintArea: (moveDistance: number) => void;
|
|
12
|
+
setIsDrawFalse: (target: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class ZoomTool extends BaseTool {
|
|
15
|
+
private container;
|
|
16
|
+
private mainAreaContainer;
|
|
17
|
+
private callbacks;
|
|
18
|
+
constructor(ctx: ToolContext, container: HTMLElement, mainAreaContainer: HTMLDivElement, callbacks: ZoomCallbacks);
|
|
19
|
+
configMouseZoomWheel(): (e: WheelEvent) => void;
|
|
20
|
+
}
|