copper3d 3.11.2 → 3.11.4
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 +27 -3
- package/ai-index/guides/nrrd-tools.md +79 -4
- package/ai-index/guides/segmentation-module.md +43 -3
- package/ai-index/manifest.json +5 -5
- package/ai-index/symbols.json +1 -1
- package/dist/Utils/segmentation/CanvasState.js +0 -1
- package/dist/Utils/segmentation/CanvasState.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.js +0 -14
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +13 -0
- package/dist/Utils/segmentation/NrrdTools.js +28 -2
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/core/types.d.ts +2 -1
- package/dist/Utils/segmentation/coreTools/NrrdState.d.ts +1 -1
- package/dist/Utils/segmentation/coreTools/NrrdState.js +3 -2
- package/dist/Utils/segmentation/coreTools/NrrdState.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/gui.js +1 -1
- package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.js +0 -1
- package/dist/Utils/segmentation/eventRouter/EventRouter.js.map +1 -1
- package/dist/Utils/segmentation/eventRouter/types.d.ts +0 -1
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +4 -2
- package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -1
- package/dist/Utils/segmentation/tools/ZoomTool.js +37 -4
- package/dist/Utils/segmentation/tools/ZoomTool.js.map +1 -1
- package/dist/bundle.esm.js +76 -30
- package/dist/bundle.umd.js +76 -30
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +13 -0
- package/dist/types/Utils/segmentation/core/types.d.ts +2 -1
- package/dist/types/Utils/segmentation/coreTools/NrrdState.d.ts +1 -1
- package/dist/types/Utils/segmentation/eventRouter/types.d.ts +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -509,6 +509,25 @@ leave outline mode to annotate.
|
|
|
509
509
|
|
|
510
510
|
---
|
|
511
511
|
|
|
512
|
+
### Zoom range — showing below 1:1
|
|
513
|
+
|
|
514
|
+
The zoom factor used to bottom out at `1`. Lower the floor and a large volume can be fitted
|
|
515
|
+
into a small panel:
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
nrrdTools.setMinSizeFactor(0.5); // clamped to [0.05, 1]; default 1
|
|
519
|
+
nrrdTools.setMainAreaSize(0.6); // now valid
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
`setMainAreaSize`, wheel zoom and the `"mainAreaSize"` GUI slider all follow it; the upper
|
|
523
|
+
bound stays `8`. If the current factor is below the new floor it is raised and repainted.
|
|
524
|
+
|
|
525
|
+
The engine never recomputes the floor — the right value depends on the image and axis
|
|
526
|
+
dimensions *and* your panel size — so re-apply it after each case load, axis switch and panel
|
|
527
|
+
resize.
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
512
531
|
### 7. Channel Color Customization
|
|
513
532
|
|
|
514
533
|
**Default colors:**
|
|
@@ -587,9 +606,13 @@ window.addEventListener('keydown', (e) => {
|
|
|
587
606
|
| Redo | `y` |
|
|
588
607
|
| Contrast adjust | `Ctrl` / `Meta` (hold) |
|
|
589
608
|
| Crosshair | `s` |
|
|
590
|
-
| Sphere mode | `q` |
|
|
591
609
|
| Mouse wheel | Zoom |
|
|
592
610
|
|
|
611
|
+
> **Breaking:** sphere mode no longer has a shortcut. `sphere: "q"` is gone and `sphere` has
|
|
612
|
+
> been removed from `IKeyBoardSettings` — it toggled the mode behind the host's back, clearing
|
|
613
|
+
> the masks from the view while the host's UI still showed its own tool as selected. Enter it
|
|
614
|
+
> with `setMode('sphere')` and bind your own key if you want one.
|
|
615
|
+
|
|
593
616
|
```typescript
|
|
594
617
|
nrrdTools.setKeyboardSettings({ undo: 'u', mouseWheel: 'Scroll:Slice' });
|
|
595
618
|
const settings = nrrdTools.getKeyboardSettings();
|
|
@@ -697,7 +720,9 @@ yourself. It throws on an unknown layer, or a channel outside `[1, 255]`.
|
|
|
697
720
|
| **Actions** | `executeAction(action, opts?)` | Run: `"undo"` / `"redo"` / `"clearActiveSliceMask"` / `"clearActiveLayerMask"` / `"resetZoom"` / `"downloadCurrentMask"` / `"gaussianSmooth"` (takes `{ sigma? }`) |
|
|
698
721
|
| **Navigation** | `setSliceOrientation(axis)` | Switch viewing axis `"x"` / `"y"` / `"z"`; extracts the plane on demand if the load skipped it |
|
|
699
722
|
| | `setSliceMoving(step)` | Step the current slice (coalesced per animation frame) |
|
|
700
|
-
| | `setMainAreaSize(factor)` | Set the main-area zoom factor [
|
|
723
|
+
| | `setMainAreaSize(factor)` | Set the main-area zoom factor `[minSizeFactor, 8]` |
|
|
724
|
+
| | `setMinSizeFactor(f)` | Lower the zoom floor below 1:1. Clamped to `[0.05, 1]`; default `1`. Re-apply after case loads, axis switches and panel resizes |
|
|
725
|
+
| | `getMinSizeFactor()` | Read the current zoom floor |
|
|
701
726
|
| **History** | `undo()` / `redo()` | Undo / redo last stroke |
|
|
702
727
|
| **Keyboard** | `setKeyboardSettings(partial)` | Remap shortcuts |
|
|
703
728
|
| | `getKeyboardSettings()` | Read current bindings |
|
|
@@ -748,7 +773,6 @@ interface IKeyBoardSettings {
|
|
|
748
773
|
redo: string;
|
|
749
774
|
contrast: string[];
|
|
750
775
|
crosshair: string;
|
|
751
|
-
sphere: string;
|
|
752
776
|
mouseWheel: 'Scroll:Zoom' | 'Scroll:Slice';
|
|
753
777
|
}
|
|
754
778
|
|
|
@@ -522,7 +522,7 @@ const type = nrrdTools.getActiveSphereType();
|
|
|
522
522
|
##### Interaction Flow
|
|
523
523
|
|
|
524
524
|
```
|
|
525
|
-
Sphere mode activated (gui_states.mode.sphere = true,
|
|
525
|
+
Sphere mode activated (gui_states.mode.sphere = true, via setMode("sphere")):
|
|
526
526
|
├─ Shift key DISABLED (no draw mode)
|
|
527
527
|
├─ Crosshair toggle allowed (S key)
|
|
528
528
|
│
|
|
@@ -1181,11 +1181,29 @@ window.addEventListener('keydown', (e) => {
|
|
|
1181
1181
|
| Redo | `y` |
|
|
1182
1182
|
| Contrast adjust | `Ctrl` / `Meta` (hold) |
|
|
1183
1183
|
| Crosshair | `s` |
|
|
1184
|
-
| Sphere mode | `q` |
|
|
1185
1184
|
| Mouse wheel | Zoom |
|
|
1186
1185
|
| Scroll:Zoom shortcut | `Ctrl+1` |
|
|
1187
1186
|
| Scroll:Slice shortcut | `Ctrl+2` |
|
|
1188
1187
|
|
|
1188
|
+
::: warning Sphere mode no longer has a shortcut <Badge type="warning" text="breaking in 3.11.5" />
|
|
1189
|
+
The `sphere: "q"` binding is **gone**, and `sphere` has been removed from
|
|
1190
|
+
`IKeyBoardSettings`. Sphere mode is now entered only through `setMode("sphere")` — which is
|
|
1191
|
+
also how the calculator reaches it — so the host always knows which tool is active.
|
|
1192
|
+
|
|
1193
|
+
The shortcut toggled the mode behind the host's back: pressing `q` cleared the masks from the
|
|
1194
|
+
view while the host's own UI still showed whatever tool it thought was selected.
|
|
1195
|
+
|
|
1196
|
+
If you passed `sphere` to `setKeyboardSettings`, drop it — it is no longer part of the type:
|
|
1197
|
+
|
|
1198
|
+
```typescript
|
|
1199
|
+
// before
|
|
1200
|
+
nrrdTools.setKeyboardSettings({ sphere: 'e', crosshair: 'x' });
|
|
1201
|
+
// after
|
|
1202
|
+
nrrdTools.setKeyboardSettings({ crosshair: 'x' });
|
|
1203
|
+
nrrdTools.setMode('sphere'); // bind your own key to this if you want one
|
|
1204
|
+
```
|
|
1205
|
+
:::
|
|
1206
|
+
|
|
1189
1207
|
#### Reading current settings
|
|
1190
1208
|
|
|
1191
1209
|
```typescript
|
|
@@ -1286,6 +1304,62 @@ Set the base display size multiplier (1–8). Larger values use more GPU memory
|
|
|
1286
1304
|
nrrdTools.setBaseDrawDisplayCanvasesSize(2); // 2× base resolution
|
|
1287
1305
|
```
|
|
1288
1306
|
|
|
1307
|
+
#### Zoom range — `setMinSizeFactor()` <Badge type="tip" text="3.11.3" />
|
|
1308
|
+
|
|
1309
|
+
The 2D zoom factor (`sizeFactor`) used to bottom out at `1`, i.e. 1:1 with the image. Lower
|
|
1310
|
+
the floor and the image can be shown **smaller than its original size** — which is what a
|
|
1311
|
+
large volume in a small panel needs:
|
|
1312
|
+
|
|
1313
|
+
```typescript
|
|
1314
|
+
nrrdTools.setMinSizeFactor(0.5); // allow down to half size
|
|
1315
|
+
nrrdTools.setMainAreaSize(0.6); // now valid
|
|
1316
|
+
const min = nrrdTools.getMinSizeFactor();
|
|
1317
|
+
```
|
|
1318
|
+
|
|
1319
|
+
| | |
|
|
1320
|
+
|---|---|
|
|
1321
|
+
| Accepted range | clamped to `[0.05, 1]`; a non-finite value resets it to `1` |
|
|
1322
|
+
| Default | `1` — exactly the previous behaviour |
|
|
1323
|
+
| Upper bound | still `8`, unchanged |
|
|
1324
|
+
|
|
1325
|
+
Everything that moves the zoom respects it: `setMainAreaSize`, wheel zoom, and
|
|
1326
|
+
`NrrdState.setZoomFactor`. The `"mainAreaSize"` GUI slider's `min` is updated too, so a
|
|
1327
|
+
connected dat.GUI / lil-gui panel can reach the new range.
|
|
1328
|
+
|
|
1329
|
+
::: tip Wheel zoom follows scroll distance <Badge type="tip" text="3.11.4" />
|
|
1330
|
+
One notch (100px of scroll) zooms by 10%, and a single event is capped at 2×. Because the
|
|
1331
|
+
ratio comes from the distance scrolled rather than from the number of events, a trackpad's
|
|
1332
|
+
small deltas zoom smoothly, and a busy page — where the browser coalesces wheel events and
|
|
1333
|
+
sums their deltas — zooms at the same rate as an idle one. Nothing to configure.
|
|
1334
|
+
:::
|
|
1335
|
+
|
|
1336
|
+
If the current factor is **below** the new minimum it is raised to it and the view repaints
|
|
1337
|
+
immediately, so you can lower and raise the floor freely without leaving the view in an
|
|
1338
|
+
invalid state.
|
|
1339
|
+
|
|
1340
|
+
::: warning You have to re-apply it — the engine never recomputes it
|
|
1341
|
+
The minimum survives `reset()` and case loads, and the engine will not adjust it on its own:
|
|
1342
|
+
the right value depends on the image and axis dimensions *and* on the size of your panel,
|
|
1343
|
+
neither of which the engine knows. Re-apply it after each
|
|
1344
|
+
|
|
1345
|
+
- case load,
|
|
1346
|
+
- axis switch (`setSliceOrientation`), and
|
|
1347
|
+
- panel resize.
|
|
1348
|
+
|
|
1349
|
+
```typescript
|
|
1350
|
+
function fitFloor() {
|
|
1351
|
+
const [w, h] = nrrdTools.getCurrentImageDimension(); // per current axis
|
|
1352
|
+
const panel = container.getBoundingClientRect();
|
|
1353
|
+
nrrdTools.setMinSizeFactor(Math.min(panel.width / w, panel.height / h, 1));
|
|
1354
|
+
}
|
|
1355
|
+
```
|
|
1356
|
+
:::
|
|
1357
|
+
|
|
1358
|
+
::: tip A thin dimension never floors to zero
|
|
1359
|
+
`resizePaintArea` keeps a loaded image at **at least 1px** per axis, because a factor below 1
|
|
1360
|
+
could otherwise floor a thin dimension to `0`. An unloaded (0×0) image stays `0`.
|
|
1361
|
+
:::
|
|
1362
|
+
|
|
1289
1363
|
#### Reading image metadata
|
|
1290
1364
|
|
|
1291
1365
|
```typescript
|
|
@@ -1709,7 +1783,6 @@ interface IKeyBoardSettings {
|
|
|
1709
1783
|
redo: string;
|
|
1710
1784
|
contrast: string[]; // always an array, e.g. ["Control", "Meta"]
|
|
1711
1785
|
crosshair: string;
|
|
1712
|
-
sphere: string;
|
|
1713
1786
|
mouseWheel: 'Scroll:Zoom' | 'Scroll:Slice';
|
|
1714
1787
|
}
|
|
1715
1788
|
|
|
@@ -1818,7 +1891,9 @@ cap it below what the byte allows. Capping it lower is your product's call, not
|
|
|
1818
1891
|
| | `GaussianSmoother.generateKernel1D(sigma)` | Generate a normalized 1D Gaussian kernel |
|
|
1819
1892
|
| **Navigation** | `setSliceOrientation(axis)` | Switch viewing axis `"x"` / `"y"` / `"z"`; extracts the plane on demand if the load skipped it |
|
|
1820
1893
|
| | `setSliceMoving(step)` | Step the current slice by `step` (coalesced into one `requestAnimationFrame`) |
|
|
1821
|
-
| | `setMainAreaSize(factor)` | Set the main-area zoom factor [
|
|
1894
|
+
| | `setMainAreaSize(factor)` | Set the main-area zoom factor `[minSizeFactor, 8]` and reposition the paint area |
|
|
1895
|
+
| | `setMinSizeFactor(f)` | Lower the zoom floor so the image can show below 1:1. Clamped to `[0.05, 1]`; default `1`. Not recomputed by the engine — re-apply after case loads, axis switches and panel resizes |
|
|
1896
|
+
| | `getMinSizeFactor()` | Read the current zoom floor |
|
|
1822
1897
|
| | `setCalculateDistanceSphere(x, y, slice, type)` | Programmatically place a calculator sphere (simulates full click flow: record origin → draw → write to volume) |
|
|
1823
1898
|
| **History** | `undo()` | Undo last stroke |
|
|
1824
1899
|
| | `redo()` | Redo last undone stroke |
|
|
@@ -546,7 +546,9 @@ nrrdTools.setCalculateDistanceSphere(200, 150, 42, 'skin');
|
|
|
546
546
|
| `switchAllSlicesArrayData(slices)` | Swap the loaded series and rebuild the display (resets view state) |
|
|
547
547
|
| `switchSlicesPreservingView(slices)` | Swap the loaded series via `switchPreservingView()`, keeping slice index, zoom and pan |
|
|
548
548
|
| `setSliceMoving(step)` | Step the current slice; steps are accumulated and applied in one `requestAnimationFrame` |
|
|
549
|
-
| `setMainAreaSize(factor)` | Clamp the zoom factor to [
|
|
549
|
+
| `setMainAreaSize(factor)` | Clamp the zoom factor to `[view.minSizeFactor, 8]`, resize the paint area and reset its UI position |
|
|
550
|
+
| `setMinSizeFactor(f)` | Lower bound for `sizeFactor`, clamped to `[0.05, 1]` (non-finite → `1`). Also updates `guiParameterSettings.advance.mainAreaSize.min`, and raises + repaints the current factor if it is now below the floor. Never recomputed by the engine — it depends on image/axis dimensions *and* host panel size |
|
|
551
|
+
| `getMinSizeFactor()` | Read the current floor |
|
|
550
552
|
| `setBaseDrawDisplayCanvasesSize(size)` | Set canvas base size multiplier (1–8) |
|
|
551
553
|
| `setupGUI(gui)` | Set up the dat.GUI panel |
|
|
552
554
|
| `enableContrastDragEvents(callback)` | Enable contrast drag (window/level) events |
|
|
@@ -589,7 +591,8 @@ NrrdState groups 44 properties into 5 semantic sub-objects:
|
|
|
589
591
|
| `currentSliceIndex` | `number` | Current slice index |
|
|
590
592
|
| `maxIndex` / `minIndex` | `number` | Slice index range |
|
|
591
593
|
| `changedWidth` / `changedHeight` | `number` | Canvas display dimensions |
|
|
592
|
-
| `sizeFactor` | `number` | Scale factor |
|
|
594
|
+
| `sizeFactor` | `number` | Scale factor. Clamped to `[minSizeFactor, 8]` everywhere it is written — `setMainAreaSize`, `ZoomTool`'s wheel, `NrrdState.setZoomFactor` |
|
|
595
|
+
| `minSizeFactor` | `number` | Lower bound for `sizeFactor`, in `[0.05, 1]`. Default `1` (never smaller than 1:1). Survives `reset()` and case loads |
|
|
593
596
|
| `originWidth` / `originHeight` | `number` | Original image dimensions |
|
|
594
597
|
|
|
595
598
|
#### nrrd_states.interaction (IInteractionState)
|
|
@@ -1281,6 +1284,30 @@ EventRouter permanently binds all pointer/keyboard/wheel events to the drawingCa
|
|
|
1281
1284
|
| `'sphereBrush'` | Set by sphereBrush/sphereEraser mouseDown | `handleSphereBrushWheel` (adjusts `sphereBrushRadius`) |
|
|
1282
1285
|
| `'none'` | Set by mouseDown in draw mode | No-op (wheel suppressed) |
|
|
1283
1286
|
|
|
1287
|
+
#### Wheel zoom ratio <Badge type="tip" text="3.11.4" />
|
|
1288
|
+
|
|
1289
|
+
`ZoomTool`'s `wheelZoomRatio(e)` derives the zoom ratio for one wheel event from **how far it
|
|
1290
|
+
scrolled**, not from the fact that it happened. It replaces a flat `±10%` per event.
|
|
1291
|
+
|
|
1292
|
+
```
|
|
1293
|
+
100px scrolled = one notch = ×1.1 (LOG_STEP_PER_PIXEL = ln(1.1) / 100)
|
|
1294
|
+
deltaMode 1 × 33px (lines, Firefox)
|
|
1295
|
+
deltaMode 2 × 800px (pages)
|
|
1296
|
+
no deltaY → one notch, direction from `detail` / `wheelDelta` (legacy events)
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
Positive `deltaY` (scrolling down) zooms out. The ratio is computed in log space and clamped
|
|
1300
|
+
to `MAX_RATIO_PER_EVENT = 2`, so a single runaway delta cannot jump the view.
|
|
1301
|
+
|
|
1302
|
+
**Why distance rather than event count.** A busy page makes the browser coalesce wheel events
|
|
1303
|
+
and sum their deltas. Counting events therefore zoomed a heavy view *slower* than a light one —
|
|
1304
|
+
the same physical scroll produced less zoom exactly when the app was under load. Following the
|
|
1305
|
+
distance zooms both alike, and it is what lets a trackpad's many small deltas zoom smoothly
|
|
1306
|
+
instead of in 10% jumps.
|
|
1307
|
+
|
|
1308
|
+
The result still passes through the `[minSizeFactor, 8]` clamp and the same
|
|
1309
|
+
`requestAnimationFrame` coalescing as before; only the per-event ratio changed.
|
|
1310
|
+
|
|
1284
1311
|
### 8.4 Default Keyboard Settings
|
|
1285
1312
|
|
|
1286
1313
|
```ts
|
|
@@ -1290,7 +1317,6 @@ IKeyBoardSettings = {
|
|
|
1290
1317
|
redo: "y",
|
|
1291
1318
|
contrast: ["Control", "Meta"],
|
|
1292
1319
|
crosshair: "s",
|
|
1293
|
-
sphere: "q",
|
|
1294
1320
|
mouseWheel: "Scroll:Zoom", // or "Scroll:Slice"
|
|
1295
1321
|
}
|
|
1296
1322
|
|
|
@@ -1299,6 +1325,20 @@ IKeyBoardSettings = {
|
|
|
1299
1325
|
// Ctrl+2 → switch to Scroll:Slice
|
|
1300
1326
|
```
|
|
1301
1327
|
|
|
1328
|
+
::: warning No `sphere` key <Badge type="warning" text="breaking in 3.11.5" />
|
|
1329
|
+
`sphere: "q"` has been removed from `IKeyBoardSettings`, from `EventRouter`'s
|
|
1330
|
+
`DEFAULT_KEYBOARD_SETTINGS`, and the toggle branch is gone from `DrawToolCore`'s keydown
|
|
1331
|
+
handler.
|
|
1332
|
+
|
|
1333
|
+
Sphere mode is entered only through `setMode("sphere")` — the path the calculator already
|
|
1334
|
+
uses — so the active tool is always something the host chose. The shortcut changed
|
|
1335
|
+
`gui_states.mode.sphere` directly, which runs `enterSphereMode()` and clears the masks from
|
|
1336
|
+
the view, while the host's UI still reported its own tool as selected. There was no event to
|
|
1337
|
+
tell it otherwise.
|
|
1338
|
+
|
|
1339
|
+
A host that wants a key for it binds one itself and calls `setMode`.
|
|
1340
|
+
:::
|
|
1341
|
+
|
|
1302
1342
|
---
|
|
1303
1343
|
|
|
1304
1344
|
## 9. Undo/Redo System
|
package/ai-index/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"copper3dVersion": "3.11.
|
|
4
|
-
"generatedAt": "2026-09-
|
|
5
|
-
"symbolCount":
|
|
3
|
+
"copper3dVersion": "3.11.4",
|
|
4
|
+
"generatedAt": "2026-09-30T02:19:02.822Z",
|
|
5
|
+
"symbolCount": 1198,
|
|
6
6
|
"guides": [
|
|
7
7
|
{
|
|
8
8
|
"id": "4D-MRI-LV-rendering",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"title": "NrrdTools Usage Guide",
|
|
91
91
|
"summary": "Copper3D `NrrdTools` — Medical Image Segmentation Annotation Engine",
|
|
92
92
|
"lang": "en",
|
|
93
|
-
"bytes":
|
|
93
|
+
"bytes": 75810
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"id": "on-demand-controls",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"title": "Segmentation Module Documentation",
|
|
123
123
|
"summary": "⚠️ **Note**: All line number references in this document are from historical versions. After multiple rounds of refactoring (State Management Refactor, NrrdTools God Class Split, inheritance → composition refactor), these references are ou…",
|
|
124
124
|
"lang": "en",
|
|
125
|
-
"bytes":
|
|
125
|
+
"bytes": 76560
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
"id": "surface-annotation-api",
|