copper3d 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +183 -1028
  2. package/dist/Utils/segmentation/CanvasState.d.ts +31 -0
  3. package/dist/Utils/segmentation/CanvasState.js +167 -0
  4. package/dist/Utils/segmentation/CanvasState.js.map +1 -0
  5. package/dist/Utils/segmentation/DragOperator.d.ts +1 -1
  6. package/dist/Utils/segmentation/DragOperator.js +2 -4
  7. package/dist/Utils/segmentation/DragOperator.js.map +1 -1
  8. package/dist/Utils/segmentation/DrawToolCore.d.ts +49 -27
  9. package/dist/Utils/segmentation/DrawToolCore.js +275 -344
  10. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  11. package/dist/Utils/segmentation/NrrdTools.d.ts +89 -467
  12. package/dist/Utils/segmentation/NrrdTools.js +479 -1335
  13. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  14. package/dist/Utils/segmentation/RenderingUtils.d.ts +73 -0
  15. package/dist/Utils/segmentation/RenderingUtils.js +180 -0
  16. package/dist/Utils/segmentation/RenderingUtils.js.map +1 -0
  17. package/dist/Utils/segmentation/core/MaskVolume.d.ts +1 -1
  18. package/dist/Utils/segmentation/core/MaskVolume.js +1 -1
  19. package/dist/Utils/segmentation/core/index.d.ts +1 -1
  20. package/dist/Utils/segmentation/core/index.js.map +1 -1
  21. package/dist/Utils/segmentation/core/types.d.ts +384 -0
  22. package/dist/Utils/segmentation/core/types.js +1 -0
  23. package/dist/Utils/segmentation/core/types.js.map +1 -1
  24. package/dist/Utils/segmentation/coreTools/GuiState.d.ts +1 -1
  25. package/dist/Utils/segmentation/coreTools/NrrdState.d.ts +1 -1
  26. package/dist/Utils/segmentation/coreTools/divControlTools.d.ts +1 -1
  27. package/dist/Utils/segmentation/coreTools/gui.d.ts +1 -1
  28. package/dist/Utils/segmentation/tools/BaseTool.d.ts +1 -1
  29. package/dist/Utils/segmentation/tools/ContrastTool.d.ts +3 -6
  30. package/dist/Utils/segmentation/tools/ContrastTool.js.map +1 -1
  31. package/dist/Utils/segmentation/tools/CrosshairTool.d.ts +11 -1
  32. package/dist/Utils/segmentation/tools/CrosshairTool.js +25 -0
  33. package/dist/Utils/segmentation/tools/CrosshairTool.js.map +1 -1
  34. package/dist/Utils/segmentation/tools/DataLoader.d.ts +33 -0
  35. package/dist/Utils/segmentation/tools/DataLoader.js +159 -0
  36. package/dist/Utils/segmentation/tools/DataLoader.js.map +1 -0
  37. package/dist/Utils/segmentation/tools/DragSliceTool.d.ts +3 -12
  38. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
  39. package/dist/Utils/segmentation/tools/DrawingTool.d.ts +18 -26
  40. package/dist/Utils/segmentation/tools/DrawingTool.js +48 -0
  41. package/dist/Utils/segmentation/tools/DrawingTool.js.map +1 -1
  42. package/dist/Utils/segmentation/tools/ImageStoreHelper.d.ts +2 -5
  43. package/dist/Utils/segmentation/tools/ImageStoreHelper.js.map +1 -1
  44. package/dist/Utils/segmentation/tools/LayerChannelManager.d.ts +52 -0
  45. package/dist/Utils/segmentation/tools/LayerChannelManager.js +175 -0
  46. package/dist/Utils/segmentation/tools/LayerChannelManager.js.map +1 -0
  47. package/dist/Utils/segmentation/tools/PanTool.d.ts +2 -8
  48. package/dist/Utils/segmentation/tools/PanTool.js.map +1 -1
  49. package/dist/Utils/segmentation/tools/SliceRenderPipeline.d.ts +80 -0
  50. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +355 -0
  51. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -0
  52. package/dist/Utils/segmentation/tools/SphereTool.d.ts +25 -19
  53. package/dist/Utils/segmentation/tools/SphereTool.js +61 -7
  54. package/dist/Utils/segmentation/tools/SphereTool.js.map +1 -1
  55. package/dist/Utils/segmentation/tools/ToolHost.d.ts +74 -0
  56. package/dist/Utils/segmentation/tools/ToolHost.js +10 -0
  57. package/dist/Utils/segmentation/tools/ToolHost.js.map +1 -0
  58. package/dist/Utils/segmentation/tools/ZoomTool.d.ts +2 -6
  59. package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -1
  60. package/dist/Utils/segmentation/tools/index.d.ts +5 -7
  61. package/dist/Utils/segmentation/tools/index.js +6 -0
  62. package/dist/Utils/segmentation/tools/index.js.map +1 -1
  63. package/dist/Utils/workers/reformatSaveDataWorker.d.ts +1 -1
  64. package/dist/bundle.esm.js +2109 -2357
  65. package/dist/bundle.umd.js +2109 -2357
  66. package/dist/index.d.ts +3 -3
  67. package/dist/index.js +1 -1
  68. package/dist/types/Utils/segmentation/CanvasState.d.ts +31 -0
  69. package/dist/types/Utils/segmentation/DragOperator.d.ts +1 -1
  70. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +49 -27
  71. package/dist/types/Utils/segmentation/NrrdTools.d.ts +89 -467
  72. package/dist/types/Utils/segmentation/RenderingUtils.d.ts +73 -0
  73. package/dist/types/Utils/segmentation/core/MaskVolume.d.ts +1 -1
  74. package/dist/types/Utils/segmentation/core/index.d.ts +1 -1
  75. package/dist/types/Utils/segmentation/core/types.d.ts +384 -0
  76. package/dist/types/Utils/segmentation/coreTools/GuiState.d.ts +1 -1
  77. package/dist/types/Utils/segmentation/coreTools/NrrdState.d.ts +1 -1
  78. package/dist/types/Utils/segmentation/coreTools/divControlTools.d.ts +1 -1
  79. package/dist/types/Utils/segmentation/coreTools/gui.d.ts +1 -1
  80. package/dist/types/Utils/segmentation/tools/BaseTool.d.ts +1 -1
  81. package/dist/types/Utils/segmentation/tools/ContrastTool.d.ts +3 -6
  82. package/dist/types/Utils/segmentation/tools/CrosshairTool.d.ts +11 -1
  83. package/dist/types/Utils/segmentation/tools/DataLoader.d.ts +33 -0
  84. package/dist/types/Utils/segmentation/tools/DragSliceTool.d.ts +3 -12
  85. package/dist/types/Utils/segmentation/tools/DrawingTool.d.ts +18 -26
  86. package/dist/types/Utils/segmentation/tools/ImageStoreHelper.d.ts +2 -5
  87. package/dist/types/Utils/segmentation/tools/LayerChannelManager.d.ts +52 -0
  88. package/dist/types/Utils/segmentation/tools/PanTool.d.ts +2 -8
  89. package/dist/types/Utils/segmentation/tools/SliceRenderPipeline.d.ts +80 -0
  90. package/dist/types/Utils/segmentation/tools/SphereTool.d.ts +25 -19
  91. package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +74 -0
  92. package/dist/types/Utils/segmentation/tools/ZoomTool.d.ts +2 -6
  93. package/dist/types/Utils/segmentation/tools/index.d.ts +5 -7
  94. package/dist/types/Utils/workers/reformatSaveDataWorker.d.ts +1 -1
  95. package/dist/types/index.d.ts +3 -3
  96. package/package.json +1 -1
  97. package/dist/Utils/segmentation/CommToolsData.d.ts +0 -192
  98. package/dist/Utils/segmentation/CommToolsData.js +0 -474
  99. package/dist/Utils/segmentation/CommToolsData.js.map +0 -1
  100. package/dist/Utils/segmentation/coreTools/coreType.d.ts +0 -389
  101. package/dist/Utils/segmentation/coreTools/coreType.js +0 -3
  102. package/dist/Utils/segmentation/coreTools/coreType.js.map +0 -1
  103. package/dist/types/Utils/segmentation/CommToolsData.d.ts +0 -192
  104. package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +0 -389
