copper3d 2.0.5 → 2.0.7

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 (28) hide show
  1. package/dist/Scene/commonSceneMethod.js +1 -1
  2. package/dist/Scene/commonSceneMethod.js.map +1 -1
  3. package/dist/Utils/segmentation/CommToolsData.js +1 -0
  4. package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
  5. package/dist/Utils/segmentation/DragOperator.js +11 -0
  6. package/dist/Utils/segmentation/DragOperator.js.map +1 -1
  7. package/dist/Utils/segmentation/DrawToolCore.d.ts +30 -1
  8. package/dist/Utils/segmentation/DrawToolCore.js +193 -16
  9. package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
  10. package/dist/Utils/segmentation/NrrdTools.d.ts +7 -23
  11. package/dist/Utils/segmentation/NrrdTools.js +14 -97
  12. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  13. package/dist/Utils/segmentation/coreTools/coreType.d.ts +113 -1
  14. package/dist/Utils/segmentation/coreTools/coreType.js +1 -0
  15. package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
  16. package/dist/Utils/segmentation/coreTools/gui.d.ts +2 -91
  17. package/dist/Utils/segmentation/coreTools/gui.js +28 -10
  18. package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
  19. package/dist/bundle.esm.js +249 -125
  20. package/dist/bundle.umd.js +249 -125
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +2 -2
  23. package/dist/types/Utils/segmentation/DrawToolCore.d.ts +30 -1
  24. package/dist/types/Utils/segmentation/NrrdTools.d.ts +7 -23
  25. package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +113 -1
  26. package/dist/types/Utils/segmentation/coreTools/gui.d.ts +2 -91
  27. package/dist/types/index.d.ts +1 -1
  28. package/package.json +1 -1
@@ -48375,7 +48375,7 @@ class commonScene {
48375
48375
  (xhr) => { },
48376
48376
  // called when loading has errors
48377
48377
  (error) => {
48378
- console.log("An error happened");
48378
+ console.log("An error happened: ", error);
48379
48379
  });
48380
48380
  }
48381
48381
  }
