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.
@@ -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,
@@ -69682,6 +69682,12 @@ void main() {
69682
69682
  .onChange(() => {
69683
69683
  updateGuiSphereState();
69684
69684
  });
69685
+ actionsFolder
69686
+ .add(configs.gui_states, "calculator")
69687
+ .name("Calculator")
69688
+ .onChange(() => {
69689
+ updateCalculatorState();
69690
+ });
69685
69691
  actionsFolder
69686
69692
  .add(configs.gui_states, "brushAndEraserSize")
69687
69693
  .name("BrushAndEraserSize")
@@ -69708,6 +69714,12 @@ void main() {
69708
69714
  updateGuiImageContrastOnFinished();
69709
69715
  });
69710
69716
  const advanceFolder = configs.modeFolder.addFolder("AdvanceSettings");
69717
+ advanceFolder
69718
+ .add(configs.gui_states, "cal_distance", ["tumour", "skin", "ribcage", "nipple"])
69719
+ .name("Label")
69720
+ .onChange((val) => {
69721
+ updateCalDistance(val);
69722
+ });
69711
69723
  advanceFolder
69712
69724
  .add(configs.gui_states, "label", ["label1", "label2", "label3"])
69713
69725
  .name("Label")
@@ -69854,6 +69866,43 @@ void main() {
69854
69866
  configs.clearStoreImages();
69855
69867
  }
69856
69868
  };
