copper3d 3.0.1 → 3.1.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.
Files changed (134) hide show
  1. package/README.md +197 -875
  2. package/dist/Utils/segmentation/CanvasState.d.ts +31 -0
  3. package/dist/Utils/segmentation/CanvasState.js +167 -0
  4. package/dist/Utils/segmentation/CanvasState.js.map +1 -0
  5. package/dist/Utils/segmentation/DragOperator.d.ts +10 -2
  6. package/dist/Utils/segmentation/DragOperator.js +16 -8
  7. package/dist/Utils/segmentation/DragOperator.js.map +1 -1
  8. package/dist/Utils/segmentation/DrawToolCore.d.ts +64 -35
  9. package/dist/Utils/segmentation/DrawToolCore.js +332 -584
  10. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  11. package/dist/Utils/segmentation/NrrdTools.d.ts +117 -353
  12. package/dist/Utils/segmentation/NrrdTools.js +622 -1081
  13. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  14. package/dist/Utils/segmentation/RenderingUtils.d.ts +73 -0
  15. package/dist/Utils/segmentation/RenderingUtils.js +180 -0
  16. package/dist/Utils/segmentation/RenderingUtils.js.map +1 -0
  17. package/dist/Utils/segmentation/core/MaskVolume.js +23 -2
  18. package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -1
  19. package/dist/Utils/segmentation/core/UndoManager.d.ts +1 -1
  20. package/dist/Utils/segmentation/core/UndoManager.js +1 -1
  21. package/dist/Utils/segmentation/core/index.d.ts +1 -3
  22. package/dist/Utils/segmentation/core/index.js +0 -1
  23. package/dist/Utils/segmentation/core/index.js.map +1 -1
  24. package/dist/Utils/segmentation/core/types.d.ts +384 -0
  25. package/dist/Utils/segmentation/core/types.js +25 -24
  26. package/dist/Utils/segmentation/core/types.js.map +1 -1
  27. package/dist/Utils/segmentation/coreTools/GuiState.d.ts +22 -0
  28. package/dist/Utils/segmentation/coreTools/GuiState.js +48 -0
  29. package/dist/Utils/segmentation/coreTools/GuiState.js.map +1 -0
  30. package/dist/Utils/segmentation/coreTools/NrrdState.d.ts +25 -0
  31. package/dist/Utils/segmentation/coreTools/NrrdState.js +85 -0
  32. package/dist/Utils/segmentation/coreTools/NrrdState.js.map +1 -0
  33. package/dist/Utils/segmentation/coreTools/divControlTools.d.ts +1 -1
  34. package/dist/Utils/segmentation/coreTools/divControlTools.js +1 -1
  35. package/dist/Utils/segmentation/coreTools/divControlTools.js.map +1 -1
  36. package/dist/Utils/segmentation/coreTools/gui.d.ts +12 -12
  37. package/dist/Utils/segmentation/coreTools/gui.js +81 -107
  38. package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
  39. package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -1
  40. package/dist/Utils/segmentation/eventRouter/EventRouter.js +15 -10
  41. package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -1
  42. package/dist/Utils/segmentation/eventRouter/types.d.ts +3 -3
  43. package/dist/Utils/segmentation/tools/BaseTool.d.ts +8 -5
  44. package/dist/Utils/segmentation/tools/BaseTool.js +1 -2
  45. package/dist/Utils/segmentation/tools/BaseTool.js.map +1 -1
  46. package/dist/Utils/segmentation/tools/ContrastTool.d.ts +3 -6
  47. package/dist/Utils/segmentation/tools/ContrastTool.js.map +1 -1
  48. package/dist/Utils/segmentation/tools/CrosshairTool.d.ts +11 -1
  49. package/dist/Utils/segmentation/tools/CrosshairTool.js +50 -25
  50. package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -1
  51. package/dist/Utils/segmentation/tools/DataLoader.d.ts +33 -0
  52. package/dist/Utils/segmentation/tools/DataLoader.js +159 -0
  53. package/dist/Utils/segmentation/tools/DataLoader.js.map +1 -0
  54. package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +3 -10
  55. package/dist/Utils/segmentation/tools/DragSliceTool.js +63 -53
  56. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
  57. package/dist/Utils/segmentation/tools/DrawingTool.d.ts +85 -0
  58. package/dist/Utils/segmentation/tools/DrawingTool.js +270 -0
  59. package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -0
  60. package/dist/Utils/segmentation/tools/EraserTool.js +8 -8
  61. package/dist/Utils/segmentation/tools/EraserTool.js.map +1 -1
  62. package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +13 -33
  63. package/dist/Utils/segmentation/tools/ImageStoreHelper.js +39 -82
  64. package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -1
  65. package/dist/Utils/segmentation/tools/LayerChannelManager.d.ts +52 -0
  66. package/dist/Utils/segmentation/tools/LayerChannelManager.js +175 -0
  67. package/dist/Utils/segmentation/tools/LayerChannelManager.js.map +1 -0
  68. package/dist/Utils/segmentation/tools/PanTool.d.ts +47 -0
  69. package/dist/Utils/segmentation/tools/PanTool.js +90 -0
  70. package/dist/Utils/segmentation/tools/PanTool.js.map +1 -0
  71. package/dist/Utils/segmentation/tools/SliceRenderPipeline.d.ts +80 -0
  72. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +355 -0
  73. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -0
  74. package/dist/Utils/segmentation/tools/SphereTool.d.ts +223 -10
  75. package/dist/Utils/segmentation/tools/SphereTool.js +512 -47
  76. package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -1
  77. package/dist/Utils/segmentation/tools/ToolHost.d.ts +74 -0
  78. package/dist/Utils/segmentation/tools/ToolHost.js +10 -0
  79. package/dist/Utils/segmentation/tools/ToolHost.js.map +1 -0
  80. package/dist/Utils/segmentation/tools/ZoomTool.d.ts +2 -6
  81. package/dist/Utils/segmentation/tools/ZoomTool.js +3 -3
  82. package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -1
  83. package/dist/Utils/segmentation/tools/index.d.ts +8 -6
  84. package/dist/Utils/segmentation/tools/index.js +10 -1
  85. package/dist/Utils/segmentation/tools/index.js.map +1 -1
  86. package/dist/Utils/workers/reformatSaveDataWorker.d.ts +1 -1
  87. package/dist/bundle.esm.js +3729 -3017
  88. package/dist/bundle.umd.js +3729 -3017
  89. package/dist/index.d.ts +6 -3
  90. package/dist/index.js +1 -1
  91. package/dist/index.js.map +1 -1
  92. package/dist/types/Utils/segmentation/CanvasState.d.ts +31 -0
  93. package/dist/types/Utils/segmentation/DragOperator.d.ts +10 -2
  94. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +64 -35
  95. package/dist/types/Utils/segmentation/NrrdTools.d.ts +117 -353
  96. package/dist/types/Utils/segmentation/RenderingUtils.d.ts +73 -0
  97. package/dist/types/Utils/segmentation/core/UndoManager.d.ts +1 -1
  98. package/dist/types/Utils/segmentation/core/index.d.ts +1 -3
  99. package/dist/types/Utils/segmentation/core/types.d.ts +384 -0
  100. package/dist/types/Utils/segmentation/coreTools/GuiState.d.ts +22 -0
  101. package/dist/types/Utils/segmentation/coreTools/NrrdState.d.ts +25 -0
  102. package/dist/types/Utils/segmentation/coreTools/divControlTools.d.ts +1 -1
  103. package/dist/types/Utils/segmentation/coreTools/gui.d.ts +12 -12
  104. package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -1
  105. package/dist/types/Utils/segmentation/eventRouter/types.d.ts +3 -3
  106. package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +8 -5
  107. package/dist/types/Utils/segmentation/tools/ContrastTool.d.ts +3 -6
  108. package/dist/types/Utils/segmentation/tools/CrosshairTool.d.ts +11 -1
  109. package/dist/types/Utils/segmentation/tools/DataLoader.d.ts +33 -0
  110. package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +3 -10
  111. package/dist/types/Utils/segmentation/tools/DrawingTool.d.ts +85 -0
  112. package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +13 -33
  113. package/dist/types/Utils/segmentation/tools/LayerChannelManager.d.ts +52 -0
  114. package/dist/types/Utils/segmentation/tools/PanTool.d.ts +47 -0
  115. package/dist/types/Utils/segmentation/tools/SliceRenderPipeline.d.ts +80 -0
  116. package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +223 -10
  117. package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +74 -0
  118. package/dist/types/Utils/segmentation/tools/ZoomTool.d.ts +2 -6
  119. package/dist/types/Utils/segmentation/tools/index.d.ts +8 -6
  120. package/dist/types/Utils/workers/reformatSaveDataWorker.d.ts +1 -1
  121. package/dist/types/index.d.ts +6 -3
  122. package/package.json +1 -1
  123. package/dist/Utils/segmentation/CommToolsData.d.ts +0 -177
  124. package/dist/Utils/segmentation/CommToolsData.js +0 -548
  125. package/dist/Utils/segmentation/CommToolsData.js.map +0 -1
  126. package/dist/Utils/segmentation/core/MigrationUtils.d.ts +0 -97
  127. package/dist/Utils/segmentation/core/MigrationUtils.js +0 -163
  128. package/dist/Utils/segmentation/core/MigrationUtils.js.map +0 -1
  129. package/dist/Utils/segmentation/coreTools/coreType.d.ts +0 -363
  130. package/dist/Utils/segmentation/coreTools/coreType.js +0 -3
  131. package/dist/Utils/segmentation/coreTools/coreType.js.map +0 -1
  132. package/dist/types/Utils/segmentation/CommToolsData.d.ts +0 -177
  133. package/dist/types/Utils/segmentation/core/MigrationUtils.d.ts +0 -97
  134. package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +0 -363