package/dist/index.d.ts CHANGED
@@ -17,13 +17,13 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
17
17
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
18
18
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
19
19
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader } from "./types/types";
20
- import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/coreTools/coreType";
20
+ import { IPaintImage, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, IGuiMeta } from "./Utils/segmentation/core/types";
21
21
  import { NrrdState } from "./Utils/segmentation/coreTools/NrrdState";
22
22
  import { GuiState } from "./Utils/segmentation/coreTools/GuiState";
23
- import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/coreTools/coreType";
23
+ import type { ToolMode, IAnnotationCallbacks } from "./Utils/segmentation/core/types";
24
24
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
25
25
  import type { LayerId, ChannelValue } from "./Utils/segmentation/core/index";
26
26
  import "./css/style.css";
27
- export declare const REVISION = "v3.0.2-beta";
27
+ export declare const REVISION = "v3.1.0-beta";
28
28
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, };
29
29
  export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, ICommXYZ, IGUIStates, IGuiParameterSettings, INrrdStates, NrrdState, GuiState, IGuiMeta, ToolMode, IAnnotationCallbacks, LayerId, ChannelValue, };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ import { MeshNodeTool } from "./Utils/MeshNodeTool";
20
20
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
21
21
  import { CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss } from "./Utils/segmentation/core/index";