69869
+ const updateCalculatorState = () => {
69870
+ if (configs.gui_states.calculator) {
69871
+ // disable mouse to drag slices
69872
+ configs.removeDragMode();
69873
+ }
69874
+ else {
69875
+ // enable mouse to drag slices
69876
+ configs.configDragMode();
69877
+ // clear canvas
69878
+ configs.clearPaint();
69879
+ configs.clearStoreImages();
69880
+ }
69881
+ };
69882
+ const updateCalDistance = (val) => {
69883
+ switch (val) {
69884
+ case "tumour":
69885
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69886
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69887
+ break;
69888
+ case "skin":
69889
+ configs.gui_states.fillColor = configs.nrrd_states.skinColor;
69890
+ configs.gui_states.brushColor = configs.nrrd_states.skinColor;
69891
+ break;
69892
+ case "ribcage":
69893
+ configs.gui_states.fillColor = configs.nrrd_states.ribcageColor;
69894
+ configs.gui_states.brushColor = configs.nrrd_states.ribcageColor;
69895
+ break;
69896
+ case "nipple":
69897
+ configs.gui_states.fillColor = configs.nrrd_states.nippleColor;
69898
+ configs.gui_states.brushColor = configs.nrrd_states.nippleColor;
69899
+ break;
69900
+ default:
69901
+ configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
69902
+ configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
69903
+ break;
69904
+ }
69905
+ };
69857
69906
  const updateGuiImageWindowLowOnChange = (value) => {
69858
69907
  configs.gui_states.readyToUpdate = false;
69859
69908
  configs.updateSlicesContrast(value, "windowLow");
@@ -69892,6 +69941,14 @@ void main() {
69892
69941
  name: "Eraser",
69893
69942
  onChange: updateGuiEraserState,
69894
69943
  },
69944
+ calculator: {
69945
+ name: "Calculator",
69946
+ onChange: updateCalculatorState,
69947
+ },
69948
+ cal_distance: {
69949
+ name: "CalculatorDistance",
69950
+ onChange: updateCalDistance
69951
+ },
69895
69952
  clear: {
69896
69953
  name: "Clear",
69897
69954
  },
@@ -70316,6 +70373,14 @@ void main() {
70316
70373
  cursorPageX: 0,
70317
70374
  cursorPageY: 0,
70318
70375
  sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
70376
+ tumourSphereOrigin: null,
70377
+ skinSphereOrigin: null,
70378
+ ribSphereOrigin: null,
70379
+ nippleSphereOrigin: null,
70380
+ tumourColor: "#00ff00",
70381
+ skinColor: "#FFEB3B",
70382
+ ribcageColor: "#2196F3",
70383
+ nippleColor: "#E91E63",
70319
70384
  spherePlanB: true,
70320
70385
  sphereRadius: 10,
70321
70386
  Mouse_Over_x: 0,
@@ -70330,6 +70395,7 @@ void main() {
70330
70395
  labels: ["label1", "label2", "label3"],
70331
70396
  getMask: (mask, sliceId, label, width, height, clearAllFlag) => { },
70332
70397
  getSphere: (sphereOrigin, sphereRadius) => { },
70398
+ getCalculateSpherePositions: (tumourSphereOrigin, skinSphereOrigin, ribSphereOrigin, nippleSphereOrigin, aixs) => { },
70333
70399
  drawStartPos: { x: 1, y: 1 },
70334
70400
  };
70335
70401
  this.cursorPage = {
@@ -70365,7 +70431,9 @@ void main() {
70365
70431
  brushAndEraserSize: 15,
70366
70432
  cursor: "dot",
70367
70433
  label: "label1",
70434
+ cal_distance: "tumour",
70368
70435
  sphere: false,
70436
+ calculator: false,
70369
70437
  readyToUpdate: true,
70370
70438
  defaultPaintCursor: switchPencilIcon("dot"),
70371
70439
  max_sensitive: 100,
@@ -70475,6 +70543,12 @@ void main() {
70475
70543
  clearStoreImages() {
70476
70544
  throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70477
70545
  }
70546
+ /**
70547
+ * Rewrite this {createEmptyPaintImage} function under NrrdTools
70548
+ */
70549
+ createEmptyPaintImage(dimensions, paintImages) {
70550
+ throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
70551
+ }
70478
70552
  /**
70479
70553
  * Rewrite this {resizePaintArea} function under NrrdTools
70480
70554
  */
@@ -70609,7 +70683,7 @@ void main() {
70609
70683
  initDrawToolCore() {
70610
70684
  let undoFlag = false;
70611
70685
  this.container.addEventListener("keydown", (ev) => {
70612
- if (ev.key === "Shift" && !this.gui_states.sphere) {
70686
+ if (ev.key === "Shift" && !this.gui_states.sphere && !this.gui_states.calculator) {
70613
70687
  if (this.protectedData.Is_Ctrl_Pressed) {
70614
70688
  this.protectedData.Is_Shift_Pressed = false;
70615
70689
  return;
@@ -70686,9 +70760,64 @@ void main() {
70686
70760
  if (!!opts) {
70687
70761
  this.nrrd_states.getMask = opts === null || opts === void 0 ? void 0 : opts.getMaskData;
70688
70762
  this.nrrd_states.getSphere = opts === null || opts === void 0 ? void 0 : opts.getSphereData;
70763
+ this.nrrd_states.getCalculateSpherePositions = opts === null || opts === void 0 ? void 0 : opts.getCalculateSpherePositionsData;
70689
70764
  }
70690
70765
  this.paintOnCanvas();
70691
70766
  }
70767
+ drawCalSphereDown(x, y, sliceIndex, cal_position) {
70768
+ this.nrrd_states.sphereRadius = 5;
70769
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70770
+ let mouseX = x / this.nrrd_states.sizeFoctor;
70771
+ let mouseY = y / this.nrrd_states.sizeFoctor;
70772
+ // record mouseX,Y, and enable crosshair function
70773
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70774
+ mouseX,
70775
+ mouseY,
70776
+ sliceIndex,
70777
+ ];
70778
+ this.setUpSphereOrigins(mouseX, mouseY, sliceIndex);
70779
+ switch (cal_position) {
70780
+ case "tumour":
70781
+ this.nrrd_states.tumourSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70782
+ break;
70783
+ case "skin":
70784
+ this.nrrd_states.skinSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70785
+ break;
70786
+ case "nipple":
70787
+ this.nrrd_states.nippleSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70788
+ break;
70789
+ case "ribcage":
70790
+ this.nrrd_states.ribSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
70791
+ break;
70792
+ }
70793
+ this.nrrd_states.cursorPageX = mouseX;
70794
+ this.nrrd_states.cursorPageY = mouseY;
70795
+ this.enableCrosshair();
70796
+ // draw circle setup width/height for sphere canvas
70797
+ this.drawCalculatorSphere(this.nrrd_states.sphereRadius);
70798
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70799
+ }
70800
+ drawCalSphereUp() {
70801
+ // TODO send data to outside
70802
+ // this.clearStoreImages();
70803
+ this.clearSpherePrintStoreImages();
70804
+ this.drawCalculatorSphereOnEachViews("x");
70805
+ this.drawCalculatorSphereOnEachViews("y");
70806
+ this.drawCalculatorSphereOnEachViews("z");
70807
+ !!this.nrrd_states.getCalculateSpherePositions &&
70808
+ this.nrrd_states.getCalculateSpherePositions(this.nrrd_states.tumourSphereOrigin, this.nrrd_states.skinSphereOrigin, this.nrrd_states.ribSphereOrigin, this.nrrd_states.nippleSphereOrigin, this.protectedData.axis);
70809
+ this.zoomActionAfterDrawSphere();
70810
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70811
+ }
70812
+ zoomActionAfterDrawSphere() {
70813
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70814
+ }
70815
+ clearSpherePrintStoreImages() {
70816
+ this.protectedData.maskData.paintImages.x.length = 0;
70817
+ this.protectedData.maskData.paintImages.y.length = 0;
70818
+ this.protectedData.maskData.paintImages.z.length = 0;
70819
+ this.createEmptyPaintImage(this.nrrd_states.dimensions, this.protectedData.maskData.paintImages);
70820
+ }
70692
70821
  paintOnCanvas() {
70693
70822
  var _a, _b, _c;
70694
70823
  /**
@@ -70811,25 +70940,13 @@ void main() {
70811
70940
  this.nrrd_states.cursorPageY =
70812
70941
  e.offsetY / this.nrrd_states.sizeFoctor;
70813
70942
  this.enableCrosshair();
70943
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70814
70944
  }
70815
70945
  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);
70946
+ sphere(e);
70947
+ }
70948
+ else if (this.gui_states.calculator && !this.nrrd_states.enableCursorChoose) {
70949
+ this.drawCalSphereDown(e.offsetX, e.offsetY, this.nrrd_states.currentIndex, this.gui_states.cal_distance);
70833
70950
  }
70834
70951
  }
70835
70952
  else if (e.button === 2) {
@@ -70848,6 +70965,27 @@ void main() {
70848
70965
  };
70849
70966
  // disable browser right click menu
70850
70967
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
70968
+ const sphere = (e) => {
70969
+ // set sphere size
70970
+ this.nrrd_states.sphereRadius = 10;
70971
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70972
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70973
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70974
+ // record mouseX,Y, and enable crosshair function
70975
+ this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70976
+ mouseX,
70977
+ mouseY,
70978
+ this.nrrd_states.currentIndex,
70979
+ ];
70980
+ this.setUpSphereOrigins(mouseX, mouseY, this.nrrd_states.currentIndex);
70981
+ this.nrrd_states.cursorPageX = mouseX;
70982
+ this.nrrd_states.cursorPageY = mouseY;
70983
+ this.enableCrosshair();
70984
+ // draw circle setup width/height for sphere canvas
70985
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70986
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70987
+ this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70988
+ };
70851
70989
  const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
70852
70990
  var _a;
70853
70991
  let paintImages;
@@ -70941,7 +71079,8 @@ void main() {
70941
71079
  // findout all index in the sphere radius range in Axial view
70942
71080
  if (this.nrrd_states.spherePlanB) {
70943
71081
  // clear stroe images
70944
- this.clearStoreImages();
71082
+ // this.clearStoreImages();
71083
+ this.clearSpherePrintStoreImages();
70945
71084
  for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
70946
71085
  this.drawSphereOnEachViews(i, "x");
70947
71086
  this.drawSphereOnEachViews(i, "y");
@@ -70950,18 +71089,31 @@ void main() {
70950
71089
  }
70951
71090
  !!this.nrrd_states.getSphere &&
70952
71091
  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
71092
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
71093
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71094
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70955
71095
  }
70956
- else if (this.gui_states.sphere &&
71096
+ else if ((this.gui_states.sphere || this.gui_states.calculator) &&
70957
71097
  this.nrrd_states.enableCursorChoose) {
70958
71098
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
71099
+ this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
71100
+ }
71101
+ else if (this.gui_states.calculator &&
71102
+ !this.nrrd_states.enableCursorChoose) {
71103
+ // When mouse up
71104
+ this.drawCalSphereUp();
70959
71105
  }
70960
71106
  }
70961
71107
  else if (e.button === 2) {
70962
71108
  rightclicked = false;
70963
71109
  this.protectedData.canvases.drawingCanvas.style.cursor = "grab";
71110
+ setTimeout(() => {
71111
+ this.protectedData.canvases.drawingCanvas.style.cursor = this.gui_states.defaultPaintCursor;
71112
+ }, 2000);
70964
71113
  this.protectedData.canvases.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
71114
+ if (this.gui_states.sphere || this.gui_states.calculator) {
71115
+ this.zoomActionAfterDrawSphere();
71116
+ }
70965
71117
  }
70966
71118
  else {
70967
71119
  return;
@@ -71023,8 +71175,8 @@ void main() {
71023
71175
  this.protectedData.ctxes.drawingCtx.clearRect(0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71024
71176
  const ex = this.nrrd_states.cursorPageX * this.nrrd_states.sizeFoctor;
71025
71177
  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);
71178
+ this.drawLine(ex, 0, ex, this.nrrd_states.changedWidth);
71179
+ this.drawLine(0, ey, this.nrrd_states.changedHeight, ey);
71028
71180
  }
71029
71181
  }
71030
71182
  this.protectedData.ctxes.drawingCtx.drawImage(this.protectedData.canvases.drawingCanvasLayerMaster, 0, 0);
@@ -71154,15 +71306,17 @@ void main() {
71154
71306
  moveDistance = w / this.nrrd_states.originWidth;
71155
71307
  if (moveDistance > 8) {
71156
71308
  moveDistance = 8;
71309
+ this.resetPaintAreaUIPosition();
71157
71310
  }
71158
71311
  else if (moveDistance < 1) {
71159
71312
  moveDistance = 1;
71313
+ this.resetPaintAreaUIPosition();
71160
71314
  }
71161
71315
  else {
71162
- this.resizePaintArea(moveDistance);
71163
71316
  this.resetPaintAreaUIPosition(l, t);
71164
- this.setIsDrawFalse(1000);
71165
71317
  }
71318
+ this.resizePaintArea(moveDistance);
71319
+ this.setIsDrawFalse(1000);
71166
71320
  this.nrrd_states.sizeFoctor = moveDistance;
71167
71321
  };
71168
71322
  return handleZoomWheelMove;
@@ -71190,6 +71344,60 @@ void main() {
71190
71344
  drawImageOnEmptyImage(canvas) {
71191
71345
  this.protectedData.ctxes.emptyCtx.drawImage(canvas, 0, 0, this.protectedData.canvases.emptyCanvas.width, this.protectedData.canvases.emptyCanvas.height);
71192
71346
  }
71347
+ /****************************Sphere calculate distance functions****************************************************/
71348
+ getSpherePosition(position, axis) {
71349
+ const mouseX = position[axis][0];
71350
+ const mouseY = position[axis][1];
71351
+ const sliceIndex = position[axis][2];
71352
+ return { x: mouseX, y: mouseY, z: sliceIndex };
71353
+ }
71354
+ drawCalculatorSphereOnEachViews(axis) {
71355
+ // init sphere canvas width and height
71356
+ this.setSphereCanvasSize(axis);
71357
+ // get drawingSphere canvas for storing
71358
+ const ctx = this.protectedData.ctxes.drawingSphereCtx;
71359
+ const canvas = this.protectedData.canvases.drawingSphereCanvas;
71360
+ let tumourPosition = !!this.nrrd_states.tumourSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.tumourSphereOrigin, axis), { color: this.nrrd_states.tumourColor }) : null;
71361
+ let skinPosition = !!this.nrrd_states.skinSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.skinSphereOrigin, axis), { color: this.nrrd_states.skinColor }) : null;
71362
+ let ribcagePosition = !!this.nrrd_states.ribSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.ribSphereOrigin, axis), { color: this.nrrd_states.ribcageColor }) : null;
71363
+ let nipplePosition = !!this.nrrd_states.nippleSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.nippleSphereOrigin, axis), { color: this.nrrd_states.nippleColor }) : null;
71364
+ let positionGroup = [];
71365
+ if (!!tumourPosition)
71366
+ positionGroup.push(tumourPosition);
71367
+ if (!!skinPosition)
71368
+ positionGroup.push(skinPosition);
71369
+ if (!!ribcagePosition)
71370
+ positionGroup.push(ribcagePosition);
71371
+ if (!!nipplePosition)
71372
+ positionGroup.push(nipplePosition);
71373
+ let copyPosition = JSON.parse(JSON.stringify(positionGroup));
71374
+ let rePositionGroup = [];
71375
+ // group same slice points
71376
+ positionGroup.forEach((p) => {
71377
+ let temp = [];
71378
+ let sameIndex = [];
71379
+ for (let i = 0; i < copyPosition.length; i++) {
71380
+ if (p.z == copyPosition[i].z) {
71381
+ temp.push(copyPosition[i]);
71382
+ sameIndex.push(i);
71383
+ }
71384
+ }
71385
+ sameIndex.reverse();
71386
+ sameIndex.forEach(i => copyPosition.splice(i, 1));
71387
+ if (temp.length > 0)
71388
+ rePositionGroup.push(temp);
71389
+ if (copyPosition.length == 0) {
71390
+ return;
71391
+ }
71392
+ });
71393
+ rePositionGroup.forEach((group) => {
71394
+ group.forEach(p => {
71395
+ this.drawSphereCore(ctx, p.x, p.y, this.nrrd_states.sphereRadius, p.color);
71396
+ });
71397
+ this.storeSphereImages(group[0].z, axis);
71398
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
71399
+ });
71400
+ }
71193
71401
  /****************************Sphere functions****************************************************/
71194
71402
  // for sphere
71195
71403
  storeSphereImages(index, axis) {
@@ -71209,21 +71417,29 @@ void main() {
71209
71417
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
71210
71418
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71211
71419
  if (preIndex === nextIndex) {
71212
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
71420
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius, this.gui_states.fillColor);
71213
71421
  this.storeSphereImages(preIndex, axis);
71214
71422
  }
71215
71423
  else {
71216
- this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
71424
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay), this.gui_states.fillColor);
71217
71425
  this.drawImageOnEmptyImage(canvas);
71218
71426
  this.storeSphereImages(preIndex, axis);
71219
71427
  this.storeSphereImages(nextIndex, axis);
71220
71428
  }
71221
71429
  ctx.clearRect(0, 0, canvas.width, canvas.height);
71222
71430
  }
71223
- drawSphereCore(ctx, x, y, radius) {
71431
+ /**
71432
+ *
71433
+ * @param ctx draw sphere canvas ctx
71434
+ * @param x width must be match the origin size, size factor 1, ignore the size factor
71435
+ * @param y height must be match the origin size, size factor 1, ignore the size factor
71436
+ * @param radius radius must be match the origin size, size factor 1, ignore the size factor
71437
+ * @param color sphere color
71438
+ */
71439
+ drawSphereCore(ctx, x, y, radius, color) {
71224
71440
  ctx.beginPath();
71225
71441
  ctx.arc(x, y, radius, 0, 2 * Math.PI);
71226
- ctx.fillStyle = this.gui_states.fillColor;
71442
+ ctx.fillStyle = color;
71227
71443
  ctx.fill();
71228
71444
  ctx.closePath();
71229
71445
  }
@@ -71268,17 +71484,46 @@ void main() {
71268
71484
  };
71269
71485
  return sphereEvent;
71270
71486
  }
71487
+ drawCalculatorSphere(radius) {
71488
+ // clear canvas
71489
+ const [canvas, ctx] = this.clearSphereCanvas();
71490
+ if (!!this.nrrd_states.tumourSphereOrigin && this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71491
+ this.drawSphereCore(ctx, this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][0], this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.tumourColor);
71492
+ }
71493
+ if (!!this.nrrd_states.skinSphereOrigin && this.nrrd_states.skinSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71494
+ this.drawSphereCore(ctx, this.nrrd_states.skinSphereOrigin[this.protectedData.axis][0], this.nrrd_states.skinSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.skinColor);
71495
+ }
71496
+ if (!!this.nrrd_states.ribSphereOrigin && this.nrrd_states.ribSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71497
+ this.drawSphereCore(ctx, this.nrrd_states.ribSphereOrigin[this.protectedData.axis][0], this.nrrd_states.ribSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.ribcageColor);
71498
+ }
71499
+ if (!!this.nrrd_states.nippleSphereOrigin && this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
71500
+ this.drawSphereCore(ctx, this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][0], this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.nippleColor);
71501
+ }
71502
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71503
+ }
71271
71504
  drawSphere(mouseX, mouseY, radius) {
71272
71505
  // 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;
71506
+ const [canvas, ctx] = this.clearSphereCanvas();
71507
+ this.drawSphereCore(ctx, mouseX, mouseY, radius, this.gui_states.fillColor);
71508
+ console.log("when drawing shpere on canvas");
71509
+ console.log("Line 1256 mastercanvasesize:", this.protectedData.canvases.drawingCanvasLayerMaster.width, this.protectedData.canvases.drawingCanvasLayerMaster.height);
71510
+ console.log("current xy:", mouseX, mouseY);
71511
+ console.log("current changed width:", this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71512
+ this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
71513
+ }
71514
+ clearSphereCanvas() {
71515
+ // this.protectedData.canvases.drawingSphereCanvas.width =
71516
+ // this.protectedData.canvases.drawingCanvasLayerMaster.width;
71517
+ // this.protectedData.canvases.drawingSphereCanvas.height =
71518
+ // this.protectedData.canvases.drawingCanvasLayerMaster.height;
71519
+ // clear drawingCanvasLayerMaster
71520
+ this.protectedData.canvases.drawingCanvasLayerMaster.width = this.protectedData.canvases.drawingCanvasLayerMaster.width;
71521
+ // resize sphere canvas size to original size
71522
+ this.protectedData.canvases.drawingSphereCanvas.width = this.protectedData.canvases.originCanvas.width;
71523
+ this.protectedData.canvases.drawingSphereCanvas.height = this.protectedData.canvases.originCanvas.height;
71277
71524
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
71278
71525
  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);
71526
+ return [canvas, ctx];
71282
71527
  }
