copper3d 1.15.10 → 1.15.12
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/copperRenderer.d.ts +6 -1
- package/dist/Renderer/copperRenderer.js +38 -4
- package/dist/Renderer/copperRenderer.js.map +1 -1
- package/dist/Scene/baseScene.d.ts +1 -1
- package/dist/Scene/baseScene.js +1 -1
- package/dist/Scene/baseScene.js.map +1 -1
- package/dist/Scene/copperScene.d.ts +1 -1
- package/dist/Scene/copperScene.js +7 -4
- package/dist/Scene/copperScene.js.map +1 -1
- package/dist/Utils/nrrd_tool.d.ts +77 -4
- package/dist/Utils/nrrd_tool.js +569 -305
- package/dist/Utils/nrrd_tool.js.map +1 -1
- package/dist/Utils/utils.d.ts +4 -0
- package/dist/Utils/utils.js +35 -0
- package/dist/Utils/utils.js.map +1 -1
- package/dist/bundle.esm.js +616 -316
- package/dist/bundle.umd.js +616 -316
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/types/Renderer/copperRenderer.d.ts +6 -1
- package/dist/types/Scene/baseScene.d.ts +1 -1
- package/dist/types/Scene/copperScene.d.ts +1 -1
- package/dist/types/Utils/nrrd_tool.d.ts +77 -4
- package/dist/types/Utils/utils.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/types.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/bundle.umd.js
CHANGED
|
@@ -47413,7 +47413,7 @@
|
|
|
47413
47413
|
this.container.clientWidth / this.container.clientHeight;
|
|
47414
47414
|
this.camera.updateProjectionMatrix();
|
|
47415
47415
|
}
|
|
47416
|
-
render() {
|
|
47416
|
+
render(time) {
|
|
47417
47417
|
// this.onWindowResize();
|
|
47418
47418
|
this.renderer.render(this.scene, this.camera);
|
|
47419
47419
|
}
|
|
@@ -56526,14 +56526,17 @@
|
|
|
56526
56526
|
}
|
|
56527
56527
|
this.camera.updateProjectionMatrix();
|
|
56528
56528
|
}
|
|
56529
|
-
render() {
|
|
56529
|
+
render(time) {
|
|
56530
56530
|
this.controls.update();
|
|
56531
56531
|
if (this.modelReady) {
|
|
56532
56532
|
this.mixer && this.mixer.update(this.clock.getDelta() * this.playRate);
|
|
56533
|
+
// this.mixer && this.mixer.update((time as number) * this.playRate);
|
|
56534
|
+
}
|
|
56535
|
+
if (this.preRenderCallbackFunctions.cache.length > 0) {
|
|
56536
|
+
Object.values(this.preRenderCallbackFunctions.cache).forEach((item) => {
|
|
56537
|
+
item && item.call(null);
|
|
56538
|
+
});
|
|
56533
56539
|
}
|
|
56534
|
-
Object.values(this.preRenderCallbackFunctions.cache).forEach((item) => {
|
|
56535
|
-
item && item.call(null);
|
|
56536
|
-
});
|
|
56537
56540
|
if (this.subDiv && this.subCamera && this.subRender) {
|
|
56538
56541
|
this.subCamera.aspect =
|
|
56539
56542
|
this.subDiv.clientWidth / this.subDiv.clientHeight;
|
|
@@ -56551,16 +56554,49 @@
|
|
|
56551
56554
|
constructor(container, options) {
|
|
56552
56555
|
super(container, options);
|
|
56553
56556
|
this.sceneMap = {};
|
|
56557
|
+
this.fps = 30;
|
|
56558
|
+
this.renderClock = new Clock();
|
|
56559
|
+
this.delta = 0;
|
|
56560
|
+
this.interval = 1 / this.fps;
|
|
56554
56561
|
this.preRenderCallbackFunctions = [];
|
|
56555
|
-
this.animate = () => {
|
|
56556
|
-
this.
|
|
56557
|
-
this.
|
|
56558
|
-
|
|
56562
|
+
this.animate = (time) => {
|
|
56563
|
+
// if (this.start) {
|
|
56564
|
+
// this.fpsCap = createFpsCap(this.render, 10);
|
|
56565
|
+
// this.start = false;
|
|
56566
|
+
// }
|
|
56567
|
+
var _a, _b, _c;
|
|
56568
|
+
switch ((_a = this.options) === null || _a === void 0 ? void 0 : _a.fpsMode) {
|
|
56569
|
+
case "1":
|
|
56570
|
+
// fpsControl one: 30fps
|
|
56571
|
+
setTimeout(() => {
|
|
56572
|
+
requestAnimationFrame(this.animate);
|
|
56573
|
+
}, 1000 / this.fps);
|
|
56574
|
+
this.render();
|
|
56575
|
+
if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.performanceGui)
|
|
56576
|
+
this.stats.update();
|
|
56577
|
+
break;
|
|
56578
|
+
default:
|
|
56579
|
+
// fpsControl two: 30fps
|
|
56580
|
+
requestAnimationFrame(this.animate);
|
|
56581
|
+
if (this.delta === 0) {
|
|
56582
|
+
this.render();
|
|
56583
|
+
}
|
|
56584
|
+
this.delta += this.renderClock.getDelta();
|
|
56585
|
+
if (this.delta > this.interval) {
|
|
56586
|
+
this.render();
|
|
56587
|
+
if ((_c = this.options) === null || _c === void 0 ? void 0 : _c.performanceGui)
|
|
56588
|
+
this.stats.update();
|
|
56589
|
+
this.delta = this.delta % this.interval;
|
|
56590
|
+
}
|
|
56591
|
+
}
|
|
56559
56592
|
};
|
|
56560
56593
|
}
|
|
56561
56594
|
getSceneByName(name) {
|
|
56562
56595
|
return this.sceneMap[name];
|
|
56563
56596
|
}
|
|
56597
|
+
setFPS(fps) {
|
|
56598
|
+
this.fps = fps;
|
|
56599
|
+
}
|
|
56564
56600
|
setCurrentScene(sceneIn) {
|
|
56565
56601
|
var _a;
|
|
56566
56602
|
if (sceneIn) {
|
|
@@ -67612,6 +67648,7 @@
|
|
|
67612
67648
|
label2: this.paintImagesLabel2,
|
|
67613
67649
|
label3: this.paintImagesLabel3,
|
|
67614
67650
|
};
|
|
67651
|
+
// used to store display marks with multiple labels
|
|
67615
67652
|
this.paintImages = { x: [], y: [], z: [] };
|
|
67616
67653
|
// store all contrast slices, include x, y, z orientation
|
|
67617
67654
|
this.allSlicesArray = [];
|
|
@@ -67639,7 +67676,6 @@
|
|
|
67639
67676
|
this.Is_Shift_Pressed = false;
|
|
67640
67677
|
this.Is_Draw = false;
|
|
67641
67678
|
this.sensitiveArray = [];
|
|
67642
|
-
this.handleWheelMove = () => { };
|
|
67643
67679
|
this.start = () => { };
|
|
67644
67680
|
this.undoArray = [];
|
|
67645
67681
|
this.initState = true;
|
|
@@ -67675,6 +67711,10 @@
|
|
|
67675
67711
|
isCursorSelect: false,
|
|
67676
67712
|
cursorPageX: 0,
|
|
67677
67713
|
cursorPageY: 0,
|
|
67714
|
+
// x: [cursorX, cursorY, sliceIndex]
|
|
67715
|
+
sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
|
|
67716
|
+
spherePlanB: false,
|
|
67717
|
+
sphereRadius: 10,
|
|
67678
67718
|
Mouse_Over_x: 0,
|
|
67679
67719
|
Mouse_Over_y: 0,
|
|
67680
67720
|
Mouse_Over: false,
|
|
@@ -67724,12 +67764,9 @@
|
|
|
67724
67764
|
brushAndEraserSize: 15,
|
|
67725
67765
|
cursor: "dot",
|
|
67726
67766
|
label: "label1",
|
|
67767
|
+
sphere: false,
|
|
67727
67768
|
// EraserSize: 25,
|
|
67728
67769
|
clear: () => {
|
|
67729
|
-
// const text = "Are you sure remove annotations on Current slice?";
|
|
67730
|
-
// if (confirm(text) === true) {
|
|
67731
|
-
// this.clearPaint();
|
|
67732
|
-
// }
|
|
67733
67770
|
this.clearPaint();
|
|
67734
67771
|
},
|
|
67735
67772
|
clearAll: () => {
|
|
@@ -67763,6 +67800,36 @@
|
|
|
67763
67800
|
this.exportData();
|
|
67764
67801
|
},
|
|
67765
67802
|
};
|
|
67803
|
+
this.dragPrameters = {
|
|
67804
|
+
move: 0,
|
|
67805
|
+
y: 0,
|
|
67806
|
+
h: 0,
|
|
67807
|
+
sensivity: 1,
|
|
67808
|
+
handleOnDragMouseUp: (ev) => { },
|
|
67809
|
+
handleOnDragMouseDown: (ev) => { },
|
|
67810
|
+
handleOnDragMouseMove: (ev) => { },
|
|
67811
|
+
};
|
|
67812
|
+
this.drawingPrameters = {
|
|
67813
|
+
handleOnDrawingMouseDown: (ev) => { },
|
|
67814
|
+
handleOnDrawingMouseMove: (ev) => { },
|
|
67815
|
+
handleOnPanMouseMove: (ev) => { },
|
|
67816
|
+
handleOnDrawingMouseUp: (ev) => { },
|
|
67817
|
+
handleOnDrawingMouseLeave: (ev) => { },
|
|
67818
|
+
handleOnDrawingBrushCricleMove: (ev) => { },
|
|
67819
|
+
handleZoomWheel: (e) => { },
|
|
67820
|
+
handleSphereWheel: (e) => { },
|
|
67821
|
+
};
|
|
67822
|
+
this.configDragMode = () => {
|
|
67823
|
+
this.container.style.cursor = "pointer";
|
|
67824
|
+
this.container.addEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
|
|
67825
|
+
this.container.addEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
|
|
67826
|
+
};
|
|
67827
|
+
this.removeDragMode = () => {
|
|
67828
|
+
this.container.style.cursor = "";
|
|
67829
|
+
this.container.removeEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
|
|
67830
|
+
this.container.removeEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
|
|
67831
|
+
this.setIsDrawFalse(1000);
|
|
67832
|
+
};
|
|
67766
67833
|
this.drawLine = (x1, y1, x2, y2) => {
|
|
67767
67834
|
this.drawingCtx.beginPath();
|
|
67768
67835
|
this.drawingCtx.moveTo(x1, y1);
|
|
@@ -67795,7 +67862,7 @@
|
|
|
67795
67862
|
this.sensitiveArray.push((i + 1) / 20);
|
|
67796
67863
|
}
|
|
67797
67864
|
this.container.addEventListener("keydown", (ev) => {
|
|
67798
|
-
if (ev.key === "Shift") {
|
|
67865
|
+
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
67799
67866
|
this.Is_Shift_Pressed = true;
|
|
67800
67867
|
this.nrrd_states.enableCursorChoose = false;
|
|
67801
67868
|
}
|
|
@@ -67975,12 +68042,94 @@
|
|
|
67975
68042
|
paintImages.z.push(initMark_z);
|
|
67976
68043
|
}
|
|
67977
68044
|
}
|
|
68045
|
+
convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
|
|
68046
|
+
const nrrd = this.nrrd_states;
|
|
68047
|
+
const dimensions = nrrd.dimensions;
|
|
68048
|
+
const ratios = nrrd.ratios;
|
|
68049
|
+
const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
|
|
68050
|
+
let currentIndex = 0;
|
|
68051
|
+
let oldIndex = 0;
|
|
68052
|
+
let convertCursorNumX = 0;
|
|
68053
|
+
let convertCursorNumY = 0;
|
|
68054
|
+
const convertIndex = {
|
|
68055
|
+
x: {
|
|
68056
|
+
y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
68057
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
68058
|
+
},
|
|
68059
|
+
y: {
|
|
68060
|
+
x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
68061
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
68062
|
+
},
|
|
68063
|
+
z: {
|
|
68064
|
+
x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
68065
|
+
y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
68066
|
+
},
|
|
68067
|
+
};
|
|
68068
|
+
const convertCursor = {
|
|
68069
|
+
x: {
|
|
68070
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
68071
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
68072
|
+
},
|
|
68073
|
+
y: {
|
|
68074
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
68075
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
68076
|
+
},
|
|
68077
|
+
z: {
|
|
68078
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
68079
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
68080
|
+
},
|
|
68081
|
+
};
|
|
68082
|
+
if (from === to) {
|
|
68083
|
+
return;
|
|
68084
|
+
}
|
|
68085
|
+
if (from === "z" && to === "x") {
|
|
68086
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
68087
|
+
oldIndex = currentIndex * ratios[to];
|
|
68088
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
68089
|
+
convertCursorNumY = cursorNumY;
|
|
68090
|
+
}
|
|
68091
|
+
else if (from === "y" && to === "x") {
|
|
68092
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
68093
|
+
oldIndex = currentIndex * ratios.x;
|
|
68094
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
68095
|
+
convertCursorNumX = cursorNumY;
|
|
68096
|
+
}
|
|
68097
|
+
else if (from === "z" && to === "y") {
|
|
68098
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
68099
|
+
oldIndex = currentIndex * ratios[to];
|
|
68100
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
68101
|
+
convertCursorNumX = cursorNumX;
|
|
68102
|
+
}
|
|
68103
|
+
else if (from === "x" && to === "y") {
|
|
68104
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
68105
|
+
oldIndex = currentIndex * ratios[to];
|
|
68106
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
68107
|
+
convertCursorNumY = cursorNumX;
|
|
68108
|
+
}
|
|
68109
|
+
else if (from === "x" && to === "z") {
|
|
68110
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
68111
|
+
oldIndex = currentIndex * ratios[to];
|
|
68112
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
68113
|
+
convertCursorNumY = cursorNumY;
|
|
68114
|
+
}
|
|
68115
|
+
else if (from === "y" && to === "z") {
|
|
68116
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
68117
|
+
oldIndex = currentIndex * ratios.z;
|
|
68118
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
68119
|
+
convertCursorNumX = cursorNumX;
|
|
68120
|
+
}
|
|
68121
|
+
else {
|
|
68122
|
+
return;
|
|
68123
|
+
}
|
|
68124
|
+
return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
|
|
68125
|
+
}
|
|
67978
68126
|
/**
|
|
67979
68127
|
* Switch all contrast slices' orientation
|
|
67980
68128
|
* @param {string} aixs:"x" | "y" | "z"
|
|
67981
68129
|
* */
|
|
67982
|
-
setSliceOrientation(
|
|
67983
|
-
|
|
68130
|
+
setSliceOrientation(axisTo) {
|
|
68131
|
+
let convetObj;
|
|
68132
|
+
if (this.nrrd_states.enableCursorChoose || this.gui_states.sphere) {
|
|
67984
68133
|
if (this.axis === "z") {
|
|
67985
68134
|
this.cursorPage.z.index = this.nrrd_states.currentIndex;
|
|
67986
68135
|
this.cursorPage.z.cursorPageX = this.nrrd_states.cursorPageX;
|
|
@@ -67996,27 +68145,19 @@
|
|
|
67996
68145
|
this.cursorPage.y.cursorPageX = this.nrrd_states.cursorPageX;
|
|
67997
68146
|
this.cursorPage.y.cursorPageY = this.nrrd_states.cursorPageY;
|
|
67998
68147
|
}
|
|
67999
|
-
if (
|
|
68148
|
+
if (axisTo === "z") {
|
|
68000
68149
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.z.updated) {
|
|
68001
68150
|
if (this.axis === "x") {
|
|
68002
|
-
|
|
68003
|
-
|
|
68004
|
-
this.nrrd_states.oldIndex =
|
|
68005
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
|
|
68006
|
-
this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
|
|
68007
|
-
this.nrrd_states.nrrd_x_mm);
|
|
68151
|
+
// convert x to z
|
|
68152
|
+
convetObj = this.convertCursorPoint("x", "z", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
|
|
68008
68153
|
}
|
|
68009
68154
|
if (this.axis === "y") {
|
|
68010
|
-
|
|
68011
|
-
|
|
68012
|
-
this.nrrd_states.oldIndex =
|
|
68013
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
|
|
68014
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
|
|
68015
|
-
this.nrrd_states.nrrd_y_mm);
|
|
68155
|
+
// convert y to z
|
|
68156
|
+
convetObj = this.convertCursorPoint("y", "z", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
|
|
68016
68157
|
}
|
|
68017
|
-
this.cursorPage.z.updated = true;
|
|
68018
68158
|
}
|
|
68019
68159
|
else {
|
|
68160
|
+
// not cursor select, freedom to switch x -> z or y -> z and z -> x or z -> y
|
|
68020
68161
|
this.nrrd_states.currentIndex = this.cursorPage.z.index;
|
|
68021
68162
|
this.nrrd_states.oldIndex =
|
|
68022
68163
|
this.cursorPage.z.index * this.nrrd_states.ratios.z;
|
|
@@ -68024,28 +68165,19 @@
|
|
|
68024
68165
|
this.nrrd_states.cursorPageY = this.cursorPage.z.cursorPageY;
|
|
68025
68166
|
}
|
|
68026
68167
|
}
|
|
68027
|
-
else if (
|
|
68168
|
+
else if (axisTo === "x") {
|
|
68028
68169
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.x.updated) {
|
|
68029
68170
|
if (this.axis === "z") {
|
|
68030
|
-
|
|
68031
|
-
|
|
68032
|
-
this.nrrd_states.oldIndex =
|
|
68033
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
|
|
68034
|
-
this.nrrd_states.cursorPageX = Math.floor((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
|
|
68035
|
-
this.nrrd_states.nrrd_z_mm);
|
|
68171
|
+
// convert z to x
|
|
68172
|
+
convetObj = this.convertCursorPoint("z", "x", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
|
|
68036
68173
|
}
|
|
68037
68174
|
if (this.axis === "y") {
|
|
68038
|
-
|
|
68039
|
-
|
|
68040
|
-
this.nrrd_states.oldIndex =
|
|
68041
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
|
|
68042
|
-
this.nrrd_states.cursorPageX = this.cursorPage.y.cursorPageY;
|
|
68043
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
|
|
68044
|
-
this.nrrd_states.nrrd_y_mm);
|
|
68175
|
+
// convert y to x
|
|
68176
|
+
convetObj = this.convertCursorPoint("y", "x", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
|
|
68045
68177
|
}
|
|
68046
|
-
this.cursorPage.x.updated = true;
|
|
68047
68178
|
}
|
|
68048
68179
|
else {
|
|
68180
|
+
// not cursor select, freedom to switch z -> x or y -> x and x -> z or x -> y
|
|
68049
68181
|
this.nrrd_states.currentIndex = this.cursorPage.x.index;
|
|
68050
68182
|
this.nrrd_states.oldIndex =
|
|
68051
68183
|
this.cursorPage.x.index * this.nrrd_states.ratios.x;
|
|
@@ -68053,28 +68185,19 @@
|
|
|
68053
68185
|
this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageY;
|
|
68054
68186
|
}
|
|
68055
68187
|
}
|
|
68056
|
-
else if (
|
|
68188
|
+
else if (axisTo === "y") {
|
|
68057
68189
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.y.updated) {
|
|
68058
68190
|
if (this.axis === "z") {
|
|
68059
|
-
|
|
68060
|
-
|
|
68061
|
-
this.nrrd_states.oldIndex =
|
|
68062
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
|
|
68063
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
|
|
68064
|
-
this.nrrd_states.nrrd_z_mm);
|
|
68191
|
+
// convert z to y
|
|
68192
|
+
convetObj = this.convertCursorPoint("z", "y", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
|
|
68065
68193
|
}
|
|
68066
68194
|
if (this.axis === "x") {
|
|
68067
|
-
|
|
68068
|
-
|
|
68069
|
-
this.nrrd_states.oldIndex =
|
|
68070
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
|
|
68071
|
-
this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
|
|
68072
|
-
this.nrrd_states.nrrd_x_mm);
|
|
68073
|
-
this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageX;
|
|
68195
|
+
// convert x to y
|
|
68196
|
+
convetObj = this.convertCursorPoint("x", "y", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
|
|
68074
68197
|
}
|
|
68075
|
-
this.cursorPage.y.updated = true;
|
|
68076
68198
|
}
|
|
68077
68199
|
else {
|
|
68200
|
+
// not cursor select, freedom to switch z -> y or x -> y and y -> z or y -> x
|
|
68078
68201
|
this.nrrd_states.currentIndex = this.cursorPage.y.index;
|
|
68079
68202
|
this.nrrd_states.oldIndex =
|
|
68080
68203
|
this.cursorPage.y.index * this.nrrd_states.ratios.y;
|
|
@@ -68082,14 +68205,38 @@
|
|
|
68082
68205
|
this.nrrd_states.cursorPageY = this.cursorPage.y.cursorPageY;
|
|
68083
68206
|
}
|
|
68084
68207
|
}
|
|
68208
|
+
if (convetObj) {
|
|
68209
|
+
// update convert cursor point, when cursor select
|
|
68210
|
+
this.nrrd_states.currentIndex = convetObj.currentIndex;
|
|
68211
|
+
this.nrrd_states.oldIndex = convetObj.oldIndex;
|
|
68212
|
+
this.nrrd_states.cursorPageX = convetObj.convertCursorNumX;
|
|
68213
|
+
this.nrrd_states.cursorPageY = convetObj.convertCursorNumY;
|
|
68214
|
+
convetObj = undefined;
|
|
68215
|
+
switch (axisTo) {
|
|
68216
|
+
case "x":
|
|
68217
|
+
this.cursorPage.x.updated = true;
|
|
68218
|
+
break;
|
|
68219
|
+
case "y":
|
|
68220
|
+
this.cursorPage.y.updated = true;
|
|
68221
|
+
break;
|
|
68222
|
+
case "z":
|
|
68223
|
+
this.cursorPage.z.updated = true;
|
|
68224
|
+
break;
|
|
68225
|
+
}
|
|
68226
|
+
}
|
|
68085
68227
|
if (this.cursorPage.x.updated &&
|
|
68086
68228
|
this.cursorPage.y.updated &&
|
|
68087
68229
|
this.cursorPage.z.updated) {
|
|
68230
|
+
// one point convert to all axis, reset all updated status
|
|
68088
68231
|
this.nrrd_states.isCursorSelect = false;
|
|
68089
68232
|
}
|
|
68090
68233
|
}
|
|
68091
|
-
this.axis =
|
|
68234
|
+
this.axis = axisTo;
|
|
68092
68235
|
this.resetDisplaySlicesStatus();
|
|
68236
|
+
// for sphere plan a
|
|
68237
|
+
if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
|
|
68238
|
+
this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
|
|
68239
|
+
}
|
|
68093
68240
|
}
|
|
68094
68241
|
addSkip(index) {
|
|
68095
68242
|
this.skipSlicesDic[index] = this.backUpDisplaySlices[index];
|
|
@@ -68166,6 +68313,15 @@
|
|
|
68166
68313
|
this.resetPaintArea();
|
|
68167
68314
|
this.setIsDrawFalse(1000);
|
|
68168
68315
|
}
|
|
68316
|
+
getContainer() {
|
|
68317
|
+
return this.mainAreaContainer;
|
|
68318
|
+
}
|
|
68319
|
+
getDrawingCanvas() {
|
|
68320
|
+
return this.drawingCanvas;
|
|
68321
|
+
}
|
|
68322
|
+
getNrrdToolsSettings() {
|
|
68323
|
+
return this.nrrd_states;
|
|
68324
|
+
}
|
|
68169
68325
|
getMaxSliceNum() {
|
|
68170
68326
|
if (this.nrrd_states.showContrast) {
|
|
68171
68327
|
return [
|
|
@@ -68406,62 +68562,51 @@
|
|
|
68406
68562
|
this.mainAreaContainer.appendChild(loadingbar);
|
|
68407
68563
|
}
|
|
68408
68564
|
drag(opts) {
|
|
68409
|
-
|
|
68410
|
-
let y;
|
|
68411
|
-
let h = this.container.offsetHeight;
|
|
68412
|
-
let sensivity = 1;
|
|
68413
|
-
let handleOnMouseUp;
|
|
68414
|
-
let handleOnMouseDown;
|
|
68415
|
-
let handleOnMouseMove;
|
|
68565
|
+
this.dragPrameters.h = this.container.offsetHeight;
|
|
68416
68566
|
this.sensitiveArray.reverse();
|
|
68417
68567
|
if (opts === null || opts === void 0 ? void 0 : opts.showNumber) {
|
|
68418
68568
|
this.container.appendChild(this.showDragNumberDiv);
|
|
68419
68569
|
}
|
|
68420
|
-
|
|
68570
|
+
this.dragPrameters.handleOnDragMouseDown = (ev) => {
|
|
68421
68571
|
// before start drag event, remove wheel event.
|
|
68422
|
-
this.drawingCanvas.removeEventListener("wheel", this.
|
|
68572
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
68423
68573
|
if (ev.button === 0) {
|
|
68424
68574
|
// this.setSyncsliceNum();
|
|
68425
|
-
y = ev.offsetY / h;
|
|
68426
|
-
this.container.addEventListener("pointermove",
|
|
68427
|
-
|
|
68575
|
+
this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
|
|
68576
|
+
this.container.addEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
|
|
68577
|
+
this.dragPrameters.sensivity =
|
|
68578
|
+
this.sensitiveArray[this.gui_states.dragSensitivity - 1];
|
|
68428
68579
|
}
|
|
68429
68580
|
};
|
|
68430
|
-
|
|
68431
|
-
if (y - ev.offsetY / h >= 0) {
|
|
68432
|
-
move = -Math.ceil(((y - ev.offsetY / h) * 10) /
|
|
68581
|
+
this.dragPrameters.handleOnDragMouseMove = throttle((ev) => {
|
|
68582
|
+
if (this.dragPrameters.y - ev.offsetY / this.dragPrameters.h >= 0) {
|
|
68583
|
+
this.dragPrameters.move = -Math.ceil(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
|
|
68584
|
+
this.dragPrameters.sensivity);
|
|
68433
68585
|
}
|
|
68434
68586
|
else {
|
|
68435
|
-
move = -Math.floor(((y - ev.offsetY / h) * 10) /
|
|
68587
|
+
this.dragPrameters.move = -Math.floor(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
|
|
68588
|
+
this.dragPrameters.sensivity);
|
|
68436
68589
|
}
|
|
68437
|
-
this.updateIndex(move);
|
|
68590
|
+
this.updateIndex(this.dragPrameters.move);
|
|
68438
68591
|
(opts === null || opts === void 0 ? void 0 : opts.getSliceNum) &&
|
|
68439
68592
|
opts.getSliceNum(this.nrrd_states.currentIndex, this.nrrd_states.contrastNum);
|
|
68440
|
-
y = ev.offsetY / h;
|
|
68441
|
-
}, sensivity * 200);
|
|
68442
|
-
|
|
68593
|
+
this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
|
|
68594
|
+
}, this.dragPrameters.sensivity * 200);
|
|
68595
|
+
this.dragPrameters.handleOnDragMouseUp = (ev) => {
|
|
68443
68596
|
// after drag, add the wheel event
|
|
68444
|
-
this.drawingCanvas.addEventListener("wheel", this.
|
|
68597
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
68445
68598
|
this.setSyncsliceNum();
|
|
68446
|
-
this.container.removeEventListener("pointermove",
|
|
68599
|
+
this.container.removeEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
|
|
68447
68600
|
};
|
|
68448
|
-
|
|
68449
|
-
this.container.style.cursor = "pointer";
|
|
68450
|
-
this.container.addEventListener("pointerdown", handleOnMouseDown, true);
|
|
68451
|
-
this.container.addEventListener("pointerup", handleOnMouseUp, true);
|
|
68452
|
-
};
|
|
68453
|
-
configDragMode();
|
|
68601
|
+
this.configDragMode();
|
|
68454
68602
|
this.container.addEventListener("keydown", (ev) => {
|
|
68455
68603
|
if (ev.key === "Shift") {
|
|
68456
|
-
this.
|
|
68457
|
-
this.container.removeEventListener("pointerdown", handleOnMouseDown, true);
|
|
68458
|
-
this.container.removeEventListener("pointerup", handleOnMouseUp, false);
|
|
68459
|
-
this.setIsDrawFalse(1000);
|
|
68604
|
+
this.removeDragMode();
|
|
68460
68605
|
}
|
|
68461
68606
|
});
|
|
68462
68607
|
this.container.addEventListener("keyup", (ev) => {
|
|
68463
|
-
if (ev.key === "Shift") {
|
|
68464
|
-
configDragMode();
|
|
68608
|
+
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
68609
|
+
this.configDragMode();
|
|
68465
68610
|
}
|
|
68466
68611
|
});
|
|
68467
68612
|
}
|
|
@@ -68619,6 +68764,7 @@
|
|
|
68619
68764
|
// draw lines starts position
|
|
68620
68765
|
let Is_Painting = false;
|
|
68621
68766
|
let lines = [];
|
|
68767
|
+
const clearArc = this.useEraser();
|
|
68622
68768
|
this.updateOriginAndChangedWH();
|
|
68623
68769
|
this.initAllCanvas();
|
|
68624
68770
|
this.configGui(modeFolder);
|
|
@@ -68628,12 +68774,15 @@
|
|
|
68628
68774
|
(_c = this.displayCtx) === null || _c === void 0 ? void 0 : _c.restore();
|
|
68629
68775
|
this.previousDrawingImage = this.drawingCtx.getImageData(0, 0, this.drawingCanvas.width, this.drawingCanvas.height);
|
|
68630
68776
|
// let a global variable to store the wheel move event
|
|
68631
|
-
this.
|
|
68777
|
+
this.drawingPrameters.handleZoomWheel = this.configMouseZoomWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
|
|
68632
68778
|
// init to add it
|
|
68633
|
-
this.drawingCanvas.addEventListener("wheel", this.
|
|
68779
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
|
|
68634
68780
|
passive: false,
|
|
68635
68781
|
});
|
|
68636
|
-
|
|
68782
|
+
// sphere Wheel
|
|
68783
|
+
this.drawingPrameters.handleSphereWheel = this.configMouseSphereWheel();
|
|
68784
|
+
// pan move
|
|
68785
|
+
this.drawingPrameters.handleOnPanMouseMove = (e) => {
|
|
68637
68786
|
this.drawingCanvas.style.cursor = "grabbing";
|
|
68638
68787
|
this.nrrd_states.previousPanelL = e.clientX - panelMoveInnerX;
|
|
68639
68788
|
this.nrrd_states.previousPanelT = e.clientY - panelMoveInnerY;
|
|
@@ -68642,8 +68791,9 @@
|
|
|
68642
68791
|
this.displayCanvas.style.top = this.drawingCanvas.style.top =
|
|
68643
68792
|
this.nrrd_states.previousPanelT + "px";
|
|
68644
68793
|
};
|
|
68645
|
-
//
|
|
68646
|
-
|
|
68794
|
+
// brush circle move
|
|
68795
|
+
this.drawingPrameters.handleOnDrawingBrushCricleMove = (e) => {
|
|
68796
|
+
e.preventDefault();
|
|
68647
68797
|
this.nrrd_states.Mouse_Over_x = e.offsetX;
|
|
68648
68798
|
this.nrrd_states.Mouse_Over_y = e.offsetY;
|
|
68649
68799
|
if (this.nrrd_states.Mouse_Over_x === undefined) {
|
|
@@ -68652,21 +68802,31 @@
|
|
|
68652
68802
|
}
|
|
68653
68803
|
if (e.type === "mouseout") {
|
|
68654
68804
|
this.nrrd_states.Mouse_Over = false;
|
|
68655
|
-
this.drawingCanvas.removeEventListener("mousemove",
|
|
68805
|
+
this.drawingCanvas.removeEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
68656
68806
|
}
|
|
68657
68807
|
else if (e.type === "mouseover") {
|
|
68658
68808
|
this.nrrd_states.Mouse_Over = true;
|
|
68659
|
-
this.drawingCanvas.addEventListener("mousemove",
|
|
68809
|
+
this.drawingCanvas.addEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
68660
68810
|
}
|
|
68661
|
-
e.preventDefault();
|
|
68662
68811
|
};
|
|
68663
|
-
//
|
|
68664
|
-
this.
|
|
68665
|
-
|
|
68666
|
-
|
|
68667
|
-
|
|
68812
|
+
// drawing move
|
|
68813
|
+
this.drawingPrameters.handleOnDrawingMouseMove = (e) => {
|
|
68814
|
+
this.Is_Draw = true;
|
|
68815
|
+
if (Is_Painting) {
|
|
68816
|
+
if (this.gui_states.Eraser) {
|
|
68817
|
+
this.nrrd_states.stepClear = 1;
|
|
68818
|
+
// drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
|
|
68819
|
+
clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
|
|
68820
|
+
}
|
|
68821
|
+
else {
|
|
68822
|
+
lines.push({ x: e.offsetX, y: e.offsetY });
|
|
68823
|
+
this.paintOnCanvasLayer(e.offsetX, e.offsetY);
|
|
68824
|
+
}
|
|
68825
|
+
}
|
|
68826
|
+
};
|
|
68827
|
+
this.drawingPrameters.handleOnDrawingMouseDown = (e) => {
|
|
68668
68828
|
if (leftclicked || rightclicked) {
|
|
68669
|
-
this.drawingCanvas.removeEventListener("pointerup",
|
|
68829
|
+
this.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
68670
68830
|
this.drawingLayerMasterCtx.closePath();
|
|
68671
68831
|
return;
|
|
68672
68832
|
}
|
|
@@ -68677,7 +68837,7 @@
|
|
|
68677
68837
|
currentSliceIndex = this.mainPreSlice.index;
|
|
68678
68838
|
}
|
|
68679
68839
|
// remove it when mouse click down
|
|
68680
|
-
this.drawingCanvas.removeEventListener("wheel", this.
|
|
68840
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
68681
68841
|
if (e.button === 0) {
|
|
68682
68842
|
if (this.Is_Shift_Pressed) {
|
|
68683
68843
|
leftclicked = true;
|
|
@@ -68697,32 +68857,24 @@
|
|
|
68697
68857
|
}
|
|
68698
68858
|
this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
|
|
68699
68859
|
// this.drawingLayerMasterCtx.beginPath();
|
|
68700
|
-
this.drawingCanvas.addEventListener("pointerup",
|
|
68701
|
-
this.drawingCanvas.addEventListener("pointermove",
|
|
68860
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
68861
|
+
this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
68702
68862
|
}
|
|
68703
68863
|
else if (this.nrrd_states.enableCursorChoose) {
|
|
68704
68864
|
this.nrrd_states.cursorPageX =
|
|
68705
68865
|
e.offsetX / this.nrrd_states.sizeFoctor;
|
|
68706
68866
|
this.nrrd_states.cursorPageY =
|
|
68707
68867
|
e.offsetY / this.nrrd_states.sizeFoctor;
|
|
68708
|
-
this.
|
|
68709
|
-
|
|
68710
|
-
|
|
68711
|
-
|
|
68712
|
-
|
|
68713
|
-
|
|
68714
|
-
|
|
68715
|
-
|
|
68716
|
-
|
|
68717
|
-
|
|
68718
|
-
this.cursorPage.z.updated = false;
|
|
68719
|
-
break;
|
|
68720
|
-
case "z":
|
|
68721
|
-
this.cursorPage.x.updated = false;
|
|
68722
|
-
this.cursorPage.y.updated = false;
|
|
68723
|
-
this.cursorPage.z.updated = true;
|
|
68724
|
-
break;
|
|
68725
|
-
}
|
|
68868
|
+
this.enableCrosshair();
|
|
68869
|
+
}
|
|
68870
|
+
else if (this.gui_states.sphere) {
|
|
68871
|
+
console.log("sphere down");
|
|
68872
|
+
let mouseX = e.offsetX;
|
|
68873
|
+
let mouseY = e.offsetY;
|
|
68874
|
+
// draw circle
|
|
68875
|
+
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
68876
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
68877
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
68726
68878
|
}
|
|
68727
68879
|
}
|
|
68728
68880
|
else if (e.button === 2) {
|
|
@@ -68734,28 +68886,15 @@
|
|
|
68734
68886
|
panelMoveInnerX = e.clientX - offsetX;
|
|
68735
68887
|
panelMoveInnerY = e.clientY - offsetY;
|
|
68736
68888
|
this.drawingCanvas.style.cursor = "grab";
|
|
68737
|
-
this.drawingCanvas.addEventListener("pointerup",
|
|
68738
|
-
this.drawingCanvas.addEventListener("pointermove",
|
|
68889
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
68890
|
+
this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
68739
68891
|
}
|
|
68740
68892
|
else {
|
|
68741
68893
|
return;
|
|
68742
68894
|
}
|
|
68743
|
-
}, true);
|
|
68744
|
-
const clearArc = this.useEraser();
|
|
68745
|
-
const handleOnPainterMove = (e) => {
|
|
68746
|
-
this.Is_Draw = true;
|
|
68747
|
-
if (Is_Painting) {
|
|
68748
|
-
if (this.gui_states.Eraser) {
|
|
68749
|
-
this.nrrd_states.stepClear = 1;
|
|
68750
|
-
// drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
|
|
68751
|
-
clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
|
|
68752
|
-
}
|
|
68753
|
-
else {
|
|
68754
|
-
lines.push({ x: e.offsetX, y: e.offsetY });
|
|
68755
|
-
this.paintOnCanvasLayer(e.offsetX, e.offsetY);
|
|
68756
|
-
}
|
|
68757
|
-
}
|
|
68758
68895
|
};
|
|
68896
|
+
// disable browser right click menu
|
|
68897
|
+
this.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
|
|
68759
68898
|
const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
|
|
68760
68899
|
var _a;
|
|
68761
68900
|
let paintImages;
|
|
@@ -68782,13 +68921,13 @@
|
|
|
68782
68921
|
// draw privous image
|
|
68783
68922
|
ctx.drawImage(this.emptyCanvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
68784
68923
|
};
|
|
68785
|
-
|
|
68924
|
+
this.drawingPrameters.handleOnDrawingMouseUp = (e) => {
|
|
68786
68925
|
if (e.button === 0) {
|
|
68787
68926
|
if (this.Is_Shift_Pressed || Is_Painting) {
|
|
68788
68927
|
leftclicked = false;
|
|
68789
68928
|
let { ctx, canvas } = this.setCurrentLayer();
|
|
68790
68929
|
ctx.closePath();
|
|
68791
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
68930
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
68792
68931
|
if (!this.gui_states.Eraser) {
|
|
68793
68932
|
if (this.gui_states.segmentation) {
|
|
68794
68933
|
this.drawingCanvasLayerMaster.width =
|
|
@@ -68836,20 +68975,66 @@
|
|
|
68836
68975
|
undoObj.layers[this.gui_states.label].push(image);
|
|
68837
68976
|
this.undoArray.push(undoObj);
|
|
68838
68977
|
}
|
|
68978
|
+
// add wheel after pointer up
|
|
68979
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
|
|
68980
|
+
passive: false,
|
|
68981
|
+
});
|
|
68982
|
+
}
|
|
68983
|
+
else if (this.gui_states.sphere &&
|
|
68984
|
+
!this.nrrd_states.enableCursorChoose) {
|
|
68985
|
+
console.log("sphere up");
|
|
68986
|
+
let { ctx, canvas } = this.setCurrentLayer();
|
|
68987
|
+
let mouseX = e.offsetX;
|
|
68988
|
+
let mouseY = e.offsetY;
|
|
68989
|
+
this.nrrd_states.sphereOrigin[this.axis] = [
|
|
68990
|
+
mouseX,
|
|
68991
|
+
mouseY,
|
|
68992
|
+
this.nrrd_states.currentIndex,
|
|
68993
|
+
];
|
|
68994
|
+
/************ */
|
|
68995
|
+
this.setUpSphereOrigins(mouseX, mouseY);
|
|
68996
|
+
console.log(this.nrrd_states.sphereOrigin);
|
|
68997
|
+
this.nrrd_states.cursorPageX = mouseX;
|
|
68998
|
+
this.nrrd_states.cursorPageY = mouseY;
|
|
68999
|
+
this.enableCrosshair();
|
|
69000
|
+
// plan B
|
|
69001
|
+
// findout all index in the sphere radius range in Axial view
|
|
69002
|
+
if (this.nrrd_states.spherePlanB) {
|
|
69003
|
+
// clear stroe images
|
|
69004
|
+
this.clearStoreImages();
|
|
69005
|
+
for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
|
|
69006
|
+
this.setEmptyCanvasSize();
|
|
69007
|
+
const preIndex = this.nrrd_states.currentIndex - i;
|
|
69008
|
+
const nextIndex = this.nrrd_states.currentIndex + i;
|
|
69009
|
+
if (preIndex < this.nrrd_states.minIndex ||
|
|
69010
|
+
nextIndex > this.nrrd_states.maxIndex)
|
|
69011
|
+
return;
|
|
69012
|
+
if (preIndex === nextIndex) {
|
|
69013
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
69014
|
+
this.drawImageOnEmptyImage(canvas);
|
|
69015
|
+
this.storeAllImages(preIndex, "");
|
|
69016
|
+
}
|
|
69017
|
+
else {
|
|
69018
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - i);
|
|
69019
|
+
this.drawImageOnEmptyImage(canvas);
|
|
69020
|
+
this.storeAllImages(preIndex, "");
|
|
69021
|
+
this.storeAllImages(nextIndex, "");
|
|
69022
|
+
}
|
|
69023
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
69024
|
+
}
|
|
69025
|
+
}
|
|
69026
|
+
console.log(this.nrrd_states.sphereRadius);
|
|
69027
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
68839
69028
|
}
|
|
68840
69029
|
}
|
|
68841
69030
|
else if (e.button === 2) {
|
|
68842
69031
|
rightclicked = false;
|
|
68843
69032
|
this.drawingCanvas.style.cursor = "grab";
|
|
68844
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
69033
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
68845
69034
|
}
|
|
68846
69035
|
else {
|
|
68847
69036
|
return;
|
|
68848
69037
|
}
|
|
68849
|
-
// add wheel after pointer up
|
|
68850
|
-
this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
|
|
68851
|
-
passive: false,
|
|
68852
|
-
});
|
|
68853
69038
|
if (!this.gui_states.segmentation) {
|
|
68854
69039
|
this.setIsDrawFalse(100);
|
|
68855
69040
|
}
|
|
@@ -68860,12 +69045,13 @@
|
|
|
68860
69045
|
if (leftclicked) {
|
|
68861
69046
|
leftclicked = false;
|
|
68862
69047
|
this.drawingLayerMasterCtx.closePath();
|
|
68863
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
69048
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
69049
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
68864
69050
|
}
|
|
68865
69051
|
if (rightclicked) {
|
|
68866
69052
|
rightclicked = false;
|
|
68867
69053
|
this.drawingCanvas.style.cursor = "grab";
|
|
68868
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
69054
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
68869
69055
|
}
|
|
68870
69056
|
this.setIsDrawFalse(100);
|
|
68871
69057
|
if (this.gui_states.segmentation) {
|
|
@@ -68920,6 +69106,68 @@
|
|
|
68920
69106
|
}
|
|
68921
69107
|
});
|
|
68922
69108
|
}
|
|
69109
|
+
enableCrosshair() {
|
|
69110
|
+
this.nrrd_states.isCursorSelect = true;
|
|
69111
|
+
switch (this.axis) {
|
|
69112
|
+
case "x":
|
|
69113
|
+
this.cursorPage.x.updated = true;
|
|
69114
|
+
this.cursorPage.y.updated = false;
|
|
69115
|
+
this.cursorPage.z.updated = false;
|
|
69116
|
+
break;
|
|
69117
|
+
case "y":
|
|
69118
|
+
this.cursorPage.x.updated = false;
|
|
69119
|
+
this.cursorPage.y.updated = true;
|
|
69120
|
+
this.cursorPage.z.updated = false;
|
|
69121
|
+
break;
|
|
69122
|
+
case "z":
|
|
69123
|
+
this.cursorPage.x.updated = false;
|
|
69124
|
+
this.cursorPage.y.updated = false;
|
|
69125
|
+
this.cursorPage.z.updated = true;
|
|
69126
|
+
break;
|
|
69127
|
+
}
|
|
69128
|
+
}
|
|
69129
|
+
setUpSphereOrigins(mouseX, mouseY) {
|
|
69130
|
+
const convertCursor = (from, to) => {
|
|
69131
|
+
const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
|
|
69132
|
+
return {
|
|
69133
|
+
convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
|
|
69134
|
+
convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
|
|
69135
|
+
currentIndex: convertObj === null || convertObj === void 0 ? void 0 : convertObj.currentIndex,
|
|
69136
|
+
};
|
|
69137
|
+
};
|
|
69138
|
+
const axisConversions = {
|
|
69139
|
+
x: { axisTo1: "y", axisTo2: "z" },
|
|
69140
|
+
y: { axisTo1: "z", axisTo2: "x" },
|
|
69141
|
+
z: { axisTo1: "x", axisTo2: "y" },
|
|
69142
|
+
};
|
|
69143
|
+
const { axisTo1, axisTo2 } = axisConversions[this.axis];
|
|
69144
|
+
this.nrrd_states.sphereOrigin[axisTo1] = [
|
|
69145
|
+
convertCursor(this.axis, axisTo1).convertCursorNumX,
|
|
69146
|
+
convertCursor(this.axis, axisTo1).convertCursorNumY,
|
|
69147
|
+
convertCursor(this.axis, axisTo1).currentIndex,
|
|
69148
|
+
];
|
|
69149
|
+
this.nrrd_states.sphereOrigin[axisTo2] = [
|
|
69150
|
+
convertCursor(this.axis, axisTo2).convertCursorNumX,
|
|
69151
|
+
convertCursor(this.axis, axisTo2).convertCursorNumY,
|
|
69152
|
+
convertCursor(this.axis, axisTo2).currentIndex,
|
|
69153
|
+
];
|
|
69154
|
+
}
|
|
69155
|
+
// for sphere
|
|
69156
|
+
drawSphereCore(ctx, x, y, radius) {
|
|
69157
|
+
ctx.beginPath();
|
|
69158
|
+
ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
|
|
69159
|
+
ctx.fillStyle = this.gui_states.fillColor;
|
|
69160
|
+
ctx.fill();
|
|
69161
|
+
ctx.closePath();
|
|
69162
|
+
}
|
|
69163
|
+
drawSphere(mouseX, mouseY, radius) {
|
|
69164
|
+
let { ctx, canvas } = this.setCurrentLayer();
|
|
69165
|
+
// clear canvas
|
|
69166
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
69167
|
+
this.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
|
|
69168
|
+
this.drawSphereCore(ctx, mouseX, mouseY, radius);
|
|
69169
|
+
this.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
69170
|
+
}
|
|
68923
69171
|
// need to update
|
|
68924
69172
|
undoLastPainting() {
|
|
68925
69173
|
let { ctx, canvas } = this.setCurrentLayer();
|
|
@@ -68937,7 +69185,9 @@
|
|
|
68937
69185
|
if (layerLen > 0) {
|
|
68938
69186
|
// const imageSrc = undo.undos[undo.undos.length - 1];
|
|
68939
69187
|
const image = layerUndos[layerLen - 1];
|
|
68940
|
-
|
|
69188
|
+
if (!!image) {
|
|
69189
|
+
ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
69190
|
+
}
|
|
68941
69191
|
}
|
|
68942
69192
|
if (undo.layers.label1.length > 0) {
|
|
68943
69193
|
const image = undo.layers.label1[undo.layers.label1.length - 1];
|
|
@@ -68961,9 +69211,29 @@
|
|
|
68961
69211
|
return item.sliceIndex === this.nrrd_states.currentIndex;
|
|
68962
69212
|
});
|
|
68963
69213
|
}
|
|
68964
|
-
|
|
69214
|
+
// drawing canvas mouse shpere wheel
|
|
69215
|
+
configMouseSphereWheel() {
|
|
69216
|
+
const sphereEvent = (e) => {
|
|
69217
|
+
e.preventDefault();
|
|
69218
|
+
if (e.deltaY < 0) {
|
|
69219
|
+
this.nrrd_states.sphereRadius += 1;
|
|
69220
|
+
}
|
|
69221
|
+
else {
|
|
69222
|
+
this.nrrd_states.sphereRadius -= 1;
|
|
69223
|
+
}
|
|
69224
|
+
// limited the radius max and min
|
|
69225
|
+
this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
|
|
69226
|
+
// get mouse position
|
|
69227
|
+
const mouseX = e.offsetX;
|
|
69228
|
+
const mouseY = e.offsetY;
|
|
69229
|
+
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
69230
|
+
};
|
|
69231
|
+
return sphereEvent;
|
|
69232
|
+
}
|
|
69233
|
+
// drawing canvas mouse zoom wheel
|
|
69234
|
+
configMouseZoomWheel(controls) {
|
|
68965
69235
|
let moveDistance = 1;
|
|
68966
|
-
const
|
|
69236
|
+
const handleZoomWheelMove = (e) => {
|
|
68967
69237
|
if (this.Is_Shift_Pressed) {
|
|
68968
69238
|
return;
|
|
68969
69239
|
}
|
|
@@ -68999,7 +69269,7 @@
|
|
|
68999
69269
|
}
|
|
69000
69270
|
this.nrrd_states.sizeFoctor = moveDistance;
|
|
69001
69271
|
};
|
|
69002
|
-
return
|
|
69272
|
+
return handleZoomWheelMove;
|
|
69003
69273
|
}
|
|
69004
69274
|
useEraser() {
|
|
69005
69275
|
const clearArc = (x, y, radius) => {
|
|
@@ -69110,155 +69380,6 @@
|
|
|
69110
69380
|
}
|
|
69111
69381
|
return { ctx, canvas };
|
|
69112
69382
|
}
|
|
69113
|
-
configGui(modeFolder) {
|
|
69114
|
-
if (modeFolder.__controllers.length > 0)
|
|
69115
|
-
this.removeGuiFolderChilden(modeFolder);
|
|
69116
|
-
modeFolder.open();
|
|
69117
|
-
const actionsFolder = modeFolder.addFolder("Default Actions");
|
|
69118
|
-
actionsFolder
|
|
69119
|
-
.add(this.gui_states, "label", ["label1", "label2", "label3"])
|
|
69120
|
-
.onChange((val) => {
|
|
69121
|
-
if (val === "label1") {
|
|
69122
|
-
this.gui_states.fillColor = "#00ff00";
|
|
69123
|
-
this.gui_states.brushColor = "#00ff00";
|
|
69124
|
-
}
|
|
69125
|
-
else if (val === "label2") {
|
|
69126
|
-
this.gui_states.fillColor = "#ff0000";
|
|
69127
|
-
this.gui_states.brushColor = "#ff0000";
|
|
69128
|
-
}
|
|
69129
|
-
else if (val === "label3") {
|
|
69130
|
-
this.gui_states.fillColor = "#0000ff";
|
|
69131
|
-
this.gui_states.brushColor = "#0000ff";
|
|
69132
|
-
}
|
|
69133
|
-
});
|
|
69134
|
-
actionsFolder
|
|
69135
|
-
.add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
|
|
69136
|
-
.name("cursor icons")
|
|
69137
|
-
.onChange((value) => {
|
|
69138
|
-
if (value === "crosshair") {
|
|
69139
|
-
this.nrrd_states.defaultPaintCursor = "crosshair";
|
|
69140
|
-
}
|
|
69141
|
-
if (value === "pencil") {
|
|
69142
|
-
this.nrrd_states.defaultPaintCursor =
|
|
69143
|
-
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
|
|
69144
|
-
}
|
|
69145
|
-
if (value === "dot") {
|
|
69146
|
-
this.nrrd_states.defaultPaintCursor =
|
|
69147
|
-
"url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
|
|
69148
|
-
}
|
|
69149
|
-
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
69150
|
-
});
|
|
69151
|
-
actionsFolder
|
|
69152
|
-
.add(this.gui_states, "mainAreaSize")
|
|
69153
|
-
.name("zoom")
|
|
69154
|
-
.min(1)
|
|
69155
|
-
.max(8)
|
|
69156
|
-
.onFinishChange((factor) => {
|
|
69157
|
-
this.resetPaintArea();
|
|
69158
|
-
this.nrrd_states.sizeFoctor = factor;
|
|
69159
|
-
this.resizePaintArea(factor);
|
|
69160
|
-
});
|
|
69161
|
-
actionsFolder.add(this.gui_states, "resetZoom");
|
|
69162
|
-
actionsFolder
|
|
69163
|
-
.add(this.gui_states, "globalAlpha")
|
|
69164
|
-
.name("opacity")
|
|
69165
|
-
.min(0.1)
|
|
69166
|
-
.max(1)
|
|
69167
|
-
.step(0.01);
|
|
69168
|
-
actionsFolder.add(this.gui_states, "segmentation").name("Pencil");
|
|
69169
|
-
actionsFolder
|
|
69170
|
-
.add(this.gui_states, "brushAndEraserSize")
|
|
69171
|
-
.min(5)
|
|
69172
|
-
.max(50)
|
|
69173
|
-
.step(1)
|
|
69174
|
-
.onChange(() => {
|
|
69175
|
-
if (this.gui_states.Eraser) {
|
|
69176
|
-
this.eraserUrls.length > 0
|
|
69177
|
-
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
69178
|
-
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
69179
|
-
}
|
|
69180
|
-
});
|
|
69181
|
-
actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
|
|
69182
|
-
this.gui_states.Eraser = value;
|
|
69183
|
-
if (this.gui_states.Eraser) {
|
|
69184
|
-
this.eraserUrls.length > 0
|
|
69185
|
-
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
69186
|
-
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
69187
|
-
}
|
|
69188
|
-
else {
|
|
69189
|
-
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
69190
|
-
}
|
|
69191
|
-
});
|
|
69192
|
-
actionsFolder.add(this.gui_states, "clear");
|
|
69193
|
-
actionsFolder.add(this.gui_states, "clearAll");
|
|
69194
|
-
actionsFolder.add(this.gui_states, "undo");
|
|
69195
|
-
actionsFolder
|
|
69196
|
-
.add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
69197
|
-
.name("Image contrast")
|
|
69198
|
-
.onChange((value) => {
|
|
69199
|
-
this.nrrd_states.readyToUpdate = false;
|
|
69200
|
-
this.updateSlicesContrast(value, "windowHigh");
|
|
69201
|
-
})
|
|
69202
|
-
.onFinishChange(() => {
|
|
69203
|
-
this.repraintAllContrastSlices();
|
|
69204
|
-
this.nrrd_states.readyToUpdate = true;
|
|
69205
|
-
});
|
|
69206
|
-
actionsFolder.add(this.gui_states, "exportMarks");
|
|
69207
|
-
const advanceFolder = modeFolder.addFolder("Advance settings");
|
|
69208
|
-
advanceFolder
|
|
69209
|
-
.add(this.gui_states, "dragSensitivity")
|
|
69210
|
-
.min(1)
|
|
69211
|
-
.max(this.nrrd_states.Max_sensitive)
|
|
69212
|
-
.step(1);
|
|
69213
|
-
const segmentationFolder = advanceFolder.addFolder("Pencil settings");
|
|
69214
|
-
segmentationFolder
|
|
69215
|
-
.add(this.gui_states, "lineWidth")
|
|
69216
|
-
.name("outerLineWidth")
|
|
69217
|
-
.min(1.7)
|
|
69218
|
-
.max(3)
|
|
69219
|
-
.step(0.01);
|
|
69220
|
-
segmentationFolder.addColor(this.gui_states, "color");
|
|
69221
|
-
segmentationFolder.addColor(this.gui_states, "fillColor");
|
|
69222
|
-
const bushFolder = advanceFolder.addFolder("Brush settings");
|
|
69223
|
-
bushFolder.addColor(this.gui_states, "brushColor");
|
|
69224
|
-
// modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
|
|
69225
|
-
advanceFolder.add(this.gui_states, "downloadCurrentMask");
|
|
69226
|
-
const contrastFolder = advanceFolder.addFolder("contrast advance settings");
|
|
69227
|
-
contrastFolder
|
|
69228
|
-
.add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
69229
|
-
.name("Lower Threshold")
|
|
69230
|
-
.onChange((value) => {
|
|
69231
|
-
this.nrrd_states.readyToUpdate = false;
|
|
69232
|
-
this.updateSlicesContrast(value, "lowerThreshold");
|
|
69233
|
-
})
|
|
69234
|
-
.onFinishChange(() => {
|
|
69235
|
-
this.repraintAllContrastSlices();
|
|
69236
|
-
this.nrrd_states.readyToUpdate = true;
|
|
69237
|
-
});
|
|
69238
|
-
contrastFolder
|
|
69239
|
-
.add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
69240
|
-
.name("Upper Threshold")
|
|
69241
|
-
.onChange((value) => {
|
|
69242
|
-
this.nrrd_states.readyToUpdate = false;
|
|
69243
|
-
this.updateSlicesContrast(value, "upperThreshold");
|
|
69244
|
-
})
|
|
69245
|
-
.onFinishChange(() => {
|
|
69246
|
-
this.repraintAllContrastSlices();
|
|
69247
|
-
this.nrrd_states.readyToUpdate = true;
|
|
69248
|
-
});
|
|
69249
|
-
contrastFolder
|
|
69250
|
-
.add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
69251
|
-
.name("Window Low")
|
|
69252
|
-
.onChange((value) => {
|
|
69253
|
-
this.nrrd_states.readyToUpdate = false;
|
|
69254
|
-
this.updateSlicesContrast(value, "windowLow");
|
|
69255
|
-
})
|
|
69256
|
-
.onFinishChange(() => {
|
|
69257
|
-
this.repraintAllContrastSlices();
|
|
69258
|
-
this.nrrd_states.readyToUpdate = true;
|
|
69259
|
-
});
|
|
69260
|
-
actionsFolder.open();
|
|
69261
|
-
}
|
|
69262
69383
|
updateSlicesContrast(value, flag) {
|
|
69263
69384
|
switch (flag) {
|
|
69264
69385
|
case "lowerThreshold":
|
|
@@ -69437,12 +69558,15 @@
|
|
|
69437
69558
|
delete dic[key];
|
|
69438
69559
|
}
|
|
69439
69560
|
}
|
|
69561
|
+
drawImageOnEmptyImage(canvas) {
|
|
69562
|
+
this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
69563
|
+
}
|
|
69440
69564
|
storeAllImages(index, label) {
|
|
69441
69565
|
// const image: HTMLImageElement = new Image();
|
|
69442
69566
|
// resize the drawing image data
|
|
69443
|
-
if (!this.nrrd_states.loadMaskJson) {
|
|
69567
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
69444
69568
|
this.setEmptyCanvasSize();
|
|
69445
|
-
this.
|
|
69569
|
+
this.drawImageOnEmptyImage(this.drawingCanvasLayerMaster);
|
|
69446
69570
|
}
|
|
69447
69571
|
let imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
69448
69572
|
// 1.12.23
|
|
@@ -69512,7 +69636,7 @@
|
|
|
69512
69636
|
break;
|
|
69513
69637
|
}
|
|
69514
69638
|
this.storeImageToAxis(index, this.paintImages, imageData);
|
|
69515
|
-
if (!this.nrrd_states.loadMaskJson) {
|
|
69639
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
69516
69640
|
this.storeEachLayerImage(index, label);
|
|
69517
69641
|
}
|
|
69518
69642
|
}
|
|
@@ -69547,7 +69671,7 @@
|
|
|
69547
69671
|
storeImageToLabel(index, canvas, paintedImages) {
|
|
69548
69672
|
if (!this.nrrd_states.loadMaskJson) {
|
|
69549
69673
|
this.setEmptyCanvasSize();
|
|
69550
|
-
this.
|
|
69674
|
+
this.drawImageOnEmptyImage(canvas);
|
|
69551
69675
|
}
|
|
69552
69676
|
const imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
69553
69677
|
this.storeImageToAxis(index, paintedImages, imageData);
|
|
@@ -69769,11 +69893,187 @@
|
|
|
69769
69893
|
// }
|
|
69770
69894
|
// };
|
|
69771
69895
|
}
|
|
69896
|
+
configGui(modeFolder) {
|
|
69897
|
+
if (modeFolder.__controllers.length > 0)
|
|
69898
|
+
this.removeGuiFolderChilden(modeFolder);
|
|
69899
|
+
modeFolder.open();
|
|
69900
|
+
const actionsFolder = modeFolder.addFolder("Default Actions");
|
|
69901
|
+
actionsFolder
|
|
69902
|
+
.add(this.gui_states, "label", ["label1", "label2", "label3"])
|
|
69903
|
+
.onChange((val) => {
|
|
69904
|
+
if (val === "label1") {
|
|
69905
|
+
this.gui_states.fillColor = "#00ff00";
|
|
69906
|
+
this.gui_states.brushColor = "#00ff00";
|
|
69907
|
+
}
|
|
69908
|
+
else if (val === "label2") {
|
|
69909
|
+
this.gui_states.fillColor = "#ff0000";
|
|
69910
|
+
this.gui_states.brushColor = "#ff0000";
|
|
69911
|
+
}
|
|
69912
|
+
else if (val === "label3") {
|
|
69913
|
+
this.gui_states.fillColor = "#0000ff";
|
|
69914
|
+
this.gui_states.brushColor = "#0000ff";
|
|
69915
|
+
}
|
|
69916
|
+
});
|
|
69917
|
+
actionsFolder
|
|
69918
|
+
.add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
|
|
69919
|
+
.name("cursor icons")
|
|
69920
|
+
.onChange((value) => {
|
|
69921
|
+
if (value === "crosshair") {
|
|
69922
|
+
this.nrrd_states.defaultPaintCursor = "crosshair";
|
|
69923
|
+
}
|
|
69924
|
+
if (value === "pencil") {
|
|
69925
|
+
this.nrrd_states.defaultPaintCursor =
|
|
69926
|
+
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
|
|
69927
|
+
}
|
|
69928
|
+
if (value === "dot") {
|
|
69929
|
+
this.nrrd_states.defaultPaintCursor =
|
|
69930
|
+
"url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
|
|
69931
|
+
}
|
|
69932
|
+
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
69933
|
+
});
|
|
69934
|
+
actionsFolder
|
|
69935
|
+
.add(this.gui_states, "mainAreaSize")
|
|
69936
|
+
.name("zoom")
|
|
69937
|
+
.min(1)
|
|
69938
|
+
.max(8)
|
|
69939
|
+
.onFinishChange((factor) => {
|
|
69940
|
+
this.resetPaintArea();
|
|
69941
|
+
this.nrrd_states.sizeFoctor = factor;
|
|
69942
|
+
this.resizePaintArea(factor);
|
|
69943
|
+
});
|
|
69944
|
+
actionsFolder.add(this.gui_states, "resetZoom");
|
|
69945
|
+
actionsFolder
|
|
69946
|
+
.add(this.gui_states, "globalAlpha")
|
|
69947
|
+
.name("opacity")
|
|
69948
|
+
.min(0.1)
|
|
69949
|
+
.max(1)
|
|
69950
|
+
.step(0.01);
|
|
69951
|
+
actionsFolder
|
|
69952
|
+
.add(this.gui_states, "segmentation")
|
|
69953
|
+
.name("Pencil")
|
|
69954
|
+
.onChange(() => {
|
|
69955
|
+
if (this.gui_states.segmentation) {
|
|
69956
|
+
// add canvas brush circle move event listeners
|
|
69957
|
+
this.drawingCanvas.removeEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
69958
|
+
this.drawingCanvas.removeEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
69959
|
+
}
|
|
69960
|
+
else {
|
|
69961
|
+
// add canvas brush circle move event listeners
|
|
69962
|
+
this.drawingCanvas.addEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
69963
|
+
this.drawingCanvas.addEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
69964
|
+
}
|
|
69965
|
+
});
|
|
69966
|
+
actionsFolder
|
|
69967
|
+
.add(this.gui_states, "sphere")
|
|
69968
|
+
.name("Sphere")
|
|
69969
|
+
.onChange(() => {
|
|
69970
|
+
if (this.gui_states.sphere) {
|
|
69971
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
69972
|
+
this.removeDragMode();
|
|
69973
|
+
}
|
|
69974
|
+
else {
|
|
69975
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
69976
|
+
this.configDragMode();
|
|
69977
|
+
}
|
|
69978
|
+
});
|
|
69979
|
+
actionsFolder
|
|
69980
|
+
.add(this.gui_states, "brushAndEraserSize")
|
|
69981
|
+
.min(5)
|
|
69982
|
+
.max(50)
|
|
69983
|
+
.step(1)
|
|
69984
|
+
.onChange(() => {
|
|
69985
|
+
if (this.gui_states.Eraser) {
|
|
69986
|
+
this.eraserUrls.length > 0
|
|
69987
|
+
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
69988
|
+
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
69989
|
+
}
|
|
69990
|
+
});
|
|
69991
|
+
actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
|
|
69992
|
+
this.gui_states.Eraser = value;
|
|
69993
|
+
if (this.gui_states.Eraser) {
|
|
69994
|
+
this.eraserUrls.length > 0
|
|
69995
|
+
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
69996
|
+
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
69997
|
+
}
|
|
69998
|
+
else {
|
|
69999
|
+
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
70000
|
+
}
|
|
70001
|
+
});
|
|
70002
|
+
actionsFolder.add(this.gui_states, "clear");
|
|
70003
|
+
actionsFolder.add(this.gui_states, "clearAll");
|
|
70004
|
+
actionsFolder.add(this.gui_states, "undo");
|
|
70005
|
+
actionsFolder
|
|
70006
|
+
.add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
70007
|
+
.name("Image contrast")
|
|
70008
|
+
.onChange((value) => {
|
|
70009
|
+
this.nrrd_states.readyToUpdate = false;
|
|
70010
|
+
this.updateSlicesContrast(value, "windowHigh");
|
|
70011
|
+
})
|
|
70012
|
+
.onFinishChange(() => {
|
|
70013
|
+
this.repraintAllContrastSlices();
|
|
70014
|
+
this.nrrd_states.readyToUpdate = true;
|
|
70015
|
+
});
|
|
70016
|
+
actionsFolder.add(this.gui_states, "exportMarks");
|
|
70017
|
+
const advanceFolder = modeFolder.addFolder("Advance settings");
|
|
70018
|
+
advanceFolder
|
|
70019
|
+
.add(this.gui_states, "dragSensitivity")
|
|
70020
|
+
.min(1)
|
|
70021
|
+
.max(this.nrrd_states.Max_sensitive)
|
|
70022
|
+
.step(1);
|
|
70023
|
+
const segmentationFolder = advanceFolder.addFolder("Pencil settings");
|
|
70024
|
+
segmentationFolder
|
|
70025
|
+
.add(this.gui_states, "lineWidth")
|
|
70026
|
+
.name("outerLineWidth")
|
|
70027
|
+
.min(1.7)
|
|
70028
|
+
.max(3)
|
|
70029
|
+
.step(0.01);
|
|
70030
|
+
segmentationFolder.addColor(this.gui_states, "color");
|
|
70031
|
+
segmentationFolder.addColor(this.gui_states, "fillColor");
|
|
70032
|
+
const bushFolder = advanceFolder.addFolder("Brush settings");
|
|
70033
|
+
bushFolder.addColor(this.gui_states, "brushColor");
|
|
70034
|
+
// modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
|
|
70035
|
+
advanceFolder.add(this.gui_states, "downloadCurrentMask");
|
|
70036
|
+
const contrastFolder = advanceFolder.addFolder("contrast advance settings");
|
|
70037
|
+
contrastFolder
|
|
70038
|
+
.add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
70039
|
+
.name("Lower Threshold")
|
|
70040
|
+
.onChange((value) => {
|
|
70041
|
+
this.nrrd_states.readyToUpdate = false;
|
|
70042
|
+
this.updateSlicesContrast(value, "lowerThreshold");
|
|
70043
|
+
})
|
|
70044
|
+
.onFinishChange(() => {
|
|
70045
|
+
this.repraintAllContrastSlices();
|
|
70046
|
+
this.nrrd_states.readyToUpdate = true;
|
|
70047
|
+
});
|
|
70048
|
+
contrastFolder
|
|
70049
|
+
.add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
70050
|
+
.name("Upper Threshold")
|
|
70051
|
+
.onChange((value) => {
|
|
70052
|
+
this.nrrd_states.readyToUpdate = false;
|
|
70053
|
+
this.updateSlicesContrast(value, "upperThreshold");
|
|
70054
|
+
})
|
|
70055
|
+
.onFinishChange(() => {
|
|
70056
|
+
this.repraintAllContrastSlices();
|
|
70057
|
+
this.nrrd_states.readyToUpdate = true;
|
|
70058
|
+
});
|
|
70059
|
+
contrastFolder
|
|
70060
|
+
.add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
70061
|
+
.name("Window Low")
|
|
70062
|
+
.onChange((value) => {
|
|
70063
|
+
this.nrrd_states.readyToUpdate = false;
|
|
70064
|
+
this.updateSlicesContrast(value, "windowLow");
|
|
70065
|
+
})
|
|
70066
|
+
.onFinishChange(() => {
|
|
70067
|
+
this.repraintAllContrastSlices();
|
|
70068
|
+
this.nrrd_states.readyToUpdate = true;
|
|
70069
|
+
});
|
|
70070
|
+
actionsFolder.open();
|
|
70071
|
+
}
|
|
69772
70072
|
}
|
|
69773
70073
|
|
|
69774
70074
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
69775
|
-
const REVISION = "v1.15.
|
|
69776
|
-
console.log("%cCopper3D Visualisation %cBeta:v1.15.
|
|
70075
|
+
const REVISION = "v1.15.12";
|
|
70076
|
+
console.log("%cCopper3D Visualisation %cBeta:v1.15.12", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
69777
70077
|
|
|
69778
70078
|
exports.CameraViewPoint = CameraViewPoint;
|
|
69779
70079
|
exports.Copper3dTrackballControls = Copper3dTrackballControls;
|