copper3d 3.11.1 → 3.11.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomTool.js","sourceRoot":"","sources":["../../../../src/Utils/segmentation/tools/ZoomTool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,MAAM,OAAO,QAAS,SAAQ,QAAQ;IAKpC,YACE,GAAgB,EAChB,SAAsB,EACtB,iBAAiC,EACjC,SAAuB;QAEvB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,yBAAyB;IAEzB,oBAAoB;QAClB,sEAAsE;QACtE,yEAAyE;QACzE,sEAAsE;QACtE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,IAAI,KAAK,GAAkB,IAAI,CAAC;QAChC,IAAI,OAAO,GAEA,IAAI,CAAC;QAEhB,MAAM,KAAK,GAAG,GAAG,EAAE;YACjB,KAAK,GAAG,IAAI,CAAC;YACb,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,MAAM,CAAC,GAAG,OAAO,CAAC;YAClB,OAAO,GAAG,IAAI,CAAC;YAEf,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACf,IAAI,CAAC,SAAS,CAAC,wBAAwB,EAAE,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;YAC/C,IAAI,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AAY,GAAG,SAAS,EAAE,CAAC;gBAC7B,YAAY,GAAG,SAAS,CAAC;gBACzB,OAAO,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACN,oEAAoE;gBACpE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC;gBAChE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC;gBACjE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAClB,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CACvE,CAAC;gBACF,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAClB,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CACrE,CAAC;gBACF,OAAO,GAAG,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;YACpD,CAAC;YAED,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
@@ -109144,7 +109144,7 @@ function setupGui(configs) {
109144
109144
  },