22
22
  import "./css/style.css";
23
- export const REVISION = "v3.0.2-beta";
23
+ export const REVISION = "v3.1.0-beta";
24
24
  console.log(`%cCopper3D Visualisation %cBeta:${REVISION}`, "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
25
25
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, CHANNEL_COLORS, CHANNEL_HEX_COLORS, rgbaToHex, rgbaToCss, };
26
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,31 @@
1
+ import { IProtected, ICursorPage, IKeyBoardSettings, IAnnotationCallbacks } from "./core/types";
2
+ import { NrrdState } from "./coreTools/NrrdState";
3
+ import { GuiState } from "./coreTools/GuiState";
4
+ /**
5
+ * CanvasState — Pure state container.
6
+ *
7
+ * Holds all shared mutable state that was previously scattered across the
8
+ * CommToolsData base class. No rendering logic lives here; rendering is
9
+ * handled by {@link RenderingUtils}.
10
+ *
11
+ * Created once by NrrdTools and shared (by reference) with DrawToolCore,
12
+ * RenderingUtils, DragOperator, and all legacy Tool instances.
13
+ */
14
+ export declare class CanvasState {
15
+ baseCanvasesSize: number;
16
+ /** External annotation callbacks — set via draw() options */
17
+ annotationCallbacks: IAnnotationCallbacks;
18
+ /** Whether the keyboard-config dialog is open (suppresses all shortcuts). */
19
+ configKeyBoard: boolean;
20
+ /** Active keyboard shortcut bindings. */
21
+ keyboardSettings: IKeyBoardSettings;
22
+ nrrd_states: NrrdState;
23
+ gui_states: GuiState;
24
+ protectedData: IProtected;
25
+ cursorPage: ICursorPage;
26
+ constructor(container: HTMLElement, mainAreaContainer: HTMLElement, options?: {
27
+ layers?: string[];
28
+ });
29
+ private generateSystemCanvases;
30
+ private generateLayerTargets;
31
+ }
@@ -1,4 +1,4 @@
1
- import { IDragOpts, IDrawingEvents, IProtected } from "./coreTools/coreType";
1
+ import { IDragOpts, IDrawingEvents, IProtected } from "./core/types";
2
2
  import { NrrdState } from "./coreTools/NrrdState";
