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/dist/bundle.umd.js
CHANGED
|
@@ -109152,7 +109152,7 @@ void main() {
|
|
|
109152
109152
|
},
|
|
109153
109153
|
mainAreaSize: {
|
|
109154
109154
|
name: "Zoom",
|
|
109155
|
-
min:
|
|
109155
|
+
min: configs.nrrd_states.view.minSizeFactor,
|
|
109156
109156
|
max: configs.gui_states.viewConfig.max_sensitive,
|
|
109157
109157
|
step: 1,
|
|
109158
109158
|
onFinished: null,
|
|
@@ -109951,7 +109951,6 @@ void main() {
|
|
|
109951
109951
|
redo: 'y',
|
|
109952
109952
|
contrast: ['Control', 'Meta'],
|
|
109953
109953
|
crosshair: 'c',
|
|
109954
|
-
sphere: 'q',
|
|
109955
109954
|
mouseWheel: 'Scroll:Zoom'
|
|
109956
109955
|
};
|
|
109957
109956
|
/**
|
|
@@ -110737,6 +110736,37 @@ void main() {
|
|
|
110737
110736
|
* Extracted from DrawToolCore.ts:
|
|
110738
110737
|
* - configMouseZoomWheel
|
|
110739
110738
|
*/
|
|
110739
|
+
/** Pixels one wheel notch scrolls in Chrome; one notch zooms by 10%. */
|
|
110740
|
+
const PIXELS_PER_NOTCH = 100;
|
|
110741
|
+
const LOG_STEP_PER_PIXEL = Math.log(1.1) / PIXELS_PER_NOTCH;
|
|
110742
|
+
/** deltaMode 1 (lines, Firefox) and 2 (pages) in pixels, so a notch is ~100px everywhere. */
|
|
110743
|
+
const PIXELS_PER_LINE = 33;
|
|
110744
|
+
const PIXELS_PER_PAGE = 800;
|
|
110745
|
+
/** A single event zooms by at most this ratio, so one runaway delta cannot jump the view. */
|
|
110746
|
+
const MAX_RATIO_PER_EVENT = 2;
|
|
110747
|
+
/**
|
|
110748
|
+
* The zoom ratio for one wheel event, proportional to how far it scrolled. A busy page makes
|
|
110749
|
+
* the browser coalesce wheel events and sum their deltas, so counting events would zoom a
|
|
110750
|
+
* heavy view slower than a light one; following the distance zooms both alike, and lets a
|
|
110751
|
+
* trackpad's small deltas zoom smoothly. Scrolling down (positive deltaY) zooms out.
|
|
110752
|
+
*/
|
|
110753
|
+
function wheelZoomRatio(e) {
|
|
110754
|
+
let px = e.deltaY;
|
|
110755
|
+
if (!Number.isFinite(px) || px === 0) {
|
|
110756
|
+
// No deltaY (legacy events): one notch in the direction detail/wheelDelta gives.
|
|
110757
|
+
const out = e.detail ? e.detail > 0 : e.wheelDelta < 0;
|
|
110758
|
+
px = out ? PIXELS_PER_NOTCH : -PIXELS_PER_NOTCH;
|
|
110759
|
+
}
|
|
110760
|
+
else if (e.deltaMode === 1) {
|
|
110761
|
+
px *= PIXELS_PER_LINE;
|
|
110762
|
+
}
|
|
110763
|
+
else if (e.deltaMode === 2) {
|
|
110764
|
+
px *= PIXELS_PER_PAGE;
|
|
110765
|
+
}
|
|
110766
|
+
const maxLog = Math.log(MAX_RATIO_PER_EVENT);
|
|
110767
|
+
const log = Math.max(-maxLog, Math.min(maxLog, -px * LOG_STEP_PER_PIXEL));
|
|
110768
|
+
return Math.exp(log);
|
|
110769
|
+
}
|
|
110740
110770
|
class ZoomTool extends BaseTool {
|
|
110741
110771
|
constructor(ctx, container, mainAreaContainer, callbacks) {
|
|
110742
110772
|
super(ctx);
|
|
@@ -110760,6 +110790,8 @@ void main() {
|
|
|
110760
110790
|
return;
|
|
110761
110791
|
const p = pending;
|
|
110762
110792
|
pending = null;
|
|
110793
|
+
// The host may have raised the minimum since the wheel event queued this target.
|
|
110794
|
+
p.moveDistance = Math.max(p.moveDistance, this.ctx.nrrd_states.view.minSizeFactor);
|
|
110763
110795
|
if (p.recenter) {
|
|
110764
110796
|
this.callbacks.resetPaintAreaUIPosition();
|
|
110765
110797
|
}
|
|
@@ -110781,7 +110813,6 @@ void main() {
|
|
|
110781
110813
|
return;
|
|
110782
110814
|
}
|
|
110783
110815
|
e.preventDefault();
|
|
110784
|
-
const delta = e.detail ? e.detail > 0 : e.wheelDelta < 0;
|
|
110785
110816
|
this.ctx.protectedData.isDrawing = true;
|
|
110786
110817
|
const rect = this.container.getBoundingClientRect();
|
|
110787
110818
|
const drawingCanvas = this.ctx.protectedData.canvases.drawingCanvas;
|
|
@@ -110789,7 +110820,7 @@ void main() {
|
|
|
110789
110820
|
drawingCanvas.offsetWidth;
|
|
110790
110821
|
const ratioT = (e.clientY - rect.top - this.mainAreaContainer.offsetTop - drawingCanvas.offsetTop) /
|
|
110791
110822
|
drawingCanvas.offsetHeight;
|
|
110792
|
-
const ratioDelta =
|
|
110823
|
+
const ratioDelta = wheelZoomRatio(e);
|
|
110793
110824
|
// Compound from the latest pending target (this frame) or the current
|
|
110794
110825
|
// committed sizeFactor.
|
|
110795
110826
|
const base = pending ? pending.moveDistance : this.ctx.nrrd_states.view.sizeFactor;
|
|
@@ -110801,8 +110832,9 @@ void main() {
|
|
|
110801
110832
|
this.callbacks.setIsDrawFalse(1000);
|
|
110802
110833
|
return;
|
|
110803
110834
|
}
|
|
110804
|
-
|
|
110805
|
-
|
|
110835
|
+
const minFactor = this.ctx.nrrd_states.view.minSizeFactor;
|
|
110836
|
+
if (moveDistance < minFactor) {
|
|
110837
|
+
moveDistance = minFactor;
|
|
110806
110838
|
pending = { moveDistance, l: 0, t: 0, recenter: true };
|
|
110807
110839
|
}
|
|
110808
110840
|
else {
|
|
@@ -113547,20 +113579,6 @@ void main() {
|
|
|
113547
113579
|
return; // Ctrl takes priority
|
|
113548
113580
|
}
|
|
113549
113581
|
}
|
|
113550
|
-
// Handle sphere mode toggle
|
|
113551
|
-
if (ev.key === this.state.keyboardSettings.sphere) {
|
|
113552
|
-
// Block during draw mode or contrast mode
|
|
113553
|
-
if (this.eventRouter.isShiftHeld() || this.eventRouter.isCtrlHeld()) {
|
|
113554
|
-
return;
|
|
113555
|
-
}
|
|
113556
|
-
this.state.gui_states.mode.sphere = !this.state.gui_states.mode.sphere;
|
|
113557
|
-
if (this.state.gui_states.mode.sphere) {
|
|
113558
|
-
this.enterSphereMode();
|
|
113559
|
-
}
|
|
113560
|
-
else {
|
|
113561
|
-
this.exitSphereMode();
|
|
113562
|
-
}
|
|
113563
|
-
}
|
|
113564
113582
|
});
|
|
113565
113583
|
this.eventRouter.setKeyupHandler((ev) => {
|
|
113566
113584
|
if (this.state.configKeyBoard)
|
|
@@ -114268,6 +114286,7 @@ void main() {
|
|
|
114268
114286
|
minIndex: 0,
|
|
114269
114287
|
contrastNum: 0,
|
|
114270
114288
|
sizeFactor: baseCanvasesSize,
|
|
114289
|
+
minSizeFactor: 1,
|
|
114271
114290
|
showContrast: false,
|
|
114272
114291
|
switchSliceFlag: false,
|
|
114273
114292
|
previousPanelL: -99999,
|
|
@@ -114299,9 +114318,9 @@ void main() {
|
|
|
114299
114318
|
};
|
|
114300
114319
|
}
|
|
114301
114320
|
// ── Validated Setters ────────────────────────────────────────────────────
|
|
114302
|
-
/** Set zoom factor with clamping [
|
|
114321
|
+
/** Set zoom factor with clamping [minSizeFactor, 8] */
|
|
114303
114322
|
setZoomFactor(factor) {
|
|
114304
|
-
this.view.sizeFactor = Math.max(
|
|
114323
|
+
this.view.sizeFactor = Math.max(this.view.minSizeFactor, Math.min(8, factor));
|
|
114305
114324
|
}
|
|
114306
114325
|
/** Reset all sphere state to defaults */
|
|
114307
114326
|
resetSphereState() {
|
|
@@ -114401,7 +114420,6 @@ void main() {
|
|
|
114401
114420
|
redo: "y",
|
|
114402
114421
|
contrast: ["Control", "Meta"],
|
|
114403
114422
|
crosshair: "s",
|
|
114404
|
-
sphere: "q",
|
|
114405
114423
|
mouseWheel: "Scroll:Zoom",
|
|
114406
114424
|
};
|
|
114407
114425
|
this.cursorPage = {
|
|
@@ -115241,8 +115259,10 @@ void main() {
|
|
|
115241
115259
|
* @param factor number
|
|
115242
115260
|
*/
|
|
115243
115261
|
resizePaintArea(factor) {
|
|
115244
|
-
|
|
115245
|
-
const
|
|
115262
|
+
// A factor below 1 can floor a thin dimension to 0; keep a loaded image at least 1px.
|
|
115263
|
+
const { originWidth, originHeight } = this.ctx.nrrd_states.image;
|
|
115264
|
+
const newWidth = originWidth > 0 ? Math.max(1, Math.floor(originWidth * factor)) : 0;
|
|
115265
|
+
const newHeight = originHeight > 0 ? Math.max(1, Math.floor(originHeight * factor)) : 0;
|
|
115246
115266
|
const sizeChanged = newWidth !== this.ctx.nrrd_states.view.changedWidth ||
|
|
115247
115267
|
newHeight !== this.ctx.nrrd_states.view.changedHeight;
|
|
115248
115268
|
// Always clear display/drawing/origin canvases (needed for contrast updates)
|
|
@@ -116396,12 +116416,38 @@ void main() {
|
|
|
116396
116416
|
if (this.state.nrrd_states.view.sizeFactor >= 8) {
|
|
116397
116417
|
this.state.nrrd_states.view.sizeFactor = 8;
|
|
116398
116418
|
}
|
|
116399
|
-
else if (this.state.nrrd_states.view.sizeFactor <=
|
|
116400
|
-
this.state.nrrd_states.view.sizeFactor =
|
|
116419
|
+
else if (this.state.nrrd_states.view.sizeFactor <= this.state.nrrd_states.view.minSizeFactor) {
|
|
116420
|
+
this.state.nrrd_states.view.sizeFactor = this.state.nrrd_states.view.minSizeFactor;
|
|
116401
116421
|
}
|
|
116402
116422
|
this.resizePaintArea(this.state.nrrd_states.view.sizeFactor);
|
|
116403
116423
|
this.resetPaintAreaUIPosition();
|
|
116404
116424
|
}
|
|
116425
|
+
/**
|
|
116426
|
+
* Set the lower bound for the 2D zoom factor (`sizeFactor`), so the image can be shown
|
|
116427
|
+
* smaller than its original size. Clamped to [0.05, 1]; a non-finite value resets it to 1.
|
|
116428
|
+
* The default is 1. If the current factor is below the new minimum, it is raised to it and
|
|
116429
|
+
* the view repaints. The upper bound (8) is unchanged.
|
|
116430
|
+
*
|
|
116431
|
+
* The minimum survives `reset()` and case loads, and the engine never recomputes it: the
|
|
116432
|
+
* right value depends on the image/axis size and the host panel's size, which the engine
|
|
116433
|
+
* does not know. The host must re-apply it after each case load, axis switch and panel
|
|
116434
|
+
* resize.
|
|
116435
|
+
*/
|
|
116436
|
+
setMinSizeFactor(f) {
|
|
116437
|
+
const min = Number.isFinite(f) ? Math.min(1, Math.max(0.05, f)) : 1;
|
|
116438
|
+
const view = this.state.nrrd_states.view;
|
|
116439
|
+
view.minSizeFactor = min;
|
|
116440
|
+
if (this.guiParameterSettings)
|
|
116441
|
+
this.guiParameterSettings.advance.mainAreaSize.min = min;
|
|
116442
|
+
if (view.sizeFactor < min) {
|
|
116443
|
+
view.sizeFactor = min;
|
|
116444
|
+
this.resizePaintArea(min);
|
|
116445
|
+
this.resetPaintAreaUIPosition();
|
|
116446
|
+
}
|
|
116447
|
+
}
|
|
116448
|
+
getMinSizeFactor() {
|
|
116449
|
+
return this.state.nrrd_states.view.minSizeFactor;
|
|
116450
|
+
}
|
|
116405
116451
|
switchAllSlicesArrayData(allSlices) {
|
|
116406
116452
|
this.state.protectedData.allSlicesArray.length = 0;
|
|
116407
116453
|
this.state.protectedData.allSlicesArray = [...allSlices];
|
|
@@ -118188,15 +118234,15 @@ void main() {
|
|
|
118188
118234
|
}
|
|
118189
118235
|
|
|
118190
118236
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
118191
|
-
// "v3.11.
|
|
118237
|
+
// "v3.11.4" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
|
|
118192
118238
|
// When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
|
|
118193
118239
|
// referencing it throws a ReferenceError — guard it so local loading still works.
|
|
118194
118240
|
let _revision = "unknown";
|
|
118195
118241
|
try {
|
|
118196
|
-
_revision = "v3.11.
|
|
118242
|
+
_revision = "v3.11.4";
|
|
118197
118243
|
}
|
|
118198
118244
|
catch (_a) {
|
|
118199
|
-
/* "v3.11.
|
|
118245
|
+
/* "v3.11.4" not injected (local source build) */
|
|
118200
118246
|
}
|
|
118201
118247
|
const REVISION = _revision;
|
|
118202
118248
|
// Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
|
|
@@ -179,6 +179,19 @@ export declare class NrrdTools {
|
|
|
179
179
|
setContrastIndex(index: number): void;
|
|
180
180
|
setSliceMoving(step: number): void;
|
|
181
181
|
setMainAreaSize(factor: number): void;
|
|
182
|
+
/**
|
|
183
|
+
* Set the lower bound for the 2D zoom factor (`sizeFactor`), so the image can be shown
|
|
184
|
+
* smaller than its original size. Clamped to [0.05, 1]; a non-finite value resets it to 1.
|
|
185
|
+
* The default is 1. If the current factor is below the new minimum, it is raised to it and
|
|
186
|
+
* the view repaints. The upper bound (8) is unchanged.
|
|
187
|
+
*
|
|
188
|
+
* The minimum survives `reset()` and case loads, and the engine never recomputes it: the
|
|
189
|
+
* right value depends on the image/axis size and the host panel's size, which the engine
|
|
190
|
+
* does not know. The host must re-apply it after each case load, axis switch and panel
|
|
191
|
+
* resize.
|
|
192
|
+
*/
|
|
193
|
+
setMinSizeFactor(f: number): void;
|
|
194
|
+
getMinSizeFactor(): number;
|
|
182
195
|
switchAllSlicesArrayData(allSlices: Array<nrrdSliceType>): void;
|
|
183
196
|
/**
|
|
184
197
|
* Batched form of `setSkips` + `setContrastIndex` for a load that ends by reconciling skip
|
|
@@ -420,6 +420,8 @@ export interface IViewState {
|
|
|
420
420
|
minIndex: number;
|
|
421
421
|
contrastNum: number;
|
|
422
422
|
sizeFactor: number;
|
|
423
|
+
/** Lower bound for `sizeFactor`, in [0.05, 1]. Default 1 (never smaller than 1:1). */
|
|
424
|
+
minSizeFactor: number;
|
|
423
425
|
showContrast: boolean;
|
|
424
426
|
switchSliceFlag: boolean;
|
|
425
427
|
previousPanelL: number;
|
|
@@ -518,6 +520,5 @@ export interface IKeyBoardSettings {
|
|
|
518
520
|
redo: string;
|
|
519
521
|
contrast: string[];
|
|
520
522
|
crosshair: string;
|
|
521
|
-
sphere: string;
|
|
522
523
|
mouseWheel: "Scroll:Zoom" | "Scroll:Slice";
|
|
523
524
|
}
|
|
@@ -18,7 +18,7 @@ export declare class NrrdState {
|
|
|
18
18
|
readonly sphere: ISphereState;
|
|
19
19
|
readonly flags: IInternalFlags;
|
|
20
20
|
constructor(baseCanvasesSize?: number, layers?: string[]);
|
|
21
|
-
/** Set zoom factor with clamping [
|
|
21
|
+
/** Set zoom factor with clamping [minSizeFactor, 8] */
|
|
22
22
|
setZoomFactor(factor: number): void;
|
|
23
23
|
/** Reset all sphere state to defaults */
|
|
24
24
|
resetSphereState(): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copper3d",
|
|
3
3
|
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
|
|
4
|
-
"version": "3.11.
|
|
4
|
+
"version": "3.11.4",
|
|
5
5
|
"main": "dist/bundle.umd.js",
|
|
6
6
|
"moudle": "dist/bundle.esm.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|