109145
109145
  mainAreaSize: {
109146
109146
  name: "Zoom",
109147
- min: 1,
109147
+ min: configs.nrrd_states.view.minSizeFactor,
109148
109148
  max: configs.gui_states.viewConfig.max_sensitive,
109149
109149
  step: 1,
109150
109150
  onFinished: null,
@@ -110752,6 +110752,8 @@ class ZoomTool extends BaseTool {
110752
110752
  return;
110753
110753
  const p = pending;
110754
110754
  pending = null;
110755
+ // The host may have raised the minimum since the wheel event queued this target.
110756
+ p.moveDistance = Math.max(p.moveDistance, this.ctx.nrrd_states.view.minSizeFactor);
110755
110757
  if (p.recenter) {
110756
110758
  this.callbacks.resetPaintAreaUIPosition();
110757
110759
  }
@@ -110793,8 +110795,9 @@ class ZoomTool extends BaseTool {
110793
110795
  this.callbacks.setIsDrawFalse(1000);
110794
110796
  return;
110795
110797
  }
110796
- if (moveDistance < 1) {
110797
- moveDistance = 1;
110798
+ const minFactor = this.ctx.nrrd_states.view.minSizeFactor;
110799
+ if (moveDistance < minFactor) {
110800
+ moveDistance = minFactor;
110798
110801
  pending = { moveDistance, l: 0, t: 0, recenter: true };
110799
110802
  }
110800
110803
  else {
@@ -114260,6 +114263,7 @@ class NrrdState {
114260
114263
  minIndex: 0,
114261
114264
  contrastNum: 0,
114262
114265
  sizeFactor: baseCanvasesSize,
114266
+ minSizeFactor: 1,
114263
114267
  showContrast: false,
114264
114268
  switchSliceFlag: false,
114265
114269
  previousPanelL: -99999,
@@ -114291,9 +114295,9 @@ class NrrdState {
114291
114295
  };
114292
114296
  }
114293
114297
  // ── Validated Setters ────────────────────────────────────────────────────
114294
- /** Set zoom factor with clamping [1, 8] */
114298
+ /** Set zoom factor with clamping [minSizeFactor, 8] */
114295
114299
  setZoomFactor(factor) {
114296
- this.view.sizeFactor = Math.max(1, Math.min(8, factor));
114300
+ this.view.sizeFactor = Math.max(this.view.minSizeFactor, Math.min(8, factor));
114297
114301
  }
114298
114302
  /** Reset all sphere state to defaults */
114299
114303
  resetSphereState() {
@@ -115233,8 +115237,10 @@ class SliceRenderPipeline extends BaseTool {
115233
115237
  * @param factor number
115234
115238
  */
115235
115239
  resizePaintArea(factor) {
115236
- const newWidth = Math.floor(this.ctx.nrrd_states.image.originWidth * factor);
115237
- const newHeight = Math.floor(this.ctx.nrrd_states.image.originHeight * factor);
115240
+ // A factor below 1 can floor a thin dimension to 0; keep a loaded image at least 1px.
115241
+ const { originWidth, originHeight } = this.ctx.nrrd_states.image;
115242
+ const newWidth = originWidth > 0 ? Math.max(1, Math.floor(originWidth * factor)) : 0;
115243
+ const newHeight = originHeight > 0 ? Math.max(1, Math.floor(originHeight * factor)) : 0;
115238
115244
  const sizeChanged = newWidth !== this.ctx.nrrd_states.view.changedWidth ||
115239
115245
  newHeight !== this.ctx.nrrd_states.view.changedHeight;
115240
115246
  // Always clear display/drawing/origin canvases (needed for contrast updates)
@@ -116388,12 +116394,38 @@ class NrrdTools {
116388
116394
  if (this.state.nrrd_states.view.sizeFactor >= 8) {
116389
116395
  this.state.nrrd_states.view.sizeFactor = 8;
116390
116396
  }
116391
- else if (this.state.nrrd_states.view.sizeFactor <= 1) {
116392
- this.state.nrrd_states.view.sizeFactor = 1;
116397
+ else if (this.state.nrrd_states.view.sizeFactor <= this.state.nrrd_states.view.minSizeFactor) {
116398
+ this.state.nrrd_states.view.sizeFactor = this.state.nrrd_states.view.minSizeFactor;
116393
116399
  }
116394
116400
  this.resizePaintArea(this.state.nrrd_states.view.sizeFactor);
116395
116401
  this.resetPaintAreaUIPosition();
116396
116402
  }
116403
+ /**
116404
+ * Set the lower bound for the 2D zoom factor (`sizeFactor`), so the image can be shown
116405
+ * smaller than its original size. Clamped to [0.05, 1]; a non-finite value resets it to 1.
116406
+ * The default is 1. If the current factor is below the new minimum, it is raised to it and
116407
+ * the view repaints. The upper bound (8) is unchanged.
116408
+ *
116409
+ * The minimum survives `reset()` and case loads, and the engine never recomputes it: the
116410
+ * right value depends on the image/axis size and the host panel's size, which the engine
116411
+ * does not know. The host must re-apply it after each case load, axis switch and panel
116412
+ * resize.
116413
+ */
116414
+ setMinSizeFactor(f) {
116415
+ const min = Number.isFinite(f) ? Math.min(1, Math.max(0.05, f)) : 1;
116416
+ const view = this.state.nrrd_states.view;
116417
+ view.minSizeFactor = min;
116418
+ if (this.guiParameterSettings)
116419
+ this.guiParameterSettings.advance.mainAreaSize.min = min;
116420
+ if (view.sizeFactor < min) {
116421
+ view.sizeFactor = min;
116422
+ this.resizePaintArea(min);
116423
+ this.resetPaintAreaUIPosition();
116424
+ }
116425
+ }
116426
+ getMinSizeFactor() {
116427
+ return this.state.nrrd_states.view.minSizeFactor;
116428
+ }
116397
116429
  switchAllSlicesArrayData(allSlices) {
116398
116430
  this.state.protectedData.allSlicesArray.length = 0;
116399
116431
  this.state.protectedData.allSlicesArray = [...allSlices];
@@ -116857,6 +116889,26 @@ class NrrdTools {
116857
116889
  this.state.nrrd_states.sphere.skinSphereOrigin = null;
116858
116890
  this.state.nrrd_states.sphere.nippleSphereOrigin = null;
116859
116891
  }
116892
+ /**
116893
+ * Releases what this instance holds outside its own DOM subtree, so a viewer that is torn
116894
+ * down can be garbage-collected: the event router's listeners (its window `blur` listener
116895
+ * reaches the whole engine graph), a pending slice step and the drawing-flag timer.
116896
+ *
116897
+ * The instance must not be used afterwards. Safe to call more than once.
116898
+ */
116899
+ dispose() {
116900
+ var _a;
116901
+ (_a = this.drawCore.eventRouter) === null || _a === void 0 ? void 0 : _a.unbindAll();
116902
+ if (this._sliceRAFId !== null) {
116903
+ cancelAnimationFrame(this._sliceRAFId);
116904
+ this._sliceRAFId = null;
116905
+ }
116906
+ this._pendingSliceStep = 0;
116907
+ if (this.preTimer !== undefined) {
116908
+ window.clearTimeout(this.preTimer);
116909
+ this.preTimer = undefined;
116910
+ }
116911
+ }
116860
116912
  // ═══════════════════════════════════════════════════════════════════════════
116861
116913
  // 12. Internal — Input Events
116862
116914
  // ═══════════════════════════════════════════════════════════════════════════
@@ -118160,15 +118212,15 @@ function installFastSliceRepaint(rawSlice_1) {
118160
118212
  }
118161
118213
 
118162
118214
  // import * as kiwrious from "copper3d_plugin_heart_k";
118163
- // "v3.11.1" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
118215
+ // "v3.11.3" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
118164
118216
  // When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
118165
118217
  // referencing it throws a ReferenceError — guard it so local loading still works.
118166
118218
  let _revision = "unknown";
118167
118219
  try {
118168
- _revision = "v3.11.1";
118220
+ _revision = "v3.11.3";
118169
118221
  }
118170
118222
  catch (_a) {
118171
- /* "v3.11.1" not injected (local source build) */
118223
+ /* "v3.11.3" not injected (local source build) */
118172
118224
  }
118173
118225
  const REVISION = _revision;
118174
118226
  // Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
@@ -109152,7 +109152,7 @@ void main() {
109152
109152
  },
109153
109153
  mainAreaSize: {
109154
109154
  name: "Zoom",
109155
- min: 1,
109155
+ min: configs.nrrd_states.view.minSizeFactor,
109156
109156
  max: configs.gui_states.viewConfig.max_sensitive,
109157
109157
  step: 1,
109158
109158
  onFinished: null,
@@ -110760,6 +110760,8 @@ void main() {
110760
110760
  return;
110761
110761
  const p = pending;
110762
110762
  pending = null;
110763
+ // The host may have raised the minimum since the wheel event queued this target.
110764
+ p.moveDistance = Math.max(p.moveDistance, this.ctx.nrrd_states.view.minSizeFactor);
110763
110765
  if (p.recenter) {
110764
110766
  this.callbacks.resetPaintAreaUIPosition();
110765
110767
  }
@@ -110801,8 +110803,9 @@ void main() {
110801
110803
  this.callbacks.setIsDrawFalse(1000);
110802
110804
  return;
110803
110805
  }
110804
- if (moveDistance < 1) {
110805
- moveDistance = 1;
110806
+ const minFactor = this.ctx.nrrd_states.view.minSizeFactor;
110807
+ if (moveDistance < minFactor) {
110808
+ moveDistance = minFactor;
110806
110809
  pending = { moveDistance, l: 0, t: 0, recenter: true };
110807
110810
  }
110808
110811
  else {
@@ -114268,6 +114271,7 @@ void main() {
114268
114271
  minIndex: 0,
114269
114272
  contrastNum: 0,
114270
114273
  sizeFactor: baseCanvasesSize,
114274
+ minSizeFactor: 1,
114271
114275
  showContrast: false,
114272
114276
  switchSliceFlag: false,
114273
114277
  previousPanelL: -99999,
@@ -114299,9 +114303,9 @@ void main() {
114299
114303
  };
114300
114304
  }
114301
114305
  // ── Validated Setters ────────────────────────────────────────────────────
114302
- /** Set zoom factor with clamping [1, 8] */
114306
+ /** Set zoom factor with clamping [minSizeFactor, 8] */
114303
114307
  setZoomFactor(factor) {
114304
- this.view.sizeFactor = Math.max(1, Math.min(8, factor));
114308
+ this.view.sizeFactor = Math.max(this.view.minSizeFactor, Math.min(8, factor));
114305
114309
  }
114306
114310
  /** Reset all sphere state to defaults */
114307
114311
  resetSphereState() {
@@ -115241,8 +115245,10 @@ void main() {
115241
115245
  * @param factor number
115242
115246
  */
115243
115247
  resizePaintArea(factor) {
115244
- const newWidth = Math.floor(this.ctx.nrrd_states.image.originWidth * factor);
115245
- const newHeight = Math.floor(this.ctx.nrrd_states.image.originHeight * factor);
115248
+ // A factor below 1 can floor a thin dimension to 0; keep a loaded image at least 1px.
115249
+ const { originWidth, originHeight } = this.ctx.nrrd_states.image;
115250
+ const newWidth = originWidth > 0 ? Math.max(1, Math.floor(originWidth * factor)) : 0;
115251
+ const newHeight = originHeight > 0 ? Math.max(1, Math.floor(originHeight * factor)) : 0;
115246
115252
  const sizeChanged = newWidth !== this.ctx.nrrd_states.view.changedWidth ||
115247
115253
  newHeight !== this.ctx.nrrd_states.view.changedHeight;
115248
115254
  // Always clear display/drawing/origin canvases (needed for contrast updates)
@@ -116396,12 +116402,38 @@ void main() {
116396
116402
  if (this.state.nrrd_states.view.sizeFactor >= 8) {
116397
116403
  this.state.nrrd_states.view.sizeFactor = 8;
116398
116404
  }
116399
- else if (this.state.nrrd_states.view.sizeFactor <= 1) {
116400
- this.state.nrrd_states.view.sizeFactor = 1;
116405
+ else if (this.state.nrrd_states.view.sizeFactor <= this.state.nrrd_states.view.minSizeFactor) {
116406
+ this.state.nrrd_states.view.sizeFactor = this.state.nrrd_states.view.minSizeFactor;
116401
116407
  }
116402
116408
  this.resizePaintArea(this.state.nrrd_states.view.sizeFactor);
116403
116409
  this.resetPaintAreaUIPosition();
116404
116410
  }
116411
+ /**
116412
+ * Set the lower bound for the 2D zoom factor (`sizeFactor`), so the image can be shown
116413
+ * smaller than its original size. Clamped to [0.05, 1]; a non-finite value resets it to 1.
116414
+ * The default is 1. If the current factor is below the new minimum, it is raised to it and
116415
+ * the view repaints. The upper bound (8) is unchanged.
116416
+ *
116417
+ * The minimum survives `reset()` and case loads, and the engine never recomputes it: the
116418
+ * right value depends on the image/axis size and the host panel's size, which the engine
116419
+ * does not know. The host must re-apply it after each case load, axis switch and panel
116420
+ * resize.
116421
+ */
116422
+ setMinSizeFactor(f) {
116423
+ const min = Number.isFinite(f) ? Math.min(1, Math.max(0.05, f)) : 1;
116424
+ const view = this.state.nrrd_states.view;
116425
+ view.minSizeFactor = min;
116426
+ if (this.guiParameterSettings)
116427
+ this.guiParameterSettings.advance.mainAreaSize.min = min;
116428
+ if (view.sizeFactor < min) {
116429
+ view.sizeFactor = min;
116430
+ this.resizePaintArea(min);
116431
+ this.resetPaintAreaUIPosition();
116432
+ }
116433
+ }
116434
+ getMinSizeFactor() {
116435
+ return this.state.nrrd_states.view.minSizeFactor;
116436
+ }
116405
116437
  switchAllSlicesArrayData(allSlices) {
116406
116438
  this.state.protectedData.allSlicesArray.length = 0;
116407
116439
  this.state.protectedData.allSlicesArray = [...allSlices];
@@ -116865,6 +116897,26 @@ void main() {
116865
116897
  this.state.nrrd_states.sphere.skinSphereOrigin = null;
116866
116898
  this.state.nrrd_states.sphere.nippleSphereOrigin = null;
116867
116899
  }
116900
+ /**
116901
+ * Releases what this instance holds outside its own DOM subtree, so a viewer that is torn
116902
+ * down can be garbage-collected: the event router's listeners (its window `blur` listener
116903
+ * reaches the whole engine graph), a pending slice step and the drawing-flag timer.
116904
+ *
116905
+ * The instance must not be used afterwards. Safe to call more than once.
116906
+ */
116907
+ dispose() {
116908
+ var _a;
116909
+ (_a = this.drawCore.eventRouter) === null || _a === void 0 ? void 0 : _a.unbindAll();
116910
+ if (this._sliceRAFId !== null) {
116911
+ cancelAnimationFrame(this._sliceRAFId);
116912
+ this._sliceRAFId = null;
116913
+ }
116914
+ this._pendingSliceStep = 0;
116915
+ if (this.preTimer !== undefined) {
116916
+ window.clearTimeout(this.preTimer);
116917
+ this.preTimer = undefined;
116918
+ }
116919
+ }
116868
116920
  // ═══════════════════════════════════════════════════════════════════════════
116869
116921
  // 12. Internal — Input Events
116870
116922
  // ═══════════════════════════════════════════════════════════════════════════
@@ -118168,15 +118220,15 @@ void main() {
118168
118220
  }
118169
118221
 
118170
118222
  // import * as kiwrious from "copper3d_plugin_heart_k";
118171
- // "v3.11.1" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
118223
+ // "v3.11.3" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
118172
118224
  // When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
118173
118225
  // referencing it throws a ReferenceError — guard it so local loading still works.
118174
118226
  let _revision = "unknown";
118175
118227
  try {
118176
- _revision = "v3.11.1";
118228
+ _revision = "v3.11.3";
118177
118229
  }
118178
118230
  catch (_a) {
118179
- /* "v3.11.1" not injected (local source build) */
118231
+ /* "v3.11.3" not injected (local source build) */
118180
118232
  }
118181
118233
  const REVISION = _revision;
118182
118234
  // 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
@@ -412,6 +425,14 @@ export declare class NrrdTools {
412
425
  aiCommitToLayer(targetLayer?: string): void;
413
426
  clearActiveLayer(): void;
414
427
  reset(): void;
428
+ /**
429
+ * Releases what this instance holds outside its own DOM subtree, so a viewer that is torn
430
+ * down can be garbage-collected: the event router's listeners (its window `blur` listener
431
+ * reaches the whole engine graph), a pending slice step and the drawing-flag timer.
432
+ *
433
+ * The instance must not be used afterwards. Safe to call more than once.
434
+ */
435
+ dispose(): void;
415
436
  configMouseSliceWheel(): (e: WheelEvent) => void;
416
437
  updateMouseWheelEvent(): void;
417
438
  setIsDrawFalse(target: number): void;
@@ -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;
@@ -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 [1, 8] */
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.1",
4
+ "version": "3.11.3",
5
5
  "main": "dist/bundle.umd.js",
6
6
  "moudle": "dist/bundle.esm.js",
7
7
  "types": "dist/types/index.d.ts",