71283
71528
  /**
71284
71529
  * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
@@ -71376,9 +71621,9 @@ void main() {
71376
71621
  }
71377
71622
  return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71378
71623
  }
71379
- setUpSphereOrigins(mouseX, mouseY) {
71624
+ setUpSphereOrigins(mouseX, mouseY, sliceIndex) {
71380
71625
  const convertCursor = (from, to) => {
71381
- const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
71626
+ const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, sliceIndex);
71382
71627
  return {
71383
71628
  convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
71384
71629
  convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
@@ -71505,7 +71750,7 @@ void main() {
71505
71750
  storeAllImages(index, label) {
71506
71751
  // const image: HTMLImageElement = new Image();
71507
71752
  // resize the drawing image data
71508
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71753
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71509
71754
  this.setEmptyCanvasSize();
71510
71755
  this.drawImageOnEmptyImage(this.protectedData.canvases.drawingCanvasLayerMaster);
71511
71756
  }
@@ -71577,7 +71822,7 @@ void main() {
71577
71822
  break;
71578
71823
  }
71579
71824
  this.storeImageToAxis(index, this.protectedData.maskData.paintImages, imageData);
71580
- if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
71825
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
71581
71826
  this.storeEachLayerImage(index, label);
71582
71827
  }
71583
71828
  }
@@ -72052,6 +72297,18 @@ void main() {
72052
72297
  getMaskData() {
72053
72298
  return this.protectedData.maskData;
72054
72299
  }
72300
+ // set calculate distance sphere position
72301
+ setCalculateDistanceSphere(x, y, sliceIndex, cal_position) {
72302
+ this.nrrd_states.sphereRadius = 5;
72303
+ // move to tumour slice
72304
+ const steps = sliceIndex - this.nrrd_states.currentIndex;
72305
+ this.setSliceMoving(steps * this.protectedData.displaySlices.length);
72306
+ // mock mouse down
72307
+ // if user zoom the panel, we need to consider the size factor
72308
+ this.drawCalSphereDown(x * this.nrrd_states.sizeFoctor, y * this.nrrd_states.sizeFoctor, sliceIndex, cal_position);
72309
+ // mock mouse up
72310
+ this.drawCalSphereUp();
72311
+ }
72055
72312
  getSharedPlace(len, ratio) {
72056
72313
  let old = -1;
72057
72314
  let same = [];
@@ -72277,6 +72534,10 @@ void main() {
72277
72534
  this.protectedData.canvases.drawingCanvas.width;
72278
72535
  this.protectedData.canvases.displayCanvas.width =
72279
72536
  this.protectedData.canvases.displayCanvas.width;
72537
+ this.nrrd_states.tumourSphereOrigin = null;
72538
+ this.nrrd_states.ribSphereOrigin = null;
72539
+ this.nrrd_states.skinSphereOrigin = null;
72540
+ this.nrrd_states.nippleSphereOrigin = null;
72280
72541
  }
72281
72542
  setSliceMoving(step) {
72282
72543
  if (this.protectedData.mainPreSlices) {
@@ -72458,10 +72719,13 @@ void main() {
72458
72719
  this.protectedData.canvases.originCanvas.width;
72459
72720
  this.nrrd_states.originHeight =
72460
72721
  this.protectedData.canvases.originCanvas.height;
72722
+ // In html the width and height is pixels,
72723
+ // So the value must be int
72724
+ // Therefore, we must use Math.floor rather than using Math.ceil
72461
72725
  this.nrrd_states.changedWidth =
72462
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72726
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72463
72727
  this.nrrd_states.changedHeight =
72464
- this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
72728
+ Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
72465
72729
  this.resizePaintArea(this.nrrd_states.sizeFoctor);
72466
72730
  this.resetPaintAreaUIPosition();
72467
72731
  }
@@ -72559,8 +72823,8 @@ void main() {
72559
72823
  this.protectedData.canvases.drawingCanvas.width =
72560
72824
  this.protectedData.canvases.drawingCanvas.width;
72561
72825
  this.resetLayerCanvas();
72562
- this.nrrd_states.changedWidth = this.nrrd_states.originWidth * factor;
72563
- this.nrrd_states.changedHeight = this.nrrd_states.originHeight * factor;
72826
+ this.nrrd_states.changedWidth = Math.floor(this.nrrd_states.originWidth * factor);
72827
+ this.nrrd_states.changedHeight = Math.floor(this.nrrd_states.originHeight * factor);
72564
72828
  /**
72565
72829
  * resize canvas
72566
72830
  */
@@ -72916,8 +73180,8 @@ void main() {
72916
73180
  }
72917
73181
 
72918
73182
  // 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");
73183
+ const REVISION = "v2.1.0";
73184
+ console.log("%cCopper3D Visualisation %cBeta:v2.1.0", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72921
73185
 
72922
73186
  exports.CameraViewPoint = CameraViewPoint;
72923
73187
  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.0";
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.0";
22
+ console.log("%cCopper3D Visualisation %cBeta:v2.1.0", "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
  */