copper3d 2.2.3 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +1056 -5
  2. package/dist/Scene/copperScene.d.ts +3 -0
  3. package/dist/Scene/copperScene.js +13 -0
  4. package/dist/Scene/copperScene.js.map +1 -1
  5. package/dist/Utils/segmentation/CommToolsData.d.ts +113 -11
  6. package/dist/Utils/segmentation/CommToolsData.js +314 -59
  7. package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
  8. package/dist/Utils/segmentation/DragOperator.d.ts +13 -7
  9. package/dist/Utils/segmentation/DragOperator.js +51 -165
  10. package/dist/Utils/segmentation/DragOperator.js.map +1 -1
  11. package/dist/Utils/segmentation/DrawToolCore.d.ts +56 -76
  12. package/dist/Utils/segmentation/DrawToolCore.js +383 -891
  13. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  14. package/dist/Utils/segmentation/NrrdTools.d.ts +277 -15
  15. package/dist/Utils/segmentation/NrrdTools.js +600 -234
  16. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  17. package/dist/Utils/segmentation/core/MaskVolume.d.ts +444 -0
  18. package/dist/Utils/segmentation/core/MaskVolume.js +1117 -0
  19. package/dist/Utils/segmentation/core/MaskVolume.js.map +1 -0
  20. package/dist/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
  21. package/dist/Utils/segmentation/core/MigrationUtils.js +163 -0
  22. package/dist/Utils/segmentation/core/MigrationUtils.js.map +1 -0
  23. package/dist/Utils/segmentation/core/UndoManager.d.ts +47 -0
  24. package/dist/Utils/segmentation/core/UndoManager.js +86 -0
  25. package/dist/Utils/segmentation/core/UndoManager.js.map +1 -0
  26. package/dist/Utils/segmentation/core/index.d.ts +76 -0
  27. package/dist/Utils/segmentation/core/index.js +75 -0
  28. package/dist/Utils/segmentation/core/index.js.map +1 -0
  29. package/dist/Utils/segmentation/core/types.d.ts +106 -0
  30. package/dist/Utils/segmentation/core/types.js +98 -0
  31. package/dist/Utils/segmentation/core/types.js.map +1 -0
  32. package/dist/Utils/segmentation/coreTools/coreType.d.ts +55 -39
  33. package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
  34. package/dist/Utils/segmentation/coreTools/gui.d.ts +10 -17
  35. package/dist/Utils/segmentation/coreTools/gui.js +23 -27
  36. package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
  37. package/dist/Utils/segmentation/eventRouter/EventRouter.d.ts +145 -0
  38. package/dist/Utils/segmentation/eventRouter/EventRouter.js +375 -0
  39. package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -0
  40. package/dist/Utils/segmentation/eventRouter/index.d.ts +7 -0
  41. package/dist/Utils/segmentation/eventRouter/index.js +7 -0
  42. package/dist/Utils/segmentation/eventRouter/index.js.map +1 -0
  43. package/dist/Utils/segmentation/eventRouter/types.d.ts +70 -0
  44. package/dist/Utils/segmentation/eventRouter/types.js +7 -0
  45. package/dist/Utils/segmentation/eventRouter/types.js.map +1 -0
  46. package/dist/Utils/segmentation/tools/BaseTool.d.ts +28 -0
  47. package/dist/Utils/segmentation/tools/BaseTool.js +18 -0
  48. package/dist/Utils/segmentation/tools/BaseTool.js.map +1 -0
  49. package/dist/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
  50. package/dist/Utils/segmentation/tools/ContrastTool.js +118 -0
  51. package/dist/Utils/segmentation/tools/ContrastTool.js.map +1 -0
  52. package/dist/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
  53. package/dist/Utils/segmentation/tools/CrosshairTool.js +157 -0
  54. package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -0
  55. package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
  56. package/dist/Utils/segmentation/tools/DragSliceTool.js +170 -0
  57. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -0
  58. package/dist/Utils/segmentation/tools/EraserTool.d.ts +16 -0
  59. package/dist/Utils/segmentation/tools/EraserTool.js +92 -0
  60. package/dist/Utils/segmentation/tools/EraserTool.js.map +1 -0
  61. package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +62 -0
  62. package/dist/Utils/segmentation/tools/ImageStoreHelper.js +160 -0
  63. package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -0
  64. package/dist/Utils/segmentation/tools/SphereTool.d.ts +36 -0
  65. package/dist/Utils/segmentation/tools/SphereTool.js +193 -0
  66. package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -0
  67. package/dist/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
  68. package/dist/Utils/segmentation/tools/ZoomTool.js +60 -0
  69. package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -0
  70. package/dist/Utils/segmentation/tools/index.d.ts +22 -0
  71. package/dist/Utils/segmentation/tools/index.js +23 -0
  72. package/dist/Utils/segmentation/tools/index.js.map +1 -0
  73. package/dist/bundle.esm.js +4627 -1997
  74. package/dist/bundle.umd.js +4630 -1996
  75. package/dist/index.d.ts +5 -3
  76. package/dist/index.js +4 -2
  77. package/dist/index.js.map +1 -1
  78. package/dist/types/Renderer/copperRenderer.d.ts +1 -1
  79. package/dist/types/Renderer/copperRendererOnDemond.d.ts +1 -1
  80. package/dist/types/Scene/copperScene.d.ts +3 -0
  81. package/dist/types/Utils/segmentation/CommToolsData.d.ts +113 -11
  82. package/dist/types/Utils/segmentation/DragOperator.d.ts +13 -7
  83. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +56 -76
  84. package/dist/types/Utils/segmentation/NrrdTools.d.ts +277 -15
  85. package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +444 -0
  86. package/dist/types/Utils/segmentation/core/MigrationUtils.d.ts +97 -0
  87. package/dist/types/Utils/segmentation/core/UndoManager.d.ts +47 -0
  88. package/dist/types/Utils/segmentation/core/index.d.ts +76 -0
  89. package/dist/types/Utils/segmentation/core/types.d.ts +106 -0
  90. package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +55 -39
  91. package/dist/types/Utils/segmentation/coreTools/gui.d.ts +10 -17
  92. package/dist/types/Utils/segmentation/eventRouter/EventRouter.d.ts +145 -0
  93. package/dist/types/Utils/segmentation/eventRouter/index.d.ts +7 -0
  94. package/dist/types/Utils/segmentation/eventRouter/types.d.ts +70 -0
  95. package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +28 -0
  96. package/dist/types/Utils/segmentation/tools/ContrastTool.d.ts +26 -0
  97. package/dist/types/Utils/segmentation/tools/CrosshairTool.d.ts +30 -0
  98. package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +44 -0
  99. package/dist/types/Utils/segmentation/tools/EraserTool.d.ts +16 -0
  100. package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +62 -0
  101. package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +36 -0
  102. package/dist/types/Utils/segmentation/tools/ZoomTool.d.ts +20 -0
  103. package/dist/types/Utils/segmentation/tools/index.d.ts +22 -0
  104. package/dist/types/index.d.ts +5 -3
  105. package/dist/types/types/types.d.ts +3 -3
  106. package/dist/types/types.d.ts +3 -3
  107. package/package.json +1 -1
  108. package/dist/Utils/segmentation/coreTools/archive.d.ts +0 -1
  109. package/dist/Utils/segmentation/coreTools/archive.js +0 -23
  110. package/dist/Utils/segmentation/coreTools/archive.js.map +0 -1
  111. package/dist/types/Utils/segmentation/coreTools/archive.d.ts +0 -1
