copper3d 1.15.11 → 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/Utils/nrrd_tool.d.ts +21 -4
- package/dist/Utils/nrrd_tool.js +560 -305
- package/dist/Utils/nrrd_tool.js.map +1 -1
- package/dist/bundle.esm.js +562 -307
- package/dist/bundle.umd.js +562 -307
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/types/Utils/nrrd_tool.d.ts +21 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/Utils/nrrd_tool.js
CHANGED
|
@@ -14,6 +14,7 @@ export class nrrd_tools {
|
|
|
14
14
|
label2: this.paintImagesLabel2,
|
|
15
15
|
label3: this.paintImagesLabel3,
|
|
16
16
|
};
|
|
17
|
+
// used to store display marks with multiple labels
|
|
17
18
|
this.paintImages = { x: [], y: [], z: [] };
|
|
18
19
|
// store all contrast slices, include x, y, z orientation
|
|
19
20
|
this.allSlicesArray = [];
|
|
@@ -41,7 +42,6 @@ export class nrrd_tools {
|
|
|
41
42
|
this.Is_Shift_Pressed = false;
|
|
42
43
|
this.Is_Draw = false;
|
|
43
44
|
this.sensitiveArray = [];
|
|
44
|
-
this.handleWheelMove = () => { };
|
|
45
45
|
this.start = () => { };
|
|
46
46
|
this.undoArray = [];
|
|
47
47
|
this.initState = true;
|
|
@@ -77,6 +77,10 @@ export class nrrd_tools {
|
|
|
77
77
|
isCursorSelect: false,
|
|
78
78
|
cursorPageX: 0,
|
|
79
79
|
cursorPageY: 0,
|
|
80
|
+
// x: [cursorX, cursorY, sliceIndex]
|
|
81
|
+
sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
|
|
82
|
+
spherePlanB: false,
|
|
83
|
+
sphereRadius: 10,
|
|
80
84
|
Mouse_Over_x: 0,
|
|
81
85
|
Mouse_Over_y: 0,
|
|
82
86
|
Mouse_Over: false,
|
|
@@ -126,12 +130,9 @@ export class nrrd_tools {
|
|
|
126
130
|
brushAndEraserSize: 15,
|
|
127
131
|
cursor: "dot",
|
|
128
132
|
label: "label1",
|
|
133
|
+
sphere: false,
|
|
129
134
|
// EraserSize: 25,
|
|
130
135
|
clear: () => {
|
|
131
|
-
// const text = "Are you sure remove annotations on Current slice?";
|
|
132
|
-
// if (confirm(text) === true) {
|
|
133
|
-
// this.clearPaint();
|
|
134
|
-
// }
|
|
135
136
|
this.clearPaint();
|
|
136
137
|
},
|
|
137
138
|
clearAll: () => {
|
|
@@ -165,6 +166,36 @@ export class nrrd_tools {
|
|
|
165
166
|
this.exportData();
|
|
166
167
|
},
|
|
167
168
|
};
|
|
169
|
+
this.dragPrameters = {
|
|
170
|
+
move: 0,
|
|
171
|
+
y: 0,
|
|
172
|
+
h: 0,
|
|
173
|
+
sensivity: 1,
|
|
174
|
+
handleOnDragMouseUp: (ev) => { },
|
|
175
|
+
handleOnDragMouseDown: (ev) => { },
|
|
176
|
+
handleOnDragMouseMove: (ev) => { },
|
|
177
|
+
};
|
|
178
|
+
this.drawingPrameters = {
|
|
179
|
+
handleOnDrawingMouseDown: (ev) => { },
|
|
180
|
+
handleOnDrawingMouseMove: (ev) => { },
|
|
181
|
+
handleOnPanMouseMove: (ev) => { },
|
|
182
|
+
handleOnDrawingMouseUp: (ev) => { },
|
|
183
|
+
handleOnDrawingMouseLeave: (ev) => { },
|
|
184
|
+
handleOnDrawingBrushCricleMove: (ev) => { },
|
|
185
|
+
handleZoomWheel: (e) => { },
|
|
186
|
+
handleSphereWheel: (e) => { },
|
|
187
|
+
};
|
|
188
|
+
this.configDragMode = () => {
|
|
189
|
+
this.container.style.cursor = "pointer";
|
|
190
|
+
this.container.addEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
|
|
191
|
+
this.container.addEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
|
|
192
|
+
};
|
|
193
|
+
this.removeDragMode = () => {
|
|
194
|
+
this.container.style.cursor = "";
|
|
195
|
+
this.container.removeEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
|
|
196
|
+
this.container.removeEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
|
|
197
|
+
this.setIsDrawFalse(1000);
|
|
198
|
+
};
|
|
168
199
|
this.drawLine = (x1, y1, x2, y2) => {
|
|
169
200
|
this.drawingCtx.beginPath();
|
|
170
201
|
this.drawingCtx.moveTo(x1, y1);
|
|
@@ -197,7 +228,7 @@ export class nrrd_tools {
|
|
|
197
228
|
this.sensitiveArray.push((i + 1) / 20);
|
|
198
229
|
}
|
|
199
230
|
this.container.addEventListener("keydown", (ev) => {
|
|
200
|
-
if (ev.key === "Shift") {
|
|
231
|
+
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
201
232
|
this.Is_Shift_Pressed = true;
|
|
202
233
|
this.nrrd_states.enableCursorChoose = false;
|
|
203
234
|
}
|
|
@@ -377,12 +408,94 @@ export class nrrd_tools {
|
|
|
377
408
|
paintImages.z.push(initMark_z);
|
|
378
409
|
}
|
|
379
410
|
}
|
|
411
|
+
convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
|
|
412
|
+
const nrrd = this.nrrd_states;
|
|
413
|
+
const dimensions = nrrd.dimensions;
|
|
414
|
+
const ratios = nrrd.ratios;
|
|
415
|
+
const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
|
|
416
|
+
let currentIndex = 0;
|
|
417
|
+
let oldIndex = 0;
|
|
418
|
+
let convertCursorNumX = 0;
|
|
419
|
+
let convertCursorNumY = 0;
|
|
420
|
+
const convertIndex = {
|
|
421
|
+
x: {
|
|
422
|
+
y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
423
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
424
|
+
},
|
|
425
|
+
y: {
|
|
426
|
+
x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
427
|
+
z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
|
|
428
|
+
},
|
|
429
|
+
z: {
|
|
430
|
+
x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
|
|
431
|
+
y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
const convertCursor = {
|
|
435
|
+
x: {
|
|
436
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
437
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
|
|
438
|
+
},
|
|
439
|
+
y: {
|
|
440
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
441
|
+
z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
|
|
442
|
+
},
|
|
443
|
+
z: {
|
|
444
|
+
x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
445
|
+
y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
if (from === to) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (from === "z" && to === "x") {
|
|
452
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
453
|
+
oldIndex = currentIndex * ratios[to];
|
|
454
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
455
|
+
convertCursorNumY = cursorNumY;
|
|
456
|
+
}
|
|
457
|
+
else if (from === "y" && to === "x") {
|
|
458
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
459
|
+
oldIndex = currentIndex * ratios.x;
|
|
460
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
461
|
+
convertCursorNumX = cursorNumY;
|
|
462
|
+
}
|
|
463
|
+
else if (from === "z" && to === "y") {
|
|
464
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
465
|
+
oldIndex = currentIndex * ratios[to];
|
|
466
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
467
|
+
convertCursorNumX = cursorNumX;
|
|
468
|
+
}
|
|
469
|
+
else if (from === "x" && to === "y") {
|
|
470
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
471
|
+
oldIndex = currentIndex * ratios[to];
|
|
472
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
473
|
+
convertCursorNumY = cursorNumX;
|
|
474
|
+
}
|
|
475
|
+
else if (from === "x" && to === "z") {
|
|
476
|
+
currentIndex = convertIndex[from][to](cursorNumX);
|
|
477
|
+
oldIndex = currentIndex * ratios[to];
|
|
478
|
+
convertCursorNumX = convertCursor[from][to](currentSliceIndex);
|
|
479
|
+
convertCursorNumY = cursorNumY;
|
|
480
|
+
}
|
|
481
|
+
else if (from === "y" && to === "z") {
|
|
482
|
+
currentIndex = convertIndex[from][to](cursorNumY);
|
|
483
|
+
oldIndex = currentIndex * ratios.z;
|
|
484
|
+
convertCursorNumY = convertCursor[from][to](currentSliceIndex);
|
|
485
|
+
convertCursorNumX = cursorNumX;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
|
|
491
|
+
}
|
|
380
492
|
/**
|
|
381
493
|
* Switch all contrast slices' orientation
|
|
382
494
|
* @param {string} aixs:"x" | "y" | "z"
|
|
383
495
|
* */
|
|
384
|
-
setSliceOrientation(
|
|
385
|
-
|
|
496
|
+
setSliceOrientation(axisTo) {
|
|
497
|
+
let convetObj;
|
|
498
|
+
if (this.nrrd_states.enableCursorChoose || this.gui_states.sphere) {
|
|
386
499
|
if (this.axis === "z") {
|
|
387
500
|
this.cursorPage.z.index = this.nrrd_states.currentIndex;
|
|
388
501
|
this.cursorPage.z.cursorPageX = this.nrrd_states.cursorPageX;
|
|
@@ -398,27 +511,19 @@ export class nrrd_tools {
|
|
|
398
511
|
this.cursorPage.y.cursorPageX = this.nrrd_states.cursorPageX;
|
|
399
512
|
this.cursorPage.y.cursorPageY = this.nrrd_states.cursorPageY;
|
|
400
513
|
}
|
|
401
|
-
if (
|
|
514
|
+
if (axisTo === "z") {
|
|
402
515
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.z.updated) {
|
|
403
516
|
if (this.axis === "x") {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this.nrrd_states.oldIndex =
|
|
407
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
|
|
408
|
-
this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
|
|
409
|
-
this.nrrd_states.nrrd_x_mm);
|
|
517
|
+
// convert x to z
|
|
518
|
+
convetObj = this.convertCursorPoint("x", "z", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
|
|
410
519
|
}
|
|
411
520
|
if (this.axis === "y") {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this.nrrd_states.oldIndex =
|
|
415
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
|
|
416
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
|
|
417
|
-
this.nrrd_states.nrrd_y_mm);
|
|
521
|
+
// convert y to z
|
|
522
|
+
convetObj = this.convertCursorPoint("y", "z", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
|
|
418
523
|
}
|
|
419
|
-
this.cursorPage.z.updated = true;
|
|
420
524
|
}
|
|
421
525
|
else {
|
|
526
|
+
// not cursor select, freedom to switch x -> z or y -> z and z -> x or z -> y
|
|
422
527
|
this.nrrd_states.currentIndex = this.cursorPage.z.index;
|
|
423
528
|
this.nrrd_states.oldIndex =
|
|
424
529
|
this.cursorPage.z.index * this.nrrd_states.ratios.z;
|
|
@@ -426,28 +531,19 @@ export class nrrd_tools {
|
|
|
426
531
|
this.nrrd_states.cursorPageY = this.cursorPage.z.cursorPageY;
|
|
427
532
|
}
|
|
428
533
|
}
|
|
429
|
-
else if (
|
|
534
|
+
else if (axisTo === "x") {
|
|
430
535
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.x.updated) {
|
|
431
536
|
if (this.axis === "z") {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
this.nrrd_states.oldIndex =
|
|
435
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
|
|
436
|
-
this.nrrd_states.cursorPageX = Math.floor((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
|
|
437
|
-
this.nrrd_states.nrrd_z_mm);
|
|
537
|
+
// convert z to x
|
|
538
|
+
convetObj = this.convertCursorPoint("z", "x", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
|
|
438
539
|
}
|
|
439
540
|
if (this.axis === "y") {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
this.nrrd_states.oldIndex =
|
|
443
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
|
|
444
|
-
this.nrrd_states.cursorPageX = this.cursorPage.y.cursorPageY;
|
|
445
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
|
|
446
|
-
this.nrrd_states.nrrd_y_mm);
|
|
541
|
+
// convert y to x
|
|
542
|
+
convetObj = this.convertCursorPoint("y", "x", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
|
|
447
543
|
}
|
|
448
|
-
this.cursorPage.x.updated = true;
|
|
449
544
|
}
|
|
450
545
|
else {
|
|
546
|
+
// not cursor select, freedom to switch z -> x or y -> x and x -> z or x -> y
|
|
451
547
|
this.nrrd_states.currentIndex = this.cursorPage.x.index;
|
|
452
548
|
this.nrrd_states.oldIndex =
|
|
453
549
|
this.cursorPage.x.index * this.nrrd_states.ratios.x;
|
|
@@ -455,28 +551,19 @@ export class nrrd_tools {
|
|
|
455
551
|
this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageY;
|
|
456
552
|
}
|
|
457
553
|
}
|
|
458
|
-
else if (
|
|
554
|
+
else if (axisTo === "y") {
|
|
459
555
|
if (this.nrrd_states.isCursorSelect && !this.cursorPage.y.updated) {
|
|
460
556
|
if (this.axis === "z") {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
this.nrrd_states.oldIndex =
|
|
464
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
|
|
465
|
-
this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
|
|
466
|
-
this.nrrd_states.nrrd_z_mm);
|
|
557
|
+
// convert z to y
|
|
558
|
+
convetObj = this.convertCursorPoint("z", "y", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
|
|
467
559
|
}
|
|
468
560
|
if (this.axis === "x") {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
this.nrrd_states.oldIndex =
|
|
472
|
-
this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
|
|
473
|
-
this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
|
|
474
|
-
this.nrrd_states.nrrd_x_mm);
|
|
475
|
-
this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageX;
|
|
561
|
+
// convert x to y
|
|
562
|
+
convetObj = this.convertCursorPoint("x", "y", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
|
|
476
563
|
}
|
|
477
|
-
this.cursorPage.y.updated = true;
|
|
478
564
|
}
|
|
479
565
|
else {
|
|
566
|
+
// not cursor select, freedom to switch z -> y or x -> y and y -> z or y -> x
|
|
480
567
|
this.nrrd_states.currentIndex = this.cursorPage.y.index;
|
|
481
568
|
this.nrrd_states.oldIndex =
|
|
482
569
|
this.cursorPage.y.index * this.nrrd_states.ratios.y;
|
|
@@ -484,14 +571,38 @@ export class nrrd_tools {
|
|
|
484
571
|
this.nrrd_states.cursorPageY = this.cursorPage.y.cursorPageY;
|
|
485
572
|
}
|
|
486
573
|
}
|
|
574
|
+
if (convetObj) {
|
|
575
|
+
// update convert cursor point, when cursor select
|
|
576
|
+
this.nrrd_states.currentIndex = convetObj.currentIndex;
|
|
577
|
+
this.nrrd_states.oldIndex = convetObj.oldIndex;
|
|
578
|
+
this.nrrd_states.cursorPageX = convetObj.convertCursorNumX;
|
|
579
|
+
this.nrrd_states.cursorPageY = convetObj.convertCursorNumY;
|
|
580
|
+
convetObj = undefined;
|
|
581
|
+
switch (axisTo) {
|
|
582
|
+
case "x":
|
|
583
|
+
this.cursorPage.x.updated = true;
|
|
584
|
+
break;
|
|
585
|
+
case "y":
|
|
586
|
+
this.cursorPage.y.updated = true;
|
|
587
|
+
break;
|
|
588
|
+
case "z":
|
|
589
|
+
this.cursorPage.z.updated = true;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
487
593
|
if (this.cursorPage.x.updated &&
|
|
488
594
|
this.cursorPage.y.updated &&
|
|
489
595
|
this.cursorPage.z.updated) {
|
|
596
|
+
// one point convert to all axis, reset all updated status
|
|
490
597
|
this.nrrd_states.isCursorSelect = false;
|
|
491
598
|
}
|
|
492
599
|
}
|
|
493
|
-
this.axis =
|
|
600
|
+
this.axis = axisTo;
|
|
494
601
|
this.resetDisplaySlicesStatus();
|
|
602
|
+
// for sphere plan a
|
|
603
|
+
if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
|
|
604
|
+
this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
|
|
605
|
+
}
|
|
495
606
|
}
|
|
496
607
|
addSkip(index) {
|
|
497
608
|
this.skipSlicesDic[index] = this.backUpDisplaySlices[index];
|
|
@@ -817,62 +928,51 @@ export class nrrd_tools {
|
|
|
817
928
|
this.mainAreaContainer.appendChild(loadingbar);
|
|
818
929
|
}
|
|
819
930
|
drag(opts) {
|
|
820
|
-
|
|
821
|
-
let y;
|
|
822
|
-
let h = this.container.offsetHeight;
|
|
823
|
-
let sensivity = 1;
|
|
824
|
-
let handleOnMouseUp;
|
|
825
|
-
let handleOnMouseDown;
|
|
826
|
-
let handleOnMouseMove;
|
|
931
|
+
this.dragPrameters.h = this.container.offsetHeight;
|
|
827
932
|
this.sensitiveArray.reverse();
|
|
828
933
|
if (opts === null || opts === void 0 ? void 0 : opts.showNumber) {
|
|
829
934
|
this.container.appendChild(this.showDragNumberDiv);
|
|
830
935
|
}
|
|
831
|
-
|
|
936
|
+
this.dragPrameters.handleOnDragMouseDown = (ev) => {
|
|
832
937
|
// before start drag event, remove wheel event.
|
|
833
|
-
this.drawingCanvas.removeEventListener("wheel", this.
|
|
938
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
834
939
|
if (ev.button === 0) {
|
|
835
940
|
// this.setSyncsliceNum();
|
|
836
|
-
y = ev.offsetY / h;
|
|
837
|
-
this.container.addEventListener("pointermove",
|
|
838
|
-
|
|
941
|
+
this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
|
|
942
|
+
this.container.addEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
|
|
943
|
+
this.dragPrameters.sensivity =
|
|
944
|
+
this.sensitiveArray[this.gui_states.dragSensitivity - 1];
|
|
839
945
|
}
|
|
840
946
|
};
|
|
841
|
-
|
|
842
|
-
if (y - ev.offsetY / h >= 0) {
|
|
843
|
-
move = -Math.ceil(((y - ev.offsetY / h) * 10) /
|
|
947
|
+
this.dragPrameters.handleOnDragMouseMove = throttle((ev) => {
|
|
948
|
+
if (this.dragPrameters.y - ev.offsetY / this.dragPrameters.h >= 0) {
|
|
949
|
+
this.dragPrameters.move = -Math.ceil(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
|
|
950
|
+
this.dragPrameters.sensivity);
|
|
844
951
|
}
|
|
845
952
|
else {
|
|
846
|
-
move = -Math.floor(((y - ev.offsetY / h) * 10) /
|
|
953
|
+
this.dragPrameters.move = -Math.floor(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
|
|
954
|
+
this.dragPrameters.sensivity);
|
|
847
955
|
}
|
|
848
|
-
this.updateIndex(move);
|
|
956
|
+
this.updateIndex(this.dragPrameters.move);
|
|
849
957
|
(opts === null || opts === void 0 ? void 0 : opts.getSliceNum) &&
|
|
850
958
|
opts.getSliceNum(this.nrrd_states.currentIndex, this.nrrd_states.contrastNum);
|
|
851
|
-
y = ev.offsetY / h;
|
|
852
|
-
}, sensivity * 200);
|
|
853
|
-
|
|
959
|
+
this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
|
|
960
|
+
}, this.dragPrameters.sensivity * 200);
|
|
961
|
+
this.dragPrameters.handleOnDragMouseUp = (ev) => {
|
|
854
962
|
// after drag, add the wheel event
|
|
855
|
-
this.drawingCanvas.addEventListener("wheel", this.
|
|
963
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
856
964
|
this.setSyncsliceNum();
|
|
857
|
-
this.container.removeEventListener("pointermove",
|
|
858
|
-
};
|
|
859
|
-
const configDragMode = () => {
|
|
860
|
-
this.container.style.cursor = "pointer";
|
|
861
|
-
this.container.addEventListener("pointerdown", handleOnMouseDown, true);
|
|
862
|
-
this.container.addEventListener("pointerup", handleOnMouseUp, true);
|
|
965
|
+
this.container.removeEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
|
|
863
966
|
};
|
|
864
|
-
configDragMode();
|
|
967
|
+
this.configDragMode();
|
|
865
968
|
this.container.addEventListener("keydown", (ev) => {
|
|
866
969
|
if (ev.key === "Shift") {
|
|
867
|
-
this.
|
|
868
|
-
this.container.removeEventListener("pointerdown", handleOnMouseDown, true);
|
|
869
|
-
this.container.removeEventListener("pointerup", handleOnMouseUp, false);
|
|
870
|
-
this.setIsDrawFalse(1000);
|
|
970
|
+
this.removeDragMode();
|
|
871
971
|
}
|
|
872
972
|
});
|
|
873
973
|
this.container.addEventListener("keyup", (ev) => {
|
|
874
|
-
if (ev.key === "Shift") {
|
|
875
|
-
configDragMode();
|
|
974
|
+
if (ev.key === "Shift" && !this.gui_states.sphere) {
|
|
975
|
+
this.configDragMode();
|
|
876
976
|
}
|
|
877
977
|
});
|
|
878
978
|
}
|
|
@@ -1030,6 +1130,7 @@ export class nrrd_tools {
|
|
|
1030
1130
|
// draw lines starts position
|
|
1031
1131
|
let Is_Painting = false;
|
|
1032
1132
|
let lines = [];
|
|
1133
|
+
const clearArc = this.useEraser();
|
|
1033
1134
|
this.updateOriginAndChangedWH();
|
|
1034
1135
|
this.initAllCanvas();
|
|
1035
1136
|
this.configGui(modeFolder);
|
|
@@ -1039,12 +1140,15 @@ export class nrrd_tools {
|
|
|
1039
1140
|
(_c = this.displayCtx) === null || _c === void 0 ? void 0 : _c.restore();
|
|
1040
1141
|
this.previousDrawingImage = this.drawingCtx.getImageData(0, 0, this.drawingCanvas.width, this.drawingCanvas.height);
|
|
1041
1142
|
// let a global variable to store the wheel move event
|
|
1042
|
-
this.
|
|
1143
|
+
this.drawingPrameters.handleZoomWheel = this.configMouseZoomWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
|
|
1043
1144
|
// init to add it
|
|
1044
|
-
this.drawingCanvas.addEventListener("wheel", this.
|
|
1145
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
|
|
1045
1146
|
passive: false,
|
|
1046
1147
|
});
|
|
1047
|
-
|
|
1148
|
+
// sphere Wheel
|
|
1149
|
+
this.drawingPrameters.handleSphereWheel = this.configMouseSphereWheel();
|
|
1150
|
+
// pan move
|
|
1151
|
+
this.drawingPrameters.handleOnPanMouseMove = (e) => {
|
|
1048
1152
|
this.drawingCanvas.style.cursor = "grabbing";
|
|
1049
1153
|
this.nrrd_states.previousPanelL = e.clientX - panelMoveInnerX;
|
|
1050
1154
|
this.nrrd_states.previousPanelT = e.clientY - panelMoveInnerY;
|
|
@@ -1053,8 +1157,9 @@ export class nrrd_tools {
|
|
|
1053
1157
|
this.displayCanvas.style.top = this.drawingCanvas.style.top =
|
|
1054
1158
|
this.nrrd_states.previousPanelT + "px";
|
|
1055
1159
|
};
|
|
1056
|
-
//
|
|
1057
|
-
|
|
1160
|
+
// brush circle move
|
|
1161
|
+
this.drawingPrameters.handleOnDrawingBrushCricleMove = (e) => {
|
|
1162
|
+
e.preventDefault();
|
|
1058
1163
|
this.nrrd_states.Mouse_Over_x = e.offsetX;
|
|
1059
1164
|
this.nrrd_states.Mouse_Over_y = e.offsetY;
|
|
1060
1165
|
if (this.nrrd_states.Mouse_Over_x === undefined) {
|
|
@@ -1063,21 +1168,31 @@ export class nrrd_tools {
|
|
|
1063
1168
|
}
|
|
1064
1169
|
if (e.type === "mouseout") {
|
|
1065
1170
|
this.nrrd_states.Mouse_Over = false;
|
|
1066
|
-
this.drawingCanvas.removeEventListener("mousemove",
|
|
1171
|
+
this.drawingCanvas.removeEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
1067
1172
|
}
|
|
1068
1173
|
else if (e.type === "mouseover") {
|
|
1069
1174
|
this.nrrd_states.Mouse_Over = true;
|
|
1070
|
-
this.drawingCanvas.addEventListener("mousemove",
|
|
1175
|
+
this.drawingCanvas.addEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
1071
1176
|
}
|
|
1072
|
-
e.preventDefault();
|
|
1073
1177
|
};
|
|
1074
|
-
//
|
|
1075
|
-
this.
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1178
|
+
// drawing move
|
|
1179
|
+
this.drawingPrameters.handleOnDrawingMouseMove = (e) => {
|
|
1180
|
+
this.Is_Draw = true;
|
|
1181
|
+
if (Is_Painting) {
|
|
1182
|
+
if (this.gui_states.Eraser) {
|
|
1183
|
+
this.nrrd_states.stepClear = 1;
|
|
1184
|
+
// drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
|
|
1185
|
+
clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
lines.push({ x: e.offsetX, y: e.offsetY });
|
|
1189
|
+
this.paintOnCanvasLayer(e.offsetX, e.offsetY);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
this.drawingPrameters.handleOnDrawingMouseDown = (e) => {
|
|
1079
1194
|
if (leftclicked || rightclicked) {
|
|
1080
|
-
this.drawingCanvas.removeEventListener("pointerup",
|
|
1195
|
+
this.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
1081
1196
|
this.drawingLayerMasterCtx.closePath();
|
|
1082
1197
|
return;
|
|
1083
1198
|
}
|
|
@@ -1088,7 +1203,7 @@ export class nrrd_tools {
|
|
|
1088
1203
|
currentSliceIndex = this.mainPreSlice.index;
|
|
1089
1204
|
}
|
|
1090
1205
|
// remove it when mouse click down
|
|
1091
|
-
this.drawingCanvas.removeEventListener("wheel", this.
|
|
1206
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
1092
1207
|
if (e.button === 0) {
|
|
1093
1208
|
if (this.Is_Shift_Pressed) {
|
|
1094
1209
|
leftclicked = true;
|
|
@@ -1108,32 +1223,24 @@ export class nrrd_tools {
|
|
|
1108
1223
|
}
|
|
1109
1224
|
this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
|
|
1110
1225
|
// this.drawingLayerMasterCtx.beginPath();
|
|
1111
|
-
this.drawingCanvas.addEventListener("pointerup",
|
|
1112
|
-
this.drawingCanvas.addEventListener("pointermove",
|
|
1226
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
1227
|
+
this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
1113
1228
|
}
|
|
1114
1229
|
else if (this.nrrd_states.enableCursorChoose) {
|
|
1115
1230
|
this.nrrd_states.cursorPageX =
|
|
1116
1231
|
e.offsetX / this.nrrd_states.sizeFoctor;
|
|
1117
1232
|
this.nrrd_states.cursorPageY =
|
|
1118
1233
|
e.offsetY / this.nrrd_states.sizeFoctor;
|
|
1119
|
-
this.
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
this.cursorPage.z.updated = false;
|
|
1130
|
-
break;
|
|
1131
|
-
case "z":
|
|
1132
|
-
this.cursorPage.x.updated = false;
|
|
1133
|
-
this.cursorPage.y.updated = false;
|
|
1134
|
-
this.cursorPage.z.updated = true;
|
|
1135
|
-
break;
|
|
1136
|
-
}
|
|
1234
|
+
this.enableCrosshair();
|
|
1235
|
+
}
|
|
1236
|
+
else if (this.gui_states.sphere) {
|
|
1237
|
+
console.log("sphere down");
|
|
1238
|
+
let mouseX = e.offsetX;
|
|
1239
|
+
let mouseY = e.offsetY;
|
|
1240
|
+
// draw circle
|
|
1241
|
+
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
1242
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
1243
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
1137
1244
|
}
|
|
1138
1245
|
}
|
|
1139
1246
|
else if (e.button === 2) {
|
|
@@ -1145,28 +1252,15 @@ export class nrrd_tools {
|
|
|
1145
1252
|
panelMoveInnerX = e.clientX - offsetX;
|
|
1146
1253
|
panelMoveInnerY = e.clientY - offsetY;
|
|
1147
1254
|
this.drawingCanvas.style.cursor = "grab";
|
|
1148
|
-
this.drawingCanvas.addEventListener("pointerup",
|
|
1149
|
-
this.drawingCanvas.addEventListener("pointermove",
|
|
1255
|
+
this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
|
|
1256
|
+
this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
1150
1257
|
}
|
|
1151
1258
|
else {
|
|
1152
1259
|
return;
|
|
1153
1260
|
}
|
|
1154
|
-
}, true);
|
|
1155
|
-
const clearArc = this.useEraser();
|
|
1156
|
-
const handleOnPainterMove = (e) => {
|
|
1157
|
-
this.Is_Draw = true;
|
|
1158
|
-
if (Is_Painting) {
|
|
1159
|
-
if (this.gui_states.Eraser) {
|
|
1160
|
-
this.nrrd_states.stepClear = 1;
|
|
1161
|
-
// drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
|
|
1162
|
-
clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
|
|
1163
|
-
}
|
|
1164
|
-
else {
|
|
1165
|
-
lines.push({ x: e.offsetX, y: e.offsetY });
|
|
1166
|
-
this.paintOnCanvasLayer(e.offsetX, e.offsetY);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
1261
|
};
|
|
1262
|
+
// disable browser right click menu
|
|
1263
|
+
this.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
|
|
1170
1264
|
const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
|
|
1171
1265
|
var _a;
|
|
1172
1266
|
let paintImages;
|
|
@@ -1193,13 +1287,13 @@ export class nrrd_tools {
|
|
|
1193
1287
|
// draw privous image
|
|
1194
1288
|
ctx.drawImage(this.emptyCanvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
1195
1289
|
};
|
|
1196
|
-
|
|
1290
|
+
this.drawingPrameters.handleOnDrawingMouseUp = (e) => {
|
|
1197
1291
|
if (e.button === 0) {
|
|
1198
1292
|
if (this.Is_Shift_Pressed || Is_Painting) {
|
|
1199
1293
|
leftclicked = false;
|
|
1200
1294
|
let { ctx, canvas } = this.setCurrentLayer();
|
|
1201
1295
|
ctx.closePath();
|
|
1202
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
1296
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
1203
1297
|
if (!this.gui_states.Eraser) {
|
|
1204
1298
|
if (this.gui_states.segmentation) {
|
|
1205
1299
|
this.drawingCanvasLayerMaster.width =
|
|
@@ -1247,20 +1341,66 @@ export class nrrd_tools {
|
|
|
1247
1341
|
undoObj.layers[this.gui_states.label].push(image);
|
|
1248
1342
|
this.undoArray.push(undoObj);
|
|
1249
1343
|
}
|
|
1344
|
+
// add wheel after pointer up
|
|
1345
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
|
|
1346
|
+
passive: false,
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
else if (this.gui_states.sphere &&
|
|
1350
|
+
!this.nrrd_states.enableCursorChoose) {
|
|
1351
|
+
console.log("sphere up");
|
|
1352
|
+
let { ctx, canvas } = this.setCurrentLayer();
|
|
1353
|
+
let mouseX = e.offsetX;
|
|
1354
|
+
let mouseY = e.offsetY;
|
|
1355
|
+
this.nrrd_states.sphereOrigin[this.axis] = [
|
|
1356
|
+
mouseX,
|
|
1357
|
+
mouseY,
|
|
1358
|
+
this.nrrd_states.currentIndex,
|
|
1359
|
+
];
|
|
1360
|
+
/************ */
|
|
1361
|
+
this.setUpSphereOrigins(mouseX, mouseY);
|
|
1362
|
+
console.log(this.nrrd_states.sphereOrigin);
|
|
1363
|
+
this.nrrd_states.cursorPageX = mouseX;
|
|
1364
|
+
this.nrrd_states.cursorPageY = mouseY;
|
|
1365
|
+
this.enableCrosshair();
|
|
1366
|
+
// plan B
|
|
1367
|
+
// findout all index in the sphere radius range in Axial view
|
|
1368
|
+
if (this.nrrd_states.spherePlanB) {
|
|
1369
|
+
// clear stroe images
|
|
1370
|
+
this.clearStoreImages();
|
|
1371
|
+
for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
|
|
1372
|
+
this.setEmptyCanvasSize();
|
|
1373
|
+
const preIndex = this.nrrd_states.currentIndex - i;
|
|
1374
|
+
const nextIndex = this.nrrd_states.currentIndex + i;
|
|
1375
|
+
if (preIndex < this.nrrd_states.minIndex ||
|
|
1376
|
+
nextIndex > this.nrrd_states.maxIndex)
|
|
1377
|
+
return;
|
|
1378
|
+
if (preIndex === nextIndex) {
|
|
1379
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
1380
|
+
this.drawImageOnEmptyImage(canvas);
|
|
1381
|
+
this.storeAllImages(preIndex, "");
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - i);
|
|
1385
|
+
this.drawImageOnEmptyImage(canvas);
|
|
1386
|
+
this.storeAllImages(preIndex, "");
|
|
1387
|
+
this.storeAllImages(nextIndex, "");
|
|
1388
|
+
}
|
|
1389
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
console.log(this.nrrd_states.sphereRadius);
|
|
1393
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
1250
1394
|
}
|
|
1251
1395
|
}
|
|
1252
1396
|
else if (e.button === 2) {
|
|
1253
1397
|
rightclicked = false;
|
|
1254
1398
|
this.drawingCanvas.style.cursor = "grab";
|
|
1255
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
1399
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
1256
1400
|
}
|
|
1257
1401
|
else {
|
|
1258
1402
|
return;
|
|
1259
1403
|
}
|
|
1260
|
-
// add wheel after pointer up
|
|
1261
|
-
this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
|
|
1262
|
-
passive: false,
|
|
1263
|
-
});
|
|
1264
1404
|
if (!this.gui_states.segmentation) {
|
|
1265
1405
|
this.setIsDrawFalse(100);
|
|
1266
1406
|
}
|
|
@@ -1271,12 +1411,13 @@ export class nrrd_tools {
|
|
|
1271
1411
|
if (leftclicked) {
|
|
1272
1412
|
leftclicked = false;
|
|
1273
1413
|
this.drawingLayerMasterCtx.closePath();
|
|
1274
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
1414
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
|
|
1415
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
|
|
1275
1416
|
}
|
|
1276
1417
|
if (rightclicked) {
|
|
1277
1418
|
rightclicked = false;
|
|
1278
1419
|
this.drawingCanvas.style.cursor = "grab";
|
|
1279
|
-
this.drawingCanvas.removeEventListener("pointermove",
|
|
1420
|
+
this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
|
|
1280
1421
|
}
|
|
1281
1422
|
this.setIsDrawFalse(100);
|
|
1282
1423
|
if (this.gui_states.segmentation) {
|
|
@@ -1331,6 +1472,68 @@ export class nrrd_tools {
|
|
|
1331
1472
|
}
|
|
1332
1473
|
});
|
|
1333
1474
|
}
|
|
1475
|
+
enableCrosshair() {
|
|
1476
|
+
this.nrrd_states.isCursorSelect = true;
|
|
1477
|
+
switch (this.axis) {
|
|
1478
|
+
case "x":
|
|
1479
|
+
this.cursorPage.x.updated = true;
|
|
1480
|
+
this.cursorPage.y.updated = false;
|
|
1481
|
+
this.cursorPage.z.updated = false;
|
|
1482
|
+
break;
|
|
1483
|
+
case "y":
|
|
1484
|
+
this.cursorPage.x.updated = false;
|
|
1485
|
+
this.cursorPage.y.updated = true;
|
|
1486
|
+
this.cursorPage.z.updated = false;
|
|
1487
|
+
break;
|
|
1488
|
+
case "z":
|
|
1489
|
+
this.cursorPage.x.updated = false;
|
|
1490
|
+
this.cursorPage.y.updated = false;
|
|
1491
|
+
this.cursorPage.z.updated = true;
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
setUpSphereOrigins(mouseX, mouseY) {
|
|
1496
|
+
const convertCursor = (from, to) => {
|
|
1497
|
+
const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
|
|
1498
|
+
return {
|
|
1499
|
+
convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
|
|
1500
|
+
convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
|
|
1501
|
+
currentIndex: convertObj === null || convertObj === void 0 ? void 0 : convertObj.currentIndex,
|
|
1502
|
+
};
|
|
1503
|
+
};
|
|
1504
|
+
const axisConversions = {
|
|
1505
|
+
x: { axisTo1: "y", axisTo2: "z" },
|
|
1506
|
+
y: { axisTo1: "z", axisTo2: "x" },
|
|
1507
|
+
z: { axisTo1: "x", axisTo2: "y" },
|
|
1508
|
+
};
|
|
1509
|
+
const { axisTo1, axisTo2 } = axisConversions[this.axis];
|
|
1510
|
+
this.nrrd_states.sphereOrigin[axisTo1] = [
|
|
1511
|
+
convertCursor(this.axis, axisTo1).convertCursorNumX,
|
|
1512
|
+
convertCursor(this.axis, axisTo1).convertCursorNumY,
|
|
1513
|
+
convertCursor(this.axis, axisTo1).currentIndex,
|
|
1514
|
+
];
|
|
1515
|
+
this.nrrd_states.sphereOrigin[axisTo2] = [
|
|
1516
|
+
convertCursor(this.axis, axisTo2).convertCursorNumX,
|
|
1517
|
+
convertCursor(this.axis, axisTo2).convertCursorNumY,
|
|
1518
|
+
convertCursor(this.axis, axisTo2).currentIndex,
|
|
1519
|
+
];
|
|
1520
|
+
}
|
|
1521
|
+
// for sphere
|
|
1522
|
+
drawSphereCore(ctx, x, y, radius) {
|
|
1523
|
+
ctx.beginPath();
|
|
1524
|
+
ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
|
|
1525
|
+
ctx.fillStyle = this.gui_states.fillColor;
|
|
1526
|
+
ctx.fill();
|
|
1527
|
+
ctx.closePath();
|
|
1528
|
+
}
|
|
1529
|
+
drawSphere(mouseX, mouseY, radius) {
|
|
1530
|
+
let { ctx, canvas } = this.setCurrentLayer();
|
|
1531
|
+
// clear canvas
|
|
1532
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1533
|
+
this.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
|
|
1534
|
+
this.drawSphereCore(ctx, mouseX, mouseY, radius);
|
|
1535
|
+
this.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
1536
|
+
}
|
|
1334
1537
|
// need to update
|
|
1335
1538
|
undoLastPainting() {
|
|
1336
1539
|
let { ctx, canvas } = this.setCurrentLayer();
|
|
@@ -1348,7 +1551,9 @@ export class nrrd_tools {
|
|
|
1348
1551
|
if (layerLen > 0) {
|
|
1349
1552
|
// const imageSrc = undo.undos[undo.undos.length - 1];
|
|
1350
1553
|
const image = layerUndos[layerLen - 1];
|
|
1351
|
-
|
|
1554
|
+
if (!!image) {
|
|
1555
|
+
ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
|
|
1556
|
+
}
|
|
1352
1557
|
}
|
|
1353
1558
|
if (undo.layers.label1.length > 0) {
|
|
1354
1559
|
const image = undo.layers.label1[undo.layers.label1.length - 1];
|
|
@@ -1372,9 +1577,29 @@ export class nrrd_tools {
|
|
|
1372
1577
|
return item.sliceIndex === this.nrrd_states.currentIndex;
|
|
1373
1578
|
});
|
|
1374
1579
|
}
|
|
1375
|
-
|
|
1580
|
+
// drawing canvas mouse shpere wheel
|
|
1581
|
+
configMouseSphereWheel() {
|
|
1582
|
+
const sphereEvent = (e) => {
|
|
1583
|
+
e.preventDefault();
|
|
1584
|
+
if (e.deltaY < 0) {
|
|
1585
|
+
this.nrrd_states.sphereRadius += 1;
|
|
1586
|
+
}
|
|
1587
|
+
else {
|
|
1588
|
+
this.nrrd_states.sphereRadius -= 1;
|
|
1589
|
+
}
|
|
1590
|
+
// limited the radius max and min
|
|
1591
|
+
this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
|
|
1592
|
+
// get mouse position
|
|
1593
|
+
const mouseX = e.offsetX;
|
|
1594
|
+
const mouseY = e.offsetY;
|
|
1595
|
+
this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
|
|
1596
|
+
};
|
|
1597
|
+
return sphereEvent;
|
|
1598
|
+
}
|
|
1599
|
+
// drawing canvas mouse zoom wheel
|
|
1600
|
+
configMouseZoomWheel(controls) {
|
|
1376
1601
|
let moveDistance = 1;
|
|
1377
|
-
const
|
|
1602
|
+
const handleZoomWheelMove = (e) => {
|
|
1378
1603
|
if (this.Is_Shift_Pressed) {
|
|
1379
1604
|
return;
|
|
1380
1605
|
}
|
|
@@ -1410,7 +1635,7 @@ export class nrrd_tools {
|
|
|
1410
1635
|
}
|
|
1411
1636
|
this.nrrd_states.sizeFoctor = moveDistance;
|
|
1412
1637
|
};
|
|
1413
|
-
return
|
|
1638
|
+
return handleZoomWheelMove;
|
|
1414
1639
|
}
|
|
1415
1640
|
useEraser() {
|
|
1416
1641
|
const clearArc = (x, y, radius) => {
|
|
@@ -1521,155 +1746,6 @@ export class nrrd_tools {
|
|
|
1521
1746
|
}
|
|
1522
1747
|
return { ctx, canvas };
|
|
1523
1748
|
}
|
|
1524
|
-
configGui(modeFolder) {
|
|
1525
|
-
if (modeFolder.__controllers.length > 0)
|
|
1526
|
-
this.removeGuiFolderChilden(modeFolder);
|
|
1527
|
-
modeFolder.open();
|
|
1528
|
-
const actionsFolder = modeFolder.addFolder("Default Actions");
|
|
1529
|
-
actionsFolder
|
|
1530
|
-
.add(this.gui_states, "label", ["label1", "label2", "label3"])
|
|
1531
|
-
.onChange((val) => {
|
|
1532
|
-
if (val === "label1") {
|
|
1533
|
-
this.gui_states.fillColor = "#00ff00";
|
|
1534
|
-
this.gui_states.brushColor = "#00ff00";
|
|
1535
|
-
}
|
|
1536
|
-
else if (val === "label2") {
|
|
1537
|
-
this.gui_states.fillColor = "#ff0000";
|
|
1538
|
-
this.gui_states.brushColor = "#ff0000";
|
|
1539
|
-
}
|
|
1540
|
-
else if (val === "label3") {
|
|
1541
|
-
this.gui_states.fillColor = "#0000ff";
|
|
1542
|
-
this.gui_states.brushColor = "#0000ff";
|
|
1543
|
-
}
|
|
1544
|
-
});
|
|
1545
|
-
actionsFolder
|
|
1546
|
-
.add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
|
|
1547
|
-
.name("cursor icons")
|
|
1548
|
-
.onChange((value) => {
|
|
1549
|
-
if (value === "crosshair") {
|
|
1550
|
-
this.nrrd_states.defaultPaintCursor = "crosshair";
|
|
1551
|
-
}
|
|
1552
|
-
if (value === "pencil") {
|
|
1553
|
-
this.nrrd_states.defaultPaintCursor =
|
|
1554
|
-
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
|
|
1555
|
-
}
|
|
1556
|
-
if (value === "dot") {
|
|
1557
|
-
this.nrrd_states.defaultPaintCursor =
|
|
1558
|
-
"url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
|
|
1559
|
-
}
|
|
1560
|
-
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
1561
|
-
});
|
|
1562
|
-
actionsFolder
|
|
1563
|
-
.add(this.gui_states, "mainAreaSize")
|
|
1564
|
-
.name("zoom")
|
|
1565
|
-
.min(1)
|
|
1566
|
-
.max(8)
|
|
1567
|
-
.onFinishChange((factor) => {
|
|
1568
|
-
this.resetPaintArea();
|
|
1569
|
-
this.nrrd_states.sizeFoctor = factor;
|
|
1570
|
-
this.resizePaintArea(factor);
|
|
1571
|
-
});
|
|
1572
|
-
actionsFolder.add(this.gui_states, "resetZoom");
|
|
1573
|
-
actionsFolder
|
|
1574
|
-
.add(this.gui_states, "globalAlpha")
|
|
1575
|
-
.name("opacity")
|
|
1576
|
-
.min(0.1)
|
|
1577
|
-
.max(1)
|
|
1578
|
-
.step(0.01);
|
|
1579
|
-
actionsFolder.add(this.gui_states, "segmentation").name("Pencil");
|
|
1580
|
-
actionsFolder
|
|
1581
|
-
.add(this.gui_states, "brushAndEraserSize")
|
|
1582
|
-
.min(5)
|
|
1583
|
-
.max(50)
|
|
1584
|
-
.step(1)
|
|
1585
|
-
.onChange(() => {
|
|
1586
|
-
if (this.gui_states.Eraser) {
|
|
1587
|
-
this.eraserUrls.length > 0
|
|
1588
|
-
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
1589
|
-
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
1590
|
-
}
|
|
1591
|
-
});
|
|
1592
|
-
actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
|
|
1593
|
-
this.gui_states.Eraser = value;
|
|
1594
|
-
if (this.gui_states.Eraser) {
|
|
1595
|
-
this.eraserUrls.length > 0
|
|
1596
|
-
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
1597
|
-
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
1598
|
-
}
|
|
1599
|
-
else {
|
|
1600
|
-
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
1601
|
-
}
|
|
1602
|
-
});
|
|
1603
|
-
actionsFolder.add(this.gui_states, "clear");
|
|
1604
|
-
actionsFolder.add(this.gui_states, "clearAll");
|
|
1605
|
-
actionsFolder.add(this.gui_states, "undo");
|
|
1606
|
-
actionsFolder
|
|
1607
|
-
.add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
1608
|
-
.name("Image contrast")
|
|
1609
|
-
.onChange((value) => {
|
|
1610
|
-
this.nrrd_states.readyToUpdate = false;
|
|
1611
|
-
this.updateSlicesContrast(value, "windowHigh");
|
|
1612
|
-
})
|
|
1613
|
-
.onFinishChange(() => {
|
|
1614
|
-
this.repraintAllContrastSlices();
|
|
1615
|
-
this.nrrd_states.readyToUpdate = true;
|
|
1616
|
-
});
|
|
1617
|
-
actionsFolder.add(this.gui_states, "exportMarks");
|
|
1618
|
-
const advanceFolder = modeFolder.addFolder("Advance settings");
|
|
1619
|
-
advanceFolder
|
|
1620
|
-
.add(this.gui_states, "dragSensitivity")
|
|
1621
|
-
.min(1)
|
|
1622
|
-
.max(this.nrrd_states.Max_sensitive)
|
|
1623
|
-
.step(1);
|
|
1624
|
-
const segmentationFolder = advanceFolder.addFolder("Pencil settings");
|
|
1625
|
-
segmentationFolder
|
|
1626
|
-
.add(this.gui_states, "lineWidth")
|
|
1627
|
-
.name("outerLineWidth")
|
|
1628
|
-
.min(1.7)
|
|
1629
|
-
.max(3)
|
|
1630
|
-
.step(0.01);
|
|
1631
|
-
segmentationFolder.addColor(this.gui_states, "color");
|
|
1632
|
-
segmentationFolder.addColor(this.gui_states, "fillColor");
|
|
1633
|
-
const bushFolder = advanceFolder.addFolder("Brush settings");
|
|
1634
|
-
bushFolder.addColor(this.gui_states, "brushColor");
|
|
1635
|
-
// modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
|
|
1636
|
-
advanceFolder.add(this.gui_states, "downloadCurrentMask");
|
|
1637
|
-
const contrastFolder = advanceFolder.addFolder("contrast advance settings");
|
|
1638
|
-
contrastFolder
|
|
1639
|
-
.add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
1640
|
-
.name("Lower Threshold")
|
|
1641
|
-
.onChange((value) => {
|
|
1642
|
-
this.nrrd_states.readyToUpdate = false;
|
|
1643
|
-
this.updateSlicesContrast(value, "lowerThreshold");
|
|
1644
|
-
})
|
|
1645
|
-
.onFinishChange(() => {
|
|
1646
|
-
this.repraintAllContrastSlices();
|
|
1647
|
-
this.nrrd_states.readyToUpdate = true;
|
|
1648
|
-
});
|
|
1649
|
-
contrastFolder
|
|
1650
|
-
.add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
1651
|
-
.name("Upper Threshold")
|
|
1652
|
-
.onChange((value) => {
|
|
1653
|
-
this.nrrd_states.readyToUpdate = false;
|
|
1654
|
-
this.updateSlicesContrast(value, "upperThreshold");
|
|
1655
|
-
})
|
|
1656
|
-
.onFinishChange(() => {
|
|
1657
|
-
this.repraintAllContrastSlices();
|
|
1658
|
-
this.nrrd_states.readyToUpdate = true;
|
|
1659
|
-
});
|
|
1660
|
-
contrastFolder
|
|
1661
|
-
.add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
1662
|
-
.name("Window Low")
|
|
1663
|
-
.onChange((value) => {
|
|
1664
|
-
this.nrrd_states.readyToUpdate = false;
|
|
1665
|
-
this.updateSlicesContrast(value, "windowLow");
|
|
1666
|
-
})
|
|
1667
|
-
.onFinishChange(() => {
|
|
1668
|
-
this.repraintAllContrastSlices();
|
|
1669
|
-
this.nrrd_states.readyToUpdate = true;
|
|
1670
|
-
});
|
|
1671
|
-
actionsFolder.open();
|
|
1672
|
-
}
|
|
1673
1749
|
updateSlicesContrast(value, flag) {
|
|
1674
1750
|
switch (flag) {
|
|
1675
1751
|
case "lowerThreshold":
|
|
@@ -1848,12 +1924,15 @@ export class nrrd_tools {
|
|
|
1848
1924
|
delete dic[key];
|
|
1849
1925
|
}
|
|
1850
1926
|
}
|
|
1927
|
+
drawImageOnEmptyImage(canvas) {
|
|
1928
|
+
this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
1929
|
+
}
|
|
1851
1930
|
storeAllImages(index, label) {
|
|
1852
1931
|
// const image: HTMLImageElement = new Image();
|
|
1853
1932
|
// resize the drawing image data
|
|
1854
|
-
if (!this.nrrd_states.loadMaskJson) {
|
|
1933
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
1855
1934
|
this.setEmptyCanvasSize();
|
|
1856
|
-
this.
|
|
1935
|
+
this.drawImageOnEmptyImage(this.drawingCanvasLayerMaster);
|
|
1857
1936
|
}
|
|
1858
1937
|
let imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
1859
1938
|
// 1.12.23
|
|
@@ -1923,7 +2002,7 @@ export class nrrd_tools {
|
|
|
1923
2002
|
break;
|
|
1924
2003
|
}
|
|
1925
2004
|
this.storeImageToAxis(index, this.paintImages, imageData);
|
|
1926
|
-
if (!this.nrrd_states.loadMaskJson) {
|
|
2005
|
+
if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
|
|
1927
2006
|
this.storeEachLayerImage(index, label);
|
|
1928
2007
|
}
|
|
1929
2008
|
}
|
|
@@ -1958,7 +2037,7 @@ export class nrrd_tools {
|
|
|
1958
2037
|
storeImageToLabel(index, canvas, paintedImages) {
|
|
1959
2038
|
if (!this.nrrd_states.loadMaskJson) {
|
|
1960
2039
|
this.setEmptyCanvasSize();
|
|
1961
|
-
this.
|
|
2040
|
+
this.drawImageOnEmptyImage(canvas);
|
|
1962
2041
|
}
|
|
1963
2042
|
const imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
|
|
1964
2043
|
this.storeImageToAxis(index, paintedImages, imageData);
|
|
@@ -2181,5 +2260,181 @@ export class nrrd_tools {
|
|
|
2181
2260
|
// }
|
|
2182
2261
|
// };
|
|
2183
2262
|
}
|
|
2263
|
+
configGui(modeFolder) {
|
|
2264
|
+
if (modeFolder.__controllers.length > 0)
|
|
2265
|
+
this.removeGuiFolderChilden(modeFolder);
|
|
2266
|
+
modeFolder.open();
|
|
2267
|
+
const actionsFolder = modeFolder.addFolder("Default Actions");
|
|
2268
|
+
actionsFolder
|
|
2269
|
+
.add(this.gui_states, "label", ["label1", "label2", "label3"])
|
|
2270
|
+
.onChange((val) => {
|
|
2271
|
+
if (val === "label1") {
|
|
2272
|
+
this.gui_states.fillColor = "#00ff00";
|
|
2273
|
+
this.gui_states.brushColor = "#00ff00";
|
|
2274
|
+
}
|
|
2275
|
+
else if (val === "label2") {
|
|
2276
|
+
this.gui_states.fillColor = "#ff0000";
|
|
2277
|
+
this.gui_states.brushColor = "#ff0000";
|
|
2278
|
+
}
|
|
2279
|
+
else if (val === "label3") {
|
|
2280
|
+
this.gui_states.fillColor = "#0000ff";
|
|
2281
|
+
this.gui_states.brushColor = "#0000ff";
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
actionsFolder
|
|
2285
|
+
.add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
|
|
2286
|
+
.name("cursor icons")
|
|
2287
|
+
.onChange((value) => {
|
|
2288
|
+
if (value === "crosshair") {
|
|
2289
|
+
this.nrrd_states.defaultPaintCursor = "crosshair";
|
|
2290
|
+
}
|
|
2291
|
+
if (value === "pencil") {
|
|
2292
|
+
this.nrrd_states.defaultPaintCursor =
|
|
2293
|
+
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
|
|
2294
|
+
}
|
|
2295
|
+
if (value === "dot") {
|
|
2296
|
+
this.nrrd_states.defaultPaintCursor =
|
|
2297
|
+
"url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
|
|
2298
|
+
}
|
|
2299
|
+
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
2300
|
+
});
|
|
2301
|
+
actionsFolder
|
|
2302
|
+
.add(this.gui_states, "mainAreaSize")
|
|
2303
|
+
.name("zoom")
|
|
2304
|
+
.min(1)
|
|
2305
|
+
.max(8)
|
|
2306
|
+
.onFinishChange((factor) => {
|
|
2307
|
+
this.resetPaintArea();
|
|
2308
|
+
this.nrrd_states.sizeFoctor = factor;
|
|
2309
|
+
this.resizePaintArea(factor);
|
|
2310
|
+
});
|
|
2311
|
+
actionsFolder.add(this.gui_states, "resetZoom");
|
|
2312
|
+
actionsFolder
|
|
2313
|
+
.add(this.gui_states, "globalAlpha")
|
|
2314
|
+
.name("opacity")
|
|
2315
|
+
.min(0.1)
|
|
2316
|
+
.max(1)
|
|
2317
|
+
.step(0.01);
|
|
2318
|
+
actionsFolder
|
|
2319
|
+
.add(this.gui_states, "segmentation")
|
|
2320
|
+
.name("Pencil")
|
|
2321
|
+
.onChange(() => {
|
|
2322
|
+
if (this.gui_states.segmentation) {
|
|
2323
|
+
// add canvas brush circle move event listeners
|
|
2324
|
+
this.drawingCanvas.removeEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
2325
|
+
this.drawingCanvas.removeEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
2326
|
+
}
|
|
2327
|
+
else {
|
|
2328
|
+
// add canvas brush circle move event listeners
|
|
2329
|
+
this.drawingCanvas.addEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
2330
|
+
this.drawingCanvas.addEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
|
|
2331
|
+
}
|
|
2332
|
+
});
|
|
2333
|
+
actionsFolder
|
|
2334
|
+
.add(this.gui_states, "sphere")
|
|
2335
|
+
.name("Sphere")
|
|
2336
|
+
.onChange(() => {
|
|
2337
|
+
if (this.gui_states.sphere) {
|
|
2338
|
+
this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
2339
|
+
this.removeDragMode();
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
|
|
2343
|
+
this.configDragMode();
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
actionsFolder
|
|
2347
|
+
.add(this.gui_states, "brushAndEraserSize")
|
|
2348
|
+
.min(5)
|
|
2349
|
+
.max(50)
|
|
2350
|
+
.step(1)
|
|
2351
|
+
.onChange(() => {
|
|
2352
|
+
if (this.gui_states.Eraser) {
|
|
2353
|
+
this.eraserUrls.length > 0
|
|
2354
|
+
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
2355
|
+
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
2356
|
+
}
|
|
2357
|
+
});
|
|
2358
|
+
actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
|
|
2359
|
+
this.gui_states.Eraser = value;
|
|
2360
|
+
if (this.gui_states.Eraser) {
|
|
2361
|
+
this.eraserUrls.length > 0
|
|
2362
|
+
? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
|
|
2363
|
+
: (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
|
|
2364
|
+
}
|
|
2365
|
+
else {
|
|
2366
|
+
this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
actionsFolder.add(this.gui_states, "clear");
|
|
2370
|
+
actionsFolder.add(this.gui_states, "clearAll");
|
|
2371
|
+
actionsFolder.add(this.gui_states, "undo");
|
|
2372
|
+
actionsFolder
|
|
2373
|
+
.add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
2374
|
+
.name("Image contrast")
|
|
2375
|
+
.onChange((value) => {
|
|
2376
|
+
this.nrrd_states.readyToUpdate = false;
|
|
2377
|
+
this.updateSlicesContrast(value, "windowHigh");
|
|
2378
|
+
})
|
|
2379
|
+
.onFinishChange(() => {
|
|
2380
|
+
this.repraintAllContrastSlices();
|
|
2381
|
+
this.nrrd_states.readyToUpdate = true;
|
|
2382
|
+
});
|
|
2383
|
+
actionsFolder.add(this.gui_states, "exportMarks");
|
|
2384
|
+
const advanceFolder = modeFolder.addFolder("Advance settings");
|
|
2385
|
+
advanceFolder
|
|
2386
|
+
.add(this.gui_states, "dragSensitivity")
|
|
2387
|
+
.min(1)
|
|
2388
|
+
.max(this.nrrd_states.Max_sensitive)
|
|
2389
|
+
.step(1);
|
|
2390
|
+
const segmentationFolder = advanceFolder.addFolder("Pencil settings");
|
|
2391
|
+
segmentationFolder
|
|
2392
|
+
.add(this.gui_states, "lineWidth")
|
|
2393
|
+
.name("outerLineWidth")
|
|
2394
|
+
.min(1.7)
|
|
2395
|
+
.max(3)
|
|
2396
|
+
.step(0.01);
|
|
2397
|
+
segmentationFolder.addColor(this.gui_states, "color");
|
|
2398
|
+
segmentationFolder.addColor(this.gui_states, "fillColor");
|
|
2399
|
+
const bushFolder = advanceFolder.addFolder("Brush settings");
|
|
2400
|
+
bushFolder.addColor(this.gui_states, "brushColor");
|
|
2401
|
+
// modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
|
|
2402
|
+
advanceFolder.add(this.gui_states, "downloadCurrentMask");
|
|
2403
|
+
const contrastFolder = advanceFolder.addFolder("contrast advance settings");
|
|
2404
|
+
contrastFolder
|
|
2405
|
+
.add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
2406
|
+
.name("Lower Threshold")
|
|
2407
|
+
.onChange((value) => {
|
|
2408
|
+
this.nrrd_states.readyToUpdate = false;
|
|
2409
|
+
this.updateSlicesContrast(value, "lowerThreshold");
|
|
2410
|
+
})
|
|
2411
|
+
.onFinishChange(() => {
|
|
2412
|
+
this.repraintAllContrastSlices();
|
|
2413
|
+
this.nrrd_states.readyToUpdate = true;
|
|
2414
|
+
});
|
|
2415
|
+
contrastFolder
|
|
2416
|
+
.add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
2417
|
+
.name("Upper Threshold")
|
|
2418
|
+
.onChange((value) => {
|
|
2419
|
+
this.nrrd_states.readyToUpdate = false;
|
|
2420
|
+
this.updateSlicesContrast(value, "upperThreshold");
|
|
2421
|
+
})
|
|
2422
|
+
.onFinishChange(() => {
|
|
2423
|
+
this.repraintAllContrastSlices();
|
|
2424
|
+
this.nrrd_states.readyToUpdate = true;
|
|
2425
|
+
});
|
|
2426
|
+
contrastFolder
|
|
2427
|
+
.add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
|
|
2428
|
+
.name("Window Low")
|
|
2429
|
+
.onChange((value) => {
|
|
2430
|
+
this.nrrd_states.readyToUpdate = false;
|
|
2431
|
+
this.updateSlicesContrast(value, "windowLow");
|
|
2432
|
+
})
|
|
2433
|
+
.onFinishChange(() => {
|
|
2434
|
+
this.repraintAllContrastSlices();
|
|
2435
|
+
this.nrrd_states.readyToUpdate = true;
|
|
2436
|
+
});
|
|
2437
|
+
actionsFolder.open();
|
|
2438
|
+
}
|
|
2184
2439
|
}
|
|
2185
2440
|
//# sourceMappingURL=nrrd_tool.js.map
|