3
3
  import { GuiState } from "./coreTools/GuiState";
4
4
  import type { EventRouter } from "./eventRouter";
@@ -1,5 +1,6 @@
1
- import { IConvertObjType, IDrawingEvents, IContrastEvents, IDrawOpts } from "./coreTools/coreType";
2
- import { CommToolsData } from "./CommToolsData";
1
+ import { IConvertObjType, IDrawingEvents, IContrastEvents, IDrawOpts } from "./core/types";
2
+ import { CanvasState } from "./CanvasState";
3
+ import { RenderingUtils } from "./RenderingUtils";
3
4
  import { EventRouter } from "./eventRouter";
4
5
  import { SphereTool } from "./tools/SphereTool";
5
6
  import { CrosshairTool } from "./tools/CrosshairTool";
@@ -10,17 +11,30 @@ import { PanTool } from "./tools/PanTool";
10
11
  import { DrawingTool } from "./tools/DrawingTool";
11
12
  import { ImageStoreHelper } from "./tools/ImageStoreHelper";
12
13
  import { UndoManager } from "./core";
13
- export declare class DrawToolCore extends CommToolsData {
14
+ /**
15
+ * DrawToolCore — Tool orchestration and event routing.
16
+ *
17
+ * Previously extended CommToolsData; now uses composition:
18
+ * - `state: CanvasState` — pure state container
19
+ * - `renderer: RenderingUtils` — rendering / slice-buffer helpers
20
+ *
21
+ * Created by NrrdTools which passes in a shared CanvasState.
22
+ */
23
+ export declare class DrawToolCore {
14
24
  container: HTMLElement;
15
25
  mainAreaContainer: HTMLDivElement;
26
+ /** Shared state container (created by NrrdTools, passed in). */
27
+ readonly state: CanvasState;
28
+ /** Rendering utilities (created here, uses shared state). */
29
+ readonly renderer: RenderingUtils;
16
30
  drawingPrameters: IDrawingEvents;
17
31
  contrastEventPrameters: IContrastEvents;
18
32
  eraserUrls: string[];
19
33
  pencilUrls: string[];
20
34
  undoManager: UndoManager;
21
- protected eventRouter: EventRouter | null;
22
- protected sphereTool: SphereTool;
23
- protected crosshairTool: CrosshairTool;
35
+ eventRouter: EventRouter;
36
+ sphereTool: SphereTool;
37
+ crosshairTool: CrosshairTool;
24
38
  protected contrastTool: ContrastTool;
25
39
  protected zoomTool: ZoomTool;
26
40
  protected eraserTool: EraserTool;
@@ -29,10 +43,10 @@ export declare class DrawToolCore extends CommToolsData {
29
43
  protected imageStoreHelper: ImageStoreHelper;
30
44
  /** Slice index recorded when paintOnCanvas() starts, guards stale-click */
31
45
  private paintSliceIndex;
46
+ /** Wheel event dispatch mode — replaces manual wheel add/remove (Phase 2) */
47
+ private activeWheelMode;
32
48
  start: () => void;
33
- constructor(container: HTMLElement, options?: {
34
- layers?: string[];
35
- });
49
+ constructor(container: HTMLElement, state: CanvasState);
36
50
  private initTools;
37
51
  private initDrawToolCore;
38
52
  setEraserUrls(urls: string[]): void;
@@ -40,12 +54,13 @@ export declare class DrawToolCore extends CommToolsData {
40
54
  private setCurrentLayer;
41
55
  draw(opts?: IDrawOpts): void;
42
56
  private zoomActionAfterDrawSphere;
43
- private clearSpherePrintStoreImages;
44
57
  private paintOnCanvas;
58
+ /**
59
+ * Extracted from paintOnCanvas() pointerleave handler.
60
+ */
61
+ private handlePointerLeave;
45
62
  /** Extracted from paintOnCanvas() — handles sphere placement on left-click */
46
63
  private handleSphereClick;
47
- /*************************************May consider to move outside *******************************************/
48
- private drawLine;
49
64
  private initAllCanvas;
50
65
  private useEraser;
51
66
  configMouseZoomWheel(): (e: WheelEvent) => void;
@@ -54,13 +69,11 @@ export declare class DrawToolCore extends CommToolsData {
54
69
  drawImageOnEmptyImage(canvas: HTMLCanvasElement): void;
55
70
  /****************************Sphere functions (delegated to SphereTool)****************************************************/
56
71
  drawCalculatorSphereOnEachViews(axis: "x" | "y" | "z"): void;
57
- private drawSphereOnEachViews;
58
72
  private configMouseSphereWheel;
59
73
  drawCalculatorSphere(radius: number): void;
60
74
  drawSphere(mouseX: number, mouseY: number, radius: number): void;
61
75
  /**
62
76
  * Refresh sphere canvas from sphereMaskVolume for the current slice/axis.
63
- * Called after view changes (slice switch, zoom, contrast, axis switch).
64
77
  */
65
78
  refreshSphereOverlay(): void;
66
79
  /**
@@ -74,31 +87,18 @@ export declare class DrawToolCore extends CommToolsData {
74
87
  /**************************** Undo/Redo functions (Phase 6 — Delta-based) ****************************/
75
88
  /**
76
89
  * Clear the mask on the current slice canvas for the active layer ONLY.
77
- *
78
- * This method only clears the active layer's MaskVolume slice data for the
79
- * currently viewed slice index. Other slices in the same layer remain intact.
80
- * Other background layers are also left untouched.
81
- * After clearing, all layer canvases are re-rendered from the `MaskVolume`
82
- * to keep the visuals in sync.
83
- *
84
- * The operation is recorded to the UndoManager to allow for user rollback.
85
90
  */
86
91
  clearActiveSlice(): void;
87
92
  /**
88
93
  * Undo the last drawing operation on the active layer.
89
- * Restores the MaskVolume slice to its pre-draw state, re-renders
90
- * the canvas, and notifies the backend.
91
94
  */
92
95
  undoLastPainting(): void;
93
96
  /**
94
97
  * Redo the last undone operation on the active layer.
95
- * Reapplies the MaskVolume slice to its post-draw state, re-renders
96
- * the canvas, and notifies the backend.
97
98
  */
98
99
  redoLastPainting(): void;
99
100
  /**
100
101
  * Re-render a layer canvas from MaskVolume and composite to master.
101
- * Called after writing oldSlice/newSlice back to the volume during undo/redo.
102
102
  */
103
103
  private applyUndoRedoToCanvas;
104
104
  /****************************Store images (delegated to ImageStoreHelper)****************************************************/
@@ -109,4 +109,26 @@ export declare class DrawToolCore extends CommToolsData {
109
109
  removeContrastDragMode: () => void;
110
110
  updateSlicesContrast: (value: number, flag: string) => void;
111
111
  repraintCurrentContrastSlice: () => void;
112
+ /** Override in NrrdTools */
113
+ setIsDrawFalse(target: number): void;
114
+ /** Override in NrrdTools */
115
+ setSyncsliceNum(): void;
116
+ /** Override in NrrdTools */
117
+ resetPaintAreaUIPosition(l?: number, t?: number): void;
118
+ /** Override in NrrdTools */
119
+ resizePaintArea(factor: number): void;
120
+ /** Override in NrrdTools */
121
+ setEmptyCanvasSize(axis?: "x" | "y" | "z"): void;
122
+ /** Override in NrrdTools */
123
+ flipDisplayImageByAxis(): void;
124
+ /** Override in NrrdTools */
125
+ updateOriginAndChangedWH(): void;
126
+ /** Override in NrrdTools */
127
+ resetLayerCanvas(): void;
128
+ /** Override in NrrdTools */
129
+ redrawDisplayCanvas(): void;
130
+ /** Override in NrrdTools */
131
+ enterSphereMode(): void;
132
+ /** Override in NrrdTools */
133
+ exitSphereMode(): void;
112
134
  }