@@ -0,0 +1,145 @@
1
+ /**
2
+ * EventRouter - Centralized Event Management
3
+ *
4
+ * Consolidates keyboard, pointer, and wheel event handling from
5
+ * DrawToolCore.ts and DragOperator.ts into a single unified system.
6
+ *
7
+ * Features:
8
+ * - Single point of event registration/cleanup
9
+ * - Mode-based event routing (draw, drag, contrast, crosshair, etc.)
10
+ * - Prevents memory leaks through proper handler cleanup
11
+ * - Eliminates duplicate keyboard listeners between DrawToolCore and DragOperator
12
+ */
13
+ import type { InteractionMode, GuiTool, KeyboardHandler, PointerHandler, WheelHandler, ModeChangeCallback, EventRouterConfig, KeyboardSettings, InteractionState } from './types';
14
+ export declare class EventRouter {
15
+ private container;
16
+ private canvas;
17
+ private mode;
18
+ private guiTool;
19
+ private state;
20
+ private keyboardSettings;
21
+ /** When false, contrast key (Ctrl/Meta) is ignored for mode switching. */
22
+ private contrastEnabled;
23
+ private onModeChange?;
24
+ private modeChangeSubscribers;
25
+ private keydownHandler?;
26
+ private keyupHandler?;
27
+ private pointerDownHandler?;
28
+ private pointerMoveHandler?;
29
+ private pointerUpHandler?;
30
+ private pointerLeaveHandler?;
31
+ private wheelHandler?;
32
+ private boundKeyDown;
33
+ private boundKeyUp;
34
+ private boundPointerDown;
35
+ private boundPointerMove;
36
+ private boundPointerUp;
37
+ private boundPointerLeave;
38
+ private boundWheel;
39
+ private boundContextMenu;
40
+ private isBound;
41
+ constructor(config: EventRouterConfig);
42
+ /**
43
+ * Bind all event listeners to DOM elements.
44
+ * Call this after setting handlers.
45
+ */
46
+ bindAll(): void;
47
+ /**
48
+ * Remove all event listeners from DOM elements.
49
+ * Call this on cleanup to prevent memory leaks.
50
+ */
51
+ unbindAll(): void;
52
+ /**
53
+ * Get the current interaction mode.
54
+ */
55
+ getMode(): InteractionMode;
56
+ /**
57
+ * Set the interaction mode directly.
58
+ */
59
+ setMode(mode: InteractionMode): void;
60
+ /**
61
+ * Subscribe to mode change events.
62
+ * Returns an unsubscribe function.
63
+ */
64
+ subscribeModeChange(callback: ModeChangeCallback): () => void;
65
+ /**
66
+ * Get the current GUI tool selection.
67
+ */
68
+ getGuiTool(): GuiTool;
69
+ /**
70
+ * Set the GUI tool (from UI buttons).
71
+ */
72
+ setGuiTool(tool: GuiTool): void;
73
+ /**
74
+ * Toggle crosshair mode.
75
+ * Blocked when draw or contrast mode is active (mutual exclusion).
76
+ */
77
+ toggleCrosshair(): void;
78
+ /**
79
+ * Check if crosshair mode is enabled.
80
+ */
81
+ isCrosshairEnabled(): boolean;
82
+ /**
83
+ * Get current interaction state.
84
+ */
85
+ getState(): Readonly<InteractionState>;
86
+ isShiftHeld(): boolean;
87
+ isCtrlHeld(): boolean;
88
+ isLeftButtonDown(): boolean;
89
+ isRightButtonDown(): boolean;
90
+ /**
91
+ * Update keyboard settings.
92
+ */
93
+ setKeyboardSettings(settings: Partial<KeyboardSettings>): void;
94
+ getKeyboardSettings(): KeyboardSettings;
95
+ /**
96
+ * Enable or disable the contrast shortcut (Ctrl/Meta key).
97
+ *
98
+ * When disabled:
99
+ * - `ctrlHeld` state is never set to true
100
+ * - The mode will not be changed to `'contrast'` via key events
101
+ * - If the mode is currently `'contrast'` it is reset to `'idle'`
102
+ *
103
+ * The external keydown/keyup handlers are still called regardless
104
+ * of this flag so other Ctrl-based shortcuts (e.g. Ctrl+Z undo)
105
+ * continue to work normally.
106
+ */
107
+ setContrastEnabled(enabled: boolean): void;
108
+ /** Whether the contrast shortcut is currently enabled. */
109
+ isContrastEnabled(): boolean;
110
+ /**
111
+ * Register the keydown handler (from DrawToolCore/DragOperator).
112
+ */
113
+ setKeydownHandler(handler: KeyboardHandler): void;
114
+ /**
115
+ * Register the keyup handler.
116
+ */
117
+ setKeyupHandler(handler: KeyboardHandler): void;
118
+ /**
119
+ * Register pointer down handler.
120
+ */
121
+ setPointerDownHandler(handler: PointerHandler): void;
122
+ /**
123
+ * Register pointer move handler.
124
+ */
125
+ setPointerMoveHandler(handler: PointerHandler): void;
126
+ /**
127
+ * Register pointer up handler.
128
+ */
129
+ setPointerUpHandler(handler: PointerHandler): void;
130
+ /**
131
+ * Register pointer leave handler.
132
+ */
133
+ setPointerLeaveHandler(handler: PointerHandler): void;
134
+ /**
135
+ * Register wheel handler.
136
+ */
137
+ setWheelHandler(handler: WheelHandler): void;
138
+ private handleKeyDown;
139
+ private handleKeyUp;
140
+ private handlePointerDown;
141
+ private handlePointerMove;
142
+ private handlePointerUp;
143
+ private handlePointerLeave;
144
+ private handleWheel;
145
+ }
@@ -0,0 +1,375 @@
1
+ /**
2
+ * EventRouter - Centralized Event Management
3
+ *
4
+ * Consolidates keyboard, pointer, and wheel event handling from
5
+ * DrawToolCore.ts and DragOperator.ts into a single unified system.
6
+ *
7
+ * Features:
8
+ * - Single point of event registration/cleanup
9
+ * - Mode-based event routing (draw, drag, contrast, crosshair, etc.)
10
+ * - Prevents memory leaks through proper handler cleanup
11
+ * - Eliminates duplicate keyboard listeners between DrawToolCore and DragOperator
12
+ */
13
+ /**
14
+ * Default keyboard settings matching nrrd_states.keyboardSettings
15
+ */
16
+ const DEFAULT_KEYBOARD_SETTINGS = {
17
+ draw: 'Shift',
18
+ undo: 'z',
19
+ redo: 'y',
20
+ contrast: ['Control', 'Meta'],
21
+ crosshair: 'c',
22
+ mouseWheel: 'Scroll:Zoom'
23
+ };
24
+ /**
25
+ * Drawing tools that can be used with Shift+drag
26
+ */
27
+ const DRAWING_TOOLS = new Set(['pencil', 'brush', 'eraser']);
28
+ export class EventRouter {
29
+ constructor(config) {
30
+ // === State ===
31
+ this.mode = 'idle';
32
+ this.guiTool = 'pencil';
33
+ this.state = {
34
+ shiftHeld: false,
35
+ ctrlHeld: false,
36
+ leftButtonDown: false,
37
+ rightButtonDown: false,
38
+ crosshairEnabled: false,
39
+ };
40
+ // === Configuration ===
41
+ this.keyboardSettings = DEFAULT_KEYBOARD_SETTINGS;
42
+ /** When false, contrast key (Ctrl/Meta) is ignored for mode switching. */
43
+ this.contrastEnabled = true;
44
+ this.modeChangeSubscribers = [];
45
+ // === Binding state ===
46
+ this.isBound = false;
47
+ this.container = config.container;
48
+ this.canvas = config.canvas;
49
+ this.onModeChange = config.onModeChange;
50
+ // Bind internal handlers
51
+ this.boundKeyDown = this.handleKeyDown.bind(this);
52
+ this.boundKeyUp = this.handleKeyUp.bind(this);
53
+ this.boundPointerDown = this.handlePointerDown.bind(this);
54
+ this.boundPointerMove = this.handlePointerMove.bind(this);
55
+ this.boundPointerUp = this.handlePointerUp.bind(this);
56
+ this.boundPointerLeave = this.handlePointerLeave.bind(this);
57
+ this.boundWheel = this.handleWheel.bind(this);
58
+ this.boundContextMenu = (e) => e.preventDefault();
59
+ }
60
+ // ========================================
61
+ // Lifecycle Methods
62
+ // ========================================
63
+ /**
64
+ * Bind all event listeners to DOM elements.
65
+ * Call this after setting handlers.
66
+ */
67
+ bindAll() {
68
+ if (this.isBound) {
69
+ console.warn('EventRouter: Already bound, call unbindAll() first');
70
+ return;
71
+ }
72
+ // Keyboard events on container
73
+ this.container.addEventListener('keydown', this.boundKeyDown);
74
+ this.container.addEventListener('keyup', this.boundKeyUp);
75
+ // Pointer events on canvas
76
+ this.canvas.addEventListener('pointerdown', this.boundPointerDown, true);
77
+ this.canvas.addEventListener('pointermove', this.boundPointerMove);
78
+ this.canvas.addEventListener('pointerup', this.boundPointerUp);
79
+ this.canvas.addEventListener('pointerleave', this.boundPointerLeave);
80
+ // Wheel event on canvas
81
+ this.canvas.addEventListener('wheel', this.boundWheel, { passive: false });
82
+ // Disable right-click context menu
83
+ this.canvas.addEventListener('contextmenu', this.boundContextMenu);
84
+ this.isBound = true;
85
+ }
86
+ /**
87
+ * Remove all event listeners from DOM elements.
88
+ * Call this on cleanup to prevent memory leaks.
89
+ */
90
+ unbindAll() {
91
+ if (!this.isBound) {
92
+ return;
93
+ }
94
+ // Keyboard events
95
+ this.container.removeEventListener('keydown', this.boundKeyDown);
96
+ this.container.removeEventListener('keyup', this.boundKeyUp);
97
+ // Pointer events
98
+ this.canvas.removeEventListener('pointerdown', this.boundPointerDown, true);
99
+ this.canvas.removeEventListener('pointermove', this.boundPointerMove);
100
+ this.canvas.removeEventListener('pointerup', this.boundPointerUp);
101
+ this.canvas.removeEventListener('pointerleave', this.boundPointerLeave);
102
+ // Wheel event
103
+ this.canvas.removeEventListener('wheel', this.boundWheel);
104
+ // Context menu
105
+ this.canvas.removeEventListener('contextmenu', this.boundContextMenu);
106
+ this.isBound = false;
107
+ }
108
+ // ========================================
109
+ // Mode Management
110
+ // ========================================
111
+ /**
112
+ * Get the current interaction mode.
113
+ */
114
+ getMode() {
115
+ return this.mode;
116
+ }
117
+ /**
118
+ * Set the interaction mode directly.
119
+ */
120
+ setMode(mode) {
121
+ if (this.mode === mode)
122
+ return;
123
+ const prevMode = this.mode;
124
+ this.mode = mode;
125
+ // Notify primary callback
126
+ if (this.onModeChange) {
127
+ this.onModeChange(prevMode, mode);
128
+ }
129
+ // Notify all subscribers
130
+ for (const subscriber of this.modeChangeSubscribers) {
131
+ subscriber(prevMode, mode);
132
+ }
133
+ }
134
+ /**
135
+ * Subscribe to mode change events.
136
+ * Returns an unsubscribe function.
137
+ */
138
+ subscribeModeChange(callback) {
139
+ this.modeChangeSubscribers.push(callback);
140
+ return () => {
141
+ const index = this.modeChangeSubscribers.indexOf(callback);
142
+ if (index >= 0) {
143
+ this.modeChangeSubscribers.splice(index, 1);
144
+ }
145
+ };
146
+ }
147
+ /**
148
+ * Get the current GUI tool selection.
149
+ */
150
+ getGuiTool() {
151
+ return this.guiTool;
152
+ }
153
+ /**
154
+ * Set the GUI tool (from UI buttons).
155
+ */
156
+ setGuiTool(tool) {
157
+ this.guiTool = tool;
158
+ // Reset to idle when switching tools
159
+ if (tool === 'sphere' || tool === 'calculator') {
160
+ this.state.crosshairEnabled = false;
161
+ this.setMode('idle');
162
+ }
163
+ }
164
+ /**
165
+ * Toggle crosshair mode.
166
+ * Blocked when draw or contrast mode is active (mutual exclusion).
167
+ */
168
+ toggleCrosshair() {
169
+ if (!DRAWING_TOOLS.has(this.guiTool))
170
+ return;
171
+ // Block crosshair activation during draw or contrast
172
+ if (this.state.shiftHeld || this.mode === 'draw' || this.mode === 'contrast')
173
+ return;
174
+ this.state.crosshairEnabled = !this.state.crosshairEnabled;
175
+ this.setMode(this.state.crosshairEnabled ? 'crosshair' : 'idle');
176
+ }
177
+ /**
178
+ * Check if crosshair mode is enabled.
179
+ */
180
+ isCrosshairEnabled() {
181
+ return this.state.crosshairEnabled;
182
+ }
183
+ // ========================================
184
+ // State Queries
185
+ // ========================================
186
+ /**
187
+ * Get current interaction state.
188
+ */
189
+ getState() {
190
+ return Object.assign({}, this.state);
191
+ }
192
+ isShiftHeld() {
193
+ return this.state.shiftHeld;
194
+ }
195
+ isCtrlHeld() {
196
+ return this.state.ctrlHeld;
197
+ }
198
+ isLeftButtonDown() {
199
+ return this.state.leftButtonDown;
200
+ }
201
+ isRightButtonDown() {
202
+ return this.state.rightButtonDown;
203
+ }
204
+ // ========================================
205
+ // Configuration
206
+ // ========================================
207
+ /**
208
+ * Update keyboard settings.
209
+ */
210
+ setKeyboardSettings(settings) {
211
+ this.keyboardSettings = Object.assign(Object.assign({}, this.keyboardSettings), settings);
212
+ }
213
+ getKeyboardSettings() {
214
+ return Object.assign({}, this.keyboardSettings);
215
+ }
216
+ /**
217
+ * Enable or disable the contrast shortcut (Ctrl/Meta key).
218
+ *
219
+ * When disabled:
220
+ * - `ctrlHeld` state is never set to true
221
+ * - The mode will not be changed to `'contrast'` via key events
222
+ * - If the mode is currently `'contrast'` it is reset to `'idle'`
223
+ *
224
+ * The external keydown/keyup handlers are still called regardless
225
+ * of this flag so other Ctrl-based shortcuts (e.g. Ctrl+Z undo)
226
+ * continue to work normally.
227
+ */
228
+ setContrastEnabled(enabled) {
229
+ this.contrastEnabled = enabled;
230
+ if (!enabled && this.mode === 'contrast') {
231
+ this.state.ctrlHeld = false;
232
+ this.setMode('idle');
233
+ }
234
+ }
235
+ /** Whether the contrast shortcut is currently enabled. */
236
+ isContrastEnabled() {
237
+ return this.contrastEnabled;
238
+ }
239
+ // ========================================
240
+ // Handler Registration
241
+ // ========================================
242
+ /**
243
+ * Register the keydown handler (from DrawToolCore/DragOperator).
244
+ */
245
+ setKeydownHandler(handler) {
246
+ this.keydownHandler = handler;
247
+ }
248
+ /**
249
+ * Register the keyup handler.
250
+ */
251
+ setKeyupHandler(handler) {
252
+ this.keyupHandler = handler;
253
+ }
254
+ /**
255
+ * Register pointer down handler.
256
+ */
257
+ setPointerDownHandler(handler) {
258
+ this.pointerDownHandler = handler;
259
+ }
260
+ /**
261
+ * Register pointer move handler.
262
+ */
263
+ setPointerMoveHandler(handler) {
264
+ this.pointerMoveHandler = handler;
265
+ }
266
+ /**
267
+ * Register pointer up handler.
268
+ */
269
+ setPointerUpHandler(handler) {
270
+ this.pointerUpHandler = handler;
271
+ }
272
+ /**
273
+ * Register pointer leave handler.
274
+ */
275
+ setPointerLeaveHandler(handler) {
276
+ this.pointerLeaveHandler = handler;
277
+ }
278
+ /**
279
+ * Register wheel handler.
280
+ */
281
+ setWheelHandler(handler) {
282
+ this.wheelHandler = handler;
283
+ }
284
+ // ========================================
285
+ // Internal Event Handlers
286
+ // ========================================
287
+ handleKeyDown(ev) {
288
+ // Update state based on modifier keys
289
+ if (ev.key === this.keyboardSettings.draw) {
290
+ this.state.shiftHeld = true;
291
+ // Block draw mode when crosshair or contrast is active (mutual exclusion)
292
+ if (DRAWING_TOOLS.has(this.guiTool) && !this.state.ctrlHeld && !this.state.crosshairEnabled) {
293
+ this.setMode('draw');
294
+ }
295
+ }
296
+ if (this.contrastEnabled && this.keyboardSettings.contrast.includes(ev.key)) {
297
+ // Block contrast state when crosshair or draw is active (mutual exclusion)
298
+ if (!this.state.crosshairEnabled && this.mode !== 'draw') {
299
+ this.state.ctrlHeld = true;
300
+ }
301
+ }
302
+ // Route to external handler
303
+ if (this.keydownHandler) {
304
+ this.keydownHandler(ev);
305
+ }
306
+ }
307
+ handleKeyUp(ev) {
308
+ // Update state based on modifier keys
309
+ if (ev.key === this.keyboardSettings.draw) {
310
+ this.state.shiftHeld = false;
311
+ if (this.mode === 'draw') {
312
+ this.setMode('idle');
313
+ }
314
+ }
315
+ if (this.keyboardSettings.contrast.includes(ev.key)) {
316
+ this.state.ctrlHeld = false;
317
+ // Do NOT auto-exit contrast mode here. Contrast is a toggle
318
+ // (press Ctrl once → enter, press again → exit), not a hold.
319
+ // DrawToolCore's keyupHandler manages the toggle exclusively.
320
+ // Auto-exiting here would conflict with it (EventRouter exits,
321
+ // then DrawToolCore immediately re-enters → stuck in contrast).
322
+ }
323
+ // Route to external handler
324
+ if (this.keyupHandler) {
325
+ this.keyupHandler(ev);
326
+ }
327
+ }
328
+ handlePointerDown(ev) {
329
+ if (ev.button === 0) {
330
+ this.state.leftButtonDown = true;
331
+ }
332
+ else if (ev.button === 2) {
333
+ this.state.rightButtonDown = true;
334
+ this.setMode('pan');
335
+ }
336
+ // Route to external handler
337
+ if (this.pointerDownHandler) {
338
+ this.pointerDownHandler(ev);
339
+ }
340
+ }
341
+ handlePointerMove(ev) {
342
+ // Route to external handler
343
+ if (this.pointerMoveHandler) {
344
+ this.pointerMoveHandler(ev);
345
+ }
346
+ }
347
+ handlePointerUp(ev) {
348
+ if (ev.button === 0) {
349
+ this.state.leftButtonDown = false;
350
+ }
351
+ else if (ev.button === 2) {
352
+ this.state.rightButtonDown = false;
353
+ if (this.mode === 'pan') {
354
+ this.setMode('idle');
355
+ }
356
+ }
357
+ // Route to external handler
358
+ if (this.pointerUpHandler) {
359
+ this.pointerUpHandler(ev);
360
+ }
361
+ }
362
+ handlePointerLeave(ev) {
363
+ // Route to external handler
364
+ if (this.pointerLeaveHandler) {
365
+ this.pointerLeaveHandler(ev);
366
+ }
367
+ }
368
+ handleWheel(ev) {
369
+ // Route to external handler
370
+ if (this.wheelHandler) {
371
+ this.wheelHandler(ev);
372
+ }
373
+ }
374
+ }
375
+ //# sourceMappingURL=EventRouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventRouter.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/eventRouter/EventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH;;GAEG;AACH,MAAM,yBAAyB,GAAqB;IAChD,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,GAAG;IACd,UAAU,EAAE,aAAa;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,aAAa,GAAi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AAC;YAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACvB;QAED,4BAA4B;QAC5B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;SAC/B;IACL,CAAC;IAEO,iBAAiB,CAAC,EAAgB;QACtC,4BAA4B;QAC5B,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;SAC/B;IACL,CAAC;IAEO,eAAe,CAAC,EAAgB;QACpC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YACjB,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC;SACrC;aAAM,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC;YACnC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE;gBACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACxB;SACJ;QAED,4BAA4B;QAC5B,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;SAC7B;IACL,CAAC;IAEO,kBAAkB,CAAC,EAAgB;QACvC,4BAA4B;QAC5B,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;SAChC;IACL,CAAC;IAEO,WAAW,CAAC,EAAc;QAC9B,4BAA4B;QAC5B,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;SACzB;IACL,CAAC;CACJ"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Event Router Module
3
+ *
4
+ * Exports centralized event handling components for the segmentation module.
5
+ */
6
+ export { EventRouter } from './EventRouter';
7
+ export type { InteractionMode, GuiTool, KeyboardHandler, PointerHandler, WheelHandler, ModeChangeCallback, EventRouterConfig, KeyboardSettings, InteractionState } from './types';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Event Router Module
3
+ *
4
+ * Exports centralized event handling components for the segmentation module.
5
+ */
6
+ export { EventRouter } from './EventRouter';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/eventRouter/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Event Router Types
3
+ *
4
+ * Type definitions for centralized event handling in the segmentation module.
5
+ */
6
+ /**
7
+ * Interaction modes representing the current operational state.
8
+ *
9
+ * - `idle`: Default state, allows navigation (drag slice, wheel zoom)
10
+ * - `draw`: Shift held, left-drag paints (pencil/brush/eraser)
11
+ * - `drag`: Left-drag changes slices
12
+ * - `contrast`: Ctrl held, left-drag adjusts window/level
13
+ * - `crosshair`: Crosshair mode enabled (C key toggle)
14
+ * - `sphere`: Sphere placement tool active
15
+ * - `calculator`: Distance calculator tool active
16
+ * - `pan`: Right-drag panning the canvas
17
+ */
18
+ export type InteractionMode = 'idle' | 'draw' | 'drag' | 'contrast' | 'crosshair' | 'sphere' | 'calculator' | 'pan';
19
+ /**
20
+ * GUI tool selection (set from UI buttons)
21
+ */
22
+ export type GuiTool = 'pencil' | 'brush' | 'eraser' | 'sphere' | 'calculator';
23
+ /**
24
+ * Keyboard event handler type
25
+ */
26
+ export type KeyboardHandler = (ev: KeyboardEvent) => void;
27
+ /**
28
+ * Pointer event handler type
29
+ */
30
+ export type PointerHandler = (ev: PointerEvent) => void;
31
+ /**
32
+ * Wheel event handler type
33
+ */
34
+ export type WheelHandler = (ev: WheelEvent) => void;
35
+ /**
36
+ * Mode change callback - called when interaction mode changes
37
+ */
38
+ export type ModeChangeCallback = (prevMode: InteractionMode, newMode: InteractionMode) => void;
39
+ /**
40
+ * Configuration for EventRouter initialization
41
+ */
42
+ export interface EventRouterConfig {
43
+ /** Container element to attach keyboard events */
44
+ container: HTMLElement;
45
+ /** Canvas element to attach pointer/wheel events */
46
+ canvas: HTMLCanvasElement;
47
+ /** Optional callback when mode changes */
48
+ onModeChange?: ModeChangeCallback;
49
+ }
50
+ /**
51
+ * Keyboard settings from nrrd_states
52
+ */
53
+ export interface KeyboardSettings {
54
+ draw: string;
55
+ undo: string;
56
+ redo: string;
57
+ contrast: string[];
58
+ crosshair: string;
59
+ mouseWheel: 'Scroll:Zoom' | 'Scroll:Slice';
60
+ }
61
+ /**
62
+ * State flags tracked by EventRouter
63
+ */
64
+ export interface InteractionState {
65
+ shiftHeld: boolean;
66
+ ctrlHeld: boolean;
67
+ leftButtonDown: boolean;
68
+ rightButtonDown: boolean;
69
+ crosshairEnabled: boolean;
70
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Event Router Types
3
+ *
4
+ * Type definitions for centralized event handling in the segmentation module.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/eventRouter/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * BaseTool - Abstract base for extracted DrawToolCore tools
3
+ *
4
+ * Provides shared access to the legacy state objects (nrrd_states,
5
+ * gui_states, protectedData) via a ToolContext interface.
6
+ *
7
+ * NOTE: This is for the OLD DrawToolCore system.
8
+ * The new SegmentationManager system has its own tools in manager/tools/.
9
+ */
10
+ import type { INrrdStates, IGUIStates, IProtected, ICursorPage } from "../coreTools/coreType";
11
+ import type { EventRouter } from "../eventRouter/EventRouter";
12
+ /**
13
+ * Shared context injected into every legacy tool.
14
+ * References are shared (not copied), so tools see the same state.
15
+ */
16
+ export interface ToolContext {
17
+ nrrd_states: INrrdStates;
18
+ gui_states: IGUIStates;
19
+ protectedData: IProtected;
20
+ cursorPage: ICursorPage;
21
+ /** EventRouter reference for mode/state queries. Set after initDrawToolCore(). */
22
+ eventRouter?: EventRouter;
23
+ }
24
+ export declare abstract class BaseTool {
25
+ protected ctx: ToolContext;
26
+ constructor(ctx: ToolContext);
27
+ setContext(ctx: ToolContext): void;
28
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * BaseTool - Abstract base for extracted DrawToolCore tools
3
+ *
4
+ * Provides shared access to the legacy state objects (nrrd_states,
5
+ * gui_states, protectedData) via a ToolContext interface.
6
+ *
7
+ * NOTE: This is for the OLD DrawToolCore system.
8
+ * The new SegmentationManager system has its own tools in manager/tools/.
9
+ */
10
+ export class BaseTool {
11
+ constructor(ctx) {
12
+ this.ctx = ctx;
13
+ }
14
+ setContext(ctx) {
15
+ this.ctx = ctx;
16
+ }
17
+ }
18
+ //# sourceMappingURL=BaseTool.js.map