copper3d 2.0.9 → 2.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.
@@ -49836,7 +49836,7 @@ var Stats$1 = Stats;
49836
49836
 
49837
49837
  class baseRenderer {
49838
49838
  constructor(container, options) {
49839
- var _a, _b, _c, _d;
49839
+ var _a, _b, _c, _d, _e;
49840
49840
  this.visualCtrls = [];
49841
49841
  this.container = container;
49842
49842
  this.options = options;
@@ -49866,7 +49866,7 @@ class baseRenderer {
49866
49866
  });
49867
49867
  }
49868
49868
  this.currentScene.sceneName = "default";
49869
- !!this.currentScene.vignette &&
49869
+ (!!this.currentScene.vignette && !(!!((_e = this.options) === null || _e === void 0 ? void 0 : _e.alpha))) &&
49870
49870
  this.updateEnvironment(this.currentScene.vignette);
49871
49871
  this.state = {
49872
49872
  playbackSpeed: 1.0,
@@ -69674,6 +69674,12 @@ function setupGui(configs) {
69674
69674
  .onChange(() => {
69675
69675
  updateGuiSphereState();
69676
69676
  });
69677
+ actionsFolder
69678
+ .add(configs.gui_states, "calculator")
69679
+ .name("Calculator")
69680
+ .onChange(() => {
69681
+ updateCalculatorState();
69682
+ });
69677
69683
  actionsFolder
69678
69684
  .add(configs.gui_states, "brushAndEraserSize")
69679
69685
  .name("BrushAndEraserSize")
@@ -69700,6 +69706,12 @@ function setupGui(configs) {
69700
69706
  updateGuiImageContrastOnFinished();
69701
69707
  });
69702
69708
  const advanceFolder = configs.modeFolder.addFolder("AdvanceSettings");
69709
+ advanceFolder
69710
+ .add(configs.gui_states, "cal_distance", ["tumour", "skin", "ribcage", "nipple"])
69711
+ .name("Label")
69712
+ .onChange((val) => {
69713
+ updateCalDistance(val);
69714
+ });
69703
69715
  advanceFolder
69704
69716
  .add(configs.gui_states, "label", ["label1", "label2", "label3"])
69705
69717
  .name("Label")
@@ -69846,6 +69858,43 @@ function setupGui(configs) {
69846
69858
  configs.clearStoreImages();
69847
69859
  }
69848
69860
  };
