copper3d 2.2.3 → 3.0.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.
Files changed (111) hide show
  1. package/README.md +1056 -5
  2. package/dist/Scene/copperScene.d.ts +3 -0
  3. package/dist/Scene/copperScene.js +13 -0
  4. package/dist/Scene/copperScene.js.map +1 -1
  5. package/dist/Utils/segmentation/CommToolsData.d.ts +113 -11
  6. package/dist/Utils/segmentation/CommToolsData.js +314 -59
  7. package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
  8. package/dist/Utils/segmentation/DragOperator.d.ts +13 -7
  9. package/dist/Utils/segmentation/DragOperator.js +51 -165
  10. package/dist/Utils/segmentation/DragOperator.js.map +1 -1
  11. package/dist/Utils/segmentation/DrawToolCore.d.ts +56 -76
  12. package/dist/Utils/segmentation/DrawToolCore.js +383 -891
  13. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  14. package/dist/Utils/segmentation/NrrdTools.d.ts +277 -15
  15. package/dist/Utils/segmentation/NrrdTools.js +600 -234
  16. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  17. package/dist/Utils/segmentation/core/MaskVolume.d.ts +444 -0
  18. package/dist/Utils/segmentation/core/MaskVolume.js +1117 -0
  19. package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -0
  20. package/dist/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
  21. package/dist/Utils/segmentation/core/MigrationUtils.js +163 -0
  22. package/dist/Utils/segmentation/core/MigrationUtils.js.map +1 -0
  23. package/dist/Utils/segmentation/core/UndoManager.d.ts +47 -0
  24. package/dist/Utils/segmentation/core/UndoManager.js +86 -0
  25. package/dist/Utils/segmentation/core/UndoManager.js.map +1 -0
  26. package/dist/Utils/segmentation/core/index.d.ts +76 -0
  27. package/dist/Utils/segmentation/core/index.js +75 -0
  28. package/dist/Utils/segmentation/core/index.js.map +1 -0
  29. package/dist/Utils/segmentation/core/types.d.ts +106 -0
  30. package/dist/Utils/segmentation/core/types.js +98 -0
  31. package/dist/Utils/segmentation/core/types.js.map +1 -0
  32. package/dist/Utils/segmentation/coreTools/coreType.d.ts +55 -39
  33. package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
  34. package/dist/Utils/segmentation/coreTools/gui.d.ts +10 -17
  35. package/dist/Utils/segmentation/coreTools/gui.js +23 -27
  36. package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
  37. package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +145 -0
  38. package/dist/Utils/segmentation/eventRouter/EventRouter.js +375 -0
  39. package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -0
  40. package/dist/Utils/segmentation/eventRouter/index.d.ts +7 -0
  41. package/dist/Utils/segmentation/eventRouter/index.js +7 -0
  42. package/dist/Utils/segmentation/eventRouter/index.js.map +1 -0
  43. package/dist/Utils/segmentation/eventRouter/types.d.ts +70 -0
  44. package/dist/Utils/segmentation/eventRouter/types.js +7 -0
  45. package/dist/Utils/segmentation/eventRouter/types.js.map +1 -0
  46. package/dist/Utils/segmentation/tools/BaseTool.d.ts +28 -0
  47. package/dist/Utils/segmentation/tools/BaseTool.js +18 -0
  48. package/dist/Utils/segmentation/tools/BaseTool.js.map +1 -0
  49. package/dist/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
  50. package/dist/Utils/segmentation/tools/ContrastTool.js +118 -0
  51. package/dist/Utils/segmentation/tools/ContrastTool.js.map +1 -0
  52. package/dist/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
  53. package/dist/Utils/segmentation/tools/CrosshairTool.js +157 -0
  54. package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -0
  55. package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
  56. package/dist/Utils/segmentation/tools/DragSliceTool.js +170 -0
  57. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -0
  58. package/dist/Utils/segmentation/tools/EraserTool.d.ts +16 -0
  59. package/dist/Utils/segmentation/tools/EraserTool.js +92 -0
  60. package/dist/Utils/segmentation/tools/EraserTool.js.map +1 -0
  61. package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +62 -0
  62. package/dist/Utils/segmentation/tools/ImageStoreHelper.js +160 -0
  63. package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -0
  64. package/dist/Utils/segmentation/tools/SphereTool.d.ts +36 -0
  65. package/dist/Utils/segmentation/tools/SphereTool.js +193 -0
  66. package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -0
  67. package/dist/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
  68. package/dist/Utils/segmentation/tools/ZoomTool.js +60 -0
  69. package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -0
  70. package/dist/Utils/segmentation/tools/index.d.ts +22 -0
  71. package/dist/Utils/segmentation/tools/index.js +23 -0
  72. package/dist/Utils/segmentation/tools/index.js.map +1 -0
  73. package/dist/bundle.esm.js +4627 -1997
  74. package/dist/bundle.umd.js +4630 -1996
  75. package/dist/index.d.ts +5 -3
  76. package/dist/index.js +4 -2
  77. package/dist/index.js.map +1 -1
  78. package/dist/types/Renderer/copperRenderer.d.ts +1 -1
  79. package/dist/types/Renderer/copperRendererOnDemond.d.ts +1 -1
  80. package/dist/types/Scene/copperScene.d.ts +3 -0
  81. package/dist/types/Utils/segmentation/CommToolsData.d.ts +113 -11
  82. package/dist/types/Utils/segmentation/DragOperator.d.ts +13 -7
  83. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +56 -76
  84. package/dist/types/Utils/segmentation/NrrdTools.d.ts +277 -15
  85. package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +444 -0
  86. package/dist/types/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
  87. package/dist/types/Utils/segmentation/core/UndoManager.d.ts +47 -0
  88. package/dist/types/Utils/segmentation/core/index.d.ts +76 -0
  89. package/dist/types/Utils/segmentation/core/types.d.ts +106 -0
  90. package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +55 -39
  91. package/dist/types/Utils/segmentation/coreTools/gui.d.ts +10 -17
  92. package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +145 -0
  93. package/dist/types/Utils/segmentation/eventRouter/index.d.ts +7 -0
  94. package/dist/types/Utils/segmentation/eventRouter/types.d.ts +70 -0
  95. package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +28 -0
  96. package/dist/types/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
  97. package/dist/types/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
  98. package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
  99. package/dist/types/Utils/segmentation/tools/EraserTool.d.ts +16 -0
  100. package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +62 -0
  101. package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +36 -0
  102. package/dist/types/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
  103. package/dist/types/Utils/segmentation/tools/index.d.ts +22 -0
  104. package/dist/types/index.d.ts +5 -3
  105. package/dist/types/types/types.d.ts +3 -3
  106. package/dist/types/types.d.ts +3 -3
  107. package/package.json +1 -1
  108. package/dist/Utils/segmentation/coreTools/archive.d.ts +0 -1
  109. package/dist/Utils/segmentation/coreTools/archive.js +0 -23
  110. package/dist/Utils/segmentation/coreTools/archive.js.map +0 -1
  111. 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":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,OAAO,UAAW,SAAQ,QAAQ;IAEtC;;;;;OAKG;IACH,cAAc;QACZ,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,MAAc,EAAE,EAAE;;YACxD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI,CAAC,CAAC;YAC7D,2EAA2E;YAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAA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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,62 @@
