copper3d 2.0.5 → 2.0.7
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/Scene/commonSceneMethod.js +1 -1
- package/dist/Scene/commonSceneMethod.js.map +1 -1
- package/dist/Utils/segmentation/CommToolsData.js +1 -0
- package/dist/Utils/segmentation/CommToolsData.js.map +1 -1
- package/dist/Utils/segmentation/DragOperator.js +11 -0
- package/dist/Utils/segmentation/DragOperator.js.map +1 -1
- package/dist/Utils/segmentation/DrawToolCore.d.ts +30 -1
- package/dist/Utils/segmentation/DrawToolCore.js +193 -16
- package/dist/Utils/segmentation/DrawToolCore.js.map +1 -1
- package/dist/Utils/segmentation/NrrdTools.d.ts +7 -23
- package/dist/Utils/segmentation/NrrdTools.js +14 -97
- package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/coreType.d.ts +113 -1
- package/dist/Utils/segmentation/coreTools/coreType.js +1 -0
- package/dist/Utils/segmentation/coreTools/coreType.js.map +1 -1
- package/dist/Utils/segmentation/coreTools/gui.d.ts +2 -91
- package/dist/Utils/segmentation/coreTools/gui.js +28 -10
- package/dist/Utils/segmentation/coreTools/gui.js.map +1 -1
- package/dist/bundle.esm.js +249 -125
- package/dist/bundle.umd.js +249 -125
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/types/Utils/segmentation/DrawToolCore.d.ts +30 -1
- package/dist/types/Utils/segmentation/NrrdTools.d.ts +7 -23
- package/dist/types/Utils/segmentation/coreTools/coreType.d.ts +113 -1
- package/dist/types/Utils/segmentation/coreTools/gui.d.ts +2 -91
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/bundle.umd.js
CHANGED
|
@@ -48383,7 +48383,7 @@
|
|
|
48383
48383
|
(xhr) => { },
|
|
48384
48384
|
// called when loading has errors
|
|
48385
48385
|
(error) => {
|
|
48386
|
-
console.log("An error happened");
|
|
48386
|
+
console.log("An error happened: ", error);
|
|
48387
48387
|
});
|
|
48388
48388
|
}
|
|
48389
48389
|
}
|
|
@@ -68974,7 +68974,7 @@
|
|
|
68974
68974
|
.add(configs.mainPreSlices.volume, "windowHigh", configs.mainPreSlices.volume.min, configs.mainPreSlices.volume.max, 1)
|
|
68975
68975
|
.name("ImageContrast")
|
|
68976
68976
|
.onChange((value) => {
|
|
68977
|
-
|
|
68977
|
+
updateGuiImageWindowHighOnChange(value);
|
|
68978
68978
|
})
|
|
68979
68979
|
.onFinishChange(() => {
|
|
68980
68980
|
updateGuiImageContrastOnFinished();
|
|
@@ -69068,8 +69068,7 @@
|
|
|
69068
69068
|
.add(configs.mainPreSlices.volume, "windowLow", configs.mainPreSlices.volume.min, configs.mainPreSlices.volume.max, 1)
|
|
69069
69069
|
.name("WindowLow")
|
|
69070
69070
|
.onChange((value) => {
|
|
69071
|
-
|
|
69072
|
-
configs.updateSlicesContrast(value, "windowLow");
|
|
69071
|
+
updateGuiImageWindowLowOnChange(value);
|
|
69073
69072
|
})
|
|
69074
69073
|
.onFinishChange(() => {
|
|
69075
69074
|
repraintAllContrastSlices(configs.protectedData.displaySlices);
|
|
@@ -69110,18 +69109,28 @@
|
|
|
69110
69109
|
};
|
|
69111
69110
|
const updateGuiSphereState = () => {
|
|
69112
69111
|
if (configs.gui_states.sphere) {
|
|
69113
|
-
configs.drawingCanvas.removeEventListener(
|
|
69112
|
+
// configs.drawingCanvas.removeEventListener(
|
|
69113
|
+
// "wheel",
|
|
69114
|
+
// configs.drawingPrameters.handleZoomWheel
|
|
69115
|
+
// );
|
|
69114
69116
|
configs.removeDragMode();
|
|
69115
69117
|
}
|
|
69116
69118
|
else {
|
|
69117
|
-
configs.drawingCanvas.addEventListener(
|
|
69119
|
+
// configs.drawingCanvas.addEventListener(
|
|
69120
|
+
// "wheel",
|
|
69121
|
+
// configs.drawingPrameters.handleZoomWheel
|
|
69122
|
+
// );
|
|
69118
69123
|
configs.configDragMode();
|
|
69119
69124
|
// clear canvas
|
|
69120
69125
|
configs.clearPaint();
|
|
69121
69126
|
configs.clearStoreImages();
|
|
69122
69127
|
}
|
|
69123
69128
|
};
|
|
69124
|
-
const
|
|
69129
|
+
const updateGuiImageWindowLowOnChange = (value) => {
|
|
69130
|
+
configs.gui_states.readyToUpdate = false;
|
|
69131
|
+
configs.updateSlicesContrast(value, "windowLow");
|
|
69132
|
+
};
|
|
69133
|
+
const updateGuiImageWindowHighOnChange = (value) => {
|
|
69125
69134
|
configs.gui_states.readyToUpdate = false;
|
|
69126
69135
|
configs.updateSlicesContrast(value, "windowHigh");
|
|
69127
69136
|
};
|
|
@@ -69169,11 +69178,20 @@
|
|
|
69169
69178
|
},
|
|
69170
69179
|
windowHigh: {
|
|
69171
69180
|
name: "ImageContrast",
|
|
69172
|
-
value:
|
|
69173
|
-
min:
|
|
69174
|
-
max:
|
|
69181
|
+
value: null,
|
|
69182
|
+
min: 0,
|
|
69183
|
+
max: 0,
|
|
69184
|
+
step: 1,
|
|
69185
|
+
onChange: updateGuiImageWindowHighOnChange,
|
|
69186
|
+
onFinished: updateGuiImageContrastOnFinished,
|
|
69187
|
+
},
|
|
69188
|
+
windowLow: {
|
|
69189
|
+
name: "WindowLow",
|
|
69190
|
+
value: null,
|
|
69191
|
+
min: 0,
|
|
69192
|
+
max: 0,
|
|
69175
69193
|
step: 1,
|
|
69176
|
-
onChange:
|
|
69194
|
+
onChange: updateGuiImageWindowLowOnChange,
|
|
69177
69195
|
onFinished: updateGuiImageContrastOnFinished,
|
|
69178
69196
|
},
|
|
69179
69197
|
advance: {
|
|
@@ -69375,9 +69393,20 @@
|
|
|
69375
69393
|
if (ev.key === "Shift") {
|
|
69376
69394
|
this.removeDragMode();
|
|
69377
69395
|
}
|
|
69396
|
+
if (ev.key === 'Control' || ev.key === 'Meta') {
|
|
69397
|
+
if (this.protectedData.Is_Ctrl_Pressed) {
|
|
69398
|
+
this.removeDragMode();
|
|
69399
|
+
}
|
|
69400
|
+
else {
|
|
69401
|
+
this.configDragMode();
|
|
69402
|
+
}
|
|
69403
|
+
}
|
|
69378
69404
|
});
|
|
69379
69405
|
this.container.addEventListener("keyup", (ev) => {
|
|
69380
69406
|
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
69407
|
+
if (this.protectedData.Is_Ctrl_Pressed) {
|
|
69408
|
+
return;
|
|
69409
|
+
}
|
|
69381
69410
|
this.configDragMode();
|
|
69382
69411
|
}
|
|
69383
69412
|
});
|
|
@@ -69653,6 +69682,7 @@
|
|
|
69653
69682
|
currentShowingSlice: undefined,
|
|
69654
69683
|
mainPreSlices: undefined,
|
|
69655
69684
|
Is_Shift_Pressed: false,
|
|
69685
|
+
Is_Ctrl_Pressed: false,
|
|
69656
69686
|
Is_Draw: false,
|
|
69657
69687
|
axis: "z",
|
|
69658
69688
|
maskData: {
|
|
@@ -69803,6 +69833,18 @@
|
|
|
69803
69833
|
handleZoomWheel: (e) => { },
|
|
69804
69834
|
handleSphereWheel: (e) => { },
|
|
69805
69835
|
};
|
|
69836
|
+
this.contrastEventPrameters = {
|
|
69837
|
+
move_x: 0,
|
|
69838
|
+
move_y: 0,
|
|
69839
|
+
x: 0,
|
|
69840
|
+
y: 0,
|
|
69841
|
+
w: 0,
|
|
69842
|
+
h: 0,
|
|
69843
|
+
handleOnContrastMouseDown: (ev) => { },
|
|
69844
|
+
handleOnContrastMouseMove: (ev) => { },
|
|
69845
|
+
handleOnContrastMouseUp: (ev) => { },
|
|
69846
|
+
handleOnContrastMouseLeave: (ev) => { },
|
|
69847
|
+
};
|
|
69806
69848
|
this.eraserUrls = [];
|
|
69807
69849
|
this.pencilUrls = [];
|
|
69808
69850
|
this.undoArray = [];
|
|
@@ -69816,6 +69858,19 @@
|
|
|
69816
69858
|
this.protectedData.ctxes.drawingCtx.strokeStyle = this.gui_states.color;
|
|
69817
69859
|
this.protectedData.ctxes.drawingCtx.stroke();
|
|
69818
69860
|
};
|
|
69861
|
+
this.configContrastDragMode = () => {
|
|
69862
|
+
this.container.style.cursor = "pointer";
|
|
69863
|
+
this.container.addEventListener("pointerdown", this.contrastEventPrameters.handleOnContrastMouseDown, true);
|
|
69864
|
+
this.container.addEventListener("pointerup", this.contrastEventPrameters.handleOnContrastMouseUp, true);
|
|
69865
|
+
};
|
|
69866
|
+
this.removeContrastDragMode = () => {
|
|
69867
|
+
this.container.style.cursor = "";
|
|
69868
|
+
this.container.removeEventListener("pointerdown", this.contrastEventPrameters.handleOnContrastMouseDown, true);
|
|
69869
|
+
this.container.removeEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove, true);
|
|
69870
|
+
this.container.removeEventListener("pointerup", this.contrastEventPrameters.handleOnContrastMouseUp, true);
|
|
69871
|
+
this.container.removeEventListener("pointerleave", this.contrastEventPrameters.handleOnContrastMouseLeave, true);
|
|
69872
|
+
this.setIsDrawFalse(1000);
|
|
69873
|
+
};
|
|
69819
69874
|
this.container = container;
|
|
69820
69875
|
this.mainAreaContainer = mainAreaContainer;
|
|
69821
69876
|
this.initDrawToolCore();
|
|
@@ -69823,9 +69878,24 @@
|
|
|
69823
69878
|
initDrawToolCore() {
|
|
69824
69879
|
this.container.addEventListener("keydown", (ev) => {
|
|
69825
69880
|
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
69881
|
+
if (this.protectedData.Is_Ctrl_Pressed) {
|
|
69882
|
+
this.protectedData.Is_Shift_Pressed = false;
|
|
69883
|
+
return;
|
|
69884
|
+
}
|
|
69826
69885
|
this.protectedData.Is_Shift_Pressed = true;
|
|
69827
69886
|
this.nrrd_states.enableCursorChoose = false;
|
|
69828
69887
|
}
|
|
69888
|
+
if (ev.key === 'Control' || ev.key === 'Meta') {
|
|
69889
|
+
// Ctrl key pressed on either Windows or macOS
|
|
69890
|
+
this.protectedData.Is_Shift_Pressed = false;
|
|
69891
|
+
this.protectedData.Is_Ctrl_Pressed = !this.protectedData.Is_Ctrl_Pressed;
|
|
69892
|
+
if (this.protectedData.Is_Ctrl_Pressed) {
|
|
69893
|
+
this.configContrastDragMode();
|
|
69894
|
+
}
|
|
69895
|
+
else {
|
|
69896
|
+
this.removeContrastDragMode();
|
|
69897
|
+
}
|
|
69898
|
+
}
|
|
69829
69899
|
if (ev.key === "s") {
|
|
69830
69900
|
this.protectedData.Is_Draw = false;
|
|
69831
69901
|
this.nrrd_states.enableCursorChoose =
|
|
@@ -70000,9 +70070,10 @@
|
|
|
70000
70070
|
e.offsetY / this.nrrd_states.sizeFoctor;
|
|
70001
70071
|
this.enableCrosshair();
|
|
70002
70072
|
}
|
|
70003
|
-
else if (this.gui_states.sphere) {
|
|
70004
|
-
|
|
70005
|
-
let
|
|
70073
|
+
else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
|
|
70074
|
+
this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70075
|
+
let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
|
|
70076
|
+
let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
|
|
70006
70077
|
// record mouseX,Y, and enable crosshair function
|
|
70007
70078
|
this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
|
|
70008
70079
|
mouseX,
|
|
@@ -70014,7 +70085,7 @@
|
|
|
70014
70085
|
this.nrrd_states.cursorPageY = mouseY;
|
|
70015
70086
|
this.enableCrosshair();
|
|
70016
70087
|
// draw circle setup width/height for sphere canvas
|
|
70017
|
-
this.drawSphere(
|
|
70088
|
+
this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
|
|
70018
70089
|
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
70019
70090
|
this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
70020
70091
|
}
|
|
@@ -70136,9 +70207,14 @@
|
|
|
70136
70207
|
}
|
|
70137
70208
|
}
|
|
70138
70209
|
!!this.nrrd_states.getSphere &&
|
|
70139
|
-
this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius);
|
|
70210
|
+
this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
|
|
70211
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70140
70212
|
this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
70141
70213
|
}
|
|
70214
|
+
else if (this.gui_states.sphere &&
|
|
70215
|
+
this.nrrd_states.enableCursorChoose) {
|
|
70216
|
+
this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
70217
|
+
}
|
|
70142
70218
|
}
|
|
70143
70219
|
else if (e.button === 2) {
|
|
70144
70220
|
rightclicked = false;
|
|
@@ -70395,17 +70471,12 @@
|
|
|
70395
70471
|
const nextIndex = originIndex + decay;
|
|
70396
70472
|
const ctx = this.protectedData.ctxes.drawingSphereCtx;
|
|
70397
70473
|
const canvas = this.protectedData.canvases.drawingSphereCanvas;
|
|
70398
|
-
// if (
|
|
70399
|
-
// preIndex < this.nrrd_states.minIndex ||
|
|
70400
|
-
// nextIndex > this.nrrd_states.maxIndex
|
|
70401
|
-
// )
|
|
70402
|
-
// return;
|
|
70403
70474
|
if (preIndex === nextIndex) {
|
|
70404
|
-
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
70475
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
|
|
70405
70476
|
this.storeSphereImages(preIndex, axis);
|
|
70406
70477
|
}
|
|
70407
70478
|
else {
|
|
70408
|
-
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - decay);
|
|
70479
|
+
this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
|
|
70409
70480
|
this.drawImageOnEmptyImage(canvas);
|
|
70410
70481
|
this.storeSphereImages(preIndex, axis);
|
|
70411
70482
|
this.storeSphereImages(nextIndex, axis);
|
|
@@ -70414,7 +70485,7 @@
|
|
|
70414
70485
|
}
|
|
70415
70486
|
drawSphereCore(ctx, x, y, radius) {
|
|
70416
70487
|
ctx.beginPath();
|
|
70417
|
-
ctx.arc(x, y, radius
|
|
70488
|
+
ctx.arc(x, y, radius, 0, 2 * Math.PI);
|
|
70418
70489
|
ctx.fillStyle = this.gui_states.fillColor;
|
|
70419
70490
|
ctx.fill();
|
|
70420
70491
|
ctx.closePath();
|
|
@@ -70454,8 +70525,8 @@
|
|
|
70454
70525
|
// limited the radius max and min
|
|
70455
70526
|
this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
|
|
70456
70527
|
// get mouse position
|
|
70457
|
-
const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0];
|
|
70458
|
-
const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1];
|
|
70528
|
+
const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] * this.nrrd_states.sizeFoctor;
|
|
70529
|
+
const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1] * this.nrrd_states.sizeFoctor;
|
|
70459
70530
|
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
70460
70531
|
};
|
|
70461
70532
|
return sphereEvent;
|
|
@@ -70472,6 +70543,102 @@
|
|
|
70472
70543
|
this.drawSphereCore(ctx, mouseX, mouseY, radius);
|
|
70473
70544
|
this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
70474
70545
|
}
|
|
70546
|
+
/**
|
|
70547
|
+
* We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
|
|
70548
|
+
* So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
|
|
70549
|
+
*
|
|
70550
|
+
* When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
|
|
70551
|
+
*
|
|
70552
|
+
* Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
|
|
70553
|
+
*
|
|
70554
|
+
* @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
|
|
70555
|
+
* @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
|
|
70556
|
+
* @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
|
|
70557
|
+
* @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
|
|
70558
|
+
* @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
|
|
70559
|
+
* @returns
|
|
70560
|
+
*/
|
|
70561
|
+
convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
|
|
70562
|
+
const nrrd = this.nrrd_states;
|
|
70563
|
+
const dimensions = nrrd.dimensions;
|
|
70564
|
+
const ratios = nrrd.ratios;
|
|
70565
|
+
const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
|
|
70566
|
+
let currentIndex = 0;
|
|
70567
|
+
let oldIndex = 0;
|
|
70568
|
+
let convertCursorNumX = 0;
|
|
70569
|
+
let convertCursorNumY = 0;
|
|
70570
|
+
const convertIndex = {
|
|
70571
|
+
x: {
|
|
70572
|
+
y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
70573
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
70574
|
+
},
|
|
70575
|
+
y: {
|
|
70576
|
+
x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
70577
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
70578
|
+
},
|
|
70579
|
+
z: {
|
|
70580
|
+
x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
70581
|
+
y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
70582
|
+
},
|
|
70583
|
+
};
|
|
70584
|
+
const convertCursor = {
|
|
70585
|
+
x: {
|
|
70586
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
70587
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
70588
|
+
},
|
|
70589
|
+
y: {
|
|
70590
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
70591
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
70592
|
+
},
|
|
70593
|
+
z: {
|
|
70594
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
70595
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
70596
|
+
},
|
|
70597
|
+
};
|
|
70598
|
+
if (from === to) {
|
|
70599
|
+
return;
|
|
70600
|
+
}
|
|
70601
|
+
if (from === "z" && to === "x") {
|
|
70602
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
70603
|
+
oldIndex = currentIndex * ratios[to];
|
|
70604
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
70605
|
+
convertCursorNumY = cursorNumY;
|
|
70606
|
+
}
|
|
70607
|
+
else if (from === "y" && to === "x") {
|
|
70608
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
70609
|
+
oldIndex = currentIndex * ratios.x;
|
|
70610
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
70611
|
+
convertCursorNumX = cursorNumY;
|
|
70612
|
+
}
|
|
70613
|
+
else if (from === "z" && to === "y") {
|
|
70614
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
70615
|
+
oldIndex = currentIndex * ratios[to];
|
|
70616
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
70617
|
+
convertCursorNumX = cursorNumX;
|
|
70618
|
+
}
|
|
70619
|
+
else if (from === "x" && to === "y") {
|
|
70620
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
70621
|
+
oldIndex = currentIndex * ratios[to];
|
|
70622
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
70623
|
+
convertCursorNumY = cursorNumX;
|
|
70624
|
+
}
|
|
70625
|
+
else if (from === "x" && to === "z") {
|
|
70626
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
70627
|
+
oldIndex = currentIndex * ratios[to];
|
|
70628
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
70629
|
+
convertCursorNumY = cursorNumY;
|
|
70630
|
+
}
|
|
70631
|
+
else if (from === "y" && to === "z") {
|
|
70632
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
70633
|
+
oldIndex = currentIndex * ratios.z;
|
|
70634
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
70635
|
+
convertCursorNumX = cursorNumX;
|
|
70636
|
+
}
|
|
70637
|
+
else {
|
|
70638
|
+
return;
|
|
70639
|
+
}
|
|
70640
|
+
return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
|
|
70641
|
+
}
|
|
70475
70642
|
setUpSphereOrigins(mouseX, mouseY) {
|
|
70476
70643
|
const convertCursor = (from, to) => {
|
|
70477
70644
|
const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
|
|
@@ -70838,6 +71005,46 @@
|
|
|
70838
71005
|
return sharedPlaceImages;
|
|
70839
71006
|
}
|
|
70840
71007
|
/******************************** Utils gui related functions ***************************************/
|
|
71008
|
+
/**
|
|
71009
|
+
* Set up root container events fns for drag function
|
|
71010
|
+
* @param callback
|
|
71011
|
+
*/
|
|
71012
|
+
setupConrastEvents(callback) {
|
|
71013
|
+
this.contrastEventPrameters.w = this.container.offsetWidth;
|
|
71014
|
+
this.contrastEventPrameters.h = this.container.offsetHeight;
|
|
71015
|
+
this.contrastEventPrameters.handleOnContrastMouseDown = (ev) => {
|
|
71016
|
+
if (ev.button === 0) {
|
|
71017
|
+
this.contrastEventPrameters.x = ev.offsetX / this.contrastEventPrameters.x;
|
|
71018
|
+
this.contrastEventPrameters.y = ev.offsetY / this.contrastEventPrameters.h;
|
|
71019
|
+
this.container.addEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove);
|
|
71020
|
+
}
|
|
71021
|
+
};
|
|
71022
|
+
this.contrastEventPrameters.handleOnContrastMouseUp = (ev) => {
|
|
71023
|
+
this.container.removeEventListener("pointermove", this.contrastEventPrameters.handleOnContrastMouseMove);
|
|
71024
|
+
};
|
|
71025
|
+
this.contrastEventPrameters.handleOnContrastMouseMove = throttle((ev) => {
|
|
71026
|
+
if (this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h >= 0) {
|
|
71027
|
+
this.contrastEventPrameters.move_y = -Math.ceil((this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h) * 10);
|
|
71028
|
+
}
|
|
71029
|
+
else {
|
|
71030
|
+
this.contrastEventPrameters.move_y = -Math.floor((this.contrastEventPrameters.y - ev.offsetY / this.contrastEventPrameters.h) * 10);
|
|
71031
|
+
}
|
|
71032
|
+
if (this.contrastEventPrameters.move_y !== 0 && Math.abs(this.contrastEventPrameters.move_y) === 1) {
|
|
71033
|
+
callback(this.contrastEventPrameters.move_y, "vertical");
|
|
71034
|
+
}
|
|
71035
|
+
if (this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w >= 0) {
|
|
71036
|
+
this.contrastEventPrameters.move_x = -Math.ceil((this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w) * 10);
|
|
71037
|
+
}
|
|
71038
|
+
else {
|
|
71039
|
+
this.contrastEventPrameters.move_x = -Math.floor((this.contrastEventPrameters.x - ev.offsetX / this.contrastEventPrameters.w) * 10);
|
|
71040
|
+
}
|
|
71041
|
+
if (this.contrastEventPrameters.move_x !== 0 && Math.abs(this.contrastEventPrameters.move_x) === 1) {
|
|
71042
|
+
callback(this.contrastEventPrameters.move_x, "horizental");
|
|
71043
|
+
}
|
|
71044
|
+
this.contrastEventPrameters.x = ev.offsetX / this.contrastEventPrameters.w;
|
|
71045
|
+
this.contrastEventPrameters.y = ev.offsetY / this.contrastEventPrameters.h;
|
|
71046
|
+
}, 100);
|
|
71047
|
+
}
|
|
70841
71048
|
updateSlicesContrast(value, flag) {
|
|
70842
71049
|
switch (flag) {
|
|
70843
71050
|
case "lowerThreshold":
|
|
@@ -70918,6 +71125,13 @@
|
|
|
70918
71125
|
setDisplaySliceIndexPanel(panel) {
|
|
70919
71126
|
this.dragOperator.setShowDragNumberDiv(panel);
|
|
70920
71127
|
}
|
|
71128
|
+
/**
|
|
71129
|
+
* Enable the drag function for contrast images window center and window high.
|
|
71130
|
+
* @param callback
|
|
71131
|
+
*/
|
|
71132
|
+
enableContrastDragEvents(callback) {
|
|
71133
|
+
this.setupConrastEvents(callback);
|
|
71134
|
+
}
|
|
70921
71135
|
/**
|
|
70922
71136
|
* Set up GUI for drawing panel
|
|
70923
71137
|
* @param gui GUI
|
|
@@ -70972,6 +71186,12 @@
|
|
|
70972
71186
|
this.guiParameterSettings = setupGui(guiOptions);
|
|
70973
71187
|
}
|
|
70974
71188
|
getGuiSettings() {
|
|
71189
|
+
if (!!this.guiParameterSettings) {
|
|
71190
|
+
// update image volume
|
|
71191
|
+
this.guiParameterSettings.windowHigh.value = this.guiParameterSettings.windowLow.value = this.protectedData.mainPreSlices.volume;
|
|
71192
|
+
this.guiParameterSettings.windowHigh.max = this.guiParameterSettings.windowLow.max = this.protectedData.mainPreSlices.volume.max;
|
|
71193
|
+
this.guiParameterSettings.windowHigh.min = this.guiParameterSettings.windowLow.min = this.protectedData.mainPreSlices.volume.min;
|
|
71194
|
+
}
|
|
70975
71195
|
return {
|
|
70976
71196
|
guiState: this.gui_states,
|
|
70977
71197
|
guiSetting: this.guiParameterSettings,
|
|
@@ -71152,102 +71372,6 @@
|
|
|
71152
71372
|
paintImages.z.push(initMark_z);
|
|
71153
71373
|
}
|
|
71154
71374
|
}
|
|
71155
|
-
/**
|
|
71156
|
-
* We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
|
|
71157
|
-
* So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
|
|
71158
|
-
*
|
|
71159
|
-
* When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
|
|
71160
|
-
*
|
|
71161
|
-
* Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
|
|
71162
|
-
*
|
|
71163
|
-
* @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
|
|
71164
|
-
* @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
|
|
71165
|
-
* @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
|
|
71166
|
-
* @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
|
|
71167
|
-
* @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
|
|
71168
|
-
* @returns
|
|
71169
|
-
*/
|
|
71170
|
-
convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
|
|
71171
|
-
const nrrd = this.nrrd_states;
|
|
71172
|
-
const dimensions = nrrd.dimensions;
|
|
71173
|
-
const ratios = nrrd.ratios;
|
|
71174
|
-
const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
|
|
71175
|
-
let currentIndex = 0;
|
|
71176
|
-
let oldIndex = 0;
|
|
71177
|
-
let convertCursorNumX = 0;
|
|
71178
|
-
let convertCursorNumY = 0;
|
|
71179
|
-
const convertIndex = {
|
|
71180
|
-
x: {
|
|
71181
|
-
y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
71182
|
-
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
71183
|
-
},
|
|
71184
|
-
y: {
|
|
71185
|
-
x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
71186
|
-
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
71187
|
-
},
|
|
71188
|
-
z: {
|
|
71189
|
-
x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
71190
|
-
y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
71191
|
-
},
|
|
71192
|
-
};
|
|
71193
|
-
const convertCursor = {
|
|
71194
|
-
x: {
|
|
71195
|
-
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
71196
|
-
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
71197
|
-
},
|
|
71198
|
-
y: {
|
|
71199
|
-
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
71200
|
-
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
71201
|
-
},
|
|
71202
|
-
z: {
|
|
71203
|
-
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
71204
|
-
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
71205
|
-
},
|
|
71206
|
-
};
|
|
71207
|
-
if (from === to) {
|
|
71208
|
-
return;
|
|
71209
|
-
}
|
|
71210
|
-
if (from === "z" && to === "x") {
|
|
71211
|
-
currentIndex = convertIndex[from][to](cursorNumX);
|
|
71212
|
-
oldIndex = currentIndex * ratios[to];
|
|
71213
|
-
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
71214
|
-
convertCursorNumY = cursorNumY;
|
|
71215
|
-
}
|
|
71216
|
-
else if (from === "y" && to === "x") {
|
|
71217
|
-
currentIndex = convertIndex[from][to](cursorNumX);
|
|
71218
|
-
oldIndex = currentIndex * ratios.x;
|
|
71219
|
-
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
71220
|
-
convertCursorNumX = cursorNumY;
|
|
71221
|
-
}
|
|
71222
|
-
else if (from === "z" && to === "y") {
|
|
71223
|
-
currentIndex = convertIndex[from][to](cursorNumY);
|
|
71224
|
-
oldIndex = currentIndex * ratios[to];
|
|
71225
|
-
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
71226
|
-
convertCursorNumX = cursorNumX;
|
|
71227
|
-
}
|
|
71228
|
-
else if (from === "x" && to === "y") {
|
|
71229
|
-
currentIndex = convertIndex[from][to](cursorNumY);
|
|
71230
|
-
oldIndex = currentIndex * ratios[to];
|
|
71231
|
-
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
71232
|
-
convertCursorNumY = cursorNumX;
|
|
71233
|
-
}
|
|
71234
|
-
else if (from === "x" && to === "z") {
|
|
71235
|
-
currentIndex = convertIndex[from][to](cursorNumX);
|
|
71236
|
-
oldIndex = currentIndex * ratios[to];
|
|
71237
|
-
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
71238
|
-
convertCursorNumY = cursorNumY;
|
|
71239
|
-
}
|
|
71240
|
-
else if (from === "y" && to === "z") {
|
|
71241
|
-
currentIndex = convertIndex[from][to](cursorNumY);
|
|
71242
|
-
oldIndex = currentIndex * ratios.z;
|
|
71243
|
-
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
71244
|
-
convertCursorNumX = cursorNumX;
|
|
71245
|
-
}
|
|
71246
|
-
else {
|
|
71247
|
-
return;
|
|
71248
|
-
}
|
|
71249
|
-
return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
|
|
71250
|
-
}
|
|
71251
71375
|
/**
|
|
71252
71376
|
* Switch all contrast slices' orientation
|
|
71253
71377
|
* @param {string} aixs:"x" | "y" | "z"
|
|
@@ -71360,7 +71484,7 @@
|
|
|
71360
71484
|
this.resetDisplaySlicesStatus();
|
|
71361
71485
|
// for sphere plan a
|
|
71362
71486
|
if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
|
|
71363
|
-
this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
|
|
71487
|
+
this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereOrigin[axisTo][1] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereRadius);
|
|
71364
71488
|
}
|
|
71365
71489
|
}
|
|
71366
71490
|
addSkip(index) {
|
|
@@ -72055,8 +72179,8 @@
|
|
|
72055
72179
|
}
|
|
72056
72180
|
|
|
72057
72181
|
// import * as kiwrious from "copper3d_plugin_heart_k";
|
|
72058
|
-
const REVISION = "v2.0.
|
|
72059
|
-
console.log("%cCopper3D Visualisation %cBeta:v2.0.
|
|
72182
|
+
const REVISION = "v2.0.7";
|
|
72183
|
+
console.log("%cCopper3D Visualisation %cBeta:v2.0.7", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
72060
72184
|
|
|
72061
72185
|
exports.CameraViewPoint = CameraViewPoint;
|
|
72062
72186
|
exports.Copper3dTrackballControls = Copper3dTrackballControls;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,6 @@ import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
|
19
19
|
import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader } from "./types/types";
|
|
20
20
|
import { IPaintImage } from "./Utils/segmentation/coreTools/coreType";
|
|
21
21
|
import "./css/style.css";
|
|
22
|
-
export declare const REVISION = "v2.0.
|
|
22
|
+
export declare const REVISION = "v2.0.7";
|
|
23
23
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
|
|
24
24
|
export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, };
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
|
|
|
18
18
|
import { MeshNodeTool } from "./Utils/MeshNodeTool";
|
|
19
19
|
import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
|
|
20
20
|
import "./css/style.css";
|
|
21
|
-
export const REVISION = "v2.0.
|
|
22
|
-
console.log("%cCopper3D Visualisation %cBeta:v2.0.
|
|
21
|
+
export const REVISION = "v2.0.7";
|
|
22
|
+
console.log("%cCopper3D Visualisation %cBeta:v2.0.7", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
|
|
23
23
|
export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { IDrawingEvents, IDrawOpts, IPaintImage, IPaintImages, IUndoType } from "./coreTools/coreType";
|
|
1
|
+
import { IDrawingEvents, IContrastEvents, IDrawOpts, IPaintImage, IPaintImages, IUndoType } from "./coreTools/coreType";
|
|
2
2
|
import { CommToolsData } from "./CommToolsData";
|
|
3
3
|
export declare class DrawToolCore extends CommToolsData {
|
|
4
4
|
container: HTMLElement;
|
|
5
5
|
mainAreaContainer: HTMLDivElement;
|
|
6
6
|
drawingPrameters: IDrawingEvents;
|
|
7
|
+
contrastEventPrameters: IContrastEvents;
|
|
7
8
|
eraserUrls: string[];
|
|
8
9
|
pencilUrls: string[];
|
|
9
10
|
undoArray: Array<IUndoType>;
|
|
@@ -31,6 +32,27 @@ export declare class DrawToolCore extends CommToolsData {
|
|
|
31
32
|
private setSphereCanvasSize;
|
|
32
33
|
private configMouseSphereWheel;
|
|
33
34
|
drawSphere(mouseX: number, mouseY: number, radius: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
|
|
37
|
+
* So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
|
|
38
|
+
*
|
|
39
|
+
* When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
|
|
40
|
+
*
|
|
41
|
+
* Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
|
|
42
|
+
*
|
|
43
|
+
* @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
|
|
44
|
+
* @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
|
|
45
|
+
* @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
|
|
46
|
+
* @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
|
|
47
|
+
* @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
convertCursorPoint(from: "x" | "y" | "z", to: "x" | "y" | "z", cursorNumX: number, cursorNumY: number, currentSliceIndex: number): {
|
|
51
|
+
currentIndex: number;
|
|
52
|
+
oldIndex: number;
|
|
53
|
+
convertCursorNumX: number;
|
|
54
|
+
convertCursorNumY: number;
|
|
55
|
+
} | undefined;
|
|
34
56
|
private setUpSphereOrigins;
|
|
35
57
|
/****************************label div controls****************************************************/
|
|
36
58
|
getRestLabel(): ("label1" | "label2" | "label3")[];
|
|
@@ -73,6 +95,13 @@ export declare class DrawToolCore extends CommToolsData {
|
|
|
73
95
|
replaceArray(mainArr: number[] | Uint8ClampedArray, replaceArr: number[] | Uint8ClampedArray): void;
|
|
74
96
|
findSliceInSharedPlace(): ImageData[];
|
|
75
97
|
/******************************** Utils gui related functions ***************************************/
|
|
98
|
+
/**
|
|
99
|
+
* Set up root container events fns for drag function
|
|
100
|
+
* @param callback
|
|
101
|
+
*/
|
|
102
|
+
setupConrastEvents(callback: (step: number, towards: "horizental" | "vertical") => void): void;
|
|
103
|
+
configContrastDragMode: () => void;
|
|
104
|
+
removeContrastDragMode: () => void;
|
|
76
105
|
updateSlicesContrast(value: number, flag: string): void;
|
|
77
106
|
repraintCurrentContrastSlice(): void;
|
|
78
107
|
}
|