copper3d 2.0.9 → 2.1.1

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.
@@ -49844,7 +49844,7 @@ void main() {
49844
49844
 
49845
49845
  class baseRenderer {
49846
49846
  constructor(container, options) {
49847
- var _a, _b, _c, _d;
49847
+ var _a, _b, _c, _d, _e;
49848
49848
  this.visualCtrls = [];
49849
49849
  this.container = container;
49850
49850
  this.options = options;
@@ -49874,7 +49874,7 @@ void main() {
49874
49874
  });
49875
49875
  }
49876
49876
  this.currentScene.sceneName = "default";
49877
- !!this.currentScene.vignette &&
49877
+ (!!this.currentScene.vignette && !(!!((_e = this.options) === null || _e === void 0 ? void 0 : _e.alpha))) &&
49878
49878
  this.updateEnvironment(this.currentScene.vignette);
49879
49879
  this.state = {
49880
49880
  playbackSpeed: 1.0,
@@ -49906,6 +49906,9 @@ void main() {
49906
49906
  this.container.appendChild(this.renderer.domElement);
49907
49907
  }
49908
49908
  updateEnvironment(vignette) {
49909
+ var _a;
49910
+ if (!!((_a = this.options) === null || _a === void 0 ? void 0 : _a.alpha))
49911
+ return;
49909
49912
  const environment = environments.filter((entry) => entry.name === "Venice Sunset")[0];
49910
49913
  this.getCubeMapTexture(environment).then((envMap) => {
49911
49914
  const currentScene = this.getCurrentScene();
@@ -58729,7 +58732,9 @@ void main() {
58729
58732
  alpha: alpha,
58730
58733
  });
58731
58734
  new_scene.sceneName = name;
58732
- this.updateEnvironment(new_scene.vignette);
58735
+ if (!alpha) {
58736
+ this.updateEnvironment(new_scene.vignette);
58737
+ }
58733
58738
  this.sceneMap[name] = new_scene;
58734
58739
  return new_scene;
58735
58740
  }
@@ -69682,6 +69687,12 @@ void main() {
69682
69687
  .onChange(() => {
69683
69688
  updateGuiSphereState();
69684
69689
  });
69690
+ actionsFolder
69691
+ .add(configs.gui_states, "calculator")
69692
+ .name("Calculator")
69693
+ .onChange(() => {
69694
+ updateCalculatorState();
69695
+ });
69685
69696
  actionsFolder
69686
69697
  .add(configs.gui_states, "brushAndEraserSize")
69687
69698
  .name("BrushAndEraserSize")
@@ -69708,6 +69719,12 @@ void main() {
69708
69719
  updateGuiImageContrastOnFinished();
69709
69720
  });
69710
69721
  const advanceFolder = configs.modeFolder.addFolder("AdvanceSettings");
69722
+ advanceFolder
69723
+ .add(configs.gui_states, "cal_distance", ["tumour", "skin", "ribcage", "nipple"])
69724
+ .name("Label")
69725
+ .onChange((val) => {
69726
+ updateCalDistance(val);
69727
+ });
69711
69728
  advanceFolder
69712
69729
  .add(configs.gui_states, "label", ["label1", "label2", "label3"])
69713
69730
  .name("Label")
@@ -69854,6 +69871,43 @@ void main() {
69854
69871
  configs.clearStoreImages();
69855
69872
  }
69856
69873
  };
69874
+ const updateCalculatorState = () => {
69875
+ if (configs.gui_states.calculator) {
69876
+ // disable mouse to drag slices
69877
+ configs.removeDragMode();
69878
+ }
69879
+ else {
69880
+ // enable mouse to drag slices
69881
+ configs.configDragMode();
69882
+ // clear canvas
69883
+ configs.clearPaint();
69884
+ configs.clearStoreImages();
69885
+ }
69886
+ };
69887
+ const updateCalDistance = (val) => {
69888
+ switch (val) {
69889
+ case "tumour":
69890
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69891
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69892
+ break;
69893
+ case "skin":
69894
+ configs.gui_states.fillColor = configs.nrrd_states.skinColor;
69895
+ configs.gui_states.brushColor = configs.nrrd_states.skinColor;
69896
+ break;
69897
+ case "ribcage":
69898
+ configs.gui_states.fillColor = configs.nrrd_states.ribcageColor;
69899
+ configs.gui_states.brushColor = configs.nrrd_states.ribcageColor;
69900
+ break;
69901
+ case "nipple":
69902
+ configs.gui_states.fillColor = configs.nrrd_states.nippleColor;
69903
+ configs.gui_states.brushColor = configs.nrrd_states.nippleColor;
69904
+ break;
69905
+ default:
69906
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69907
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69908
+ break;
69909
+ }
69910
+ };
69857
69911
  const updateGuiImageWindowLowOnChange = (value) => {
69858
69912
  configs.gui_states.readyToUpdate = false;
69859
69913
  configs.updateSlicesContrast(value, "windowLow");
@@ -69892,6 +69946,14 @@ void main() {
69892
69946
  name: "Eraser",
69893
69947
  onChange: updateGuiEraserState,
69894
69948
  },
69949
+ calculator: {
69950
+ name: "Calculator",
69951
+ onChange: updateCalculatorState,
69952
+ },
69953
+ cal_distance: {
69954
+ name: "CalculatorDistance",
69955
+ onChange: updateCalDistance
69956
+ },
69895
69957
  clear: {
69896
69958
  name: "Clear",
69897
69959
  },
@@ -70316,6 +70378,14 @@ void main() {
70316
70378
  cursorPageX: 0,
70317
70379
  cursorPageY: 0,
70318
70380
  sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
70381
+ tumourSphereOrigin: null,
70382
+ skinSphereOrigin: null,
70383
+ ribSphereOrigin: null,
70384
+ nippleSphereOrigin: null,
70385
+ tumourColor: "#00ff00",
70386
+ skinColor: "#FFEB3B",
70387
+ ribcageColor: "#2196F3",
70388
+ nippleColor: "#E91E63",
70319
70389
  spherePlanB: true,
70320
70390
  sphereRadius: 10,
70321
70391
  Mouse_Over_x: 0,
@@ -70330,6 +70400,7 @@ void main() {
70330
70400
  labels: ["label1", "label2", "label3"],
70331
70401
  getMask: (mask, sliceId, label, width, height, clearAllFlag) => { },
70332
70402
  getSphere: (sphereOrigin, sphereRadius) => { },
70403
+ getCalculateSpherePositions: (tumourSphereOrigin, skinSphereOrigin, ribSphereOrigin, nippleSphereOrigin, aixs) => { },
70333
70404
  drawStartPos: { x: 1, y: 1 },
70334
70405
  };
70335
70406
  this.cursorPage = {
@@ -70365,7 +70436,9 @@ void main() {
70365
70436
  brushAndEraserSize: 15,
70366
70437
  cursor: "dot",
70367
70438
  label: "label1",
70439
+ cal_distance: "tumour",
70368
70440
  sphere: false,
70441
+ calculator: false,
70369
70442
  readyToUpdate: true,
70370
70443
  defaultPaintCursor: switchPencilIcon("dot"),
70371
70444
  max_sensitive: 100,
@@ -70475,6 +70548,12 @@ void main() {
70475
70548
  clearStoreImages() {
70476
70549
  throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70477
70550
  }
70551
+ /**
70552
+ * Rewrite this {createEmptyPaintImage} function under NrrdTools
70553
+ */
70554
+ createEmptyPaintImage(dimensions, paintImages) {
70555
+ throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70556
+ }
70478
70557
  /**
70479
70558
  * Rewrite this {resizePaintArea} function under NrrdTools
70480
70559
  */
@@ -70609,7 +70688,7 @@ void main() {
70609
70688
  initDrawToolCore() {
70610
70689
  let undoFlag = false;
70611
70690
  this.container.addEventListener("keydown", (ev) => {
70612
- if (ev.key === "Shift" && !this.gui_states.sphere) {
70691
+ if (ev.key === "Shift" && !this.gui_states.sphere && !this.gui_states.calculator) {
70613
70692
  if (this.protectedData.Is_Ctrl_Pressed) {
70614
70693
  this.protectedData.Is_Shift_Pressed = false;
70615
70694
  return;
@@ -70686,9 +70765,64 @@ void main() {
70686
70765
  if (!!opts) {
70687
70766
  this.nrrd_states.getMask = opts === null || opts === void 0 ? void 0 : opts.getMaskData;
70688
70767
  this.nrrd_states.getSphere = opts === null || opts === void 0 ? void 0 : opts.getSphereData;
70768
+ this.nrrd_states.getCalculateSpherePositions = opts === null || opts === void 0 ? void 0 : opts.getCalculateSpherePositionsData;
70689
70769
  }
70690
70770
  this.paintOnCanvas();
70691
70771
  }
70772
+ drawCalSphereDown(x, y, sliceIndex, cal_position) {
70773
+ this.nrrd_states.sphereRadius = 5;
70774
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70775
+ let mouseX = x / this.nrrd_states.sizeFoctor;
70776
+ let mouseY = y / this.nrrd_states.sizeFoctor;
70777
+ // record mouseX,Y, and enable crosshair function
70778
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70779
+ mouseX,
70780
+ mouseY,
70781
+ sliceIndex,
70782
+ ];
70783
+ this.setUpSphereOrigins(mouseX, mouseY, sliceIndex);
70784
+ switch (cal_position) {
70785
+ case "tumour":
70786
+ this.nrrd_states.tumourSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70787
+ break;
70788
+ case "skin":
70789
+ this.nrrd_states.skinSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70790
+ break;
70791
+ case "nipple":
70792
+ this.nrrd_states.nippleSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70793
+ break;
70794
+ case "ribcage":
70795
+ this.nrrd_states.ribSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70796
+ break;
70797
+ }
70798
+ this.nrrd_states.cursorPageX = mouseX;
70799
+ this.nrrd_states.cursorPageY = mouseY;
70800
+ this.enableCrosshair();
70801
+ // draw circle setup width/height for sphere canvas
70802
+ this.drawCalculatorSphere(this.nrrd_states.sphereRadius);
70803
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70804
+ }
70805
+ drawCalSphereUp() {
70806
+ // TODO send data to outside
70807
+ // this.clearStoreImages();
70808
+ this.clearSpherePrintStoreImages();
70809
+ this.drawCalculatorSphereOnEachViews("x");
70810
+ this.drawCalculatorSphereOnEachViews("y");
70811
+ this.drawCalculatorSphereOnEachViews("z");
70812
+ !!this.nrrd_states.getCalculateSpherePositions &&
70813
+ this.nrrd_states.getCalculateSpherePositions(this.nrrd_states.tumourSphereOrigin, this.nrrd_states.skinSphereOrigin, this.nrrd_states.ribSphereOrigin, this.nrrd_states.nippleSphereOrigin, this.protectedData.axis);
70814
+ this.zoomActionAfterDrawSphere();
70815
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70816
+ }
70817
+ zoomActionAfterDrawSphere() {
70818
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70819
+ }
70820
+ clearSpherePrintStoreImages() {
70821
+ this.protectedData.maskData.paintImages.x.length = 0;
70822
+ this.protectedData.maskData.paintImages.y.length = 0;
70823
+ this.protectedData.maskData.paintImages.z.length = 0;
70824
+ this.createEmptyPaintImage(this.nrrd_states.dimensions, this.protectedData.maskData.paintImages);
70825
+ }
70692
70826
  paintOnCanvas() {
70693
70827
  var _a, _b, _c;
70694
70828
  /**
@@ -70811,25 +70945,13 @@ void main() {
70811
70945
  this.nrrd_states.cursorPageY =
70812
70946
  e.offsetY / this.nrrd_states.sizeFoctor;
70813
70947
  this.enableCrosshair();
70948
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70814
70949
  }
70815
70950
  else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
70816
- this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70817
- let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70818
- let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70819
- // record mouseX,Y, and enable crosshair function
70820
- this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70821
- mouseX,
70822
- mouseY,
70823
- this.nrrd_states.currentIndex,
70824
- ];
70825
- this.setUpSphereOrigins(mouseX, mouseY);
70826
- this.nrrd_states.cursorPageX = mouseX;
70827
- this.nrrd_states.cursorPageY = mouseY;
70828
- this.enableCrosshair();
70829
- // draw circle setup width/height for sphere canvas
70830
- this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
70831
- this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70832
- this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70951
+ sphere(e);
70952
+ }
70953
+ else if (this.gui_states.calculator && !this.nrrd_states.enableCursorChoose) {
70954
+ this.drawCalSphereDown(e.offsetX, e.offsetY, this.nrrd_states.currentIndex, this.gui_states.cal_distance);
70833
70955
  }
70834
70956
  }
70835
70957
  else if (e.button === 2) {
@@ -70848,6 +70970,27 @@ void main() {
70848
70970
  };
70849
70971
  // disable browser right click menu
70850
70972
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
70973
+ const sphere = (e) => {
70974
+ // set sphere size
70975
+ this.nrrd_states.sphereRadius = 10;
70976
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70977
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70978
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70979
+ // record mouseX,Y, and enable crosshair function
70980
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70981
+ mouseX,
70982
+ mouseY,
70983
+ this.nrrd_states.currentIndex,
70984
+ ];
70985
+ this.setUpSphereOrigins(mouseX, mouseY, this.nrrd_states.currentIndex);
70986
+ this.nrrd_states.cursorPageX = mouseX;
70987
+ this.nrrd_states.cursorPageY = mouseY;
70988
+ this.enableCrosshair();
70989
+ // draw circle setup width/height for sphere canvas
70990
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70991
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70992
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70993
+ };
70851
70994
  const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
70852
70995
  var _a;
70853
70996
  let paintImages;
@@ -70941,7 +71084,8 @@ void main() {
70941
71084
  // findout all index in the sphere radius range in Axial view
70942
71085
  if (this.nrrd_states.spherePlanB) {
70943
71086
  // clear stroe images
70944
- this.clearStoreImages();
71087
+ // this.clearStoreImages();
71088
+ this.clearSpherePrintStoreImages();
70945
71089
  for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
70946
71090
  this.drawSphereOnEachViews(i, "x");
70947
71091
  this.drawSphereOnEachViews(i, "y");
@@ -70950,18 +71094,31 @@ void main() {
70950
71094
  }
70951
71095
  !!this.nrrd_states.getSphere &&
70952
71096
  this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70953
- this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70954
71097
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
71098
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71099
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70955
71100
  }
70956
- else if (this.gui_states.sphere &&
71101
+ else if ((this.gui_states.sphere || this.gui_states.calculator) &&
70957
71102
  this.nrrd_states.enableCursorChoose) {
70958
71103
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71104
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
71105
+ }
71106
+ else if (this.gui_states.calculator &&
71107
+ !this.nrrd_states.enableCursorChoose) {
71108
+ // When mouse up
71109
+ this.drawCalSphereUp();
70959
71110
  }
70960
71111
  }
70961
71112
  else if (e.button === 2) {
70962
71113
  rightclicked = false;
70963
71114
  this.protectedData.canvases.drawingCanvas.style.cursor = "grab";
71115
+ setTimeout(() => {
71116
+ this.protectedData.canvases.drawingCanvas.style.cursor = this.gui_states.defaultPaintCursor;
71117
+ }, 2000);
70964
71118
  this.protectedData.canvases.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
71119
+ if (this.gui_states.sphere || this.gui_states.calculator) {
71120
+ this.zoomActionAfterDrawSphere();
71121
+ }
70965
71122
  }
70966
71123
  else {
70967
71124
  return;
@@ -71023,8 +71180,8 @@ void main() {
71023
71180
  this.protectedData.ctxes.drawingCtx.clearRect(0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71024
71181
  const ex = this.nrrd_states.cursorPageX * this.nrrd_states.sizeFoctor;
71025
71182
  const ey = this.nrrd_states.cursorPageY * this.nrrd_states.sizeFoctor;
71026
- this.drawLine(ex, 0, ex, this.protectedData.canvases.drawingCanvas.height);
71027
- this.drawLine(0, ey, this.protectedData.canvases.drawingCanvas.width, ey);
71183
+ this.drawLine(ex, 0, ex, this.nrrd_states.changedWidth);
71184
+ this.drawLine(0, ey, this.nrrd_states.changedHeight, ey);
71028
71185
  }
71029
71186
  }
71030
71187
  this.protectedData.ctxes.drawingCtx.drawImage(this.protectedData.canvases.drawingCanvasLayerMaster, 0, 0);
@@ -71154,15 +71311,17 @@ void main() {
71154
71311
  moveDistance = w / this.nrrd_states.originWidth;
71155
71312
  if (moveDistance > 8) {
71156
71313
  moveDistance = 8;
71314
+ this.resetPaintAreaUIPosition();
71157
71315
  }
71158
71316
  else if (moveDistance < 1) {
71159
71317
  moveDistance = 1;
71318
+ this.resetPaintAreaUIPosition();
71160
71319
  }
71161
71320
  else {
71162
- this.resizePaintArea(moveDistance);
71163
71321
  this.resetPaintAreaUIPosition(l, t);
71164
- this.setIsDrawFalse(1000);
71165
71322
  }
71323
+ this.resizePaintArea(moveDistance);
71324
+ this.setIsDrawFalse(1000);
71166
71325
  this.nrrd_states.sizeFoctor = moveDistance;
71167
71326
  };
71168
71327
  return handleZoomWheelMove;
@@ -71190,6 +71349,60 @@ void main() {
71190
71349
  drawImageOnEmptyImage(canvas) {
71191
71350
  this.protectedData.ctxes.emptyCtx.drawImage(canvas, 0, 0, this.protectedData.canvases.emptyCanvas.width, this.protectedData.canvases.emptyCanvas.height);
71192
71351
  }
71352
+ /****************************Sphere calculate distance functions****************************************************/
71353
+ getSpherePosition(position, axis) {
71354
+ const mouseX = position[axis][0];
71355
+ const mouseY = position[axis][1];
71356
+ const sliceIndex = position[axis][2];
71357
+ return { x: mouseX, y: mouseY, z: sliceIndex };
71358
+ }
71359
+ drawCalculatorSphereOnEachViews(axis) {
71360
+ // init sphere canvas width and height
71361
+ this.setSphereCanvasSize(axis);
71362
+ // get drawingSphere canvas for storing
71363
+ const ctx = this.protectedData.ctxes.drawingSphereCtx;
71364
+ const canvas = this.protectedData.canvases.drawingSphereCanvas;
71365
+ let tumourPosition = !!this.nrrd_states.tumourSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.tumourSphereOrigin, axis), { color: this.nrrd_states.tumourColor }) : null;
71366
+ let skinPosition = !!this.nrrd_states.skinSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.skinSphereOrigin, axis), { color: this.nrrd_states.skinColor }) : null;
71367
+ let ribcagePosition = !!this.nrrd_states.ribSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.ribSphereOrigin, axis), { color: this.nrrd_states.ribcageColor }) : null;
71368
+ let nipplePosition = !!this.nrrd_states.nippleSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.nippleSphereOrigin, axis), { color: this.nrrd_states.nippleColor }) : null;
71369
+ let positionGroup = [];
71370
+ if (!!tumourPosition)
71371
+ positionGroup.push(tumourPosition);
71372
+ if (!!skinPosition)
71373
+ positionGroup.push(skinPosition);
71374
+ if (!!ribcagePosition)
71375
+ positionGroup.push(ribcagePosition);
71376
+ if (!!nipplePosition)
71377
+ positionGroup.push(nipplePosition);
71378
+ let copyPosition = JSON.parse(JSON.stringify(positionGroup));
71379
+ let rePositionGroup = [];
71380
+ // group same slice points
71381
+ positionGroup.forEach((p) => {
71382
+ let temp = [];
71383
+ let sameIndex = [];
71384
+ for (let i = 0; i < copyPosition.length; i++) {
71385
+ if (p.z == copyPosition[i].z) {
71386
+ temp.push(copyPosition[i]);
71387
+ sameIndex.push(i);
71388
+ }
71389
+ }
71390
+ sameIndex.reverse();
71391
+ sameIndex.forEach(i => copyPosition.splice(i, 1));
71392
+ if (temp.length > 0)
71393
+ rePositionGroup.push(temp);
71394
+ if (copyPosition.length == 0) {
71395
+ return;
71396
+ }
71397
+ });
71398
+ rePositionGroup.forEach((group) => {
71399
+ group.forEach(p => {
71400
+ this.drawSphereCore(ctx, p.x, p.y, this.nrrd_states.sphereRadius, p.color);
71401
+ });
71402
+ this.storeSphereImages(group[0].z, axis);
71403
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
71404
+ });
71405
+ }
71193
71406
  /****************************Sphere functions****************************************************/
71194
71407
  // for sphere
71195
71408
  storeSphereImages(index, axis) {
@@ -71209,21 +71422,29 @@ void main() {
71209
71422
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
71210
71423
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71211
71424
  if (preIndex === nextIndex) {
71212
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
71425
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius, this.gui_states.fillColor);
71213
71426
  this.storeSphereImages(preIndex, axis);
71214
71427
  }
71215
71428
  else {
71216
- this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
71429
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay), this.gui_states.fillColor);
71217
71430
  this.drawImageOnEmptyImage(canvas);
71218
71431
  this.storeSphereImages(preIndex, axis);
71219
71432
  this.storeSphereImages(nextIndex, axis);
71220
71433
  }
71221
71434
  ctx.clearRect(0, 0, canvas.width, canvas.height);
71222
71435
  }
71223
- drawSphereCore(ctx, x, y, radius) {
71436
+ /**
71437
+ *
71438
+ * @param ctx draw sphere canvas ctx
71439
+ * @param x width must be match the origin size, size factor 1, ignore the size factor
71440
+ * @param y height must be match the origin size, size factor 1, ignore the size factor
71441
+ * @param radius radius must be match the origin size, size factor 1, ignore the size factor
71442
+ * @param color sphere color
71443
+ */
71444
+ drawSphereCore(ctx, x, y, radius, color) {
71224
71445
  ctx.beginPath();
71225
71446
  ctx.arc(x, y, radius, 0, 2 * Math.PI);
71226
- ctx.fillStyle = this.gui_states.fillColor;
71447
+ ctx.fillStyle = color;
71227
71448
  ctx.fill();
71228
71449
  ctx.closePath();
71229
71450
  }
@@ -71268,17 +71489,46 @@ void main() {
71268
71489
  };
71269
71490
  return sphereEvent;
71270
71491
  }
71492
+ drawCalculatorSphere(radius) {
71493
+ // clear canvas
71494
+ const [canvas, ctx] = this.clearSphereCanvas();
71495
+ if (!!this.nrrd_states.tumourSphereOrigin && this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71496
+ this.drawSphereCore(ctx, this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][0], this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.tumourColor);
71497
+ }
71498
+ if (!!this.nrrd_states.skinSphereOrigin && this.nrrd_states.skinSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71499
+ this.drawSphereCore(ctx, this.nrrd_states.skinSphereOrigin[this.protectedData.axis][0], this.nrrd_states.skinSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.skinColor);
71500
+ }
71501
+ if (!!this.nrrd_states.ribSphereOrigin && this.nrrd_states.ribSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71502
+ this.drawSphereCore(ctx, this.nrrd_states.ribSphereOrigin[this.protectedData.axis][0], this.nrrd_states.ribSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.ribcageColor);
71503
+ }
71504
+ if (!!this.nrrd_states.nippleSphereOrigin && this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71505
+ this.drawSphereCore(ctx, this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][0], this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.nippleColor);
71506
+ }
71507
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71508
+ }
71271
71509
  drawSphere(mouseX, mouseY, radius) {
71272
71510
  // clear canvas
71273
- this.protectedData.canvases.drawingSphereCanvas.width =
71274
- this.protectedData.canvases.drawingCanvasLayerMaster.width;
71275
- this.protectedData.canvases.drawingSphereCanvas.height =
71276
- this.protectedData.canvases.drawingCanvasLayerMaster.height;
71511
+ const [canvas, ctx] = this.clearSphereCanvas();
71512
+ this.drawSphereCore(ctx, mouseX, mouseY, radius, this.gui_states.fillColor);
71513
+ console.log("when drawing shpere on canvas");
71514
+ console.log("Line 1256 mastercanvasesize:", this.protectedData.canvases.drawingCanvasLayerMaster.width, this.protectedData.canvases.drawingCanvasLayerMaster.height);
71515
+ console.log("current xy:", mouseX, mouseY);
71516
+ console.log("current changed width:", this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71517
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71518
+ }
71519
+ clearSphereCanvas() {
71520
+ // this.protectedData.canvases.drawingSphereCanvas.width =
71521
+ // this.protectedData.canvases.drawingCanvasLayerMaster.width;
71522
+ // this.protectedData.canvases.drawingSphereCanvas.height =
71523
+ // this.protectedData.canvases.drawingCanvasLayerMaster.height;
71524
+ // clear drawingCanvasLayerMaster
71525
+ this.protectedData.canvases.drawingCanvasLayerMaster.width = this.protectedData.canvases.drawingCanvasLayerMaster.width;
71526
+ // resize sphere canvas size to original size
71527
+ this.protectedData.canvases.drawingSphereCanvas.width = this.protectedData.canvases.originCanvas.width;
71528
+ this.protectedData.canvases.drawingSphereCanvas.height = this.protectedData.canvases.originCanvas.height;
71277
71529
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71278
71530
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
71279
- this.protectedData.ctxes.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
71280
- this.drawSphereCore(ctx, mouseX, mouseY, radius);
71281
- this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71531
+ return [canvas, ctx];
71282
71532
  }
71283
71533
  /**
71284
71534
  * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
@@ -71376,9 +71626,9 @@ void main() {
71376
71626
  }
71377
71627
  return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71378
71628
  }
71379
- setUpSphereOrigins(mouseX, mouseY) {
71629
+ setUpSphereOrigins(mouseX, mouseY, sliceIndex) {
71380
71630
  const convertCursor = (from, to) => {
71381
- const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
71631
+ const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, sliceIndex);
71382
71632
  return {
71383
71633
  convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
71384
71634
  convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
@@ -71505,7 +71755,7 @@ void main() {
71505
71755
  storeAllImages(index, label) {
71506
71756
  // const image: HTMLImageElement = new Image();
71507
71757
  // resize the drawing image data
71508
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71758
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71509
71759
  this.setEmptyCanvasSize();
71510
71760
  this.drawImageOnEmptyImage(this.protectedData.canvases.drawingCanvasLayerMaster);
71511
71761
  }
@@ -71577,7 +71827,7 @@ void main() {
71577
71827
  break;
71578
71828
  }
71579
71829
  this.storeImageToAxis(index, this.protectedData.maskData.paintImages, imageData);
71580
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71830
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71581
71831
  this.storeEachLayerImage(index, label);
71582
71832
  }
71583
71833
  }
@@ -72052,6 +72302,18 @@ void main() {
72052
72302
  getMaskData() {
72053
72303
  return this.protectedData.maskData;
72054
72304
  }
72305
+ // set calculate distance sphere position
72306
+ setCalculateDistanceSphere(x, y, sliceIndex, cal_position) {
72307
+ this.nrrd_states.sphereRadius = 5;
72308
+ // move to tumour slice
72309
+ const steps = sliceIndex - this.nrrd_states.currentIndex;
72310
+ this.setSliceMoving(steps * this.protectedData.displaySlices.length);
72311
+ // mock mouse down
72312
+ // if user zoom the panel, we need to consider the size factor
72313
+ this.drawCalSphereDown(x * this.nrrd_states.sizeFoctor, y * this.nrrd_states.sizeFoctor, sliceIndex, cal_position);
72314
+ // mock mouse up
72315
+ this.drawCalSphereUp();
72316
+ }
72055
72317
  getSharedPlace(len, ratio) {
72056
72318
  let old = -1;
72057
72319
  let same = [];
@@ -72277,6 +72539,10 @@ void main() {
72277
72539
  this.protectedData.canvases.drawingCanvas.width;
72278
72540
  this.protectedData.canvases.displayCanvas.width =
72279
72541
  this.protectedData.canvases.displayCanvas.width;
72542
+ this.nrrd_states.tumourSphereOrigin = null;
72543
+ this.nrrd_states.ribSphereOrigin = null;
72544
+ this.nrrd_states.skinSphereOrigin = null;
72545
+ this.nrrd_states.nippleSphereOrigin = null;
72280
72546
  }
72281
72547
  setSliceMoving(step) {
72282
72548
  if (this.protectedData.mainPreSlices) {
@@ -72458,10 +72724,13 @@ void main() {
72458
72724
  this.protectedData.canvases.originCanvas.width;
72459
72725
  this.nrrd_states.originHeight =
72460
72726
  this.protectedData.canvases.originCanvas.height;
72727
+ // In html the width and height is pixels,
72728
+ // So the value must be int
72729
+ // Therefore, we must use Math.floor rather than using Math.ceil
72461
72730
  this.nrrd_states.changedWidth =
72462
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72731
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72463
72732
  this.nrrd_states.changedHeight =
72464
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72733
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72465
72734
  this.resizePaintArea(this.nrrd_states.sizeFoctor);
72466
72735
  this.resetPaintAreaUIPosition();
72467
72736
  }
@@ -72559,8 +72828,8 @@ void main() {
72559
72828
  this.protectedData.canvases.drawingCanvas.width =
72560
72829
  this.protectedData.canvases.drawingCanvas.width;
72561
72830
  this.resetLayerCanvas();
72562
- this.nrrd_states.changedWidth = this.nrrd_states.originWidth * factor;
72563
- this.nrrd_states.changedHeight = this.nrrd_states.originHeight * factor;
72831
+ this.nrrd_states.changedWidth = Math.floor(this.nrrd_states.originWidth * factor);
72832
+ this.nrrd_states.changedHeight = Math.floor(this.nrrd_states.originHeight * factor);
72564
72833
  /**
72565
72834
  * resize canvas
72566
72835
  */
@@ -72916,8 +73185,8 @@ void main() {
72916
73185
  }
72917
73186
 
72918
73187
  // import * as kiwrious from "copper3d_plugin_heart_k";
72919
- const REVISION = "v2.0.9";
72920
- console.log("%cCopper3D Visualisation %cBeta:v2.0.9", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
73188
+ const REVISION = "v2.1.1";
73189
+ console.log("%cCopper3D Visualisation %cBeta:v2.1.1", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72921
73190
 
72922
73191
  exports.CameraViewPoint = CameraViewPoint;
72923
73192
  exports.Copper3dTrackballControls = Copper3dTrackballControls;
package/dist/index.d.ts CHANGED
@@ -17,8 +17,8 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
17
17
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
18
18
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
19
19
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader } from "./types/types";
20
- import { IPaintImage } from "./Utils/segmentation/coreTools/coreType";
20
+ import { IPaintImage, ICommXYZ } from "./Utils/segmentation/coreTools/coreType";
21
21
  import "./css/style.css";
22
- export declare const REVISION = "v2.0.9";
22
+ export declare const REVISION = "v2.1.1";
23
23
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
24
- export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, };
24
+ export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, ICommXYZ };
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
18
18
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
19
19
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
20
20
  import "./css/style.css";
21
- export const REVISION = "v2.0.9";
22
- console.log("%cCopper3D Visualisation %cBeta:v2.0.9", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
21
+ export const REVISION = "v2.1.1";
22
+ console.log("%cCopper3D Visualisation %cBeta:v2.1.1", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
23
23
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
24
24
  //# sourceMappingURL=index.js.map
@@ -19,6 +19,10 @@ export declare class CommToolsData {
19
19
  * Rewrite this {clearStoreImages} function under NrrdTools
20
20
  */
21
21
  clearStoreImages(): void;
22
+ /**
23
+ * Rewrite this {createEmptyPaintImage} function under NrrdTools
24
+ */
25
+ createEmptyPaintImage(dimensions: Array<number>, paintImages: IPaintImages): void;
22
26
  /**
23
27
  * Rewrite this {resizePaintArea} function under NrrdTools
24
28
  */