1
+ /**
2
+ * ImageStoreHelper - Cross-axis image storage
3
+ *
4
+ * Extracted from DrawToolCore.ts:
5
+ * - storeAllImages / storeImageToAxis / storeImageToLayer / storeEachLayerImage
6
+ *
7
+ * Phase 3: MaskVolume is the sole storage backend. All IPaintImages params removed.
8
+ */
9
+ import { BaseTool } from "./BaseTool";
10
+ import type { ToolContext } from "./BaseTool";
11
+ export interface ImageStoreCallbacks {
12
+ setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
13
+ drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
14
+ }
15
+ export declare class ImageStoreHelper extends BaseTool {
16
+ private callbacks;
17
+ constructor(ctx: ToolContext, callbacks: ImageStoreCallbacks);
18
+ /**
19
+ * Get MaskVolume for a specific layer.
20
+ * Delegates to the volumes stored in protectedData.maskData.
21
+ *
22
+ * @param layer - "layer1", "layer2", or "layer3"
23
+ * @returns MaskVolume for the given layer, or layer1 as fallback
24
+ */
25
+ private getVolumeForLayer;
26
+ /**
27
+ * Get MaskVolume for the currently active layer.
28
+ */
29
+ private getCurrentVolume;
30
+ /**
31
+ * Get the canvas element for a specific layer.
32
+ */
33
+ private getCanvasForLayer;
34
+ /**
35
+ * Phase 3: No-op — MaskVolume storage happens in storeAllImages.
36
+ */
37
+ storeImageToAxis(_index: number, _imageData: ImageData, _axis?: "x" | "y" | "z"): void;
38
+ /**
39
+ * Retrieve the drawn image for a given axis and slice.
40
+ *
41
+ * Phase 3: Reads exclusively from MaskVolume.
42
+ */
43
+ filterDrawedImage(axis: "x" | "y" | "z", sliceIndex: number): {
44
+ index: number;
45
+ image: ImageData;
46
+ } | undefined;
47
+ /**
48
+ * Store all layer images for the current slice (cross-axis sync).
49
+ *
50
+ * Phase 2: Also writes into the current layer's MaskVolume.
51
+ */
52
+ storeAllImages(index: number, layer: string): void;
53
+ /**
54
+ * Store a single layer's canvas data to its MaskVolume.
55
+ * Reads from the individual layer canvas (not master) and uses RGB→channel reverse lookup.
56
+ */
57
+ storeEachLayerImage(index: number, layer: string): void;
58
+ /**
59
+ * Extract ImageData from canvas (MaskVolume storage is handled in storeAllImages).
60
+ */
61
+ storeImageToLayer(_index: number, canvas: HTMLCanvasElement): ImageData;
62
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * ImageStoreHelper - Cross-axis image storage
3
+ *
4
+ * Extracted from DrawToolCore.ts:
5
+ * - storeAllImages / storeImageToAxis / storeImageToLayer / storeEachLayerImage
6
+ *
7
+ * Phase 3: MaskVolume is the sole storage backend. All IPaintImages params removed.
8
+ */
9
+ import { BaseTool } from "./BaseTool";
10
+ export class ImageStoreHelper extends BaseTool {
11
+ constructor(ctx, callbacks) {
12
+ super(ctx);
13
+ this.callbacks = callbacks;
14
+ }
15
+ // ===== Volume Accessor Helpers (Phase 2) =====
16
+ /**
17
+ * Get MaskVolume for a specific layer.
18
+ * Delegates to the volumes stored in protectedData.maskData.
19
+ *
20
+ * @param layer - "layer1", "layer2", or "layer3"
21
+ * @returns MaskVolume for the given layer, or layer1 as fallback
22
+ */
23
+ getVolumeForLayer(layer) {
24
+ const { volumes } = this.ctx.protectedData.maskData;
25
+ const vol = volumes[layer];
26
+ if (vol)
27
+ return vol;
28
+ const firstLayerId = this.ctx.nrrd_states.layers[0];
29
+ console.warn(`ImageStoreHelper: unknown layer "${layer}", falling back to "${firstLayerId}"`);
30
+ return volumes[firstLayerId];
31
+ }
32
+ /**
33
+ * Get MaskVolume for the currently active layer.
34
+ */
35
+ getCurrentVolume() {
36
+ return this.getVolumeForLayer(this.ctx.gui_states.layer);
37
+ }
38
+ /**
39
+ * Get the canvas element for a specific layer.
40
+ */
41
+ getCanvasForLayer(layer) {
42
+ const target = this.ctx.protectedData.layerTargets.get(layer);
43
+ if (target)
44
+ return target.canvas;
45
+ return this.ctx.protectedData.canvases.drawingCanvasLayerMaster;
46
+ }
47
+ // ===== Store Image To Axis =====
48
+ /**
49
+ * Phase 3: No-op — MaskVolume storage happens in storeAllImages.
50
+ */
51
+ storeImageToAxis(_index, _imageData, _axis) {
52
+ // No-op: MaskVolume is the primary storage, updated in storeAllImages
53
+ }
54
+ /**
55
+ * Retrieve the drawn image for a given axis and slice.
56
+ *
57
+ * Phase 3: Reads exclusively from MaskVolume.
58
+ */
59
+ filterDrawedImage(axis, sliceIndex) {
60
+ try {
61
+ const volume = this.getCurrentVolume();
62
+ if (volume) {
63
+ const dims = volume.getDimensions();
64
+ const [w, h] = axis === 'z' ? [dims.width, dims.height]
65
+ : axis === 'y' ? [dims.width, dims.depth]
66
+ // Sagittal: width = depth (Z), height = height (Y)
67
+ : [dims.depth, dims.height];
68
+ const imageData = new ImageData(w, h);
69
+ const channelVis = this.ctx.gui_states.channelVisibility[this.ctx.gui_states.layer];
70
+ volume.renderLabelSliceInto(sliceIndex, axis, imageData, channelVis);
71
+ return { index: sliceIndex, image: imageData };
72
+ }
73
+ }
74
+ catch (err) {
75
+ console.warn(`filterDrawedImage: Failed to read slice ${sliceIndex} on ${axis}:`, err);
76
+ }
77
+ return undefined;
78
+ }
79
+ // ===== Store All Images (cross-axis sync) =====
80
+ /**
81
+ * Store all layer images for the current slice (cross-axis sync).
82
+ *
83
+ * Phase 2: Also writes into the current layer's MaskVolume.
84
+ */
85
+ storeAllImages(index, layer) {
86
+ const nrrd = this.ctx.nrrd_states;
87
+ // Read from the individual layer canvas (NOT master) to preserve layer isolation
88
+ const layerCanvas = this.getCanvasForLayer(layer);
89
+ if (!nrrd.loadMaskJson && !this.ctx.gui_states.sphere && !this.ctx.gui_states.calculator) {
90
+ this.callbacks.setEmptyCanvasSize();
91
+ this.callbacks.drawImageOnEmptyImage(layerCanvas);
92
+ }
93
+ const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
94
+ // Write label data into 1-channel MaskVolume with RGB→channel reverse lookup
95
+ try {
96
+ const volume = this.getVolumeForLayer(layer);
97
+ if (volume) {
98
+ const activeChannel = this.ctx.gui_states.activeChannel || 1;
99
+ // Phase 4 Fix: Pass channel visibility map to preserve hidden channels
100
+ const channelVis = this.ctx.gui_states.channelVisibility[layer];
101
+ volume.setSliceLabelsFromImageData(index, imageData, this.ctx.protectedData.axis, activeChannel, channelVis);
102
+ }
103
+ }
104
+ catch (err) {
105
+ // Volume not ready — skip
106
+ }
107
+ if (!nrrd.loadMaskJson && !this.ctx.gui_states.sphere && !this.ctx.gui_states.calculator) {
108
+ // Extract raw slice data from MaskVolume and notify parent
109
+ try {
110
+ const volume = this.getVolumeForLayer(layer);
111
+ if (volume) {
112
+ const axis = this.ctx.protectedData.axis;
113
+ const sliceIndex = this.ctx.nrrd_states.currentIndex;
114
+ const { data: sliceData, width, height } = volume.getSliceUint8(sliceIndex, axis);
115
+ const activeChannel = this.ctx.gui_states.activeChannel || 1;
116
+ this.ctx.nrrd_states.getMask(sliceData, layer, activeChannel, sliceIndex, axis, width, height, this.ctx.nrrd_states.clearAllFlag);
117
+ }
118
+ }
119
+ catch (_a) {
120
+ // Volume not ready — skip notification
121
+ }
122
+ }
123
+ }
124
+ // ===== Store Per-Layer Images =====
125
+ /**
126
+ * Store a single layer's canvas data to its MaskVolume.
127
+ * Reads from the individual layer canvas (not master) and uses RGB→channel reverse lookup.
128
+ */
129
+ storeEachLayerImage(index, layer) {
130
+ const layerCanvas = this.getCanvasForLayer(layer);
131
+ this.callbacks.setEmptyCanvasSize();
132
+ this.callbacks.drawImageOnEmptyImage(layerCanvas);
133
+ const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
134
+ try {
135
+ const volume = this.getVolumeForLayer(layer);
136
+ if (volume) {
137
+ const activeChannel = this.ctx.gui_states.activeChannel || 1;
138
+ // Phase 4 Fix: Pass channel visibility map to preserve hidden channels
139
+ const channelVis = this.ctx.gui_states.channelVisibility[layer];
140
+ volume.setSliceLabelsFromImageData(index, imageData, this.ctx.protectedData.axis, activeChannel, channelVis);
141
+ }
142
+ }
143
+ catch (_a) {
144
+ // Volume not ready — skip
145
+ }
146
+ }
147
+ /**
148
+ * Extract ImageData from canvas (MaskVolume storage is handled in storeAllImages).
149
+ */
150
+ storeImageToLayer(_index, canvas) {
151
+ if (!this.ctx.nrrd_states.loadMaskJson) {
152
+ this.callbacks.setEmptyCanvasSize();
153
+ this.callbacks.drawImageOnEmptyImage(canvas);
154
+ }
155
+ const imageData = this.ctx.protectedData.ctxes.emptyCtx.getImageData(0, 0, this.ctx.protectedData.canvases.emptyCanvas.width, this.ctx.protectedData.canvases.emptyCanvas.height);
156
+ // No longer stores to paintedImages - MaskVolume is primary storage
157
+ return imageData;
158
+ }
159
+ }
160
+ //# sourceMappingURL=ImageStoreHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageStoreHelper.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/ImageStoreHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAG5C,YAAY,GAAgB,EAAE,SAA8B;QAC1D,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,gDAAgD;IAEhD;;;;;;OAMG;IACK,iBAAiB,CAAC,KAAa;QACrC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC;QACpD,MAAM,GAAG,GAAG,O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C,IAAI,EAAE,aAAa,EAAE,UAAU,CACzE,CAAC;aACH;SACF;QAAC,WAAM;YACN,0BAA0B;SAC3B;IACH,CAAC;IAED;;OAEG;IACH,iBAAiB,CACf,MAAc,EACd,MAAyB;QAEzB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,YAAY,EAAE;YACtC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;YACpC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;SAC9C;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAClE,CAAC,EACD,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EACjD,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CACnD,CAAC;QACF,oEAAoE;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;CAGF"}
@@ -0,0 +1,36 @@
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
+ /**
14
+ * Callbacks that DrawToolCore must provide for sphere operations.
15
+ */
16
+ export interface SphereCallbacks {
17
+ setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
18
+ drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
19
+ storeImageToAxis: (index: number, imageData: ImageData, axis?: "x" | "y" | "z") => void;
20
+ }
21
+ export declare class SphereTool extends BaseTool {
22
+ private callbacks;
23
+ constructor(ctx: ToolContext, callbacks: SphereCallbacks);
24
+ setCallbacks(callbacks: SphereCallbacks): void;
25
+ setSphereCanvasSize(axis?: "x" | "y" | "z"): void;
26
+ drawSphereCore(ctx: CanvasRenderingContext2D, x: number, y: number, radius: number, color: string): void;
27
+ clearSphereCanvas(): [HTMLCanvasElement, CanvasRenderingContext2D];
28
+ drawSphere(mouseX: number, mouseY: number, radius: number): void;
29
+ configMouseSphereWheel(): (e: WheelEvent) => void;
30
+ private storeSphereImages;
31
+ drawSphereOnEachViews(decay: number, axis: "x" | "y" | "z"): void;
32
+ private getSpherePosition;
33
+ drawCalculatorSphereOnEachViews(axis: "x" | "y" | "z"): void;
34
+ drawCalculatorSphere(radius: number): void;
35
+ clearSpherePrintStoreImages(): void;
36
+ }
@@ -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, 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
+ //# sourceMapp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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
+ }