@@ -23,16 +23,17 @@ export class DragSliceTool extends BaseTool {
23
23
  updateIndex(move) {
24
24
  let sliceModifyNum = 0;
25
25
  let contrastModifyNum = 0;
26
- const nrrd = this.ctx.nrrd_states;
27
- if (nrrd.showContrast) {
26
+ const view = this.ctx.nrrd_states.view;
27
+ const image = this.ctx.nrrd_states.image;
28
+ if (view.showContrast) {
28
29
  contrastModifyNum = move % this.ctx.protectedData.displaySlices.length;
29
- nrrd.contrastNum += contrastModifyNum;
30
+ view.contrastNum += contrastModifyNum;
30
31
  if (move > 0) {
31
- if (nrrd.currentIndex <= nrrd.maxIndex) {
32
+ if (view.currentSliceIndex <= view.maxIndex) {
32
33
  sliceModifyNum = Math.floor(move / this.ctx.protectedData.displaySlices.length);
33
- if (nrrd.contrastNum > this.ctx.protectedData.displaySlices.length - 1) {
34
+ if (view.contrastNum > this.ctx.protectedData.displaySlices.length - 1) {
34
35
  sliceModifyNum += 1;
35
- nrrd.contrastNum -= this.ctx.protectedData.displaySlices.length;
36
+ view.contrastNum -= this.ctx.protectedData.displaySlices.length;
36
37
  }
37
38
  }
38
39
  else {
@@ -41,8 +42,8 @@ export class DragSliceTool extends BaseTool {
41
42
  }
42
43
  else {
43
44
  sliceModifyNum = Math.ceil(move / this.ctx.protectedData.displaySlices.length);
44
- if (nrrd.contrastNum < 0) {
45
- nrrd.contrastNum += this.ctx.protectedData.displaySlices.length;
45
+ if (view.contrastNum < 0) {
46
+ view.contrastNum += this.ctx.protectedData.displaySlices.length;
46
47
  sliceModifyNum -= 1;
47
48
  }
48
49
  }
@@ -50,65 +51,74 @@ export class DragSliceTool extends BaseTool {
50
51
  else {
51
52
  sliceModifyNum = move;
52
53
  }
53
- let newIndex = nrrd.currentIndex + sliceModifyNum;
54
- if (newIndex != nrrd.currentIndex || nrrd.showContrast) {
55
- if (newIndex > nrrd.maxIndex) {
56
- newIndex = nrrd.maxIndex;
57
- nrrd.contrastNum = this.ctx.protectedData.displaySlices.length - 1;
54
+ let newIndex = view.currentSliceIndex + sliceModifyNum;
55
+ if (newIndex != view.currentSliceIndex || view.showContrast) {
56
+ if (newIndex > view.maxIndex) {
57
+ newIndex = view.maxIndex;
58
+ view.contrastNum = this.ctx.protectedData.displaySlices.length - 1;
58
59
  }
59
- else if (newIndex < nrrd.minIndex) {
60
- newIndex = nrrd.minIndex;
61
- nrrd.contrastNum = 0;
60
+ else if (newIndex < view.minIndex) {
61
+ newIndex = view.minIndex;
62
+ view.contrastNum = 0;
62
63
  }
63
64
  else {
64
- this.ctx.protectedData.mainPreSlices.index = newIndex * nrrd.RSARatio;
65
+ this.ctx.protectedData.mainPreSlices.index = newIndex * image.RSARatio;
65
66
  this.callbacks.setSyncsliceNum();
66
67
  let isSameIndex = true;
67
- if (newIndex != nrrd.currentIndex) {
68
- nrrd.switchSliceFlag = true;
68
+ if (newIndex != view.currentSliceIndex) {
69
+ view.switchSliceFlag = true;
69
70
  isSameIndex = false;
70
71
  }
71
72
  this.cleanCanvases(isSameIndex);
72
- if (nrrd.changedWidth === 0) {
73
- nrrd.changedWidth = nrrd.originWidth;
74
- nrrd.changedHeight = nrrd.originHeight;
73
+ if (view.changedWidth === 0) {
74
+ view.changedWidth = image.originWidth;
75
+ view.changedHeight = image.originHeight;
75
76
  }
76
77
  const needToUpdateSlice = this.updateCurrentContrastSlice();
77
78
  needToUpdateSlice.repaint.call(needToUpdateSlice);
78
- nrrd.currentIndex = newIndex;
79
+ view.currentSliceIndex = newIndex;
79
80
  this.drawDragSlice(needToUpdateSlice.canvas);
80
81
  }
81
- nrrd.oldIndex = newIndex * nrrd.RSARatio;
82
- this.updateShowNumDiv(nrrd.contrastNum);
82
+ view.preSliceIndex = newIndex * image.RSARatio;
83
+ this.updateShowNumDiv(view.contrastNum);
83
84
  }
84
85
  }
85
86
  // ===== Draw Drag Slice =====
86
87
  drawDragSlice(canvas) {
87
- const nrrd = this.ctx.nrrd_states;
88
+ var _a, _b;
89
+ const view = this.ctx.nrrd_states.view;
88
90
  // Draw base image (CT/MRI scan)
89
91
  this.ctx.protectedData.ctxes.displayCtx.save();
90
92
  this.callbacks.flipDisplayImageByAxis();
91
- this.ctx.protectedData.ctxes.displayCtx.drawImage(canvas, 0, 0, nrrd.changedWidth, nrrd.changedHeight);
93
+ this.ctx.protectedData.ctxes.displayCtx.drawImage(canvas, 0, 0, view.changedWidth, view.changedHeight);
92
94
  this.ctx.protectedData.ctxes.displayCtx.restore();
93
95
  // Phase 3: Draw ALL layers from MaskVolume (multi-layer compositing)
94
- if (nrrd.switchSliceFlag) {
95
- const axis = this.ctx.protectedData.axis;
96
- const sliceIndex = nrrd.currentIndex;
97
- // Get a single reusable buffer — shared across all layer renders
98
- const buffer = this.callbacks.getOrCreateSliceBuffer(axis);
99
- if (buffer) {
100
- const w = nrrd.changedWidth;
101
- const h = nrrd.changedHeight;
102
- for (const layerId of this.ctx.nrrd_states.layers) {
103
- const target = this.ctx.protectedData.layerTargets.get(layerId);
104
- if (target) {
105
- this.callbacks.renderSliceToCanvas(layerId, axis, sliceIndex, buffer, target.ctx, w, h);
96
+ // Skip layer mask rendering when sphere mode is active —
97
+ // layer masks should remain hidden until the user exits sphere mode.
98
+ if (view.switchSliceFlag) {
99
+ if (!this.ctx.gui_states.mode.sphere) {
100
+ const axis = this.ctx.protectedData.axis;
101
+ const sliceIndex = view.currentSliceIndex;
102
+ // Get a single reusable buffer — shared across all layer renders
103
+ const buffer = this.callbacks.getOrCreateSliceBuffer(axis);
104
+ if (buffer) {
105
+ const w = view.changedWidth;
106
+ const h = view.changedHeight;
107
+ for (const layerId of this.ctx.nrrd_states.image.layers) {
108
+ const target = this.ctx.protectedData.layerTargets.get(layerId);
109
+ if (target) {
110
+ this.callbacks.renderSliceToCanvas(layerId, axis, sliceIndex, buffer, target.ctx, w, h);
111
+ }
106
112
  }
107
113
  }
114
+ // Composite all layers to master canvas
115
+ this.compositeAllLayers();
108
116
  }
109
- // Composite all layers to master canvas
110
- this.compositeAllLayers();
111
- nrrd.switchSliceFlag = false;
117
+ // Refresh sphere overlay from volume for the new slice
118
+ if (this.ctx.gui_states.mode.sphere) {
119
+ (_b = (_a = this.callbacks).refreshSphereOverlay) === null || _b === void 0 ? void 0 : _b.call(_a);
120
+ }
121
+ view.switchSliceFlag = false;
112
122
  }
113
123
  }
114
124
  /**
@@ -116,12 +126,12 @@ export class DragSliceTool extends BaseTool {
116
126
  */
117
127
  compositeAllLayers() {
118
128
  const masterCtx = this.ctx.protectedData.ctxes.drawingLayerMasterCtx;
119
- const width = this.ctx.nrrd_states.changedWidth;
120
- const height = this.ctx.nrrd_states.changedHeight;
129
+ const width = this.ctx.nrrd_states.view.changedWidth;
130
+ const height = this.ctx.nrrd_states.view.changedHeight;
121
131
  masterCtx.clearRect(0, 0, width, height);
122
132
  // Master stores full-alpha composite; globalAlpha applied in start() render loop.
123
- for (const layerId of this.ctx.nrrd_states.layers) {
124
- if (!this.ctx.gui_states.layerVisibility[layerId])
133
+ for (const layerId of this.ctx.nrrd_states.image.layers) {
134
+ if (!this.ctx.gui_states.layerChannel.layerVisibility[layerId])
125
135
  continue;
126
136
  const target = this.ctx.protectedData.layerTargets.get(layerId);
127
137
  if (target)
@@ -149,21 +159,21 @@ export class DragSliceTool extends BaseTool {
149
159
  // ===== UI Updates =====
150
160
  updateShowNumDiv(contrastNum) {
151
161
  if (this.ctx.protectedData.mainPreSlices) {
152
- const nrrd = this.ctx.nrrd_states;
153
- if (nrrd.currentIndex > nrrd.maxIndex) {
154
- nrrd.currentIndex = nrrd.maxIndex;
162
+ const view = this.ctx.nrrd_states.view;
163
+ if (view.currentSliceIndex > view.maxIndex) {
164
+ view.currentSliceIndex = view.maxIndex;
155
165
  }
156
- if (nrrd.showContrast) {
157
- this.showDragNumberDiv.innerHTML = `ContrastNum: ${contrastNum}/${this.ctx.protectedData.displaySlices.length - 1} SliceNum: ${nrrd.currentIndex}/${nrrd.maxIndex}`;
166
+ if (view.showContrast) {
167
+ this.showDragNumberDiv.innerHTML = `ContrastNum: ${contrastNum}/${this.ctx.protectedData.displaySlices.length - 1} SliceNum: ${view.currentSliceIndex}/${view.maxIndex}`;
158
168
  }
159
169
  else {
160
- this.showDragNumberDiv.innerHTML = `SliceNum: ${nrrd.currentIndex}/${nrrd.maxIndex}`;
170
+ this.showDragNumberDiv.innerHTML = `SliceNum: ${view.currentSliceIndex}/${view.maxIndex}`;
161
171
  }
162
172
  }
163
173
  }
164
174
  updateCurrentContrastSlice() {
165
175
  this.ctx.protectedData.currentShowingSlice =
166
- this.ctx.protectedData.displaySlices[this.ctx.nrrd_states.contrastNum];
176
+ this.ctx.protectedData.displaySlices[this.ctx.nrrd_states.view.contrastNum];
167
177
  return this.ctx.protectedData.currentShowingSlice;
168
178
  }
169
179
  }
@@ -1 +1 @@
1
- {"version":3,"file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C,QAAQ,CAAC;aACxC;YACD,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,gBAAgB,WAAW,IAAI,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAC9G,cAAc,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;aAC3D;iBAAM;gBACL,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,aAAa,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;aAC3F;SACF;IACH,CAAC;IAED,0BAA0B;QACxB,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,mBAAmB;YACxC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,mBAAmB,CAAC;IACpD,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * DrawingTool - Pencil/Brush/Eraser drawing on canvas layers
3
+ *
4
+ * Extracted from DrawToolCore.paintOnCanvas() closure (Phase 3).
5
+ * Handles left-click drawing operations: pencil stroke + fill, brush strokes,
6
+ * eraser, and undo snapshot capture/push.
7
+ */
8
+ import { BaseTool } from "./BaseTool";
9
+ import type { ToolContext } from "./BaseTool";
10
+ import type { DrawingHostDeps } from "./ToolHost";
11
+ export declare class DrawingTool extends BaseTool {
12
+ /** Left mouse button currently held (draw mode) */
13
+ private leftClicked;
14
+ /** True while actively painting (between pointerdown and pointerup) */
15
+ private isPainting;
16
+ /** Accumulated pencil stroke points for fill-on-release */
17
+ private drawingLines;
18
+ /** Eraser arc function, assigned once per paintOnCanvas() call */
19
+ private clearArcFn;
20
+ /** Snapshot of the active layer's slice captured on mouse-down (before drawing) */
21
+ private preDrawSlice;
22
+ private preDrawAxis;
23
+ private preDrawSliceIndex;
24
+ private callbacks;
25
+ constructor(ctx: ToolContext, callbacks: DrawingHostDeps);
26
+ /** Whether a draw operation is currently active */
27
+ get isActive(): boolean;
28
+ /** Whether paint strokes are being recorded */
29
+ get painting(): boolean;
30
+ /**
31
+ * Reset drawing state. Called at start of each paintOnCanvas() cycle.
32
+ * @param clearArcFn - Eraser function for this paint cycle
33
+ */
34
+ reset(clearArcFn: (x: number, y: number, size: number) => void): void;
35
+ /**
36
+ * Called on left-click pointerdown in draw mode.
37
+ * Sets up drawing state, cursor, undo snapshot, and start position.
38
+ */
39
+ onPointerDown(e: MouseEvent): void;
40
+ /**
41
+ * Called on pointermove during an active drawing operation.
42
+ * Handles eraser clearing or brush/pencil stroke accumulation.
43
+ */
44
+ onPointerMove(e: MouseEvent): void;
45
+ /**
46
+ * Called on pointerup in draw mode.
47
+ * Completes stroke, fills pencil path, syncs volume, pushes undo delta.
48
+ */
49
+ onPointerUp(_e: MouseEvent): void;
50
+ /**
51
+ * Called on pointerleave during drawing.
52
+ * Resets painting state and cleans up leftClicked.
53
+ * @returns true if drawing was in progress when leave occurred
54
+ */
55
+ onPointerLeave(): boolean;
56
+ /**
57
+ * Create a self-managing mouseover/mouseout/mousemove handler
58
+ * 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
+ createBrushTrackingHandler(): (e: MouseEvent) => void;
66
+ /**
67
+ * 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
+ */
71
+ renderBrushPreview(ctx: CanvasRenderingContext2D, width: number, height: number): void;
72
+ /** Capture pre-draw slice snapshot for undo */
73
+ private capturePreDrawSnapshot;
74
+ /** Push delta to UndoManager after drawing completes */
75
+ private pushUndoDelta;
76
+ /**
77
+ * Redraws persisted layer data onto ctx before new pencil fill.
78
+ * Extracted from DrawToolCore.
79
+ */
80
+ private redrawPreviousImageToLayerCtx;
81
+ /** Draw a line segment on a layer canvas */
82
+ private drawLinesOnLayer;
83
+ /** Paint a segment on the current layer canvas and composite to master */
84
+ private paintOnCanvasLayer;
85
+ }
@@ -0,0 +1,270 @@
1
+ /**
2
+ * DrawingTool - Pencil/Brush/Eraser drawing on canvas layers
3
+ *
4
+ * Extracted from DrawToolCore.paintOnCanvas() closure (Phase 3).
5
+ * Handles left-click drawing operations: pencil stroke + fill, brush strokes,
6
+ * eraser, and undo snapshot capture/push.
7
+ */
8
+ import { BaseTool } from "./BaseTool";
9
+ import { switchEraserSize } from "../../utils";
10
+ export class DrawingTool extends BaseTool {
11
+ constructor(ctx, callbacks) {
12
+ super(ctx);
13
+ /** Left mouse button currently held (draw mode) */
14
+ this.leftClicked = false;
15
+ /** True while actively painting (between pointerdown and pointerup) */
16
+ this.isPainting = false;
17
+ /** Accumulated pencil stroke points for fill-on-release */
18
+ this.drawingLines = [];
19
+ /** Eraser arc function, assigned once per paintOnCanvas() call */
20
+ this.clearArcFn = null;
21
+ /** Snapshot of the active layer's slice captured on mouse-down (before drawing) */
22
+ this.preDrawSlice = null;
23
+ this.preDrawAxis = "z";
24
+ this.preDrawSliceIndex = 0;
25
+ this.callbacks = callbacks;
26
+ }
27
+ /** Whether a draw operation is currently active */
28
+ get isActive() {
29
+ return this.leftClicked;
30
+ }
31
+ /** Whether paint strokes are being recorded */
32
+ get painting() {
33
+ return this.isPainting;
34
+ }
35
+ /**
36
+ * Reset drawing state. Called at start of each paintOnCanvas() cycle.
37
+ * @param clearArcFn - Eraser function for this paint cycle
38
+ */
39
+ reset(clearArcFn) {
40
+ this.leftClicked = false;
41
+ this.isPainting = false;
42
+ this.drawingLines = [];
43
+ this.clearArcFn = clearArcFn;
44
+ }
45
+ /**
46
+ * Called on left-click pointerdown in draw mode.
47
+ * Sets up drawing state, cursor, undo snapshot, and start position.
48
+ */
49
+ onPointerDown(e) {
50
+ this.leftClicked = true;
51
+ this.drawingLines = [];
52
+ this.isPainting = true;
53
+ this.ctx.protectedData.isDrawing = true;
54
+ // Set cursor based on mode
55
+ if (this.ctx.gui_states.mode.eraser) {
56
+ const urls = this.callbacks.getEraserUrls();
57
+ this.ctx.protectedData.canvases.drawingCanvas.style.cursor =
58
+ urls.length > 0
59
+ ? switchEraserSize(this.ctx.gui_states.drawing.brushAndEraserSize, urls)
60
+ : switchEraserSize(this.ctx.gui_states.drawing.brushAndEraserSize);
61
+ }
62
+ else {
63
+ this.ctx.protectedData.canvases.drawingCanvas.style.cursor =
64
+ this.ctx.gui_states.viewConfig.defaultPaintCursor;
65
+ }
66
+ // Record draw start position
67
+ this.ctx.nrrd_states.interaction.drawStartPos.x = e.offsetX;
68
+ this.ctx.nrrd_states.interaction.drawStartPos.y = e.offsetY;
69
+ // Capture pre-draw slice snapshot for undo
70
+ this.capturePreDrawSnapshot();
71
+ }
72
+ /**
73
+ * Called on pointermove during an active drawing operation.
74
+ * Handles eraser clearing or brush/pencil stroke accumulation.
75
+ */
76
+ onPointerMove(e) {
77
+ var _a;
78
+ this.ctx.protectedData.isDrawing = true;
79
+ if (this.isPainting) {
80
+ if (this.ctx.gui_states.mode.eraser) {
81
+ this.ctx.nrrd_states.flags.stepClear = 1;
82
+ (_a = this.clearArcFn) === null || _a === void 0 ? void 0 : _a.call(this, e.offsetX, e.offsetY, this.ctx.gui_states.drawing.brushAndEraserSize);
83
+ }
84
+ else {
85
+ this.drawingLines.push({ x: e.offsetX, y: e.offsetY });
86
+ this.paintOnCanvasLayer(e.offsetX, e.offsetY);
87
+ }
88
+ }
89
+ }
90
+ /**
91
+ * Called on pointerup in draw mode.
92
+ * Completes stroke, fills pencil path, syncs volume, pushes undo delta.
93
+ */
94
+ onPointerUp(_e) {
95
+ this.leftClicked = false;
96
+ const { ctx, canvas } = this.callbacks.setCurrentLayer();
97
+ ctx.closePath();
98
+ if (!this.ctx.gui_states.mode.eraser) {
99
+ if (this.ctx.gui_states.mode.pencil) {
100
+ // Clear only the current layer canvas (NOT master)
101
+ canvas.width = canvas.width;
102
+ // Redraw previous layer data from volume
103
+ this.redrawPreviousImageToLayerCtx(ctx);
104
+ // Draw new pencil strokes on current layer canvas
105
+ ctx.beginPath();
106
+ ctx.moveTo(this.drawingLines[0].x, this.drawingLines[0].y);
107
+ for (let i = 1; i < this.drawingLines.length; i++) {
108
+ ctx.lineTo(this.drawingLines[i].x, this.drawingLines[i].y);
109
+ }
110
+ ctx.closePath();
111
+ ctx.lineWidth = 1;
112
+ ctx.fillStyle = this.ctx.gui_states.drawing.fillColor;
113
+ ctx.fill();
114
+ // Composite ALL layers to master (not just current layer)
115
+ this.callbacks.compositeAllLayers();
116
+ }
117
+ }
118
+ this.callbacks.syncLayerSliceData(this.ctx.nrrd_states.view.currentSliceIndex, this.ctx.gui_states.layerChannel.layer);
119
+ this.isPainting = false;
120
+ // Push undo delta
121
+ this.pushUndoDelta();
122
+ }
123
+ /**
124
+ * Called on pointerleave during drawing.
125
+ * Resets painting state and cleans up leftClicked.
126
+ * @returns true if drawing was in progress when leave occurred
127
+ */
128
+ onPointerLeave() {
129
+ this.isPainting = false;
130
+ if (!this.leftClicked)
131
+ return false;
132
+ this.leftClicked = false;
133
+ this.ctx.protectedData.ctxes.drawingLayerMasterCtx.closePath();
134
+ return true;
135
+ }
136
+ // ── Brush hover tracking & preview ──────────────────────────
137
+ /**
138
+ * Create a self-managing mouseover/mouseout/mousemove handler
139
+ * that tracks brush hover position for the preview circle.
140
+ *
141
+ * The returned function should be registered on drawingCanvas for
142
+ * "mouseover" and "mouseout" events. It adds/removes a "mousemove"
143
+ * listener on itself to keep mouseOverX/Y up-to-date while the
144
+ * cursor is inside the canvas.
145
+ */
146
+ createBrushTrackingHandler() {
147
+ const handler = (e) => {
148
+ e.preventDefault();
149
+ this.ctx.nrrd_states.interaction.mouseOverX = e.offsetX;
150
+ this.ctx.nrrd_states.interaction.mouseOverY = e.offsetY;
151
+ if (this.ctx.nrrd_states.interaction.mouseOverX === undefined) {
152
+ this.ctx.nrrd_states.interaction.mouseOverX = e.clientX;
153
+ this.ctx.nrrd_states.interaction.mouseOverY = e.clientY;
154
+ }
155
+ if (e.type === "mouseout") {
156
+ this.ctx.nrrd_states.interaction.mouseOver = false;
157
+ this.ctx.protectedData.canvases.drawingCanvas.removeEventListener("mousemove", handler);
158
+ }
159
+ else if (e.type === "mouseover") {
160
+ this.ctx.nrrd_states.interaction.mouseOver = true;
161
+ this.ctx.protectedData.canvases.drawingCanvas.addEventListener("mousemove", handler);
162
+ }
163
+ };
164
+ return handler;
165
+ }
166
+ /**
167
+ * Render brush circle preview on the drawing context.
168
+ * Called from the start() render loop when in draw mode and not
169
+ * actively painting. Skipped in pencil/eraser mode.
170
+ */
171
+ renderBrushPreview(ctx, width, height) {
172
+ if (this.ctx.gui_states.mode.pencil ||
173
+ this.ctx.gui_states.mode.eraser ||
174
+ !this.ctx.nrrd_states.interaction.mouseOver) {
175
+ return;
176
+ }
177
+ ctx.clearRect(0, 0, width, height);
178
+ ctx.fillStyle = this.ctx.gui_states.drawing.brushColor;
179
+ ctx.beginPath();
180
+ ctx.arc(this.ctx.nrrd_states.interaction.mouseOverX, this.ctx.nrrd_states.interaction.mouseOverY, this.ctx.gui_states.drawing.brushAndEraserSize / 2 + 1, 0, Math.PI * 2);
181
+ ctx.strokeStyle = this.ctx.gui_states.drawing.brushColor;
182
+ ctx.stroke();
183
+ }
184
+ // ── Private helpers ────────────────────────────────────────
185
+ /** Capture pre-draw slice snapshot for undo */
186
+ capturePreDrawSnapshot() {
187
+ try {
188
+ this.preDrawAxis = this.ctx.protectedData.axis;
189
+ this.preDrawSliceIndex = this.ctx.nrrd_states.view.currentSliceIndex;
190
+ const vol = this.callbacks.getVolumeForLayer(this.ctx.gui_states.layerChannel.layer);
191
+ this.preDrawSlice = vol.getSliceUint8(this.preDrawSliceIndex, this.preDrawAxis).data.slice();
192
+ }
193
+ catch (_a) {
194
+ this.preDrawSlice = null;
195
+ }
196
+ }
197
+ /** Push delta to UndoManager after drawing completes */
198
+ pushUndoDelta() {
199
+ if (!this.preDrawSlice)
200
+ return;
201
+ try {
202
+ const vol = this.callbacks.getVolumeForLayer(this.ctx.gui_states.layerChannel.layer);
203
+ const { data: newSlice } = vol.getSliceUint8(this.preDrawSliceIndex, this.preDrawAxis);
204
+ const delta = {
205
+ layerId: this.ctx.gui_states.layerChannel.layer,
206
+ axis: this.preDrawAxis,
207
+ sliceIndex: this.preDrawSliceIndex,
208
+ oldSlice: this.preDrawSlice,
209
+ newSlice: newSlice.slice(),
210
+ };
211
+ this.callbacks.pushUndoDelta(delta);
212
+ }
213
+ catch (_a) {
214
+ // Volume not ready — skip
215
+ }
216
+ this.preDrawSlice = null;
217
+ }
218
+ /**
219
+ * Redraws persisted layer data onto ctx before new pencil fill.
220
+ * Extracted from DrawToolCore.
221
+ */
222
+ redrawPreviousImageToLayerCtx(ctx) {
223
+ var _a;
224
+ const tempPreImg = (_a = this.callbacks.filterDrawedImage(this.ctx.protectedData.axis, this.ctx.nrrd_states.view.currentSliceIndex)) === null || _a === void 0 ? void 0 : _a.image;
225
+ this.ctx.protectedData.canvases.emptyCanvas.width =
226
+ this.ctx.protectedData.canvases.emptyCanvas.width;
227
+ this.ctx.protectedData.ctxes.emptyCtx.putImageData(tempPreImg, 0, 0);
228
+ ctx.imageSmoothingEnabled = false;
229
+ // Coronal (axis='y') Z-flip: same as renderSliceToCanvas.
230
+ if (this.ctx.protectedData.axis === 'y') {
231
+ ctx.save();
232
+ ctx.scale(1, -1);
233
+ ctx.translate(0, -this.ctx.nrrd_states.view.changedHeight);
234
+ }
235
+ ctx.drawImage(this.ctx.protectedData.canvases.emptyCanvas, 0, 0, this.ctx.nrrd_states.view.changedWidth, this.ctx.nrrd_states.view.changedHeight);
236
+ if (this.ctx.protectedData.axis === 'y') {
237
+ ctx.restore();
238
+ }
239
+ }
240
+ /** Draw a line segment on a layer canvas */
241
+ drawLinesOnLayer(ctx, x, y) {
242
+ ctx.beginPath();
243
+ ctx.moveTo(this.ctx.nrrd_states.interaction.drawStartPos.x, this.ctx.nrrd_states.interaction.drawStartPos.y);
244
+ if (this.ctx.gui_states.mode.pencil) {
245
+ ctx.strokeStyle = this.ctx.gui_states.drawing.color;
246
+ ctx.lineWidth = this.ctx.gui_states.drawing.lineWidth;
247
+ }
248
+ else {
249
+ ctx.strokeStyle = this.ctx.gui_states.drawing.brushColor;
250
+ ctx.lineWidth = this.ctx.gui_states.drawing.brushAndEraserSize;
251
+ }
252
+ ctx.lineTo(x, y);
253
+ ctx.stroke();
254
+ ctx.closePath();
255
+ }
256
+ /** Paint a segment on the current layer canvas and composite to master */
257
+ paintOnCanvasLayer(x, y) {
258
+ const { ctx } = this.callbacks.setCurrentLayer();
259
+ // Draw only on the current layer canvas (not master directly)
260
+ this.drawLinesOnLayer(ctx, x, y);
261
+ // Composite all layers to master to preserve other layers' data
262
+ this.callbacks.compositeAllLayers();
263
+ // Reset drawing start position to current position
264
+ this.ctx.nrrd_states.interaction.drawStartPos.x = x;
265
+ this.ctx.nrrd_states.interaction.drawStartPos.y = y;
266
+ // Flag the map as needing updating
267
+ this.ctx.protectedData.mainPreSlices.mesh.material.map.needsUpdate = true;
268
+ }
269
+ }
270
+ //# sourceMappingURL=DrawingTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DrawingTool.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/DrawingTool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAiBvC,YAAY,GAAgB,EAAE,SAA0B;QACtD,KAAK,CAAC,GAAG,CAAC,CAAC;QAjBb,mDAAmD;QAC3C,gBAAW,GAAG,KAAK,CAAC;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AAC,SAAS,EAAE,CAAC;IAClB,CAAC;IAED,0EAA0E;IAClE,kBAAkB,CAAC,CAAS,EAAE,CAAS;QAC7C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC;QAEjD,8DAA8D;QAC9D,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,gEAAgE;QAChE,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC;QACpC,mDAAmD;QACnD,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC;QACpD,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC;QACpD,mCAAmC;QACnC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;IAC5E,CAAC;CACF"}
@@ -16,9 +16,9 @@ export class EraserTool extends BaseTool {
16
16
  createClearArc() {
17
17
  const clearArc = (x, y, radius) => {
18
18
  var _a;
19
- const activeChannel = this.ctx.gui_states.activeChannel || 1;
19
+ const activeChannel = this.ctx.gui_states.layerChannel.activeChannel || 1;
20
20
  // Get color from current layer's volume (respects custom per-layer colors)
21
- const layer = this.ctx.gui_states.layer;
21
+ const layer = this.ctx.gui_states.layerChannel.layer;
22
22
  const volume = this.ctx.protectedData.maskData.volumes[layer];
23
23
  const channelColor = volume
24
24
  ? volume.getChannelColor(activeChannel)
@@ -31,8 +31,8 @@ export class EraserTool extends BaseTool {
31
31
  // Calculate bounding box of the eraser circle
32
32
  const x0 = Math.max(0, Math.floor(x - radius));
33
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));
34
+ const x1 = Math.min(this.ctx.nrrd_states.view.changedWidth, Math.ceil(x + radius));
35
+ const y1 = Math.min(this.ctx.nrrd_states.view.changedHeight, Math.ceil(y + radius));
36
36
  const w = x1 - x0;
37
37
  const h = y1 - y0;
38
38
  if (w <= 0 || h <= 0)
@@ -75,11 +75,11 @@ export class EraserTool extends BaseTool {
75
75
  // Recomposite master from all layer canvases (full alpha;
76
76
  // globalAlpha applied in start() render loop).
77
77
  const masterCtx = this.ctx.protectedData.ctxes.drawingLayerMasterCtx;
78
- const fullW = this.ctx.nrrd_states.changedWidth;
79
- const fullH = this.ctx.nrrd_states.changedHeight;
78
+ const fullW = this.ctx.nrrd_states.view.changedWidth;
79
+ const fullH = this.ctx.nrrd_states.view.changedHeight;
80
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])
81
+ for (const layerId of this.ctx.nrrd_states.image.layers) {
82
+ if (!this.ctx.gui_states.layerChannel.layerVisibility[layerId])
83
83
  continue;
84
84
  const lt = this.ctx.protectedData.layerTargets.get(layerId);
85
85
  if (lt)