@@ -68966,7 +68966,7 @@ function setupGui(configs) {
68966
68966
  .add(configs.mainPreSlices.volume, "windowHigh", configs.mainPreSlices.volume.min, configs.mainPreSlices.volume.max, 1)
68967
68967
  .name("ImageContrast")
68968
68968
  .onChange((value) => {
68969
- updateGuiImageContrastOnChange(value);
68969
+ updateGuiImageWindowHighOnChange(value);
68970
68970
  })
68971
68971
  .onFinishChange(() => {
68972
68972
  updateGuiImageContrastOnFinished();
@@ -69060,8 +69060,7 @@ function setupGui(configs) {
69060
69060
  .add(configs.mainPreSlices.volume, "windowLow", configs.mainPreSlices.volume.min, configs.mainPreSlices.volume.max, 1)
69061
69061
  .name("WindowLow")
69062
69062
  .onChange((value) => {
69063
- configs.gui_states.readyToUpdate = false;
69064
- configs.updateSlicesContrast(value, "windowLow");
69063
+ updateGuiImageWindowLowOnChange(value);
69065
69064
  })
69066
69065
  .onFinishChange(() => {
69067
69066
  repraintAllContrastSlices(configs.protectedData.displaySlices);
@@ -69102,18 +69101,28 @@ function setupGui(configs) {
69102
69101
  };
69103
69102
  const updateGuiSphereState = () => {
69104
69103
  if (configs.gui_states.sphere) {
69105
- configs.drawingCanvas.removeEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69104
+ // configs.drawingCanvas.removeEventListener(
69105
+ // "wheel",
69106
+ // configs.drawingPrameters.handleZoomWheel
69107
+ // );
69106
69108
  configs.removeDragMode();
69107
69109
  }
69108
69110
  else {
69109
- configs.drawingCanvas.addEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69111
+ // configs.drawingCanvas.addEventListener(
69112
+ // "wheel",
69113
+ // configs.drawingPrameters.handleZoomWheel
69114
+ // );
69110
69115
  configs.configDragMode();
69111
69116
  // clear canvas
69112
69117
  configs.clearPaint();
69113
69118
  configs.clearStoreImages();
69114
69119
  }
69115
69120
  };
69116
- const updateGuiImageContrastOnChange = (value) => {
69121
+ const updateGuiImageWindowLowOnChange = (value) => {
69122
+ configs.gui_states.readyToUpdate = false;
69123
+ configs.updateSlicesContrast(value, "windowLow");
69124
+ };
69125
+ const updateGuiImageWindowHighOnChange = (value) => {
69117
69126
  configs.gui_states.readyToUpdate = false;
69118
69127
  configs.updateSlicesContrast(value, "windowHigh");
69119
69128
  };
@@ -69161,11 +69170,20 @@ function setupGui(configs) {
69161
69170
  },
69162
69171
  windowHigh: {
69163
69172
  name: "ImageContrast",
69164
- value: configs.mainPreSlices.volume,
69165
- min: configs.mainPreSlices.volume.min,
69166
- max: configs.mainPreSlices.volume.max,
69173
+ value: null,
69174
+ min: 0,
69175
+ max: 0,
69176
+ step: 1,
69177
+ onChange: updateGuiImageWindowHighOnChange,
69178
+ onFinished: updateGuiImageContrastOnFinished,
69179
+ },
69180
+ windowLow: {
69181
+ name: "WindowLow",
69182
+ value: null,
69183
+ min: 0,
69184
+ max: 0,
69167
69185
  step: 1,
69168
- onChange: updateGuiImageContrastOnChange,
69186
+ onChange: updateGuiImageWindowLowOnChange,
69169
69187
  onFinished: updateGuiImageContrastOnFinished,
69170
69188
  },
69171
69189
  advance: {
@@ -69367,9 +69385,20 @@ class DragOperator {
69367
69385
  if (ev.key === "Shift") {
69368
69386
  this.removeDragMode();
69369
69387
  }
69388
+ if (ev.key === 'Control' || ev.key === 'Meta') {
69389
+ if (this.protectedData.Is_Ctrl_Pressed) {
69390
+ this.removeDragMode();
69391
+ }
69392
+ else {
69393
+ this.configDragMode();
69394
+ }
69395
+ }
69370
69396
  });
69371
69397
  this.container.addEventListener("keyup", (ev) => {
69372
69398
  if (ev.key === "Shift" && !this.gui_states.sphere) {
69399
+ if (this.protectedData.Is_Ctrl_Pressed) {
69400
+ return;
69401
+ }
69373
69402
  this.configDragMode();
69374
69403
  }
69375
69404
  });
@@ -69645,6 +69674,7 @@ class CommToolsData {
69645
69674
  currentShowingSlice: undefined,
69646
69675
  mainPreSlices: undefined,
69647
69676
  Is_Shift_Pressed: false,
69677
+ Is_Ctrl_Pressed: false,
69648
69678
  Is_Draw: false,
69649
69679
  axis: "z",
69650
69680
  maskData: {
@@ -69795,6 +69825,18 @@ class DrawToolCore extends CommToolsData {
69795
69825
  handleZoomWheel: (e) => { },
69796
69826
  handleSphereWheel: (e) => { },
69797
69827
  };
69828
+ this.contrastEventPrameters = {
69829
+ move_x: 0,
69830
+ move_y: 0,
69831
+ x: 0,
69832
+ y: 0,
69833
+ w: 0,
69834
+ h: 0,
69835
+ handleOnContrastMouseDown: (ev) => { },
69836
+ handleOnContrastMouseMove: (ev) => { },
69837
+ handleOnContrastMouseUp: (ev) => { },
69838
+ handleOnContrastMouseLeave: (ev) => { },
69839
+ };
69798
69840
  this.eraserUrls = [];
69799
69841
  this.pencilUrls = [];
69800
69842
  this.undoArray = [];
@@ -69808,6 +69850,19 @@ class DrawToolCore extends CommToolsData {
69808
69850
  this.protectedData.ctxes.drawingCtx.strokeStyle = this.gui_states.color;
69809
69851
  this.protectedData.ctxes.drawingCtx.stroke();
69810
69852
  };
69853
+ this.configContrastDragMode = () => {
69854
+ this.container.style.cursor = "pointer";
69855
+ this.container.addEventListener("pointerdown", this.contrastEventPrameters.handleOnContrastMouseDown, true);
69856
+ this.container.addEventListener("pointerup", this.contrastEventPrameters.handleOnContrastMouseUp, true);
69857
+ };
69858
+ this.removeContrastDragMode = () => {
69859
+ this.container.style.cursor = "";
69860
+ this.container.removeEventListener("pointerdown", this.contrastEventPrameters.handleOnContrastMouseDown, true);
69861
+ this.container.removeEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove, true);
69862
+ this.container.removeEventListener("pointerup", this.contrastEventPrameters.handleOnContrastMouseUp, true);
69863
+ this.container.removeEventListener("pointerleave", this.contrastEventPrameters.handleOnContrastMouseLeave, true);
69864
+ this.setIsDrawFalse(1000);
69865
+ };
69811
69866
  this.container = container;
69812
69867
  this.mainAreaContainer = mainAreaContainer;
69813
69868
  this.initDrawToolCore();
@@ -69815,9 +69870,24 @@ class DrawToolCore extends CommToolsData {
69815
69870
  initDrawToolCore() {
69816
69871
  this.container.addEventListener("keydown", (ev) => {
69817
69872
  if (ev.key === "Shift" && !this.gui_states.sphere) {
69873
+ if (this.protectedData.Is_Ctrl_Pressed) {
69874
+ this.protectedData.Is_Shift_Pressed = false;
69875
+ return;
69876
+ }
69818
69877
  this.protectedData.Is_Shift_Pressed = true;
69819
69878
  this.nrrd_states.enableCursorChoose = false;
69820
69879
  }
69880
+ if (ev.key === 'Control' || ev.key === 'Meta') {
69881
+ // Ctrl key pressed on either Windows or macOS
69882
+ this.protectedData.Is_Shift_Pressed = false;
69883
+ this.protectedData.Is_Ctrl_Pressed = !this.protectedData.Is_Ctrl_Pressed;
69884
+ if (this.protectedData.Is_Ctrl_Pressed) {
69885
+ this.configContrastDragMode();
69886
+ }
69887
+ else {
69888
+ this.removeContrastDragMode();
69889
+ }
69890
+ }
69821
69891
  if (ev.key === "s") {
69822
69892
  this.protectedData.Is_Draw = false;
69823
69893
  this.nrrd_states.enableCursorChoose =
@@ -69992,9 +70062,10 @@ class DrawToolCore extends CommToolsData {
69992
70062
  e.offsetY / this.nrrd_states.sizeFoctor;
69993
70063
  this.enableCrosshair();
69994
70064
  }
69995
- else if (this.gui_states.sphere) {
69996
- let mouseX = e.offsetX;
69997
- let mouseY = e.offsetY;
70065
+ else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
70066
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70067
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70068
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
69998
70069
  // record mouseX,Y, and enable crosshair function
69999
70070
  this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70000
70071
  mouseX,
@@ -70006,7 +70077,7 @@ class DrawToolCore extends CommToolsData {
70006
70077
  this.nrrd_states.cursorPageY = mouseY;
70007
70078
  this.enableCrosshair();
70008
70079
  // draw circle setup width/height for sphere canvas
70009
- this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70080
+ this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
70010
70081
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70011
70082
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70012
70083
  }
@@ -70128,9 +70199,14 @@ class DrawToolCore extends CommToolsData {
70128
70199
  }
70129
70200
  }
70130
70201
  !!this.nrrd_states.getSphere &&
70131
- this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius);
70202
+ this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70203
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70132
70204
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70133
70205
  }
70206
+ else if (this.gui_states.sphere &&
70207
+ this.nrrd_states.enableCursorChoose) {
70208
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70209
+ }
70134
70210
  }
70135
70211
  else if (e.button === 2) {
70136
70212
  rightclicked = false;
@@ -70387,17 +70463,12 @@ class DrawToolCore extends CommToolsData {
70387
70463
  const nextIndex = originIndex + decay;
70388
70464
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
70389
70465
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
70390
- // if (
70391
- // preIndex < this.nrrd_states.minIndex ||
70392
- // nextIndex > this.nrrd_states.maxIndex
70393
- // )
70394
- // return;
70395
70466
  if (preIndex === nextIndex) {
70396
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
70467
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70397
70468
  this.storeSphereImages(preIndex, axis);
70398
70469
  }
70399
70470
  else {
70400
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - decay);
70471
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
70401
70472
  this.drawImageOnEmptyImage(canvas);
70402
70473
  this.storeSphereImages(preIndex, axis);
70403
70474
  this.storeSphereImages(nextIndex, axis);
@@ -70406,7 +70477,7 @@ class DrawToolCore extends CommToolsData {
70406
70477
  }
70407
70478
  drawSphereCore(ctx, x, y, radius) {
70408
70479
  ctx.beginPath();
70409
- ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
70480
+ ctx.arc(x, y, radius, 0, 2 * Math.PI);
70410
70481
  ctx.fillStyle = this.gui_states.fillColor;
70411
70482
  ctx.fill();
70412
70483
  ctx.closePath();
@@ -70446,8 +70517,8 @@ class DrawToolCore extends CommToolsData {
70446
70517
  // limited the radius max and min
70447
70518
  this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
70448
70519
  // get mouse position
70449
- const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0];
70450
- const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1];
70520
+ const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] * this.nrrd_states.sizeFoctor;
70521
+ const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1] * this.nrrd_states.sizeFoctor;
70451
70522
  this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70452
70523
  };
70453
70524
  return sphereEvent;
@@ -70464,6 +70535,102 @@ class DrawToolCore extends CommToolsData {
70464
70535
  this.drawSphereCore(ctx, mouseX, mouseY, radius);
70465
70536
  this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
70466
70537
  }
70538
+ /**
70539
+ * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
70540
+ * So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
70541
+ *
70542
+ * When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
70543
+ *
70544
+ * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
70545
+ *
70546
+ * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
70547
+ * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
70548
+ * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
70549
+ * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
70550
+ * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
70551
+ * @returns
70552
+ */
70553
+ convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
70554
+ const nrrd = this.nrrd_states;
70555
+ const dimensions = nrrd.dimensions;
70556
+ const ratios = nrrd.ratios;
70557
+ const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
70558
+ let currentIndex = 0;
70559
+ let oldIndex = 0;
70560
+ let convertCursorNumX = 0;
70561
+ let convertCursorNumY = 0;
70562
+ const convertIndex = {
70563
+ x: {
70564
+ y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70565
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70566
+ },
70567
+ y: {
70568
+ x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70569
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70570
+ },
70571
+ z: {
70572
+ x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70573
+ y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70574
+ },
70575
+ };
70576
+ const convertCursor = {
70577
+ x: {
70578
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70579
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70580
+ },
70581
+ y: {
70582
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70583
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70584
+ },
70585
+ z: {
70586
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70587
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70588
+ },
70589
+ };
70590
+ if (from === to) {
70591
+ return;
70592
+ }
70593
+ if (from === "z" && to === "x") {
70594
+ currentIndex = convertIndex[from][to](cursorNumX);
70595
+ oldIndex = currentIndex * ratios[to];
70596
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70597
+ convertCursorNumY = cursorNumY;
70598
+ }
70599
+ else if (from === "y" && to === "x") {
70600
+ currentIndex = convertIndex[from][to](cursorNumX);
70601
+ oldIndex = currentIndex * ratios.x;
70602
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70603
+ convertCursorNumX = cursorNumY;
70604
+ }
70605
+ else if (from === "z" && to === "y") {
70606
+ currentIndex = convertIndex[from][to](cursorNumY);
70607
+ oldIndex = currentIndex * ratios[to];
70608
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70609
+ convertCursorNumX = cursorNumX;
70610
+ }
70611
+ else if (from === "x" && to === "y") {
70612
+ currentIndex = convertIndex[from][to](cursorNumY);
70613
+ oldIndex = currentIndex * ratios[to];
70614
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70615
+ convertCursorNumY = cursorNumX;
70616
+ }
70617
+ else if (from === "x" && to === "z") {
70618
+ currentIndex = convertIndex[from][to](cursorNumX);
70619
+ oldIndex = currentIndex * ratios[to];
70620
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70621
+ convertCursorNumY = cursorNumY;
70622
+ }
70623
+ else if (from === "y" && to === "z") {
70624
+ currentIndex = convertIndex[from][to](cursorNumY);
70625
+ oldIndex = currentIndex * ratios.z;
70626
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70627
+ convertCursorNumX = cursorNumX;
70628
+ }
70629
+ else {
70630
+ return;
70631
+ }
70632
+ return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
70633
+ }
70467
70634
  setUpSphereOrigins(mouseX, mouseY) {
70468
70635
  const convertCursor = (from, to) => {
70469
70636
  const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
@@ -70830,6 +70997,46 @@ class DrawToolCore extends CommToolsData {
70830
70997
  return sharedPlaceImages;
70831
70998
  }
70832
70999
  /******************************** Utils gui related functions ***************************************/
71000
+ /**
71001
+ * Set up root container events fns for drag function
71002
+ * @param callback
71003
+ */
71004
+ setupConrastEvents(callback) {
71005
+ this.contrastEventPrameters.w = this.container.offsetWidth;
71006
+ this.contrastEventPrameters.h = this.container.offsetHeight;
71007
+ this.contrastEventPrameters.handleOnContrastMouseDown = (ev) => {
71008
+ if (ev.button === 0) {
71009
+ this.contrastEventPrameters.x = ev.offsetX / this.contrastEventPrameters.x;
71010
+ this.contrastEventPrameters.y = ev.offsetY / this.contrastEventPrameters.h;
71011
+ this.container.addEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove);
71012
+ }
71013
+ };
71014
+ this.contrastEventPrameters.handleOnContrastMouseUp = (ev) => {
71015
+ this.container.removeEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove);
71016
+ };
71017
+ this.contrastEventPrameters.handleOnContrastMouseMove = throttle((ev) => {
71018
+ if (this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h >= 0) {
71019
+ this.contrastEventPrameters.move_y = -Math.ceil((this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h) * 10);
71020
+ }
71021
+ else {
71022
+ this.contrastEventPrameters.move_y = -Math.floor((this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h) * 10);
71023
+ }
71024
+ if (this.contrastEventPrameters.move_y !== 0 && Math.abs(this.contrastEventPrameters.move_y) === 1) {
71025
+ callback(this.contrastEventPrameters.move_y, "vertical");
71026
+ }
71027
+ if (this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w >= 0) {
71028
+ this.contrastEventPrameters.move_x = -Math.ceil((this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w) * 10);
71029
+ }
71030
+ else {
71031
+ this.contrastEventPrameters.move_x = -Math.floor((this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w) * 10);
71032
+ }
71033
+ if (this.contrastEventPrameters.move_x !== 0 && Math.abs(this.contrastEventPrameters.move_x) === 1) {
71034
+ callback(this.contrastEventPrameters.move_x, "horizental");
71035
+ }
71036
+ this.contrastEventPrameters.x = ev.offsetX / this.contrastEventPrameters.w;
71037
+ this.contrastEventPrameters.y = ev.offsetY / this.contrastEventPrameters.h;
71038
+ }, 100);
71039
+ }
70833
71040
  updateSlicesContrast(value, flag) {
70834
71041
  switch (flag) {
70835
71042
  case "lowerThreshold":
@@ -70910,6 +71117,13 @@ class NrrdTools extends DrawToolCore {
70910
71117
  setDisplaySliceIndexPanel(panel) {
70911
71118
  this.dragOperator.setShowDragNumberDiv(panel);
70912
71119
  }
71120
+ /**
71121
+ * Enable the drag function for contrast images window center and window high.
71122
+ * @param callback
71123
+ */
71124
+ enableContrastDragEvents(callback) {
71125
+ this.setupConrastEvents(callback);
71126
+ }
70913
71127
  /**
70914
71128
  * Set up GUI for drawing panel
70915
71129
  * @param gui GUI
@@ -70964,6 +71178,12 @@ class NrrdTools extends DrawToolCore {
70964
71178
  this.guiParameterSettings = setupGui(guiOptions);
70965
71179
  }
70966
71180
  getGuiSettings() {
71181
+ if (!!this.guiParameterSettings) {
71182
+ // update image volume
71183
+ this.guiParameterSettings.windowHigh.value = this.guiParameterSettings.windowLow.value = this.protectedData.mainPreSlices.volume;
71184
+ this.guiParameterSettings.windowHigh.max = this.guiParameterSettings.windowLow.max = this.protectedData.mainPreSlices.volume.max;
71185
+ this.guiParameterSettings.windowHigh.min = this.guiParameterSettings.windowLow.min = this.protectedData.mainPreSlices.volume.min;
71186
+ }
70967
71187
  return {
70968
71188
  guiState: this.gui_states,
70969
71189
  guiSetting: this.guiParameterSettings,
@@ -71144,102 +71364,6 @@ class NrrdTools extends DrawToolCore {
71144
71364
  paintImages.z.push(initMark_z);
71145
71365
  }
71146
71366
  }
71147
- /**
71148
- * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
71149
- * So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
71150
- *
71151
- * When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
71152
- *
71153
- * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
71154
- *
71155
- * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
71156
- * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
71157
- * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
71158
- * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
71159
- * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
71160
- * @returns
71161
- */
71162
- convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
71163
- const nrrd = this.nrrd_states;
71164
- const dimensions = nrrd.dimensions;
71165
- const ratios = nrrd.ratios;
71166
- const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
71167
- let currentIndex = 0;
71168
- let oldIndex = 0;
71169
- let convertCursorNumX = 0;
71170
- let convertCursorNumY = 0;
71171
- const convertIndex = {
71172
- x: {
71173
- y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71174
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71175
- },
71176
- y: {
71177
- x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71178
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71179
- },
71180
- z: {
71181
- x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71182
- y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71183
- },
71184
- };
71185
- const convertCursor = {
71186
- x: {
71187
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71188
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71189
- },
71190
- y: {
71191
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71192
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71193
- },
71194
- z: {
71195
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71196
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71197
- },
71198
- };
71199
- if (from === to) {
71200
- return;
71201
- }
71202
- if (from === "z" && to === "x") {
71203
- currentIndex = convertIndex[from][to](cursorNumX);
71204
- oldIndex = currentIndex * ratios[to];
71205
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71206
- convertCursorNumY = cursorNumY;
71207
- }
71208
- else if (from === "y" && to === "x") {
71209
- currentIndex = convertIndex[from][to](cursorNumX);
71210
- oldIndex = currentIndex * ratios.x;
71211
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71212
- convertCursorNumX = cursorNumY;
71213
- }
71214
- else if (from === "z" && to === "y") {
71215
- currentIndex = convertIndex[from][to](cursorNumY);
71216
- oldIndex = currentIndex * ratios[to];
71217
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71218
- convertCursorNumX = cursorNumX;
71219
- }
71220
- else if (from === "x" && to === "y") {
71221
- currentIndex = convertIndex[from][to](cursorNumY);
71222
- oldIndex = currentIndex * ratios[to];
71223
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71224
- convertCursorNumY = cursorNumX;
71225
- }
71226
- else if (from === "x" && to === "z") {
71227
- currentIndex = convertIndex[from][to](cursorNumX);
71228
- oldIndex = currentIndex * ratios[to];
71229
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71230
- convertCursorNumY = cursorNumY;
71231
- }
71232
- else if (from === "y" && to === "z") {
71233
- currentIndex = convertIndex[from][to](cursorNumY);
71234
- oldIndex = currentIndex * ratios.z;
71235
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71236
- convertCursorNumX = cursorNumX;
71237
- }
71238
- else {
71239
- return;
71240
- }
71241
- return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71242
- }
71243
71367
  /**
71244
71368
  * Switch all contrast slices' orientation
71245
71369
  * @param {string} aixs:"x" | "y" | "z"
@@ -71352,7 +71476,7 @@ class NrrdTools extends DrawToolCore {
71352
71476
  this.resetDisplaySlicesStatus();
71353
71477
  // for sphere plan a
71354
71478
  if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
71355
- this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
71479
+ this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereOrigin[axisTo][1] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereRadius);
71356
71480
  }
71357
71481
  }
71358
71482
  addSkip(index) {
@@ -72047,7 +72171,7 @@ function evaluateElement(element, weights) {
72047
72171
  }
72048
72172
 
72049
72173
  // import * as kiwrious from "copper3d_plugin_heart_k";
72050
- const REVISION = "v2.0.5";
72051
- console.log("%cCopper3D Visualisation %cBeta:v2.0.5", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72174
+ const REVISION = "v2.0.7";
72175
+ console.log("%cCopper3D Visualisation %cBeta:v2.0.7", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72052
72176
 
72053
72177
  export { CameraViewPoint, Copper3dTrackballControls, MeshNodeTool, NrrdTools, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, removeGuiFolderChilden, setHDRFilePath, throttle };