copper3d 3.0.1 → 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 +24 -9
- package/dist/Utils/segmentation/CommToolsData.js +65 -139
- package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
- package/dist/Utils/segmentation/DragOperator.d.ts +10 -2
- package/dist/Utils/segmentation/DragOperator.js +14 -4
- package/dist/Utils/segmentation/DragOperator.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +23 -16
- package/dist/Utils/segmentation/DrawToolCore.js +218 -401
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +152 -10
- package/dist/Utils/segmentation/NrrdTools.js +599 -202
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.d.ts +1 -1
- package/dist/Utils/segmentation/core/MaskVolume.js +24 -3
- 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 -62
- 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 -12
- 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 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.js +15 -10
- 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 +8 -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 +11 -28
- package/dist/Utils/segmentation/tools/ImageStoreHelper.js +39 -82
- 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 -1
- 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 +3 -3
- 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 +2452 -1492
- package/dist/bundle.umd.js +2452 -1492
- 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 +24 -9
- package/dist/types/Utils/segmentation/DragOperator.d.ts +10 -2
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +23 -16
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +152 -10
- package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +1 -1
- 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 -62
- package/dist/types/Utils/segmentation/coreTools/gui.d.ts +12 -12
- package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +2 -1
- package/dist/types/Utils/segmentation/eventRouter/types.d.ts +3 -3
- package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +8 -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 +11 -28
- package/dist/types/Utils/segmentation/tools/PanTool.d.ts +53 -0
- package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +208 -1
- 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,10 +121,9 @@ interface IProtected {
|
|
|
99
121
|
skipSlicesDic: ISkipSlicesDictType;
|
|
100
122
|
currentShowingSlice: any;
|
|
101
123
|
mainPreSlices: any;
|
|
102
|
-
|
|
124
|
+
isDrawing: boolean;
|
|
103
125
|
axis: "x" | "y" | "z";
|
|
104
126
|
maskData: IMaskData;
|
|
105
|
-
previousDrawingImage?: ImageData;
|
|
106
127
|
/** Dynamic per-layer canvas+ctx pairs. Replaces hardcoded LayerOne/Two/Three fields. */
|
|
107
128
|
layerTargets: Map<string, ILayerRenderTarget>;
|
|
108
129
|
canvases: {
|
|
@@ -121,31 +142,34 @@ interface IProtected {
|
|
|
121
142
|
drawingLayerMasterCtx: CanvasRenderingContext2D;
|
|
122
143
|
};
|
|
123
144
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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 {
|
|
128
154
|
globalAlpha: number;
|
|
129
155
|
lineWidth: number;
|
|
130
156
|
color: string;
|
|
131
|
-
pencil: boolean;
|
|
132
157
|
fillColor: string;
|
|
133
158
|
brushColor: string;
|
|
134
159
|
brushAndEraserSize: number;
|
|
160
|
+
}
|
|
161
|
+
/** View configuration — UI layout and interaction parameters */
|
|
162
|
+
interface IViewConfig {
|
|
163
|
+
mainAreaSize: number;
|
|
164
|
+
dragSensitivity: number;
|
|
135
165
|
cursor: string;
|
|
136
|
-
layer: string;
|
|
137
|
-
cal_distance: "tumour" | "skin" | "nipple" | "ribcage";
|
|
138
|
-
sphere: boolean;
|
|
139
|
-
calculator: boolean;
|
|
140
|
-
readyToUpdate: boolean;
|
|
141
166
|
defaultPaintCursor: string;
|
|
142
167
|
max_sensitive: number;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
resetZoom: () => void;
|
|
168
|
+
readyToUpdate: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** Layer/channel state — active layer, channel, and visibility */
|
|
171
|
+
interface ILayerChannelState {
|
|
172
|
+
layer: string;
|
|
149
173
|
/** Currently active channel (1-8). Channel 0 is transparent/erased. */
|
|
150
174
|
activeChannel: number;
|
|
151
175
|
/** Layer visibility state: { layer1: true, layer2: true, layer3: true } */
|
|
@@ -153,15 +177,19 @@ interface IGUIStates {
|
|
|
153
177
|
/** Per-layer channel visibility: { layer1: { 1: true, ..., 8: true }, ... } */
|
|
154
178
|
channelVisibility: Record<string, Record<number, boolean>>;
|
|
155
179
|
}
|
|
180
|
+
interface IGUIStates extends IToolModeState, IDrawingConfig, IViewConfig, ILayerChannelState {
|
|
181
|
+
}
|
|
156
182
|
interface IKeyBoardSettings {
|
|
157
183
|
draw: string;
|
|
158
184
|
undo: string;
|
|
159
185
|
redo: string;
|
|
160
186
|
contrast: string[];
|
|
161
187
|
crosshair: string;
|
|
188
|
+
sphere: string;
|
|
162
189
|
mouseWheel: "Scroll:Zoom" | "Scroll:Slice";
|
|
163
190
|
}
|
|
164
|
-
|
|
191
|
+
/** Image metadata — set once during NRRD loading, read-only at runtime */
|
|
192
|
+
interface IImageMetadata {
|
|
165
193
|
originWidth: number;
|
|
166
194
|
originHeight: number;
|
|
167
195
|
nrrd_x_mm: number;
|
|
@@ -170,55 +198,57 @@ interface INrrdStates {
|
|
|
170
198
|
nrrd_x_pixel: number;
|
|
171
199
|
nrrd_y_pixel: number;
|
|
172
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 {
|
|
173
210
|
changedWidth: number;
|
|
174
211
|
changedHeight: number;
|
|
175
|
-
|
|
176
|
-
|
|
212
|
+
currentSliceIndex: number;
|
|
213
|
+
preSliceIndex: number;
|
|
177
214
|
maxIndex: number;
|
|
178
215
|
minIndex: number;
|
|
179
|
-
RSARatio: number;
|
|
180
|
-
voxelSpacing: number[];
|
|
181
|
-
spaceOrigin: number[];
|
|
182
|
-
dimensions: number[];
|
|
183
|
-
loadMaskJson: boolean;
|
|
184
|
-
ratios: ICommXYZ;
|
|
185
216
|
contrastNum: number;
|
|
217
|
+
sizeFactor: number;
|
|
186
218
|
showContrast: boolean;
|
|
187
|
-
|
|
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;
|
|
188
228
|
cursorPageX: number;
|
|
189
229
|
cursorPageY: number;
|
|
230
|
+
isCursorSelect: boolean;
|
|
231
|
+
drawStartPos: ICommXY;
|
|
232
|
+
}
|
|
233
|
+
/** Sphere state — SphereTool-specific data */
|
|
234
|
+
interface ISphereState {
|
|
190
235
|
sphereOrigin: ICommXYZ;
|
|
191
236
|
tumourSphereOrigin: ICommXYZ | null;
|
|
192
237
|
skinSphereOrigin: ICommXYZ | null;
|
|
193
238
|
ribSphereOrigin: ICommXYZ | null;
|
|
194
239
|
nippleSphereOrigin: ICommXYZ | null;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
ribcageColor: "#2196F3";
|
|
198
|
-
nippleColor: "#E91E63";
|
|
199
|
-
spherePlanB: boolean;
|
|
240
|
+
/** Dedicated MaskVolume for SphereTool 3D sphere data. Type is `any` to avoid circular deps. */
|
|
241
|
+
sphereMaskVolume: any;
|
|
200
242
|
sphereRadius: number;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
243
|
+
}
|
|
244
|
+
/** Internal flags — transient operational flags */
|
|
245
|
+
interface IInternalFlags {
|
|
204
246
|
stepClear: number;
|
|
205
|
-
sizeFoctor: number;
|
|
206
247
|
clearAllFlag: boolean;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
getMask: (sliceData: Uint8Array, layerId: string, channelId: number, sliceIndex: number, axis: "x" | "y" | "z", width: number, height: number, clearFlag: boolean) => void;
|
|
212
|
-
onClearLayerVolume: (layerId: string) => void;
|
|
213
|
-
onChannelColorChanged: (layerId: string, channel: number, color: {
|
|
214
|
-
r: number;
|
|
215
|
-
g: number;
|
|
216
|
-
b: number;
|
|
217
|
-
a: number;
|
|
218
|
-
}) => void;
|
|
219
|
-
getSphere: (sphereOrigin: number[], sphereRadius: number) => void;
|
|
220
|
-
getCalculateSpherePositions: (tumourSphereOrigin: ICommXYZ | null, skinSphereOrigin: ICommXYZ | null, ribSphereOrigin: ICommXYZ | null, nippleSphereOrigin: ICommXYZ | null, aixs: "x" | "y" | "z") => void;
|
|
221
|
-
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 {
|
|
222
252
|
}
|
|
223
253
|
interface IDragOpts {
|
|
224
254
|
showNumber?: boolean;
|
|
@@ -272,15 +302,11 @@ interface IGuiParameterSettings {
|
|
|
272
302
|
step: number;
|
|
273
303
|
onChange: () => void;
|
|
274
304
|
};
|
|
275
|
-
|
|
305
|
+
eraser: {
|
|
276
306
|
name: "Eraser";
|
|
277
307
|
onChange: () => void;
|
|
278
308
|
};
|
|
279
|
-
|
|
280
|
-
name: "Calculator";
|
|
281
|
-
onChange: () => void;
|
|
282
|
-
};
|
|
283
|
-
cal_distance: {
|
|
309
|
+
activeSphereType: {
|
|
284
310
|
name: "CalculatorDistance";
|
|
285
311
|
onChange: (val: "tumour" | "skin" | "ribcage" | "nipple") => void;
|
|
286
312
|
};
|
|
@@ -360,4 +386,4 @@ interface IGuiParameterSettings {
|
|
|
360
386
|
};
|
|
361
387
|
};
|
|
362
388
|
}
|
|
363
|
-
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,17 +28,15 @@ interface IConfigGUI {
|
|
|
26
28
|
resetLayerCanvas: () => void;
|
|
27
29
|
redrawDisplayCanvas: () => void;
|
|
28
30
|
flipDisplayImageByAxis: () => void;
|
|
29
|
-
filterDrawedImage: (axis: "x" | "y" | "z", sliceIndex: number) => {
|
|
30
|
-
index: number;
|
|
31
|
-
image: ImageData;
|
|
32
|
-
} | undefined;
|
|
33
31
|
setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
|
|
34
|
-
|
|
32
|
+
syncLayerSliceData: (index: number, layer: string) => void;
|
|
35
33
|
drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
|
|
36
|
-
storeEachLayerImage: (index: number, layer: string) => void;
|
|
37
|
-
storeImageToLayer: (index: number, canvas: HTMLCanvasElement) => ImageData;
|
|
38
34
|
getRestLayer: () => string[];
|
|
39
35
|
setIsDrawFalse: (target: number) => void;
|
|
36
|
+
undoLastPainting: () => void;
|
|
37
|
+
redoLastPainting: () => void;
|
|
38
|
+
resetZoom: () => void;
|
|
39
|
+
downloadCurrentMask: () => void;
|
|
40
40
|
}
|
|
41
41
|
declare function setupGui(configs: IConfigGUI): IGuiParameterSettings;
|
|
42
42
|
declare function removeGuiFolderChilden(modeFolder: GUI): void;
|
|
@@ -72,7 +72,8 @@ export declare class EventRouter {
|
|
|
72
72
|
setGuiTool(tool: GuiTool): void;
|
|
73
73
|
/**
|
|
74
74
|
* Toggle crosshair mode.
|
|
75
|
-
*
|
|
75
|
+
* Allowed in drawing tools AND sphere mode.
|
|
76
|
+
* Blocked when draw or contrast mode is active, or left button is held (mutual exclusion).
|
|
76
77
|
*/
|
|
77
78
|
toggleCrosshair(): void;
|
|
78
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,23 +1,26 @@
|
|
|
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";
|
|
11
12
|
import type { EventRouter } from "../eventRouter/EventRouter";
|
|
12
13
|
/**
|
|
13
14
|
* Shared context injected into every legacy tool.
|
|
14
15
|
* References are shared (not copied), so tools see the same state.
|
|
15
16
|
*/
|
|
16
17
|
export interface ToolContext {
|
|
17
|
-
nrrd_states:
|
|
18
|
-
gui_states:
|
|
18
|
+
nrrd_states: NrrdState;
|
|
19
|
+
gui_states: GuiState;
|
|
19
20
|
protectedData: IProtected;
|
|
20
21
|
cursorPage: ICursorPage;
|
|
22
|
+
/** External annotation callbacks (Phase 2) */
|
|
23
|
+
callbacks: IAnnotationCallbacks;
|
|
21
24
|
/** EventRouter reference for mode/state queries. Set after initDrawToolCore(). */
|
|
22
25
|
eventRouter?: EventRouter;
|
|
23
26
|
}
|
|
@@ -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,7 +2,7 @@
|
|
|
2
2
|
* ImageStoreHelper - Cross-axis image storage
|
|
3
3
|
*
|
|
4
4
|
* Extracted from DrawToolCore.ts:
|
|
5
|
-
* -
|
|
5
|
+
* - syncLayerSliceData
|
|
6
6
|
*
|
|
7
7
|
* Phase 3: MaskVolume is the sole storage backend. All IPaintImages params removed.
|
|
8
8
|
*/
|
|
@@ -23,40 +23,23 @@ export declare class ImageStoreHelper extends BaseTool {
|
|
|
23
23
|
* @returns MaskVolume for the given layer, or layer1 as fallback
|
|
24
24
|
*/
|
|
25
25
|
private getVolumeForLayer;
|
|
26
|
-
/**
|
|
27
|
-
* Get MaskVolume for the currently active layer.
|
|
28
|
-
*/
|
|
29
|
-
private getCurrentVolume;
|
|
30
26
|
/**
|
|
31
27
|
* Get the canvas element for a specific layer.
|
|
32
28
|
*/
|
|
33
29
|
private getCanvasForLayer;
|
|
34
30
|
/**
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
storeImageToAxis(_index: number, _imageData: ImageData, _axis?: "x" | "y" | "z"): void;
|
|
38
|
-
/**
|
|
39
|
-
* Retrieve the drawn image for a given axis and slice.
|
|
31
|
+
* Vertically flip an ImageData buffer in-place (swap rows top↔bottom).
|
|
40
32
|
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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.
|
|
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.
|
|
56
38
|
*/
|
|
57
|
-
|
|
39
|
+
private flipImageDataVertically;
|
|
58
40
|
/**
|
|
59
|
-
*
|
|
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.
|
|
60
43
|
*/
|
|
61
|
-
|
|
44
|
+
syncLayerSliceData(index: number, layer: string): void;
|
|
62
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
|
+
}
|