copper3d 3.0.0 → 3.0.2
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 +195 -28
- package/dist/Utils/segmentation/CommToolsData.d.ts +32 -18
- package/dist/Utils/segmentation/CommToolsData.js +69 -152
- package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
- package/dist/Utils/segmentation/DragOperator.d.ts +10 -2
- package/dist/Utils/segmentation/DragOperator.js +18 -8
- package/dist/Utils/segmentation/DragOperator.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +24 -18
- package/dist/Utils/segmentation/DrawToolCore.js +255 -436
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +152 -10
- package/dist/Utils/segmentation/NrrdTools.js +604 -203
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.d.ts +1 -34
- package/dist/Utils/segmentation/core/MaskVolume.js +24 -124
- package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -1
- package/dist/Utils/segmentation/core/UndoManager.d.ts +1 -1
- package/dist/Utils/segmentation/core/UndoManager.js +1 -1
- package/dist/Utils/segmentation/core/index.d.ts +0 -2
- package/dist/Utils/segmentation/core/index.js +0 -1
- package/dist/Utils/segmentation/core/index.js.map +1 -1
- package/dist/Utils/segmentation/core/types.js +24 -24
- package/dist/Utils/segmentation/core/types.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/GuiState.d.ts +22 -0
- package/dist/Utils/segmentation/coreTools/GuiState.js +48 -0
- package/dist/Utils/segmentation/coreTools/GuiState.js.map +1 -0
- package/dist/Utils/segmentation/coreTools/NrrdState.d.ts +25 -0
- package/dist/Utils/segmentation/coreTools/NrrdState.js +85 -0
- package/dist/Utils/segmentation/coreTools/NrrdState.js.map +1 -0
- package/dist/Utils/segmentation/coreTools/coreType.d.ts +88 -65
- package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/divControlTools.js +1 -1
- package/dist/Utils/segmentation/coreTools/divControlTools.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/gui.d.ts +12 -9
- package/dist/Utils/segmentation/coreTools/gui.js +81 -107
- package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -0
- package/dist/Utils/segmentation/eventRouter/EventRouter.js +19 -8
- package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/types.d.ts +3 -3
- package/dist/Utils/segmentation/tools/BaseTool.d.ts +11 -5
- package/dist/Utils/segmentation/tools/BaseTool.js +1 -2
- package/dist/Utils/segmentation/tools/BaseTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/CrosshairTool.js +25 -25
- package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +2 -0
- package/dist/Utils/segmentation/tools/DragSliceTool.js +63 -53
- package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/DrawingTool.d.ts +93 -0
- package/dist/Utils/segmentation/tools/DrawingTool.js +222 -0
- package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/EraserTool.js +8 -8
- package/dist/Utils/segmentation/tools/EraserTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +12 -32
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js +45 -102
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -1
- package/dist/Utils/segmentation/tools/PanTool.d.ts +53 -0
- package/dist/Utils/segmentation/tools/PanTool.js +90 -0
- package/dist/Utils/segmentation/tools/PanTool.js.map +1 -0
- package/dist/Utils/segmentation/tools/SphereTool.d.ts +208 -3
- package/dist/Utils/segmentation/tools/SphereTool.js +456 -45
- package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/ZoomTool.js +5 -4
- package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -1
- package/dist/Utils/segmentation/tools/index.d.ts +6 -2
- package/dist/Utils/segmentation/tools/index.js +4 -1
- package/dist/Utils/segmentation/tools/index.js.map +1 -1
- package/dist/bundle.esm.js +2451 -1622
- package/dist/bundle.umd.js +2451 -1622
- package/dist/index.d.ts +6 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/Utils/segmentation/CommToolsData.d.ts +32 -18
- package/dist/types/Utils/segmentation/DragOperator.d.ts +10 -2
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +24 -18
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +152 -10
- package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +1 -34
- package/dist/types/Utils/segmentation/core/UndoManager.d.ts +1 -1
- package/dist/types/Utils/segmentation/core/index.d.ts +0 -2
- package/dist/types/Utils/segmentation/coreTools/GuiState.d.ts +22 -0
- package/dist/types/Utils/segmentation/coreTools/NrrdState.d.ts +25 -0
- package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +88 -65
- package/dist/types/Utils/segmentation/coreTools/gui.d.ts +12 -9
- package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -0
- package/dist/types/Utils/segmentation/eventRouter/types.d.ts +3 -3
- package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +11 -5
- package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +2 -0
- package/dist/types/Utils/segmentation/tools/DrawingTool.d.ts +93 -0
- package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +12 -32
- package/dist/types/Utils/segmentation/tools/PanTool.d.ts +53 -0
- package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +208 -3
- package/dist/types/Utils/segmentation/tools/index.d.ts +6 -2
- package/dist/types/index.d.ts +6 -3
- package/package.json +1 -1
- package/dist/Utils/segmentation/core/MigrationUtils.d.ts +0 -97
- package/dist/Utils/segmentation/core/MigrationUtils.js +0 -163
- package/dist/Utils/segmentation/core/MigrationUtils.js.map +0 -1
- package/dist/types/Utils/segmentation/core/MigrationUtils.d.ts +0 -97
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/** Tool mode types for segmentation tools */
|
|
2
|
+
type ToolMode = "pencil" | "brush" | "eraser" | "sphere" | "calculator";
|
|
3
|
+
/** Metadata for a GUI slider/control — used by Vue components to configure slider UI */
|
|
4
|
+
interface IGuiMeta {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
step: number;
|
|
8
|
+
value: number;
|
|
9
|
+
}
|
|
10
|
+
/** Callbacks for external notification of annotation data changes */
|
|
11
|
+
interface IAnnotationCallbacks {
|
|
12
|
+
onMaskChanged(sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag: boolean): void;
|
|
13
|
+
onSphereChanged(sphereOrigin: number[], sphereRadius: number): void;
|
|
14
|
+
onCalculatorPositionsChanged(tumour: ICommXYZ | null, skin: ICommXYZ | null, rib: ICommXYZ | null, nipple: ICommXYZ | null, axis: "x" | "y" | "z"): void;
|
|
15
|
+
onLayerVolumeCleared(layerId: string): void;
|
|
16
|
+
onChannelColorChanged(layerId: string, channel: number, color: {
|
|
17
|
+
r: number;
|
|
18
|
+
g: number;
|
|
19
|
+
b: number;
|
|
20
|
+
a: number;
|
|
21
|
+
}): void;
|
|
22
|
+
}
|
|
1
23
|
interface ICommXYZ {
|
|
2
24
|
x: any;
|
|
3
25
|
y: any;
|
|
@@ -12,14 +34,14 @@ interface ISkipSlicesDictType {
|
|
|
12
34
|
}
|
|
13
35
|
interface IDownloadImageConfig {
|
|
14
36
|
axis: "x" | "y" | "z";
|
|
15
|
-
|
|
37
|
+
currentSliceIndex: number;
|
|
16
38
|
drawingCanvas: HTMLCanvasElement;
|
|
17
39
|
originWidth: number;
|
|
18
40
|
originHeight: number;
|
|
19
41
|
}
|
|
20
42
|
interface IConvertObjType {
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
currentNewSliceIndex: number;
|
|
44
|
+
preSliceIndex: number;
|
|
23
45
|
convertCursorNumX: number;
|
|
24
46
|
convertCursorNumY: number;
|
|
25
47
|
}
|
|
@@ -99,12 +121,9 @@ interface IProtected {
|
|
|
99
121
|
skipSlicesDic: ISkipSlicesDictType;
|
|
100
122
|
currentShowingSlice: any;
|
|
101
123
|
mainPreSlices: any;
|
|
102
|
-
|
|
103
|
-
Is_Ctrl_Pressed: boolean;
|
|
104
|
-
Is_Draw: boolean;
|
|
124
|
+
isDrawing: boolean;
|
|
105
125
|
axis: "x" | "y" | "z";
|
|
106
126
|
maskData: IMaskData;
|
|
107
|
-
previousDrawingImage?: ImageData;
|
|
108
127
|
/** Dynamic per-layer canvas+ctx pairs. Replaces hardcoded LayerOne/Two/Three fields. */
|
|
109
128
|
layerTargets: Map<string, ILayerRenderTarget>;
|
|
110
129
|
canvases: {
|
|
@@ -123,31 +142,34 @@ interface IProtected {
|
|
|
123
142
|
drawingLayerMasterCtx: CanvasRenderingContext2D;
|
|
124
143
|
};
|
|
125
144
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
/** Tool mode flags — which tool is currently active */
|
|
146
|
+
interface IToolModeState {
|
|
147
|
+
pencil: boolean;
|
|
148
|
+
eraser: boolean;
|
|
149
|
+
sphere: boolean;
|
|
150
|
+
activeSphereType: "tumour" | "skin" | "nipple" | "ribcage";
|
|
151
|
+
}
|
|
152
|
+
/** Drawing configuration — brush/pencil appearance and behavior */
|
|
153
|
+
interface IDrawingConfig {
|
|
130
154
|
globalAlpha: number;
|
|
131
155
|
lineWidth: number;
|
|
132
156
|
color: string;
|
|
133
|
-
pencil: boolean;
|
|
134
157
|
fillColor: string;
|
|
135
158
|
brushColor: string;
|
|
136
159
|
brushAndEraserSize: number;
|
|
160
|
+
}
|
|
161
|
+
/** View configuration — UI layout and interaction parameters */
|
|
162
|
+
interface IViewConfig {
|
|
163
|
+
mainAreaSize: number;
|
|
164
|
+
dragSensitivity: number;
|
|
137
165
|
cursor: string;
|
|
138
|
-
layer: string;
|
|
139
|
-
cal_distance: "tumour" | "skin" | "nipple" | "ribcage";
|
|
140
|
-
sphere: boolean;
|
|
141
|
-
calculator: boolean;
|
|
142
|
-
readyToUpdate: boolean;
|
|
143
166
|
defaultPaintCursor: string;
|
|
144
167
|
max_sensitive: number;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
resetZoom: () => void;
|
|
168
|
+
readyToUpdate: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** Layer/channel state — active layer, channel, and visibility */
|
|
171
|
+
interface ILayerChannelState {
|
|
172
|
+
layer: string;
|
|
151
173
|
/** Currently active channel (1-8). Channel 0 is transparent/erased. */
|
|
152
174
|
activeChannel: number;
|
|
153
175
|
/** Layer visibility state: { layer1: true, layer2: true, layer3: true } */
|
|
@@ -155,15 +177,19 @@ interface IGUIStates {
|
|
|
155
177
|
/** Per-layer channel visibility: { layer1: { 1: true, ..., 8: true }, ... } */
|
|
156
178
|
channelVisibility: Record<string, Record<number, boolean>>;
|
|
157
179
|
}
|
|
180
|
+
interface IGUIStates extends IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState {
|
|
181
|
+
}
|
|
158
182
|
interface IKeyBoardSettings {
|
|
159
183
|
draw: string;
|
|
160
184
|
undo: string;
|
|
161
185
|
redo: string;
|
|
162
186
|
contrast: string[];
|
|
163
187
|
crosshair: string;
|
|
188
|
+
sphere: string;
|
|
164
189
|
mouseWheel: "Scroll:Zoom" | "Scroll:Slice";
|
|
165
190
|
}
|
|
166
|
-
|
|
191
|
+
/** Image metadata — set once during NRRD loading, read-only at runtime */
|
|
192
|
+
interface IImageMetadata {
|
|
167
193
|
originWidth: number;
|
|
168
194
|
originHeight: number;
|
|
169
195
|
nrrd_x_mm: number;
|
|
@@ -172,56 +198,57 @@ interface INrrdStates {
|
|
|
172
198
|
nrrd_x_pixel: number;
|
|
173
199
|
nrrd_y_pixel: number;
|
|
174
200
|
nrrd_z_pixel: number;
|
|
201
|
+
dimensions: number[];
|
|
202
|
+
voxelSpacing: number[];
|
|
203
|
+
spaceOrigin: number[];
|
|
204
|
+
RSARatio: number;
|
|
205
|
+
ratios: ICommXYZ;
|
|
206
|
+
layers: string[];
|
|
207
|
+
}
|
|
208
|
+
/** View state — runtime display/navigation state */
|
|
209
|
+
interface IViewState {
|
|
175
210
|
changedWidth: number;
|
|
176
211
|
changedHeight: number;
|
|
177
|
-
|
|
178
|
-
|
|
212
|
+
currentSliceIndex: number;
|
|
213
|
+
preSliceIndex: number;
|
|
179
214
|
maxIndex: number;
|
|
180
215
|
minIndex: number;
|
|
181
|
-
RSARatio: number;
|
|
182
|
-
voxelSpacing: number[];
|
|
183
|
-
spaceOrigin: number[];
|
|
184
|
-
dimensions: number[];
|
|
185
|
-
loadMaskJson: boolean;
|
|
186
|
-
ratios: ICommXYZ;
|
|
187
216
|
contrastNum: number;
|
|
217
|
+
sizeFactor: number;
|
|
188
218
|
showContrast: boolean;
|
|
189
|
-
|
|
190
|
-
|
|
219
|
+
switchSliceFlag: boolean;
|
|
220
|
+
previousPanelL: number;
|
|
221
|
+
previousPanelT: number;
|
|
222
|
+
}
|
|
223
|
+
/** Interaction state — mouse/cursor tracking */
|
|
224
|
+
interface IInteractionState {
|
|
225
|
+
mouseOverX: number;
|
|
226
|
+
mouseOverY: number;
|
|
227
|
+
mouseOver: boolean;
|
|
191
228
|
cursorPageX: number;
|
|
192
229
|
cursorPageY: number;
|
|
230
|
+
isCursorSelect: boolean;
|
|
231
|
+
drawStartPos: ICommXY;
|
|
232
|
+
}
|
|
233
|
+
/** Sphere state — SphereTool-specific data */
|
|
234
|
+
interface ISphereState {
|
|
193
235
|
sphereOrigin: ICommXYZ;
|
|
194
236
|
tumourSphereOrigin: ICommXYZ | null;
|
|
195
237
|
skinSphereOrigin: ICommXYZ | null;
|
|
196
238
|
ribSphereOrigin: ICommXYZ | null;
|
|
197
239
|
nippleSphereOrigin: ICommXYZ | null;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
ribcageColor: "#2196F3";
|
|
201
|
-
nippleColor: "#E91E63";
|
|
202
|
-
spherePlanB: boolean;
|
|
240
|
+
/** Dedicated MaskVolume for SphereTool 3D sphere data. Type is `any` to avoid circular deps. */
|
|
241
|
+
sphereMaskVolume: any;
|
|
203
242
|
sphereRadius: number;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
243
|
+
}
|
|
244
|
+
/** Internal flags — transient operational flags */
|
|
245
|
+
interface IInternalFlags {
|
|
207
246
|
stepClear: number;
|
|
208
|
-
sizeFoctor: number;
|
|
209
247
|
clearAllFlag: boolean;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
getMask: (sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag: boolean) => void;
|
|
215
|
-
onClearLayerVolume: (layerId: string) => void;
|
|
216
|
-
onChannelColorChanged: (layerId: string, channel: number, color: {
|
|
217
|
-
r: number;
|
|
218
|
-
g: number;
|
|
219
|
-
b: number;
|
|
220
|
-
a: number;
|
|
221
|
-
}) => void;
|
|
222
|
-
getSphere: (sphereOrigin: number[], sphereRadius: number) => void;
|
|
223
|
-
getCalculateSpherePositions: (tumourSphereOrigin: ICommXYZ | null, skinSphereOrigin: ICommXYZ | null, ribSphereOrigin: ICommXYZ | null, nippleSphereOrigin: ICommXYZ | null, aixs: "x" | "y" | "z") => void;
|
|
224
|
-
drawStartPos: ICommXY;
|
|
248
|
+
loadingMaskData: boolean;
|
|
249
|
+
}
|
|
250
|
+
/** Legacy flat interface — kept for backward compatibility during migration */
|
|
251
|
+
interface INrrdStates extends IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags {
|
|
225
252
|
}
|
|
226
253
|
interface IDragOpts {
|
|
227
254
|
showNumber?: boolean;
|
|
@@ -275,15 +302,11 @@ interface IGuiParameterSettings {
|
|
|
275
302
|
step: number;
|
|
276
303
|
onChange: () => void;
|
|
277
304
|
};
|
|
278
|
-
|
|
305
|
+
eraser: {
|
|
279
306
|
name: "Eraser";
|
|
280
307
|
onChange: () => void;
|
|
281
308
|
};
|
|
282
|
-
|
|
283
|
-
name: "Calculator";
|
|
284
|
-
onChange: () => void;
|
|
285
|
-
};
|
|
286
|
-
cal_distance: {
|
|
309
|
+
activeSphereType: {
|
|
287
310
|
name: "CalculatorDistance";
|
|
288
311
|
onChange: (val: "tumour" | "skin" | "ribcage" | "nipple") => void;
|
|
289
312
|
};
|
|
@@ -363,4 +386,4 @@ interface IGuiParameterSettings {
|
|
|
363
386
|
};
|
|
364
387
|
};
|
|
365
388
|
}
|
|
366
|
-
export { ICommXYZ, ICommXY, IDownloadImageConfig, IConvertObjType, IDragPrameters, IDrawingEvents, IContrastEvents, IProtected, IGUIStates, IDragOpts, IDrawOpts, INrrdStates, IPaintImage, IPaintImages, ISkipSlicesDictType, IMaskData, INewMaskData, ILayerRenderTarget, ICursorPage, IGuiParameterSettings, IKeyBoardSettings };
|
|
389
|
+
export { ToolMode, IGuiMeta, IAnnotationCallbacks, ICommXYZ, ICommXY, IDownloadImageConfig, IConvertObjType, IDragPrameters, IDrawingEvents, IContrastEvents, IProtected, IGUIStates, IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState, IDragOpts, IDrawOpts, INrrdStates, IImageMetadata, IViewState, IInteractionState, ISphereState, IInternalFlags, IPaintImage, IPaintImages, ISkipSlicesDictType, IMaskData, INewMaskData, ILayerRenderTarget, ICursorPage, IGuiParameterSettings, IKeyBoardSettings };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { GUI } from "dat.gui";
|
|
2
|
-
import { IDrawingEvents,
|
|
2
|
+
import { IDrawingEvents, IProtected, IGuiParameterSettings } from "./coreType";
|
|
3
|
+
import type { GuiState } from "./GuiState";
|
|
4
|
+
import { NrrdState } from "./NrrdState";
|
|
3
5
|
import { DragOperator } from "../DragOperator";
|
|
4
6
|
interface IConfigGUI {
|
|
5
7
|
modeFolder: GUI;
|
|
6
8
|
dragOperator: DragOperator;
|
|
7
|
-
nrrd_states:
|
|
8
|
-
gui_states:
|
|
9
|
+
nrrd_states: NrrdState;
|
|
10
|
+
gui_states: GuiState;
|
|
9
11
|
drawingCanvas: HTMLCanvasElement;
|
|
10
12
|
drawingPrameters: IDrawingEvents;
|
|
11
13
|
protectedData: IProtected;
|
|
@@ -15,8 +17,8 @@ interface IConfigGUI {
|
|
|
15
17
|
mainPreSlices: any;
|
|
16
18
|
removeDragMode: () => void;
|
|
17
19
|
configDragMode: () => void;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
clearActiveSlice: () => void;
|
|
21
|
+
clearActiveLayer: () => void;
|
|
20
22
|
updateSlicesContrast: (value: number, flag: string) => void;
|
|
21
23
|
setMainAreaSize: (factor: number) => void;
|
|
22
24
|
resetPaintAreaUIPosition: () => void;
|
|
@@ -26,14 +28,15 @@ interface IConfigGUI {
|
|
|
26
28
|
resetLayerCanvas: () => void;
|
|
27
29
|
redrawDisplayCanvas: () => void;
|
|
28
30
|
flipDisplayImageByAxis: () => void;
|
|
29
|
-
filterDrawedImage: (axis: "x" | "y" | "z", sliceIndex: number) => IPaintImage | undefined;
|
|
30
31
|
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
31
|
-
|
|
32
|
+
syncLayerSliceData: (index: number, layer: string) => void;
|
|
32
33
|
drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
|
|
33
|
-
storeEachLayerImage: (index: number, layer: string) => void;
|
|
34
|
-
storeImageToLayer: (index: number, canvas: HTMLCanvasElement, paintedImages: IPaintImages) => ImageData;
|
|
35
34
|
getRestLayer: () => string[];
|
|
36
35
|
setIsDrawFalse: (target: number) => void;
|
|
36
|
+
undoLastPainting: () => void;
|
|
37
|
+
redoLastPainting: () => void;
|
|
38
|
+
resetZoom: () => void;
|
|
39
|
+
downloadCurrentMask: () => void;
|
|
37
40
|
}
|
|
38
41
|
declare function setupGui(configs: IConfigGUI): IGuiParameterSettings;
|
|
39
42
|
declare function removeGuiFolderChilden(modeFolder: GUI): void;
|
|
@@ -72,6 +72,8 @@ export declare class EventRouter {
|
|
|
72
72
|
setGuiTool(tool: GuiTool): void;
|
|
73
73
|
/**
|
|
74
74
|
* Toggle crosshair mode.
|
|
75
|
+
* Allowed in drawing tools AND sphere mode.
|
|
76
|
+
* Blocked when draw or contrast mode is active, or left button is held (mutual exclusion).
|
|
75
77
|
*/
|
|
76
78
|
toggleCrosshair(): void;
|
|
77
79
|
/**
|
|
@@ -12,14 +12,13 @@
|
|
|
12
12
|
* - `contrast`: Ctrl held, left-drag adjusts window/level
|
|
13
13
|
* - `crosshair`: Crosshair mode enabled (C key toggle)
|
|
14
14
|
* - `sphere`: Sphere placement tool active
|
|
15
|
-
* - `calculator`: Distance calculator tool active
|
|
16
15
|
* - `pan`: Right-drag panning the canvas
|
|
17
16
|
*/
|
|
18
|
-
export type InteractionMode = 'idle' | 'draw' | 'drag' | 'contrast' | 'crosshair' | 'sphere' | '
|
|
17
|
+
export type InteractionMode = 'idle' | 'draw' | 'drag' | 'contrast' | 'crosshair' | 'sphere' | 'pan';
|
|
19
18
|
/**
|
|
20
19
|
* GUI tool selection (set from UI buttons)
|
|
21
20
|
*/
|
|
22
|
-
export type GuiTool = 'pencil' | 'brush' | 'eraser' | 'sphere'
|
|
21
|
+
export type GuiTool = 'pencil' | 'brush' | 'eraser' | 'sphere';
|
|
23
22
|
/**
|
|
24
23
|
* Keyboard event handler type
|
|
25
24
|
*/
|
|
@@ -56,6 +55,7 @@ export interface KeyboardSettings {
|
|
|
56
55
|
redo: string;
|
|
57
56
|
contrast: string[];
|
|
58
57
|
crosshair: string;
|
|
58
|
+
sphere: string;
|
|
59
59
|
mouseWheel: 'Scroll:Zoom' | 'Scroll:Slice';
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BaseTool - Abstract base for extracted DrawToolCore tools
|
|
3
3
|
*
|
|
4
|
-
* Provides shared access to
|
|
5
|
-
* gui_states, protectedData) via a ToolContext interface.
|
|
4
|
+
* Provides shared access to state objects via a ToolContext interface.
|
|
6
5
|
*
|
|
7
6
|
* NOTE: This is for the OLD DrawToolCore system.
|
|
8
7
|
* The new SegmentationManager system has its own tools in manager/tools/.
|
|
9
8
|
*/
|
|
10
|
-
import type {
|
|
9
|
+
import type { IProtected, ICursorPage, IAnnotationCallbacks } from "../coreTools/coreType";
|
|
10
|
+
import type { NrrdState } from "../coreTools/NrrdState";
|
|
11
|
+
import type { GuiState } from "../coreTools/GuiState";
|
|
12
|
+
import type { EventRouter } from "../eventRouter/EventRouter";
|
|
11
13
|
/**
|
|
12
14
|
* Shared context injected into every legacy tool.
|
|
13
15
|
* References are shared (not copied), so tools see the same state.
|
|
14
16
|
*/
|
|
15
17
|
export interface ToolContext {
|
|
16
|
-
nrrd_states:
|
|
17
|
-
gui_states:
|
|
18
|
+
nrrd_states: NrrdState;
|
|
19
|
+
gui_states: GuiState;
|
|
18
20
|
protectedData: IProtected;
|
|
19
21
|
cursorPage: ICursorPage;
|
|
22
|
+
/** External annotation callbacks (Phase 2) */
|
|
23
|
+
callbacks: IAnnotationCallbacks;
|
|
24
|
+
/** EventRouter reference for mode/state queries. Set after initDrawToolCore(). */
|
|
25
|
+
eventRouter?: EventRouter;
|
|
20
26
|
}
|
|
21
27
|
export declare abstract class BaseTool {
|
|
22
28
|
protected ctx: ToolContext;
|
|
@@ -18,6 +18,8 @@ export interface DragSliceCallbacks {
|
|
|
18
18
|
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
19
19
|
getOrCreateSliceBuffer: (axis: "x" | "y" | "z") => ImageData | null;
|
|
20
20
|
renderSliceToCanvas: (layer: string, axis: "x" | "y" | "z", sliceIndex: number, buffer: ImageData, targetCtx: CanvasRenderingContext2D, scaledWidth: number, scaledHeight: number) => void;
|
|
21
|
+
/** Refresh sphere overlay from sphereMaskVolume after slice change. */
|
|
22
|
+
refreshSphereOverlay?: () => void;
|
|
21
23
|
}
|
|
22
24
|
interface IDragEffectCanvases {
|
|
23
25
|
drawingCanvasLayerMaster: HTMLCanvasElement;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { MaskDelta } from "../core";
|
|
11
|
+
/**
|
|
12
|
+
* Callbacks DrawingTool needs from its host (DrawToolCore).
|
|
13
|
+
*/
|
|
14
|
+
export interface DrawingCallbacks {
|
|
15
|
+
/** Get current layer's canvas and 2D context */
|
|
16
|
+
setCurrentLayer: () => {
|
|
17
|
+
ctx: CanvasRenderingContext2D;
|
|
18
|
+
canvas: HTMLCanvasElement;
|
|
19
|
+
};
|
|
20
|
+
/** Composite all layers to master canvas */
|
|
21
|
+
compositeAllLayers: () => void;
|
|
22
|
+
/** Sync layer slice data to MaskVolume */
|
|
23
|
+
syncLayerSliceData: (index: number, layer: string) => void;
|
|
24
|
+
/** Get stored image data for previous image redraw */
|
|
25
|
+
filterDrawedImage: (axis: "x" | "y" | "z", index: number) => {
|
|
26
|
+
image: ImageData;
|
|
27
|
+
} | undefined;
|
|
28
|
+
/** Get MaskVolume for a layer (undo snapshots) */
|
|
29
|
+
getVolumeForLayer: (layer: string) => any;
|
|
30
|
+
/** Push delta to UndoManager */
|
|
31
|
+
pushUndoDelta: (delta: MaskDelta) => void;
|
|
32
|
+
/** Get eraser icon URLs */
|
|
33
|
+
getEraserUrls: () => string[];
|
|
34
|
+
}
|
|
35
|
+
export declare class DrawingTool extends BaseTool {
|
|
36
|
+
/** Left mouse button currently held (draw mode) */
|
|
37
|
+
private leftClicked;
|
|
38
|
+
/** True while actively painting (between pointerdown and pointerup) */
|
|
39
|
+
private isPainting;
|
|
40
|
+
/** Accumulated pencil stroke points for fill-on-release */
|
|
41
|
+
private drawingLines;
|
|
42
|
+
/** Eraser arc function, assigned once per paintOnCanvas() call */
|
|
43
|
+
private clearArcFn;
|
|
44
|
+
/** Snapshot of the active layer's slice captured on mouse-down (before drawing) */
|
|
45
|
+
private preDrawSlice;
|
|
46
|
+
private preDrawAxis;
|
|
47
|
+
private preDrawSliceIndex;
|
|
48
|
+
private callbacks;
|
|
49
|
+
constructor(ctx: ToolContext, callbacks: DrawingCallbacks);
|
|
50
|
+
/** Whether a draw operation is currently active */
|
|
51
|
+
get isActive(): boolean;
|
|
52
|
+
/** Whether paint strokes are being recorded */
|
|
53
|
+
get painting(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Reset drawing state. Called at start of each paintOnCanvas() cycle.
|
|
56
|
+
* @param clearArcFn - Eraser function for this paint cycle
|
|
57
|
+
*/
|
|
58
|
+
reset(clearArcFn: (x: number, y: number, size: number) => void): void;
|
|
59
|
+
/**
|
|
60
|
+
* Called on left-click pointerdown in draw mode.
|
|
61
|
+
* Sets up drawing state, cursor, undo snapshot, and start position.
|
|
62
|
+
*/
|
|
63
|
+
onPointerDown(e: MouseEvent): void;
|
|
64
|
+
/**
|
|
65
|
+
* Called on pointermove during an active drawing operation.
|
|
66
|
+
* Handles eraser clearing or brush/pencil stroke accumulation.
|
|
67
|
+
*/
|
|
68
|
+
onPointerMove(e: MouseEvent): void;
|
|
69
|
+
/**
|
|
70
|
+
* Called on pointerup in draw mode.
|
|
71
|
+
* Completes stroke, fills pencil path, syncs volume, pushes undo delta.
|
|
72
|
+
*/
|
|
73
|
+
onPointerUp(_e: MouseEvent): void;
|
|
74
|
+
/**
|
|
75
|
+
* Called on pointerleave during drawing.
|
|
76
|
+
* Resets painting state and cleans up leftClicked.
|
|
77
|
+
* @returns true if drawing was in progress when leave occurred
|
|
78
|
+
*/
|
|
79
|
+
onPointerLeave(): boolean;
|
|
80
|
+
/** Capture pre-draw slice snapshot for undo */
|
|
81
|
+
private capturePreDrawSnapshot;
|
|
82
|
+
/** Push delta to UndoManager after drawing completes */
|
|
83
|
+
private pushUndoDelta;
|
|
84
|
+
/**
|
|
85
|
+
* Redraws persisted layer data onto ctx before new pencil fill.
|
|
86
|
+
* Extracted from DrawToolCore.
|
|
87
|
+
*/
|
|
88
|
+
private redrawPreviousImageToLayerCtx;
|
|
89
|
+
/** Draw a line segment on a layer canvas */
|
|
90
|
+
private drawLinesOnLayer;
|
|
91
|
+
/** Paint a segment on the current layer canvas and composite to master */
|
|
92
|
+
private paintOnCanvasLayer;
|
|
93
|
+
}
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
* ImageStoreHelper - Cross-axis image storage
|
|
3
3
|
*
|
|
4
4
|
* Extracted from DrawToolCore.ts:
|
|
5
|
-
* -
|
|
5
|
+
* - syncLayerSliceData
|
|
6
6
|
*
|
|
7
|
-
* Phase
|
|
8
|
-
* Volume is the primary storage; IPaintImages kept for backward compatibility.
|
|
7
|
+
* Phase 3: MaskVolume is the sole storage backend. All IPaintImages params removed.
|
|
9
8
|
*/
|
|
10
9
|
import { BaseTool } from "./BaseTool";
|
|
11
10
|
import type { ToolContext } from "./BaseTool";
|
|
12
|
-
import type { IPaintImage, IPaintImages } from "../coreTools/coreType";
|
|
13
11
|
export interface ImageStoreCallbacks {
|
|
14
12
|
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
15
13
|
drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
|
|
@@ -25,41 +23,23 @@ export declare class ImageStoreHelper extends BaseTool {
|
|
|
25
23
|
* @returns MaskVolume for the given layer, or layer1 as fallback
|
|
26
24
|
*/
|
|
27
25
|
private getVolumeForLayer;
|
|
28
|
-
/**
|
|
29
|
-
* Get MaskVolume for the currently active layer.
|
|
30
|
-
*/
|
|
31
|
-
private getCurrentVolume;
|
|
32
26
|
/**
|
|
33
27
|
* Get the canvas element for a specific layer.
|
|
34
28
|
*/
|
|
35
29
|
private getCanvasForLayer;
|
|
36
30
|
/**
|
|
37
|
-
*
|
|
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.
|
|
31
|
+
* Vertically flip an ImageData buffer in-place (swap rows top↔bottom).
|
|
44
32
|
*
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
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.
|
|
33
|
+
* Used to compensate for the Z-axis direction reversal between sagittal
|
|
34
|
+
* and coronal views. On coronal, Z runs along the canvas j-axis (vertical),
|
|
35
|
+
* and the display flip (scale(1,-1)) reverses Z relative to sagittal's
|
|
36
|
+
* horizontal Z mapping. This row-swap aligns the Z ordering so that
|
|
37
|
+
* MaskVolume stores data in a consistent coordinate system.
|
|
57
38
|
*/
|
|
58
|
-
|
|
39
|
+
private flipImageDataVertically;
|
|
59
40
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
41
|
+
* Sync the current layer canvas to its MaskVolume slice and notify the parent
|
|
42
|
+
* via getMask. This is the primary write path after any draw/erase operation.
|
|
62
43
|
*/
|
|
63
|
-
|
|
64
|
-
private hasNonZeroPixels;
|
|
44
|
+
syncLayerSliceData(index: number, layer: string): void;
|
|
65
45
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PanTool - Right-click pan/drag navigation
|
|
3
|
+
*
|
|
4
|
+
* Extracted from DrawToolCore.paintOnCanvas() closure.
|
|
5
|
+
* Handles right-click drag to reposition the canvas view.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseTool } from "./BaseTool";
|
|
8
|
+
import type { ToolContext } from "./BaseTool";
|
|
9
|
+
/**
|
|
10
|
+
* Callbacks PanTool needs from its host (DrawToolCore).
|
|
11
|
+
*/
|
|
12
|
+
export interface PanCallbacks {
|
|
13
|
+
/** Re-enable zoom wheel after pan ends in sphere mode */
|
|
14
|
+
zoomActionAfterDrawSphere: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare class PanTool extends BaseTool {
|
|
17
|
+
/** Right mouse button currently held */
|
|
18
|
+
private rightClicked;
|
|
19
|
+
/** Pan drag offset X (clientX − canvas.offsetLeft at drag start) */
|
|
20
|
+
private panMoveInnerX;
|
|
21
|
+
/** Pan drag offset Y (clientY − canvas.offsetTop at drag start) */
|
|
22
|
+
private panMoveInnerY;
|
|
23
|
+
private callbacks;
|
|
24
|
+
/**
|
|
25
|
+
* Bound handler reference for pointermove so we can add/remove it.
|
|
26
|
+
* Arrow function preserves `this` binding.
|
|
27
|
+
*/
|
|
28
|
+
private readonly boundPointerMove;
|
|
29
|
+
constructor(ctx: ToolContext, callbacks: PanCallbacks);
|
|
30
|
+
/** Whether a pan drag is currently active */
|
|
31
|
+
get isActive(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Called on right-click pointerdown.
|
|
34
|
+
* Captures initial offsets and registers pointermove listener.
|
|
35
|
+
*/
|
|
36
|
+
onPointerDown(e: MouseEvent): void;
|
|
37
|
+
/**
|
|
38
|
+
* Called on pointerup (button === 2).
|
|
39
|
+
* Cleans up listeners and restores cursor.
|
|
40
|
+
*/
|
|
41
|
+
onPointerUp(e: MouseEvent, defaultCursor: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Called on pointerleave while pan is active.
|
|
44
|
+
* Resets state and removes listener.
|
|
45
|
+
*/
|
|
46
|
+
onPointerLeave(): void;
|
|
47
|
+
/** Reset pan state (called when paintOnCanvas re-initializes) */
|
|
48
|
+
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Pointermove handler — updates canvas position during drag.
|
|
51
|
+
*/
|
|
52
|
+
private handlePointerMove;
|
|
53
|
+
}
|