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.
- package/dist/Renderer/baseRenderer.js +5 -2
- package/dist/Renderer/baseRenderer.js.map +1 -1
- package/dist/Renderer/copperRenderer.js +3 -1
- package/dist/Renderer/copperRenderer.js.map +1 -1
- package/dist/Utils/segmentation/CommToolsData.d.ts +4 -0
- package/dist/Utils/segmentation/CommToolsData.js +17 -0
- package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +17 -0
- package/dist/Utils/segmentation/DrawToolCore.js +211 -40
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +3 -2
- package/dist/Utils/segmentation/NrrdTools.js +23 -4
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/coreType.d.ts +20 -0
- package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/gui.js +57 -0
- package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
- package/dist/bundle.esm.js +318 -49
- package/dist/bundle.umd.js +318 -49
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/types/Utils/segmentation/CommToolsData.d.ts +4 -0
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +17 -0
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +3 -2
- package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +20 -0
- package/dist/types/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/bundle.esm.js
CHANGED
|
@@ -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,
|
|
@@ -49898,6 +49898,9 @@ class baseRenderer {
|
|
|
49898
49898
|
this.container.appendChild(this.renderer.domElement);
|
|
49899
49899
|
}
|
|
49900
49900
|
updateEnvironment(vignette) {
|
|
49901
|
+
var _a;
|
|
49902
|
+
if (!!((_a = this.options) === null || _a === void 0 ? void 0 : _a.alpha))
|
|
49903
|
+
return;
|
|
49901
49904
|
const environment = environments.filter((entry) => entry.name === "Venice Sunset")[0];
|
|
49902
49905
|
this.getCubeMapTexture(environment).then((envMap) => {
|
|
49903
49906
|
const currentScene = this.getCurrentScene();
|
|
@@ -58721,7 +58724,9 @@ class copperRenderer extends baseRenderer {
|
|
|
58721
58724
|
alpha: alpha,
|
|
58722
58725
|
});
|
|
58723
58726
|
new_scene.sceneName = name;
|
|
58724
|
-
|
|
58727
|
+
if (!alpha) {
|
|
58728
|
+
this.updateEnvironment(new_scene.vignette);
|
|
58729
|
+
}
|
|
58725
58730
|
this.sceneMap[name] = new_scene;
|
|
58726
58731
|
return new_scene;
|
|
58727
58732
|
}
|
|
@@ -69674,6 +69679,12 @@ function setupGui(configs) {
|
|
|
69674
69679
|
.onChange(() => {
|
|
69675
69680
|
updateGuiSphereState();
|
|
69676
69681
|
});
|
|
69682
|
+
actionsFolder
|
|
69683
|
+
.add(configs.gui_states, "calculator")
|
|
69684
|
+
.name("Calculator")
|
|
69685
|
+
.onChange(() => {
|
|
69686
|
+
updateCalculatorState();
|
|
69687
|
+
});
|
|
69677
69688
|
actionsFolder
|
|
69678
69689
|
.add(configs.gui_states, "brushAndEraserSize")
|
|
69679
69690
|
.name("BrushAndEraserSize")
|
|
@@ -69700,6 +69711,12 @@ function setupGui(configs) {
|
|
|
69700
69711
|
updateGuiImageContrastOnFinished();
|
|
69701
69712
|
});
|
|
69702
69713
|
const advanceFolder = configs.modeFolder.addFolder("AdvanceSettings");
|
|
69714
|
+
advanceFolder
|
|
69715
|
+
.add(configs.gui_states, "cal_distance", ["tumour", "skin", "ribcage", "nipple"])
|
|
69716
|
+
.name("Label")
|
|
69717
|
+
.onChange((val) => {
|
|
69718
|
+
updateCalDistance(val);
|
|
69719
|
+
});
|
|
69703
69720
|
advanceFolder
|
|
69704
69721
|
.add(configs.gui_states, "label", ["label1", "label2", "label3"])
|
|
69705
69722
|
.name("Label")
|
|
@@ -69846,6 +69863,43 @@ function setupGui(configs) {
|
|
|
69846
69863
|
configs.clearStoreImages();
|
|
69847
69864
|
}
|
|
69848
69865
|
};
|
|
69866
|
+
const updateCalculatorState = () => {
|
|
69867
|
+
if (configs.gui_states.calculator) {
|
|
69868
|
+
// disable mouse to drag slices
|
|
69869
|
+
configs.removeDragMode();
|
|
69870
|
+
}
|
|
69871
|
+
else {
|
|
69872
|
+
// enable mouse to drag slices
|
|
69873
|
+
configs.configDragMode();
|
|
69874
|
+
// clear canvas
|
|
69875
|
+
configs.clearPaint();
|
|
69876
|
+
configs.clearStoreImages();
|
|
69877
|
+
}
|
|
69878
|
+
};
|
|
69879
|
+
const updateCalDistance = (val) => {
|
|
69880
|
+
switch (val) {
|
|
69881
|
+
case "tumour":
|
|
69882
|
+
configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
|
|
69883
|
+
configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
|
|
69884
|
+
break;
|
|
69885
|
+
case "skin":
|
|
69886
|
+
configs.gui_states.fillColor = configs.nrrd_states.skinColor;
|
|
69887
|
+
configs.gui_states.brushColor = configs.nrrd_states.skinColor;
|
|
69888
|
+
break;
|
|
69889
|
+
case "ribcage":
|
|
69890
|
+
configs.gui_states.fillColor = configs.nrrd_states.ribcageColor;
|
|
69891
|
+
configs.gui_states.brushColor = configs.nrrd_states.ribcageColor;
|
|
69892
|
+
break;
|
|
69893
|
+
case "nipple":
|
|
69894
|
+
configs.gui_states.fillColor = configs.nrrd_states.nippleColor;
|
|
69895
|
+
configs.gui_states.brushColor = configs.nrrd_states.nippleColor;
|
|
69896
|
+
break;
|
|
69897
|
+
default:
|
|
69898
|
+
configs.gui_states.fillColor = configs.nrrd_states.tumourColor;
|
|
69899
|
+
configs.gui_states.brushColor = configs.nrrd_states.tumourColor;
|
|
69900
|
+
break;
|
|
69901
|
+
}
|
|
69902
|
+
};
|
|
69849
69903
|
const updateGuiImageWindowLowOnChange = (value) => {
|
|
69850
69904
|
configs.gui_states.readyToUpdate = false;
|
|
69851
69905
|
configs.updateSlicesContrast(value, "windowLow");
|
|
@@ -69884,6 +69938,14 @@ function setupGui(configs) {
|
|
|
69884
69938
|
name: "Eraser",
|
|
69885
69939
|
onChange: updateGuiEraserState,
|
|
69886
69940
|
},
|
|
69941
|
+
calculator: {
|
|
69942
|
+
name: "Calculator",
|
|
69943
|
+
onChange: updateCalculatorState,
|
|
69944
|
+
},
|
|
69945
|
+
cal_distance: {
|
|
69946
|
+
name: "CalculatorDistance",
|
|
69947
|
+
onChange: updateCalDistance
|
|
69948
|
+
},
|
|
69887
69949
|
clear: {
|
|
69888
69950
|
name: "Clear",
|
|
69889
69951
|
},
|
|
@@ -70308,6 +70370,14 @@ class CommToolsData {
|
|
|
70308
70370
|
cursorPageX: 0,
|
|
70309
70371
|
cursorPageY: 0,
|
|
70310
70372
|
sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
|
|
70373
|
+
tumourSphereOrigin: null,
|
|
70374
|
+
skinSphereOrigin: null,
|
|
70375
|
+
ribSphereOrigin: null,
|
|
70376
|
+
nippleSphereOrigin: null,
|
|
70377
|
+
tumourColor: "#00ff00",
|
|
70378
|
+
skinColor: "#FFEB3B",
|
|
70379
|
+
ribcageColor: "#2196F3",
|
|
70380
|
+
nippleColor: "#E91E63",
|
|
70311
70381
|
spherePlanB: true,
|
|
70312
70382
|
sphereRadius: 10,
|
|
70313
70383
|
Mouse_Over_x: 0,
|
|
@@ -70322,6 +70392,7 @@ class CommToolsData {
|
|
|
70322
70392
|
labels: ["label1", "label2", "label3"],
|
|
70323
70393
|
getMask: (mask, sliceId, label, width, height, clearAllFlag) => { },
|
|
70324
70394
|
getSphere: (sphereOrigin, sphereRadius) => { },
|
|
70395
|
+
getCalculateSpherePositions: (tumourSphereOrigin, skinSphereOrigin, ribSphereOrigin, nippleSphereOrigin, aixs) => { },
|
|
70325
70396
|
drawStartPos: { x: 1, y: 1 },
|
|
70326
70397
|
};
|
|
70327
70398
|
this.cursorPage = {
|
|
@@ -70357,7 +70428,9 @@ class CommToolsData {
|
|
|
70357
70428
|
brushAndEraserSize: 15,
|
|
70358
70429
|
cursor: "dot",
|
|
70359
70430
|
label: "label1",
|
|
70431
|
+
cal_distance: "tumour",
|
|
70360
70432
|
sphere: false,
|
|
70433
|
+
calculator: false,
|
|
70361
70434
|
readyToUpdate: true,
|
|
70362
70435
|
defaultPaintCursor: switchPencilIcon("dot"),
|
|
70363
70436
|
max_sensitive: 100,
|
|
@@ -70467,6 +70540,12 @@ class CommToolsData {
|
|
|
70467
70540
|
clearStoreImages() {
|
|
70468
70541
|
throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
|
|
70469
70542
|
}
|
|
70543
|
+
/**
|
|
70544
|
+
* Rewrite this {createEmptyPaintImage} function under NrrdTools
|
|
70545
|
+
*/
|
|
70546
|
+
createEmptyPaintImage(dimensions, paintImages) {
|
|
70547
|
+
throw new Error("Child class must implement abstract clearStoreImages, currently you can find it in NrrdTools.");
|
|
70548
|
+
}
|
|
70470
70549
|
/**
|
|
70471
70550
|
* Rewrite this {resizePaintArea} function under NrrdTools
|
|
70472
70551
|
*/
|
|
@@ -70601,7 +70680,7 @@ class DrawToolCore extends CommToolsData {
|
|
|
70601
70680
|
initDrawToolCore() {
|
|
70602
70681
|
let undoFlag = false;
|
|
70603
70682
|
this.container.addEventListener("keydown", (ev) => {
|
|
70604
|
-
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
70683
|
+
if (ev.key === "Shift" && !this.gui_states.sphere && !this.gui_states.calculator) {
|
|
70605
70684
|
if (this.protectedData.Is_Ctrl_Pressed) {
|
|
70606
70685
|
this.protectedData.Is_Shift_Pressed = false;
|
|
70607
70686
|
return;
|
|
@@ -70678,9 +70757,64 @@ class DrawToolCore extends CommToolsData {
|
|
|
70678
70757
|
if (!!opts) {
|
|
70679
70758
|
this.nrrd_states.getMask = opts === null || opts === void 0 ? void 0 : opts.getMaskData;
|
|
70680
70759
|
this.nrrd_states.getSphere = opts === null || opts === void 0 ? void 0 : opts.getSphereData;
|
|
70760
|
+
this.nrrd_states.getCalculateSpherePositions = opts === null || opts === void 0 ? void 0 : opts.getCalculateSpherePositionsData;
|
|
70681
70761
|
}
|
|
70682
70762
|
this.paintOnCanvas();
|
|
70683
70763
|
}
|
|
70764
|
+
drawCalSphereDown(x, y, sliceIndex, cal_position) {
|
|
70765
|
+
this.nrrd_states.sphereRadius = 5;
|
|
70766
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70767
|
+
let mouseX = x / this.nrrd_states.sizeFoctor;
|
|
70768
|
+
let mouseY = y / this.nrrd_states.sizeFoctor;
|
|
70769
|
+
// record mouseX,Y, and enable crosshair function
|
|
70770
|
+
this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
|
|
70771
|
+
mouseX,
|
|
70772
|
+
mouseY,
|
|
70773
|
+
sliceIndex,
|
|
70774
|
+
];
|
|
70775
|
+
this.setUpSphereOrigins(mouseX, mouseY, sliceIndex);
|
|
70776
|
+
switch (cal_position) {
|
|
70777
|
+
case "tumour":
|
|
70778
|
+
this.nrrd_states.tumourSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
|
|
70779
|
+
break;
|
|
70780
|
+
case "skin":
|
|
70781
|
+
this.nrrd_states.skinSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
|
|
70782
|
+
break;
|
|
70783
|
+
case "nipple":
|
|
70784
|
+
this.nrrd_states.nippleSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
|
|
70785
|
+
break;
|
|
70786
|
+
case "ribcage":
|
|
70787
|
+
this.nrrd_states.ribSphereOrigin = JSON.parse(JSON.stringify(this.nrrd_states.sphereOrigin));
|
|
70788
|
+
break;
|
|
70789
|
+
}
|
|
70790
|
+
this.nrrd_states.cursorPageX = mouseX;
|
|
70791
|
+
this.nrrd_states.cursorPageY = mouseY;
|
|
70792
|
+
this.enableCrosshair();
|
|
70793
|
+
// draw circle setup width/height for sphere canvas
|
|
70794
|
+
this.drawCalculatorSphere(this.nrrd_states.sphereRadius);
|
|
70795
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70796
|
+
}
|
|
70797
|
+
drawCalSphereUp() {
|
|
70798
|
+
// TODO send data to outside
|
|
70799
|
+
// this.clearStoreImages();
|
|
70800
|
+
this.clearSpherePrintStoreImages();
|
|
70801
|
+
this.drawCalculatorSphereOnEachViews("x");
|
|
70802
|
+
this.drawCalculatorSphereOnEachViews("y");
|
|
70803
|
+
this.drawCalculatorSphereOnEachViews("z");
|
|
70804
|
+
!!this.nrrd_states.getCalculateSpherePositions &&
|
|
70805
|
+
this.nrrd_states.getCalculateSpherePositions(this.nrrd_states.tumourSphereOrigin, this.nrrd_states.skinSphereOrigin, this.nrrd_states.ribSphereOrigin, this.nrrd_states.nippleSphereOrigin, this.protectedData.axis);
|
|
70806
|
+
this.zoomActionAfterDrawSphere();
|
|
70807
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70808
|
+
}
|
|
70809
|
+
zoomActionAfterDrawSphere() {
|
|
70810
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70811
|
+
}
|
|
70812
|
+
clearSpherePrintStoreImages() {
|
|
70813
|
+
this.protectedData.maskData.paintImages.x.length = 0;
|
|
70814
|
+
this.protectedData.maskData.paintImages.y.length = 0;
|
|
70815
|
+
this.protectedData.maskData.paintImages.z.length = 0;
|
|
70816
|
+
this.createEmptyPaintImage(this.nrrd_states.dimensions, this.protectedData.maskData.paintImages);
|
|
70817
|
+
}
|
|
70684
70818
|
paintOnCanvas() {
|
|
70685
70819
|
var _a, _b, _c;
|
|
70686
70820
|
/**
|
|
@@ -70803,25 +70937,13 @@ class DrawToolCore extends CommToolsData {
|
|
|
70803
70937
|
this.nrrd_states.cursorPageY =
|
|
70804
70938
|
e.offsetY / this.nrrd_states.sizeFoctor;
|
|
70805
70939
|
this.enableCrosshair();
|
|
70940
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70806
70941
|
}
|
|
70807
70942
|
else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
|
|
70808
|
-
|
|
70809
|
-
|
|
70810
|
-
|
|
70811
|
-
|
|
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);
|
|
70943
|
+
sphere(e);
|
|
70944
|
+
}
|
|
70945
|
+
else if (this.gui_states.calculator && !this.nrrd_states.enableCursorChoose) {
|
|
70946
|
+
this.drawCalSphereDown(e.offsetX, e.offsetY, this.nrrd_states.currentIndex, this.gui_states.cal_distance);
|
|
70825
70947
|
}
|
|
70826
70948
|
}
|
|
70827
70949
|
else if (e.button === 2) {
|
|
@@ -70840,6 +70962,27 @@ class DrawToolCore extends CommToolsData {
|
|
|
70840
70962
|
};
|
|
70841
70963
|
// disable browser right click menu
|
|
70842
70964
|
this.protectedData.canvases.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
|
|
70965
|
+
const sphere = (e) => {
|
|
70966
|
+
// set sphere size
|
|
70967
|
+
this.nrrd_states.sphereRadius = 10;
|
|
70968
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70969
|
+
let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
|
|
70970
|
+
let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
|
|
70971
|
+
// record mouseX,Y, and enable crosshair function
|
|
70972
|
+
this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
|
|
70973
|
+
mouseX,
|
|
70974
|
+
mouseY,
|
|
70975
|
+
this.nrrd_states.currentIndex,
|
|
70976
|
+
];
|
|
70977
|
+
this.setUpSphereOrigins(mouseX, mouseY, this.nrrd_states.currentIndex);
|
|
70978
|
+
this.nrrd_states.cursorPageX = mouseX;
|
|
70979
|
+
this.nrrd_states.cursorPageY = mouseY;
|
|
70980
|
+
this.enableCrosshair();
|
|
70981
|
+
// draw circle setup width/height for sphere canvas
|
|
70982
|
+
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
70983
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
70984
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70985
|
+
};
|
|
70843
70986
|
const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
|
|
70844
70987
|
var _a;
|
|
70845
70988
|
let paintImages;
|
|
@@ -70933,7 +71076,8 @@ class DrawToolCore extends CommToolsData {
|
|
|
70933
71076
|
// findout all index in the sphere radius range in Axial view
|
|
70934
71077
|
if (this.nrrd_states.spherePlanB) {
|
|
70935
71078
|
// clear stroe images
|
|
70936
|
-
this.clearStoreImages();
|
|
71079
|
+
// this.clearStoreImages();
|
|
71080
|
+
this.clearSpherePrintStoreImages();
|
|
70937
71081
|
for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
|
|
70938
71082
|
this.drawSphereOnEachViews(i, "x");
|
|
70939
71083
|
this.drawSphereOnEachViews(i, "y");
|
|
@@ -70942,18 +71086,31 @@ class DrawToolCore extends CommToolsData {
|
|
|
70942
71086
|
}
|
|
70943
71087
|
!!this.nrrd_states.getSphere &&
|
|
70944
71088
|
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
71089
|
this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
71090
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
71091
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70947
71092
|
}
|
|
70948
|
-
else if (this.gui_states.sphere &&
|
|
71093
|
+
else if ((this.gui_states.sphere || this.gui_states.calculator) &&
|
|
70949
71094
|
this.nrrd_states.enableCursorChoose) {
|
|
70950
71095
|
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
71096
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
71097
|
+
}
|
|
71098
|
+
else if (this.gui_states.calculator &&
|
|
71099
|
+
!this.nrrd_states.enableCursorChoose) {
|
|
71100
|
+
// When mouse up
|
|
71101
|
+
this.drawCalSphereUp();
|
|
70951
71102
|
}
|
|
70952
71103
|
}
|
|
70953
71104
|
else if (e.button === 2) {
|
|
70954
71105
|
rightclicked = false;
|
|
70955
71106
|
this.protectedData.canvases.drawingCanvas.style.cursor = "grab";
|
|
71107
|
+
setTimeout(() => {
|
|
71108
|
+
this.protectedData.canvases.drawingCanvas.style.cursor = this.gui_states.defaultPaintCursor;
|
|
71109
|
+
}, 2000);
|
|
70956
71110
|
this.protectedData.canvases.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
71111
|
+
if (this.gui_states.sphere || this.gui_states.calculator) {
|
|
71112
|
+
this.zoomActionAfterDrawSphere();
|
|
71113
|
+
}
|
|
70957
71114
|
}
|
|
70958
71115
|
else {
|
|
70959
71116
|
return;
|
|
@@ -71015,8 +71172,8 @@ class DrawToolCore extends CommToolsData {
|
|
|
71015
71172
|
this.protectedData.ctxes.drawingCtx.clearRect(0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
71016
71173
|
const ex = this.nrrd_states.cursorPageX * this.nrrd_states.sizeFoctor;
|
|
71017
71174
|
const ey = this.nrrd_states.cursorPageY * this.nrrd_states.sizeFoctor;
|
|
71018
|
-
this.drawLine(ex, 0, ex, this.
|
|
71019
|
-
this.drawLine(0, ey, this.
|
|
71175
|
+
this.drawLine(ex, 0, ex, this.nrrd_states.changedWidth);
|
|
71176
|
+
this.drawLine(0, ey, this.nrrd_states.changedHeight, ey);
|
|
71020
71177
|
}
|
|
71021
71178
|
}
|
|
71022
71179
|
this.protectedData.ctxes.drawingCtx.drawImage(this.protectedData.canvases.drawingCanvasLayerMaster, 0, 0);
|
|
@@ -71146,15 +71303,17 @@ class DrawToolCore extends CommToolsData {
|
|
|
71146
71303
|
moveDistance = w / this.nrrd_states.originWidth;
|
|
71147
71304
|
if (moveDistance > 8) {
|
|
71148
71305
|
moveDistance = 8;
|
|
71306
|
+
this.resetPaintAreaUIPosition();
|
|
71149
71307
|
}
|
|
71150
71308
|
else if (moveDistance < 1) {
|
|
71151
71309
|
moveDistance = 1;
|
|
71310
|
+
this.resetPaintAreaUIPosition();
|
|
71152
71311
|
}
|
|
71153
71312
|
else {
|
|
71154
|
-
this.resizePaintArea(moveDistance);
|
|
71155
71313
|
this.resetPaintAreaUIPosition(l, t);
|
|
71156
|
-
this.setIsDrawFalse(1000);
|
|
71157
71314
|
}
|
|
71315
|
+
this.resizePaintArea(moveDistance);
|
|
71316
|
+
this.setIsDrawFalse(1000);
|
|
71158
71317
|
this.nrrd_states.sizeFoctor = moveDistance;
|
|
71159
71318
|
};
|
|
71160
71319
|
return handleZoomWheelMove;
|
|
@@ -71182,6 +71341,60 @@ class DrawToolCore extends CommToolsData {
|
|
|
71182
71341
|
drawImageOnEmptyImage(canvas) {
|
|
71183
71342
|
this.protectedData.ctxes.emptyCtx.drawImage(canvas, 0, 0, this.protectedData.canvases.emptyCanvas.width, this.protectedData.canvases.emptyCanvas.height);
|
|
71184
71343
|
}
|
|
71344
|
+
/****************************Sphere calculate distance functions****************************************************/
|
|
71345
|
+
getSpherePosition(position, axis) {
|
|
71346
|
+
const mouseX = position[axis][0];
|
|
71347
|
+
const mouseY = position[axis][1];
|
|
71348
|
+
const sliceIndex = position[axis][2];
|
|
71349
|
+
return { x: mouseX, y: mouseY, z: sliceIndex };
|
|
71350
|
+
}
|
|
71351
|
+
drawCalculatorSphereOnEachViews(axis) {
|
|
71352
|
+
// init sphere canvas width and height
|
|
71353
|
+
this.setSphereCanvasSize(axis);
|
|
71354
|
+
// get drawingSphere canvas for storing
|
|
71355
|
+
const ctx = this.protectedData.ctxes.drawingSphereCtx;
|
|
71356
|
+
const canvas = this.protectedData.canvases.drawingSphereCanvas;
|
|
71357
|
+
let tumourPosition = !!this.nrrd_states.tumourSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.tumourSphereOrigin, axis), { color: this.nrrd_states.tumourColor }) : null;
|
|
71358
|
+
let skinPosition = !!this.nrrd_states.skinSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.skinSphereOrigin, axis), { color: this.nrrd_states.skinColor }) : null;
|
|
71359
|
+
let ribcagePosition = !!this.nrrd_states.ribSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.ribSphereOrigin, axis), { color: this.nrrd_states.ribcageColor }) : null;
|
|
71360
|
+
let nipplePosition = !!this.nrrd_states.nippleSphereOrigin ? Object.assign(this.getSpherePosition(this.nrrd_states.nippleSphereOrigin, axis), { color: this.nrrd_states.nippleColor }) : null;
|
|
71361
|
+
let positionGroup = [];
|
|
71362
|
+
if (!!tumourPosition)
|
|
71363
|
+
positionGroup.push(tumourPosition);
|
|
71364
|
+
if (!!skinPosition)
|
|
71365
|
+
positionGroup.push(skinPosition);
|
|
71366
|
+
if (!!ribcagePosition)
|
|
71367
|
+
positionGroup.push(ribcagePosition);
|
|
71368
|
+
if (!!nipplePosition)
|
|
71369
|
+
positionGroup.push(nipplePosition);
|
|
71370
|
+
let copyPosition = JSON.parse(JSON.stringify(positionGroup));
|
|
71371
|
+
let rePositionGroup = [];
|
|
71372
|
+
// group same slice points
|
|
71373
|
+
positionGroup.forEach((p) => {
|
|
71374
|
+
let temp = [];
|
|
71375
|
+
let sameIndex = [];
|
|
71376
|
+
for (let i = 0; i < copyPosition.length; i++) {
|
|
71377
|
+
if (p.z == copyPosition[i].z) {
|
|
71378
|
+
temp.push(copyPosition[i]);
|
|
71379
|
+
sameIndex.push(i);
|
|
71380
|
+
}
|
|
71381
|
+
}
|
|
71382
|
+
sameIndex.reverse();
|
|
71383
|
+
sameIndex.forEach(i => copyPosition.splice(i, 1));
|
|
71384
|
+
if (temp.length > 0)
|
|
71385
|
+
rePositionGroup.push(temp);
|
|
71386
|
+
if (copyPosition.length == 0) {
|
|
71387
|
+
return;
|
|
71388
|
+
}
|
|
71389
|
+
});
|
|
71390
|
+
rePositionGroup.forEach((group) => {
|
|
71391
|
+
group.forEach(p => {
|
|
71392
|
+
this.drawSphereCore(ctx, p.x, p.y, this.nrrd_states.sphereRadius, p.color);
|
|
71393
|
+
});
|
|
71394
|
+
this.storeSphereImages(group[0].z, axis);
|
|
71395
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
71396
|
+
});
|
|
71397
|
+
}
|
|
71185
71398
|
/****************************Sphere functions****************************************************/
|
|
71186
71399
|
// for sphere
|
|
71187
71400
|
storeSphereImages(index, axis) {
|
|
@@ -71201,21 +71414,29 @@ class DrawToolCore extends CommToolsData {
|
|
|
71201
71414
|
const ctx = this.protectedData.ctxes.drawingSphereCtx;
|
|
71202
71415
|
const canvas = this.protectedData.canvases.drawingSphereCanvas;
|
|
71203
71416
|
if (preIndex === nextIndex) {
|
|
71204
|
-
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius
|
|
71417
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius, this.gui_states.fillColor);
|
|
71205
71418
|
this.storeSphereImages(preIndex, axis);
|
|
71206
71419
|
}
|
|
71207
71420
|
else {
|
|
71208
|
-
this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay)
|
|
71421
|
+
this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay), this.gui_states.fillColor);
|
|
71209
71422
|
this.drawImageOnEmptyImage(canvas);
|
|
71210
71423
|
this.storeSphereImages(preIndex, axis);
|
|
71211
71424
|
this.storeSphereImages(nextIndex, axis);
|
|
71212
71425
|
}
|
|
71213
71426
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
71214
71427
|
}
|
|
71215
|
-
|
|
71428
|
+
/**
|
|
71429
|
+
*
|
|
71430
|
+
* @param ctx draw sphere canvas ctx
|
|
71431
|
+
* @param x width must be match the origin size, size factor 1, ignore the size factor
|
|
71432
|
+
* @param y height must be match the origin size, size factor 1, ignore the size factor
|
|
71433
|
+
* @param radius radius must be match the origin size, size factor 1, ignore the size factor
|
|
71434
|
+
* @param color sphere color
|
|
71435
|
+
*/
|
|
71436
|
+
drawSphereCore(ctx, x, y, radius, color) {
|
|
71216
71437
|
ctx.beginPath();
|
|
71217
71438
|
ctx.arc(x, y, radius, 0, 2 * Math.PI);
|
|
71218
|
-
ctx.fillStyle =
|
|
71439
|
+
ctx.fillStyle = color;
|
|
71219
71440
|
ctx.fill();
|
|
71220
71441
|
ctx.closePath();
|
|
71221
71442
|
}
|
|
@@ -71260,17 +71481,46 @@ class DrawToolCore extends CommToolsData {
|
|
|
71260
71481
|
};
|
|
71261
71482
|
return sphereEvent;
|
|
71262
71483
|
}
|
|
71484
|
+
drawCalculatorSphere(radius) {
|
|
71485
|
+
// clear canvas
|
|
71486
|
+
const [canvas, ctx] = this.clearSphereCanvas();
|
|
71487
|
+
if (!!this.nrrd_states.tumourSphereOrigin && this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
|
|
71488
|
+
this.drawSphereCore(ctx, this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][0], this.nrrd_states.tumourSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.tumourColor);
|
|
71489
|
+
}
|
|
71490
|
+
if (!!this.nrrd_states.skinSphereOrigin && this.nrrd_states.skinSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
|
|
71491
|
+
this.drawSphereCore(ctx, this.nrrd_states.skinSphereOrigin[this.protectedData.axis][0], this.nrrd_states.skinSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.skinColor);
|
|
71492
|
+
}
|
|
71493
|
+
if (!!this.nrrd_states.ribSphereOrigin && this.nrrd_states.ribSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
|
|
71494
|
+
this.drawSphereCore(ctx, this.nrrd_states.ribSphereOrigin[this.protectedData.axis][0], this.nrrd_states.ribSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.ribcageColor);
|
|
71495
|
+
}
|
|
71496
|
+
if (!!this.nrrd_states.nippleSphereOrigin && this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][2] === this.nrrd_states.currentIndex) {
|
|
71497
|
+
this.drawSphereCore(ctx, this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][0], this.nrrd_states.nippleSphereOrigin[this.protectedData.axis][1], radius, this.nrrd_states.nippleColor);
|
|
71498
|
+
}
|
|
71499
|
+
this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
71500
|
+
}
|
|
71263
71501
|
drawSphere(mouseX, mouseY, radius) {
|
|
71264
71502
|
// clear canvas
|
|
71265
|
-
this.
|
|
71266
|
-
|
|
71267
|
-
|
|
71268
|
-
|
|
71503
|
+
const [canvas, ctx] = this.clearSphereCanvas();
|
|
71504
|
+
this.drawSphereCore(ctx, mouseX, mouseY, radius, this.gui_states.fillColor);
|
|
71505
|
+
console.log("when drawing shpere on canvas");
|
|
71506
|
+
console.log("Line 1256 mastercanvasesize:", this.protectedData.canvases.drawingCanvasLayerMaster.width, this.protectedData.canvases.drawingCanvasLayerMaster.height);
|
|
71507
|
+
console.log("current xy:", mouseX, mouseY);
|
|
71508
|
+
console.log("current changed width:", this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
71509
|
+
this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
71510
|
+
}
|
|
71511
|
+
clearSphereCanvas() {
|
|
71512
|
+
// this.protectedData.canvases.drawingSphereCanvas.width =
|
|
71513
|
+
// this.protectedData.canvases.drawingCanvasLayerMaster.width;
|
|
71514
|
+
// this.protectedData.canvases.drawingSphereCanvas.height =
|
|
71515
|
+
// this.protectedData.canvases.drawingCanvasLayerMaster.height;
|
|
71516
|
+
// clear drawingCanvasLayerMaster
|
|
71517
|
+
this.protectedData.canvases.drawingCanvasLayerMaster.width = this.protectedData.canvases.drawingCanvasLayerMaster.width;
|
|
71518
|
+
// resize sphere canvas size to original size
|
|
71519
|
+
this.protectedData.canvases.drawingSphereCanvas.width = this.protectedData.canvases.originCanvas.width;
|
|
71520
|
+
this.protectedData.canvases.drawingSphereCanvas.height = this.protectedData.canvases.originCanvas.height;
|
|
71269
71521
|
const canvas = this.protectedData.canvases.drawingSphereCanvas;
|
|
71270
71522
|
const ctx = this.protectedData.ctxes.drawingSphereCtx;
|
|
71271
|
-
|
|
71272
|
-
this.drawSphereCore(ctx, mouseX, mouseY, radius);
|
|
71273
|
-
this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
71523
|
+
return [canvas, ctx];
|
|
71274
71524
|
}
|
|
71275
71525
|
/**
|
|
71276
71526
|
* We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
|
|
@@ -71368,9 +71618,9 @@ class DrawToolCore extends CommToolsData {
|
|
|
71368
71618
|
}
|
|
71369
71619
|
return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
|
|
71370
71620
|
}
|
|
71371
|
-
setUpSphereOrigins(mouseX, mouseY) {
|
|
71621
|
+
setUpSphereOrigins(mouseX, mouseY, sliceIndex) {
|
|
71372
71622
|
const convertCursor = (from, to) => {
|
|
71373
|
-
const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY,
|
|
71623
|
+
const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, sliceIndex);
|
|
71374
71624
|
return {
|
|
71375
71625
|
convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
|
|
71376
71626
|
convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
|
|
@@ -71497,7 +71747,7 @@ class DrawToolCore extends CommToolsData {
|
|
|
71497
71747
|
storeAllImages(index, label) {
|
|
71498
71748
|
// const image: HTMLImageElement = new Image();
|
|
71499
71749
|
// resize the drawing image data
|
|
71500
|
-
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
71750
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
|
|
71501
71751
|
this.setEmptyCanvasSize();
|
|
71502
71752
|
this.drawImageOnEmptyImage(this.protectedData.canvases.drawingCanvasLayerMaster);
|
|
71503
71753
|
}
|
|
@@ -71569,7 +71819,7 @@ class DrawToolCore extends CommToolsData {
|
|
|
71569
71819
|
break;
|
|
71570
71820
|
}
|
|
71571
71821
|
this.storeImageToAxis(index, this.protectedData.maskData.paintImages, imageData);
|
|
71572
|
-
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
71822
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere && !this.gui_states.calculator) {
|
|
71573
71823
|
this.storeEachLayerImage(index, label);
|
|
71574
71824
|
}
|
|
71575
71825
|
}
|
|
@@ -72044,6 +72294,18 @@ class NrrdTools extends DrawToolCore {
|
|
|
72044
72294
|
getMaskData() {
|
|
72045
72295
|
return this.protectedData.maskData;
|
|
72046
72296
|
}
|
|
72297
|
+
// set calculate distance sphere position
|
|
72298
|
+
setCalculateDistanceSphere(x, y, sliceIndex, cal_position) {
|
|
72299
|
+
this.nrrd_states.sphereRadius = 5;
|
|
72300
|
+
// move to tumour slice
|
|
72301
|
+
const steps = sliceIndex - this.nrrd_states.currentIndex;
|
|
72302
|
+
this.setSliceMoving(steps * this.protectedData.displaySlices.length);
|
|
72303
|
+
// mock mouse down
|
|
72304
|
+
// if user zoom the panel, we need to consider the size factor
|
|
72305
|
+
this.drawCalSphereDown(x * this.nrrd_states.sizeFoctor, y * this.nrrd_states.sizeFoctor, sliceIndex, cal_position);
|
|
72306
|
+
// mock mouse up
|
|
72307
|
+
this.drawCalSphereUp();
|
|
72308
|
+
}
|
|
72047
72309
|
getSharedPlace(len, ratio) {
|
|
72048
72310
|
let old = -1;
|
|
72049
72311
|
let same = [];
|
|
@@ -72269,6 +72531,10 @@ class NrrdTools extends DrawToolCore {
|
|
|
72269
72531
|
this.protectedData.canvases.drawingCanvas.width;
|
|
72270
72532
|
this.protectedData.canvases.displayCanvas.width =
|
|
72271
72533
|
this.protectedData.canvases.displayCanvas.width;
|
|
72534
|
+
this.nrrd_states.tumourSphereOrigin = null;
|
|
72535
|
+
this.nrrd_states.ribSphereOrigin = null;
|
|
72536
|
+
this.nrrd_states.skinSphereOrigin = null;
|
|
72537
|
+
this.nrrd_states.nippleSphereOrigin = null;
|
|
72272
72538
|
}
|
|
72273
72539
|
setSliceMoving(step) {
|
|
72274
72540
|
if (this.protectedData.mainPreSlices) {
|
|
@@ -72450,10 +72716,13 @@ class NrrdTools extends DrawToolCore {
|
|
|
72450
72716
|
this.protectedData.canvases.originCanvas.width;
|
|
72451
72717
|
this.nrrd_states.originHeight =
|
|
72452
72718
|
this.protectedData.canvases.originCanvas.height;
|
|
72719
|
+
// In html the width and height is pixels,
|
|
72720
|
+
// So the value must be int
|
|
72721
|
+
// Therefore, we must use Math.floor rather than using Math.ceil
|
|
72453
72722
|
this.nrrd_states.changedWidth =
|
|
72454
|
-
this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
|
|
72723
|
+
Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
|
|
72455
72724
|
this.nrrd_states.changedHeight =
|
|
72456
|
-
this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor);
|
|
72725
|
+
Math.floor(this.nrrd_states.originWidth * Number(this.nrrd_states.sizeFoctor));
|
|
72457
72726
|
this.resizePaintArea(this.nrrd_states.sizeFoctor);
|
|
72458
72727
|
this.resetPaintAreaUIPosition();
|
|
72459
72728
|
}
|
|
@@ -72551,8 +72820,8 @@ class NrrdTools extends DrawToolCore {
|
|
|
72551
72820
|
this.protectedData.canvases.drawingCanvas.width =
|
|
72552
72821
|
this.protectedData.canvases.drawingCanvas.width;
|
|
72553
72822
|
this.resetLayerCanvas();
|
|
72554
|
-
this.nrrd_states.changedWidth = this.nrrd_states.originWidth * factor;
|
|
72555
|
-
this.nrrd_states.changedHeight = this.nrrd_states.originHeight * factor;
|
|
72823
|
+
this.nrrd_states.changedWidth = Math.floor(this.nrrd_states.originWidth * factor);
|
|
72824
|
+
this.nrrd_states.changedHeight = Math.floor(this.nrrd_states.originHeight * factor);
|
|
72556
72825
|
/**
|
|
72557
72826
|
* resize canvas
|
|
72558
72827
|
*/
|
|
@@ -72908,7 +73177,7 @@ function evaluateElement(element, weights) {
|
|
|
72908
73177
|
}
|
|
72909
73178
|
|
|
72910
73179
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
72911
|
-
const REVISION = "v2.
|
|
72912
|
-
console.log("%cCopper3D Visualisation %cBeta:v2.
|
|
73180
|
+
const REVISION = "v2.1.1";
|
|
73181
|
+
console.log("%cCopper3D Visualisation %cBeta:v2.1.1", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
72913
73182
|
|
|
72914
73183
|
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 };
|