69861
+ const updateCalculatorState = () => {
69862
+ if (configs.gui_states.calculator) {
69863
+ // disable mouse to drag slices
69864
+ configs.removeDragMode();
69865
+ }
69866
+ else {
69867
+ // enable mouse to drag slices
69868
+ configs.configDragMode();
69869
+ // clear canvas
69870
+ configs.clearPaint();
69871
+ configs.clearStoreImages();
69872
+ }
69873
+ };
69874
+ const updateCalDistance = (val) => {
69875
+ switch (val) {
69876
+ case "tumour":
69877
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69878
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69879
+ break;
69880
+ case "skin":
69881
+ configs.gui_states.fillColor = configs.nrrd_states.skinColor;
69882
+ configs.gui_states.brushColor = configs.nrrd_states.skinColor;
69883
+ break;
69884
+ case "ribcage":
69885
+ configs.gui_states.fillColor = configs.nrrd_states.ribcageColor;
69886
+ configs.gui_states.brushColor = configs.nrrd_states.ribcageColor;
69887
+ break;
69888
+ case "nipple":
69889
+ configs.gui_states.fillColor = configs.nrrd_states.nippleColor;
69890
+ configs.gui_states.brushColor = configs.nrrd_states.nippleColor;
69891
+ break;
69892
+ default:
69893
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69894
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69895
+ break;
69896
+ }
69897
+ };
69849
69898
  const updateGuiImageWindowLowOnChange = (value) => {
69850
69899
  configs.gui_states.readyToUpdate = false;
69851
69900
  configs.updateSlicesContrast(value, "windowLow");
@@ -69884,6 +69933,14 @@ function setupGui(configs) {
69884
69933
  name: "Eraser",
69885
69934
  onChange: updateGuiEraserState,
69886
69935
  },
69936
+ calculator: {
69937
+ name: "Calculator",
69938
+ onChange: updateCalculatorState,
69939
+ },
69940
+ cal_distance: {
69941
+ name: "CalculatorDistance",
69942
+ onChange: updateCalDistance
69943
+ },
69887
69944
  clear: {
69888
69945
  name: "Clear",
69889
69946
  },
@@ -70308,6 +70365,14 @@ class CommToolsData {
70308
70365
  cursorPageX: 0,
70309
70366
  cursorPageY: 0,
70310
70367
  sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
70368
+ tumourSphereOrigin: null,
70369
+ skinSphereOrigin: null,
70370
+ ribSphereOrigin: null,
70371
+ nippleSphereOrigin: null,
70372
+ tumourColor: "#00ff00",
70373
+ skinColor: "#FFEB3B",
70374
+ ribcageColor: "#2196F3",
70375
+ nippleColor: "#E91E63",
70311
70376
  spherePlanB: true,
70312
70377
  sphereRadius: 10,
70313
70378
  Mouse_Over_x: 0,
@@ -70322,6 +70387,7 @@ class CommToolsData {
70322
70387
  labels: ["label1", "label2", "label3"],
70323
70388
  getMask: (mask, sliceId, label, width, height, clearAllFlag) => { },
70324
70389
  getSphere: (sphereOrigin, sphereRadius) => { },
70390
+ getCalculateSpherePositions: (tumourSphereOrigin, skinSphereOrigin, ribSphereOrigin, nippleSphereOrigin, aixs) => { },
70325
70391
  drawStartPos: { x: 1, y: 1 },
70326
70392
  };
70327
70393
  this.cursorPage = {
@@ -70357,7 +70423,9 @@ class CommToolsData {
70357
70423
  brushAndEraserSize: 15,
70358
70424
  cursor: "dot",
70359
70425
  label: "label1",
70426
+ cal_distance: "tumour",
70360
70427
  sphere: false,
70428
+ calculator: false,
70361
70429
  readyToUpdate: true,
70362
70430
  defaultPaintCursor: switchPencilIcon("dot"),
70363
70431
  max_sensitive: 100,
@@ -70467,6 +70535,12 @@ class CommToolsData {
70467
70535
  clearStoreImages() {
70468
70536
  throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70469
70537
  }
70538
+ /**
70539
+ * Rewrite this {createEmptyPaintImage} function under NrrdTools
70540
+ */
70541
+ createEmptyPaintImage(dimensions, paintImages) {
70542
+ throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70543
+ }
70470
70544
  /**
70471
70545
  * Rewrite this {resizePaintArea} function under NrrdTools
70472
70546
  */
@@ -70601,7 +70675,7 @@ class DrawToolCore extends CommToolsData {
70601
70675
  initDrawToolCore() {
70602
70676
  let undoFlag = false;
70603
70677
  this.container.addEventListener("keydown", (ev) => {
70604
- if (ev.key === "Shift" && !this.gui_states.sphere) {
70678
+ if (ev.key === "Shift" && !this.gui_states.sphere && !this.gui_states.calculator) {
70605
70679
  if (this.protectedData.Is_Ctrl_Pressed) {
70606
70680
  this.protectedData.Is_Shift_Pressed = false;
70607
70681
  return;
@@ -70678,9 +70752,64 @@ class DrawToolCore extends CommToolsData {
70678
70752
  if (!!opts) {
70679
70753
  this.nrrd_states.getMask = opts === null || opts === void 0 ? void 0 : opts.getMaskData;
70680
70754
  this.nrrd_states.getSphere = opts === null || opts === void 0 ? void 0 : opts.getSphereData;
70755
+ this.nrrd_states.getCalculateSpherePositions = opts === null || opts === void 0 ? void 0 : opts.getCalculateSpherePositionsData;
70681
70756
  }
70682
70757
  this.paintOnCanvas();
70683
70758
  }
70759
+ drawCalSphereDown(x, y, sliceIndex, cal_position) {
70760
+ this.nrrd_states.sphereRadius = 5;
70761
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70762
+ let mouseX = x / this.nrrd_states.sizeFoctor;
70763
+ let mouseY = y / this.nrrd_states.sizeFoctor;
70764
+ // record mouseX,Y, and enable crosshair function
70765
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70766
+ mouseX,
70767
+ mouseY,
70768
+ sliceIndex,
70769
+ ];
70770
+ this.setUpSphereOrigins(mouseX, mouseY, sliceIndex);
70771
+ switch (cal_position) {
70772
+ case "tumour":
70773
+ this.nrrd_states.tumourSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70774
+ break;
70775
+ case "skin":
70776
+ this.nrrd_states.skinSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70777
+ break;
70778
+ case "nipple":
70779
+ this.nrrd_states.nippleSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70780
+ break;
70781
+ case "ribcage":
70782
+ this.nrrd_states.ribSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70783
+ break;
70784
+ }
70785
+ this.nrrd_states.cursorPageX = mouseX;
70786
+ this.nrrd_states.cursorPageY = mouseY;
70787
+ this.enableCrosshair();
70788
+ // draw circle setup width/height for sphere canvas
70789
+ this.drawCalculatorSphere(this.nrrd_states.sphereRadius);
70790
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70791
+ }
70792
+ drawCalSphereUp() {
70793
+ // TODO send data to outside
70794
+ // this.clearStoreImages();
70795
+ this.clearSpherePrintStoreImages();
70796
+ this.drawCalculatorSphereOnEachViews("x");
70797
+ this.drawCalculatorSphereOnEachViews("y");
70798
+ this.drawCalculatorSphereOnEachViews("z");
70799
+ !!this.nrrd_states.getCalculateSpherePositions &&
70800
+ this.nrrd_states.getCalculateSpherePositions(this.nrrd_states.tumourSphereOrigin, this.nrrd_states.skinSphereOrigin, this.nrrd_states.ribSphereOrigin, this.nrrd_states.nippleSphereOrigin, this.protectedData.axis);
70801
+ this.zoomActionAfterDrawSphere();
70802
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70803
+ }
70804
+ zoomActionAfterDrawSphere() {
70805
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70806
+ }
70807
+ clearSpherePrintStoreImages() {
70808
+ this.protectedData.maskData.paintImages.x.length = 0;
70809
+ this.protectedData.maskData.paintImages.y.length = 0;
70810
+ this.protectedData.maskData.paintImages.z.length = 0;
70811
+ this.createEmptyPaintImage(this.nrrd_states.dimensions, this.protectedData.maskData.paintImages);
70812
+ }
70684
70813
  paintOnCanvas() {
70685
70814
  var _a, _b, _c;
70686
70815
  /**
@@ -70803,25 +70932,13 @@ class DrawToolCore extends CommToolsData {
70803
70932
  this.nrrd_states.cursorPageY =
70804
70933
  e.offsetY / this.nrrd_states.sizeFoctor;
70805
70934
  this.enableCrosshair();
70935
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70806
70936
  }
70807
70937
  else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
70808
- this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70809
- let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70810
- let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70811
- // record mouseX,Y, and enable crosshair function
70812
- this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70813
- mouseX,
70814
- mouseY,
70815
- this.nrrd_states.currentIndex,
70816
- ];
70817
- this.setUpSphereOrigins(mouseX, mouseY);
70818
- this.nrrd_states.cursorPageX = mouseX;
70819
- this.nrrd_states.cursorPageY = mouseY;
70820
- this.enableCrosshair();
70821
- // draw circle setup width/height for sphere canvas
70822
- this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
70823
- this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70824
- this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70938
+ sphere(e);
70939
+ }
70940
+ else if (this.gui_states.calculator && !this.nrrd_states.enableCursorChoose) {
70941
+ this.drawCalSphereDown(e.offsetX, e.offsetY, this.nrrd_states.currentIndex, this.gui_states.cal_distance);
70825
70942
  }
70826
70943
  }
70827
70944
  else if (e.button === 2) {
@@ -70840,6 +70957,27 @@ class DrawToolCore extends CommToolsData {
70840
70957
  };
70841
70958
  // disable browser right click menu
70842
70959
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
70960
+ const sphere = (e) => {
70961
+ // set sphere size
70962
+ this.nrrd_states.sphereRadius = 10;
70963
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70964
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70965
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70966
+ // record mouseX,Y, and enable crosshair function
70967
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70968
+ mouseX,
70969
+ mouseY,
70970
+ this.nrrd_states.currentIndex,
70971
+ ];
70972
+ this.setUpSphereOrigins(mouseX, mouseY, this.nrrd_states.currentIndex);
70973
+ this.nrrd_states.cursorPageX = mouseX;
70974
+ this.nrrd_states.cursorPageY = mouseY;
70975
+ this.enableCrosshair();
70976
+ // draw circle setup width/height for sphere canvas
70977
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70978
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70979
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70980
+ };
70843
70981
  const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
70844
70982
  var _a;
70845
70983
  let paintImages;
@@ -70933,7 +71071,8 @@ class DrawToolCore extends CommToolsData {
70933
71071
  // findout all index in the sphere radius range in Axial view
70934
71072
  if (this.nrrd_states.spherePlanB) {
70935
71073
  // clear stroe images
70936
- this.clearStoreImages();
71074
+ // this.clearStoreImages();
71075
+ this.clearSpherePrintStoreImages();
70937
71076
  for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
70938
71077
  this.drawSphereOnEachViews(i, "x");
70939
71078
  this.drawSphereOnEachViews(i, "y");
@@ -70942,18 +71081,31 @@ class DrawToolCore extends CommToolsData {
70942
71081
  }
70943
71082
  !!this.nrrd_states.getSphere &&
70944
71083
  this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70945
- this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70946
71084
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
71085
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71086
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70947
71087
  }
70948
- else if (this.gui_states.sphere &&
71088
+ else if ((this.gui_states.sphere || this.gui_states.calculator) &&
70949
71089
  this.nrrd_states.enableCursorChoose) {
70950
71090
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71091
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
71092
+ }
71093
+ else if (this.gui_states.calculator &&
71094
+ !this.nrrd_states.enableCursorChoose) {
71095
+ // When mouse up
71096
+ this.drawCalSphereUp();
70951
71097
  }
70952
71098
  }
70953
71099
  else if (e.button === 2) {
70954
71100
  rightclicked = false;
70955
71101
  this.protectedData.canvases.drawingCanvas.style.cursor = "grab";
71102
+ setTimeout(() => {
71103
+ this.protectedData.canvases.drawingCanvas.style.cursor = this.gui_states.defaultPaintCursor;
71104
+ }, 2000);
70956
71105
  this.protectedData.canvases.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
71106
+ if (this.gui_states.sphere || this.gui_states.calculator) {
71107
+ this.zoomActionAfterDrawSphere();
71108
+ }
70957
71109
  }
70958
71110
  else {
70959
71111
  return;
@@ -71015,8 +71167,8 @@ class DrawToolCore extends CommToolsData {
71015
71167
  this.protectedData.ctxes.drawingCtx.clearRect(0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71016
71168
  const ex = this.nrrd_states.cursorPageX * this.nrrd_states.sizeFoctor;
71017
71169
  const ey = this.nrrd_states.cursorPageY * this.nrrd_states.sizeFoctor;
71018
- this.drawLine(ex, 0, ex, this.protectedData.canvases.drawingCanvas.height);
71019
- this.drawLine(0, ey, this.protectedData.canvases.drawingCanvas.width, ey);
71170
+ this.drawLine(ex, 0, ex, this.nrrd_states.changedWidth);
71171
+ this.drawLine(0, ey, this.nrrd_states.changedHeight, ey);
71020
71172
  }
71021
71173
  }
71022
71174
  this.protectedData.ctxes.drawingCtx.drawImage(this.protectedData.canvases.drawingCanvasLayerMaster, 0, 0);
@@ -71146,15 +71298,17 @@ class DrawToolCore extends CommToolsData {
71146
71298
  moveDistance = w / this.nrrd_states.originWidth;
71147
71299
  if (moveDistance > 8) {
71148
71300
  moveDistance = 8;
71301
+ this.resetPaintAreaUIPosition();
71149
71302
  }
71150
71303
  else if (moveDistance < 1) {
71151
71304
  moveDistance = 1;
71305
+ this.resetPaintAreaUIPosition();
71152
71306
  }
71153
71307
  else {
71154
- this.resizePaintArea(moveDistance);
71155
71308
  this.resetPaintAreaUIPosition(l, t);
71156
- this.setIsDrawFalse(1000);
71157
71309
  }
71310
+ this.resizePaintArea(moveDistance);
71311
+ this.setIsDrawFalse(1000);
71158
71312
  this.nrrd_states.sizeFoctor = moveDistance;
71159
71313
  };
71160
71314
  return handleZoomWheelMove;
@@ -71182,6 +71336,60 @@ class DrawToolCore extends CommToolsData {
71182
71336
  drawImageOnEmptyImage(canvas) {
71183
71337
  this.protectedData.ctxes.emptyCtx.drawImage(canvas, 0, 0, this.protectedData.canvases.emptyCanvas.width, this.protectedData.canvases.emptyCanvas.height);
71184
71338
  }
71339
+ /****************************Sphere calculate distance functions****************************************************/
71340
+ getSpherePosition(position, axis) {
71341
+ const mouseX = position[axis][0];
71342
+ const mouseY = position[axis][1];
71343
+ const sliceIndex = position[axis][2];
71344
+ return { x: mouseX, y: mouseY, z: sliceIndex };
71345
+ }
71346
+ drawCalculatorSphereOnEachViews(axis) {
71347
+ // init sphere canvas width and height
71348
+ this.setSphereCanvasSize(axis);
71349
+ // get drawingSphere canvas for storing
71350
+ const ctx = this.protectedData.ctxes.drawingSphereCtx;
71351
+ const canvas = this.protectedData.canvases.drawingSphereCanvas;
71352
+ let tumourPosition = !!this.nrrd_states.tumourSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.tumourSphereOrigin, axis), { color: this.nrrd_states.tumourColor }) : null;
71353
+ let skinPosition = !!this.nrrd_states.skinSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.skinSphereOrigin, axis), { color: this.nrrd_states.skinColor }) : null;
71354
+ let ribcagePosition = !!this.nrrd_states.ribSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.ribSphereOrigin, axis), { color: this.nrrd_states.ribcageColor }) : null;
71355
+ let nipplePosition = !!this.nrrd_states.nippleSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.nippleSphereOrigin, axis), { color: this.nrrd_states.nippleColor }) : null;
71356
+ let positionGroup = [];
71357
+ if (!!tumourPosition)
71358
+ positionGroup.push(tumourPosition);
71359
+ if (!!skinPosition)
71360
+ positionGroup.push(skinPosition);
71361
+ if (!!ribcagePosition)
71362
+ positionGroup.push(ribcagePosition);
71363
+ if (!!nipplePosition)
71364
+ positionGroup.push(nipplePosition);
71365
+ let copyPosition = JSON.parse(JSON.stringify(positionGroup));
71366
+ let rePositionGroup = [];
71367
+ // group same slice points
71368
+ positionGroup.forEach((p) => {
71369
+ let temp = [];
71370
+ let sameIndex = [];
71371
+ for (let i = 0; i < copyPosition.length; i++) {
71372
+ if (p.z == copyPosition[i].z) {
71373
+ temp.push(copyPosition[i]);
71374
+ sameIndex.push(i);
71375
+ }
71376
+ }
71377
+ sameIndex.reverse();
71378
+ sameIndex.forEach(i => copyPosition.splice(i, 1));
71379
+ if (temp.length > 0)
71380
+ rePositionGroup.push(temp);
71381
+ if (copyPosition.length == 0) {
71382
+ return;
71383
+ }
71384
+ });
71385
+ rePositionGroup.forEach((group) => {
71386
+ group.forEach(p => {
71387
+ this.drawSphereCore(ctx, p.x, p.y, this.nrrd_states.sphereRadius, p.color);
71388
+ });
71389
+ this.storeSphereImages(group[0].z, axis);
71390
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
71391
+ });
71392
+ }
71185
71393
  /****************************Sphere functions****************************************************/
71186
71394
  // for sphere
71187
71395
  storeSphereImages(index, axis) {
@@ -71201,21 +71409,29 @@ class DrawToolCore extends CommToolsData {
71201
71409
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
71202
71410
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71203
71411
  if (preIndex === nextIndex) {
71204
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
71412
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius, this.gui_states.fillColor);
71205
71413
  this.storeSphereImages(preIndex, axis);
71206
71414
  }
71207
71415
  else {
71208
- this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
71416
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay), this.gui_states.fillColor);
71209
71417
  this.drawImageOnEmptyImage(canvas);
71210
71418
  this.storeSphereImages(preIndex, axis);
71211
71419
  this.storeSphereImages(nextIndex, axis);
71212
71420
  }
71213
71421
  ctx.clearRect(0, 0, canvas.width, canvas.height);
71214
71422
  }
71215
- drawSphereCore(ctx, x, y, radius) {
71423
+ /**
71424
+ *
71425
+ * @param ctx draw sphere canvas ctx
71426
+ * @param x width must be match the origin size, size factor 1, ignore the size factor
71427
+ * @param y height must be match the origin size, size factor 1, ignore the size factor
71428
+ * @param radius radius must be match the origin size, size factor 1, ignore the size factor
71429
+ * @param color sphere color
71430
+ */
71431
+ drawSphereCore(ctx, x, y, radius, color) {
71216
71432
  ctx.beginPath();
71217
71433
  ctx.arc(x, y, radius, 0, 2 * Math.PI);
71218
- ctx.fillStyle = this.gui_states.fillColor;
71434
+ ctx.fillStyle = color;
71219
71435
  ctx.fill();
71220
71436
  ctx.closePath();
71221
71437
  }
@@ -71260,17 +71476,46 @@ class DrawToolCore extends CommToolsData {
71260
71476
  };
71261
71477
  return sphereEvent;
71262
71478
  }
71479
+ drawCalculatorSphere(radius) {
71480
+ // clear canvas
71481
+ const [canvas, ctx] = this.clearSphereCanvas();
71482
+ if (!!this.nrrd_states.tumourSphereOrigin && this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71483
+ this.drawSphereCore(ctx, this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][0], this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.tumourColor);
71484
+ }
71485
+ if (!!this.nrrd_states.skinSphereOrigin && this.nrrd_states.skinSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71486
+ this.drawSphereCore(ctx, this.nrrd_states.skinSphereOrigin[this.protectedData.axis][0], this.nrrd_states.skinSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.skinColor);
71487
+ }
71488
+ if (!!this.nrrd_states.ribSphereOrigin && this.nrrd_states.ribSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71489
+ this.drawSphereCore(ctx, this.nrrd_states.ribSphereOrigin[this.protectedData.axis][0], this.nrrd_states.ribSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.ribcageColor);
71490
+ }
71491
+ if (!!this.nrrd_states.nippleSphereOrigin && this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71492
+ this.drawSphereCore(ctx, this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][0], this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.nippleColor);
71493
+ }
71494
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71495
+ }
71263
71496
  drawSphere(mouseX, mouseY, radius) {
71264
71497
  // clear canvas
71265
- this.protectedData.canvases.drawingSphereCanvas.width =
71266
- this.protectedData.canvases.drawingCanvasLayerMaster.width;
71267
- this.protectedData.canvases.drawingSphereCanvas.height =
71268
- this.protectedData.canvases.drawingCanvasLayerMaster.height;
71498
+ const [canvas, ctx] = this.clearSphereCanvas();
71499
+ this.drawSphereCore(ctx, mouseX, mouseY, radius, this.gui_states.fillColor);
71500
+ console.log("when drawing shpere on canvas");
71501
+ console.log("Line 1256 mastercanvasesize:", this.protectedData.canvases.drawingCanvasLayerMaster.width, this.protectedData.canvases.drawingCanvasLayerMaster.height);
71502
+ console.log("current xy:", mouseX, mouseY);
71503
+ console.log("current changed width:", this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71504
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71505
+ }
71506
+ clearSphereCanvas() {
71507
+ // this.protectedData.canvases.drawingSphereCanvas.width =
71508
+ // this.protectedData.canvases.drawingCanvasLayerMaster.width;
71509
+ // this.protectedData.canvases.drawingSphereCanvas.height =
71510
+ // this.protectedData.canvases.drawingCanvasLayerMaster.height;
71511
+ // clear drawingCanvasLayerMaster
71512
+ this.protectedData.canvases.drawingCanvasLayerMaster.width = this.protectedData.canvases.drawingCanvasLayerMaster.width;
71513
+ // resize sphere canvas size to original size
71514
+ this.protectedData.canvases.drawingSphereCanvas.width = this.protectedData.canvases.originCanvas.width;
71515
+ this.protectedData.canvases.drawingSphereCanvas.height = this.protectedData.canvases.originCanvas.height;
71269
71516
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71270
71517
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
71271
- this.protectedData.ctxes.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
71272
- this.drawSphereCore(ctx, mouseX, mouseY, radius);
71273
- this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71518
+ return [canvas, ctx];
71274
71519
  }
71275
71520
  /**
71276
71521
  * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
@@ -71368,9 +71613,9 @@ class DrawToolCore extends CommToolsData {
71368
71613
  }
71369
71614
  return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71370
71615
  }
71371
- setUpSphereOrigins(mouseX, mouseY) {
71616
+ setUpSphereOrigins(mouseX, mouseY, sliceIndex) {
71372
71617
  const convertCursor = (from, to) => {
71373
- const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
71618
+ const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, sliceIndex);
71374
71619
  return {
71375
71620
  convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
71376
71621
  convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
@@ -71497,7 +71742,7 @@ class DrawToolCore extends CommToolsData {
71497
71742
  storeAllImages(index, label) {
71498
71743
  // const image: HTMLImageElement = new Image();
71499
71744
  // resize the drawing image data
71500
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71745
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71501
71746
  this.setEmptyCanvasSize();
71502
71747
  this.drawImageOnEmptyImage(this.protectedData.canvases.drawingCanvasLayerMaster);
71503
71748
  }
@@ -71569,7 +71814,7 @@ class DrawToolCore extends CommToolsData {
71569
71814
  break;
71570
71815
  }
71571
71816
  this.storeImageToAxis(index, this.protectedData.maskData.paintImages, imageData);
71572
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71817
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71573
71818
  this.storeEachLayerImage(index, label);
71574
71819
  }
71575
71820
  }
@@ -72044,6 +72289,18 @@ class NrrdTools extends DrawToolCore {
72044
72289
  getMaskData() {
72045
72290
  return this.protectedData.maskData;
72046
72291
  }
72292
+ // set calculate distance sphere position
72293
+ setCalculateDistanceSphere(x, y, sliceIndex, cal_position) {
72294
+ this.nrrd_states.sphereRadius = 5;
72295
+ // move to tumour slice
72296
+ const steps = sliceIndex - this.nrrd_states.currentIndex;
72297
+ this.setSliceMoving(steps * this.protectedData.displaySlices.length);
72298
+ // mock mouse down
72299
+ // if user zoom the panel, we need to consider the size factor
72300
+ this.drawCalSphereDown(x * this.nrrd_states.sizeFoctor, y * this.nrrd_states.sizeFoctor, sliceIndex, cal_position);
72301
+ // mock mouse up
72302
+ this.drawCalSphereUp();
72303
+ }
72047
72304
  getSharedPlace(len, ratio) {
72048
72305
  let old = -1;
72049
72306
  let same = [];
@@ -72269,6 +72526,10 @@ class NrrdTools extends DrawToolCore {
72269
72526
  this.protectedData.canvases.drawingCanvas.width;
72270
72527
  this.protectedData.canvases.displayCanvas.width =
72271
72528
  this.protectedData.canvases.displayCanvas.width;
72529
+ this.nrrd_states.tumourSphereOrigin = null;
72530
+ this.nrrd_states.ribSphereOrigin = null;
72531
+ this.nrrd_states.skinSphereOrigin = null;
72532
+ this.nrrd_states.nippleSphereOrigin = null;
72272
72533
  }
72273
72534
  setSliceMoving(step) {
72274
72535
  if (this.protectedData.mainPreSlices) {
@@ -72450,10 +72711,13 @@ class NrrdTools extends DrawToolCore {
72450
72711
  this.protectedData.canvases.originCanvas.width;
72451
72712
  this.nrrd_states.originHeight =
72452
72713
  this.protectedData.canvases.originCanvas.height;
72714
+ // In html the width and height is pixels,
72715
+ // So the value must be int
72716
+ // Therefore, we must use Math.floor rather than using Math.ceil
72453
72717
  this.nrrd_states.changedWidth =
72454
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72718
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72455
72719
  this.nrrd_states.changedHeight =
72456
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72720
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72457
72721
  this.resizePaintArea(this.nrrd_states.sizeFoctor);
72458
72722
  this.resetPaintAreaUIPosition();
72459
72723
  }
@@ -72551,8 +72815,8 @@ class NrrdTools extends DrawToolCore {
72551
72815
  this.protectedData.canvases.drawingCanvas.width =
72552
72816
  this.protectedData.canvases.drawingCanvas.width;
72553
72817
  this.resetLayerCanvas();
72554
- this.nrrd_states.changedWidth = this.nrrd_states.originWidth * factor;
72555
- this.nrrd_states.changedHeight = this.nrrd_states.originHeight * factor;
72818
+ this.nrrd_states.changedWidth = Math.floor(this.nrrd_states.originWidth * factor);
72819
+ this.nrrd_states.changedHeight = Math.floor(this.nrrd_states.originHeight * factor);
72556
72820
  /**
72557
72821
  * resize canvas
72558
72822
  */
@@ -72908,7 +73172,7 @@ function evaluateElement(element, weights) {
72908
73172
  }
72909
73173
 
72910
73174
  // import * as kiwrious from "copper3d_plugin_heart_k";
72911
- const REVISION = "v2.0.9";
72912
- console.log("%cCopper3D Visualisation %cBeta:v2.0.9", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
73175
+ const REVISION = "v2.1.0";
73176
+ console.log("%cCopper3D Visualisation %cBeta:v2.1.0", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72913
73177
 
72914
73178
  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 };