copper3d 1.15.11 → 1.15.13

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.
@@ -67648,6 +67648,7 @@
67648
67648
  label2: this.paintImagesLabel2,
67649
67649
  label3: this.paintImagesLabel3,
67650
67650
  };
67651
+ // used to store display marks with multiple labels
67651
67652
  this.paintImages = { x: [], y: [], z: [] };
67652
67653
  // store all contrast slices, include x, y, z orientation
67653
67654
  this.allSlicesArray = [];
@@ -67675,7 +67676,6 @@
67675
67676
  this.Is_Shift_Pressed = false;
67676
67677
  this.Is_Draw = false;
67677
67678
  this.sensitiveArray = [];
67678
- this.handleWheelMove = () => { };
67679
67679
  this.start = () => { };
67680
67680
  this.undoArray = [];
67681
67681
  this.initState = true;
@@ -67711,6 +67711,10 @@
67711
67711
  isCursorSelect: false,
67712
67712
  cursorPageX: 0,
67713
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,
67714
67718
  Mouse_Over_x: 0,
67715
67719
  Mouse_Over_y: 0,
67716
67720
  Mouse_Over: false,
@@ -67760,12 +67764,9 @@
67760
67764
  brushAndEraserSize: 15,
67761
67765
  cursor: "dot",
67762
67766
  label: "label1",
67767
+ sphere: false,
67763
67768
  // EraserSize: 25,
67764
67769
  clear: () => {
67765
- // const text = "Are you sure remove annotations on Current slice?";
67766
- // if (confirm(text) === true) {
67767
- // this.clearPaint();
67768
- // }
67769
67770
  this.clearPaint();
67770
67771
  },
67771
67772
  clearAll: () => {
@@ -67799,6 +67800,36 @@
67799
67800
  this.exportData();
67800
67801
  },
67801
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
+ };
67802
67833
  this.drawLine = (x1, y1, x2, y2) => {
67803
67834
  this.drawingCtx.beginPath();
67804
67835
  this.drawingCtx.moveTo(x1, y1);
@@ -67831,7 +67862,7 @@
67831
67862
  this.sensitiveArray.push((i + 1) / 20);
67832
67863
  }
67833
67864
  this.container.addEventListener("keydown", (ev) => {
67834
- if (ev.key === "Shift") {
67865
+ if (ev.key === "Shift" && !this.gui_states.sphere) {
67835
67866
  this.Is_Shift_Pressed = true;
67836
67867
  this.nrrd_states.enableCursorChoose = false;
67837
67868
  }
@@ -68011,12 +68042,94 @@
68011
68042
  paintImages.z.push(initMark_z);
68012
68043
  }
68013
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
+ }
68014
68126
  /**
68015
68127
  * Switch all contrast slices' orientation
68016
68128
  * @param {string} aixs:"x" | "y" | "z"
68017
68129
  * */
68018
- setSliceOrientation(axis) {
68019
- if (this.nrrd_states.enableCursorChoose) {
68130
+ setSliceOrientation(axisTo) {
68131
+ let convetObj;
68132
+ if (this.nrrd_states.enableCursorChoose || this.gui_states.sphere) {
68020
68133
  if (this.axis === "z") {
68021
68134
  this.cursorPage.z.index = this.nrrd_states.currentIndex;
68022
68135
  this.cursorPage.z.cursorPageX = this.nrrd_states.cursorPageX;
@@ -68032,27 +68145,19 @@
68032
68145
  this.cursorPage.y.cursorPageX = this.nrrd_states.cursorPageX;
68033
68146
  this.cursorPage.y.cursorPageY = this.nrrd_states.cursorPageY;
68034
68147
  }
68035
- if (axis === "z") {
68148
+ if (axisTo === "z") {
68036
68149
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.z.updated) {
68037
68150
  if (this.axis === "x") {
68038
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.x.cursorPageX / this.nrrd_states.nrrd_z_mm) *
68039
- this.nrrd_states.dimensions[2]);
68040
- this.nrrd_states.oldIndex =
68041
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
68042
- this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
68043
- 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);
68044
68153
  }
68045
68154
  if (this.axis === "y") {
68046
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.y.cursorPageY / this.nrrd_states.nrrd_z_mm) *
68047
- this.nrrd_states.dimensions[2]);
68048
- this.nrrd_states.oldIndex =
68049
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
68050
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
68051
- 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);
68052
68157
  }
68053
- this.cursorPage.z.updated = true;
68054
68158
  }
68055
68159
  else {
68160
+ // not cursor select, freedom to switch x -> z or y -> z and z -> x or z -> y
68056
68161
  this.nrrd_states.currentIndex = this.cursorPage.z.index;
68057
68162
  this.nrrd_states.oldIndex =
68058
68163
  this.cursorPage.z.index * this.nrrd_states.ratios.z;
@@ -68060,28 +68165,19 @@
68060
68165
  this.nrrd_states.cursorPageY = this.cursorPage.z.cursorPageY;
68061
68166
  }
68062
68167
  }
68063
- else if (axis === "x") {
68168
+ else if (axisTo === "x") {
68064
68169
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.x.updated) {
68065
68170
  if (this.axis === "z") {
68066
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.z.cursorPageX / this.nrrd_states.nrrd_x_mm) *
68067
- this.nrrd_states.dimensions[0]);
68068
- this.nrrd_states.oldIndex =
68069
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
68070
- this.nrrd_states.cursorPageX = Math.floor((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
68071
- 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);
68072
68173
  }
68073
68174
  if (this.axis === "y") {
68074
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.y.cursorPageX / this.nrrd_states.nrrd_y_mm) *
68075
- this.nrrd_states.dimensions[1]);
68076
- this.nrrd_states.oldIndex =
68077
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
68078
- this.nrrd_states.cursorPageX = this.cursorPage.y.cursorPageY;
68079
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
68080
- 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);
68081
68177
  }
68082
- this.cursorPage.x.updated = true;
68083
68178
  }
68084
68179
  else {
68180
+ // not cursor select, freedom to switch z -> x or y -> x and x -> z or x -> y
68085
68181
  this.nrrd_states.currentIndex = this.cursorPage.x.index;
68086
68182
  this.nrrd_states.oldIndex =
68087
68183
  this.cursorPage.x.index * this.nrrd_states.ratios.x;
@@ -68089,28 +68185,19 @@
68089
68185
  this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageY;
68090
68186
  }
68091
68187
  }
68092
- else if (axis === "y") {
68188
+ else if (axisTo === "y") {
68093
68189
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.y.updated) {
68094
68190
  if (this.axis === "z") {
68095
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.z.cursorPageY / this.nrrd_states.nrrd_y_mm) *
68096
- this.nrrd_states.dimensions[1]);
68097
- this.nrrd_states.oldIndex =
68098
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
68099
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
68100
- 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);
68101
68193
  }
68102
68194
  if (this.axis === "x") {
68103
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.x.cursorPageY / this.nrrd_states.nrrd_x_mm) *
68104
- this.nrrd_states.dimensions[0]);
68105
- this.nrrd_states.oldIndex =
68106
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
68107
- this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
68108
- this.nrrd_states.nrrd_x_mm);
68109
- 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);
68110
68197
  }
68111
- this.cursorPage.y.updated = true;
68112
68198
  }
68113
68199
  else {
68200
+ // not cursor select, freedom to switch z -> y or x -> y and y -> z or y -> x
68114
68201
  this.nrrd_states.currentIndex = this.cursorPage.y.index;
68115
68202
  this.nrrd_states.oldIndex =
68116
68203
  this.cursorPage.y.index * this.nrrd_states.ratios.y;
@@ -68118,14 +68205,38 @@
68118
68205
  this.nrrd_states.cursorPageY = this.cursorPage.y.cursorPageY;
68119
68206
  }
68120
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
+ }
68121
68227
  if (this.cursorPage.x.updated &&
68122
68228
  this.cursorPage.y.updated &&
68123
68229
  this.cursorPage.z.updated) {
68230
+ // one point convert to all axis, reset all updated status
68124
68231
  this.nrrd_states.isCursorSelect = false;
68125
68232
  }
68126
68233
  }
68127
- this.axis = axis;
68234
+ this.axis = axisTo;
68128
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
+ }
68129
68240
  }
68130
68241
  addSkip(index) {
68131
68242
  this.skipSlicesDic[index] = this.backUpDisplaySlices[index];
@@ -68451,62 +68562,51 @@
68451
68562
  this.mainAreaContainer.appendChild(loadingbar);
68452
68563
  }
68453
68564
  drag(opts) {
68454
- let move;
68455
- let y;
68456
- let h = this.container.offsetHeight;
68457
- let sensivity = 1;
68458
- let handleOnMouseUp;
68459
- let handleOnMouseDown;
68460
- let handleOnMouseMove;
68565
+ this.dragPrameters.h = this.container.offsetHeight;
68461
68566
  this.sensitiveArray.reverse();
68462
68567
  if (opts === null || opts === void 0 ? void 0 : opts.showNumber) {
68463
68568
  this.container.appendChild(this.showDragNumberDiv);
68464
68569
  }
68465
- handleOnMouseDown = (ev) => {
68570
+ this.dragPrameters.handleOnDragMouseDown = (ev) => {
68466
68571
  // before start drag event, remove wheel event.
68467
- this.drawingCanvas.removeEventListener("wheel", this.handleWheelMove);
68572
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68468
68573
  if (ev.button === 0) {
68469
68574
  // this.setSyncsliceNum();
68470
- y = ev.offsetY / h;
68471
- this.container.addEventListener("pointermove", handleOnMouseMove, false);
68472
- sensivity = this.sensitiveArray[this.gui_states.dragSensitivity - 1];
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];
68473
68579
  }
68474
68580
  };
68475
- handleOnMouseMove = throttle((ev) => {
68476
- if (y - ev.offsetY / h >= 0) {
68477
- move = -Math.ceil(((y - ev.offsetY / h) * 10) / sensivity);
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);
68478
68585
  }
68479
68586
  else {
68480
- move = -Math.floor(((y - ev.offsetY / h) * 10) / sensivity);
68587
+ this.dragPrameters.move = -Math.floor(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
68588
+ this.dragPrameters.sensivity);
68481
68589
  }
68482
- this.updateIndex(move);
68590
+ this.updateIndex(this.dragPrameters.move);
68483
68591
  (opts === null || opts === void 0 ? void 0 : opts.getSliceNum) &&
68484
68592
  opts.getSliceNum(this.nrrd_states.currentIndex, this.nrrd_states.contrastNum);
68485
- y = ev.offsetY / h;
68486
- }, sensivity * 200);
68487
- handleOnMouseUp = (ev) => {
68593
+ this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
68594
+ }, this.dragPrameters.sensivity * 200);
68595
+ this.dragPrameters.handleOnDragMouseUp = (ev) => {
68488
68596
  // after drag, add the wheel event
68489
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove);
68597
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68490
68598
  this.setSyncsliceNum();
68491
- this.container.removeEventListener("pointermove", handleOnMouseMove, false);
68492
- };
68493
- const configDragMode = () => {
68494
- this.container.style.cursor = "pointer";
68495
- this.container.addEventListener("pointerdown", handleOnMouseDown, true);
68496
- this.container.addEventListener("pointerup", handleOnMouseUp, true);
68599
+ this.container.removeEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
68497
68600
  };
68498
- configDragMode();
68601
+ this.configDragMode();
68499
68602
  this.container.addEventListener("keydown", (ev) => {
68500
68603
  if (ev.key === "Shift") {
68501
- this.container.style.cursor = "";
68502
- this.container.removeEventListener("pointerdown", handleOnMouseDown, true);
68503
- this.container.removeEventListener("pointerup", handleOnMouseUp, false);
68504
- this.setIsDrawFalse(1000);
68604
+ this.removeDragMode();
68505
68605
  }
68506
68606
  });
68507
68607
  this.container.addEventListener("keyup", (ev) => {
68508
- if (ev.key === "Shift") {
68509
- configDragMode();
68608
+ if (ev.key === "Shift" && !this.gui_states.sphere) {
68609
+ this.configDragMode();
68510
68610
  }
68511
68611
  });
68512
68612
  }
@@ -68664,6 +68764,7 @@
68664
68764
  // draw lines starts position
68665
68765
  let Is_Painting = false;
68666
68766
  let lines = [];
68767
+ const clearArc = this.useEraser();
68667
68768
  this.updateOriginAndChangedWH();
68668
68769
  this.initAllCanvas();
68669
68770
  this.configGui(modeFolder);
@@ -68673,12 +68774,15 @@
68673
68774
  (_c = this.displayCtx) === null || _c === void 0 ? void 0 : _c.restore();
68674
68775
  this.previousDrawingImage = this.drawingCtx.getImageData(0, 0, this.drawingCanvas.width, this.drawingCanvas.height);
68675
68776
  // let a global variable to store the wheel move event
68676
- this.handleWheelMove = this.configMouseWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
68777
+ this.drawingPrameters.handleZoomWheel = this.configMouseZoomWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
68677
68778
  // init to add it
68678
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
68779
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
68679
68780
  passive: false,
68680
68781
  });
68681
- const handleDragPaintPanel = (e) => {
68782
+ // sphere Wheel
68783
+ this.drawingPrameters.handleSphereWheel = this.configMouseSphereWheel();
68784
+ // pan move
68785
+ this.drawingPrameters.handleOnPanMouseMove = (e) => {
68682
68786
  this.drawingCanvas.style.cursor = "grabbing";
68683
68787
  this.nrrd_states.previousPanelL = e.clientX - panelMoveInnerX;
68684
68788
  this.nrrd_states.previousPanelT = e.clientY - panelMoveInnerY;
@@ -68687,8 +68791,9 @@
68687
68791
  this.displayCanvas.style.top = this.drawingCanvas.style.top =
68688
68792
  this.nrrd_states.previousPanelT + "px";
68689
68793
  };
68690
- // throttle(, 80);
68691
- const handleDisplayMouseMove = (e) => {
68794
+ // brush circle move
68795
+ this.drawingPrameters.handleOnDrawingBrushCricleMove = (e) => {
68796
+ e.preventDefault();
68692
68797
  this.nrrd_states.Mouse_Over_x = e.offsetX;
68693
68798
  this.nrrd_states.Mouse_Over_y = e.offsetY;
68694
68799
  if (this.nrrd_states.Mouse_Over_x === undefined) {
@@ -68697,21 +68802,31 @@
68697
68802
  }
68698
68803
  if (e.type === "mouseout") {
68699
68804
  this.nrrd_states.Mouse_Over = false;
68700
- this.drawingCanvas.removeEventListener("mousemove", handleDisplayMouseMove);
68805
+ this.drawingCanvas.removeEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
68701
68806
  }
68702
68807
  else if (e.type === "mouseover") {
68703
68808
  this.nrrd_states.Mouse_Over = true;
68704
- this.drawingCanvas.addEventListener("mousemove", handleDisplayMouseMove);
68809
+ this.drawingCanvas.addEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
68705
68810
  }
68706
- e.preventDefault();
68707
68811
  };
68708
- // add canvas event listeners
68709
- this.drawingCanvas.addEventListener("mouseover", handleDisplayMouseMove);
68710
- this.drawingCanvas.addEventListener("mouseout", handleDisplayMouseMove);
68711
- // disable browser right click menu
68712
- this.drawingCanvas.addEventListener("pointerdown", (e) => {
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) => {
68713
68828
  if (leftclicked || rightclicked) {
68714
- this.drawingCanvas.removeEventListener("pointerup", handlePointerUp);
68829
+ this.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68715
68830
  this.drawingLayerMasterCtx.closePath();
68716
68831
  return;
68717
68832
  }
@@ -68722,7 +68837,7 @@
68722
68837
  currentSliceIndex = this.mainPreSlice.index;
68723
68838
  }
68724
68839
  // remove it when mouse click down
68725
- this.drawingCanvas.removeEventListener("wheel", this.handleWheelMove);
68840
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68726
68841
  if (e.button === 0) {
68727
68842
  if (this.Is_Shift_Pressed) {
68728
68843
  leftclicked = true;
@@ -68742,32 +68857,23 @@
68742
68857
  }
68743
68858
  this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
68744
68859
  // this.drawingLayerMasterCtx.beginPath();
68745
- this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
68746
- this.drawingCanvas.addEventListener("pointermove", handleOnPainterMove);
68860
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68861
+ this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
68747
68862
  }
68748
68863
  else if (this.nrrd_states.enableCursorChoose) {
68749
68864
  this.nrrd_states.cursorPageX =
68750
68865
  e.offsetX / this.nrrd_states.sizeFoctor;
68751
68866
  this.nrrd_states.cursorPageY =
68752
68867
  e.offsetY / this.nrrd_states.sizeFoctor;
68753
- this.nrrd_states.isCursorSelect = true;
68754
- switch (this.axis) {
68755
- case "x":
68756
- this.cursorPage.x.updated = true;
68757
- this.cursorPage.y.updated = false;
68758
- this.cursorPage.z.updated = false;
68759
- break;
68760
- case "y":
68761
- this.cursorPage.x.updated = false;
68762
- this.cursorPage.y.updated = true;
68763
- this.cursorPage.z.updated = false;
68764
- break;
68765
- case "z":
68766
- this.cursorPage.x.updated = false;
68767
- this.cursorPage.y.updated = false;
68768
- this.cursorPage.z.updated = true;
68769
- break;
68770
- }
68868
+ this.enableCrosshair();
68869
+ }
68870
+ else if (this.gui_states.sphere) {
68871
+ let mouseX = e.offsetX;
68872
+ let mouseY = e.offsetY;
68873
+ // draw circle
68874
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
68875
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68876
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68771
68877
  }
68772
68878
  }
68773
68879
  else if (e.button === 2) {
@@ -68779,28 +68885,15 @@
68779
68885
  panelMoveInnerX = e.clientX - offsetX;
68780
68886
  panelMoveInnerY = e.clientY - offsetY;
68781
68887
  this.drawingCanvas.style.cursor = "grab";
68782
- this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
68783
- this.drawingCanvas.addEventListener("pointermove", handleDragPaintPanel);
68888
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68889
+ this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68784
68890
  }
68785
68891
  else {
68786
68892
  return;
68787
68893
  }
68788
- }, true);
68789
- const clearArc = this.useEraser();
68790
- const handleOnPainterMove = (e) => {
68791
- this.Is_Draw = true;
68792
- if (Is_Painting) {
68793
- if (this.gui_states.Eraser) {
68794
- this.nrrd_states.stepClear = 1;
68795
- // drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
68796
- clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
68797
- }
68798
- else {
68799
- lines.push({ x: e.offsetX, y: e.offsetY });
68800
- this.paintOnCanvasLayer(e.offsetX, e.offsetY);
68801
- }
68802
- }
68803
68894
  };
68895
+ // disable browser right click menu
68896
+ this.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
68804
68897
  const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
68805
68898
  var _a;
68806
68899
  let paintImages;
@@ -68827,13 +68920,13 @@
68827
68920
  // draw privous image
68828
68921
  ctx.drawImage(this.emptyCanvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
68829
68922
  };
68830
- const handlePointerUp = (e) => {
68923
+ this.drawingPrameters.handleOnDrawingMouseUp = (e) => {
68831
68924
  if (e.button === 0) {
68832
68925
  if (this.Is_Shift_Pressed || Is_Painting) {
68833
68926
  leftclicked = false;
68834
68927
  let { ctx, canvas } = this.setCurrentLayer();
68835
68928
  ctx.closePath();
68836
- this.drawingCanvas.removeEventListener("pointermove", handleOnPainterMove);
68929
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
68837
68930
  if (!this.gui_states.Eraser) {
68838
68931
  if (this.gui_states.segmentation) {
68839
68932
  this.drawingCanvasLayerMaster.width =
@@ -68881,20 +68974,63 @@
68881
68974
  undoObj.layers[this.gui_states.label].push(image);
68882
68975
  this.undoArray.push(undoObj);
68883
68976
  }
68977
+ // add wheel after pointer up
68978
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
68979
+ passive: false,
68980
+ });
68981
+ }
68982
+ else if (this.gui_states.sphere &&
68983
+ !this.nrrd_states.enableCursorChoose) {
68984
+ let { ctx, canvas } = this.setCurrentLayer();
68985
+ let mouseX = e.offsetX;
68986
+ let mouseY = e.offsetY;
68987
+ this.nrrd_states.sphereOrigin[this.axis] = [
68988
+ mouseX,
68989
+ mouseY,
68990
+ this.nrrd_states.currentIndex,
68991
+ ];
68992
+ /************ */
68993
+ this.setUpSphereOrigins(mouseX, mouseY);
68994
+ this.nrrd_states.cursorPageX = mouseX;
68995
+ this.nrrd_states.cursorPageY = mouseY;
68996
+ this.enableCrosshair();
68997
+ // plan B
68998
+ // findout all index in the sphere radius range in Axial view
68999
+ if (this.nrrd_states.spherePlanB) {
69000
+ // clear stroe images
69001
+ this.clearStoreImages();
69002
+ for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
69003
+ this.setEmptyCanvasSize();
69004
+ const preIndex = this.nrrd_states.currentIndex - i;
69005
+ const nextIndex = this.nrrd_states.currentIndex + i;
69006
+ if (preIndex < this.nrrd_states.minIndex ||
69007
+ nextIndex > this.nrrd_states.maxIndex)
69008
+ return;
69009
+ if (preIndex === nextIndex) {
69010
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
69011
+ this.drawImageOnEmptyImage(canvas);
69012
+ this.storeAllImages(preIndex, "");
69013
+ }
69014
+ else {
69015
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - i);
69016
+ this.drawImageOnEmptyImage(canvas);
69017
+ this.storeAllImages(preIndex, "");
69018
+ this.storeAllImages(nextIndex, "");
69019
+ }
69020
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
69021
+ }
69022
+ }
69023
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68884
69024
  }
68885
69025
  }
68886
69026
  else if (e.button === 2) {
68887
69027
  rightclicked = false;
68888
69028
  this.drawingCanvas.style.cursor = "grab";
68889
- this.drawingCanvas.removeEventListener("pointermove", handleDragPaintPanel);
69029
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68890
69030
  }
68891
69031
  else {
68892
69032
  return;
68893
69033
  }
68894
- // add wheel after pointer up
68895
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
68896
- passive: false,
68897
- });
68898
69034
  if (!this.gui_states.segmentation) {
68899
69035
  this.setIsDrawFalse(100);
68900
69036
  }
@@ -68905,12 +69041,13 @@
68905
69041
  if (leftclicked) {
68906
69042
  leftclicked = false;
68907
69043
  this.drawingLayerMasterCtx.closePath();
68908
- this.drawingCanvas.removeEventListener("pointermove", handleOnPainterMove);
69044
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
69045
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68909
69046
  }
68910
69047
  if (rightclicked) {
68911
69048
  rightclicked = false;
68912
69049
  this.drawingCanvas.style.cursor = "grab";
68913
- this.drawingCanvas.removeEventListener("pointermove", handleDragPaintPanel);
69050
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68914
69051
  }
68915
69052
  this.setIsDrawFalse(100);
68916
69053
  if (this.gui_states.segmentation) {
@@ -68965,6 +69102,68 @@
68965
69102
  }
68966
69103
  });
68967
69104
  }
69105
+ enableCrosshair() {
69106
+ this.nrrd_states.isCursorSelect = true;
69107
+ switch (this.axis) {
69108
+ case "x":
69109
+ this.cursorPage.x.updated = true;
69110
+ this.cursorPage.y.updated = false;
69111
+ this.cursorPage.z.updated = false;
69112
+ break;
69113
+ case "y":
69114
+ this.cursorPage.x.updated = false;
69115
+ this.cursorPage.y.updated = true;
69116
+ this.cursorPage.z.updated = false;
69117
+ break;
69118
+ case "z":
69119
+ this.cursorPage.x.updated = false;
69120
+ this.cursorPage.y.updated = false;
69121
+ this.cursorPage.z.updated = true;
69122
+ break;
69123
+ }
69124
+ }
69125
+ setUpSphereOrigins(mouseX, mouseY) {
69126
+ const convertCursor = (from, to) => {
69127
+ const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
69128
+ return {
69129
+ convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
69130
+ convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
69131
+ currentIndex: convertObj === null || convertObj === void 0 ? void 0 : convertObj.currentIndex,
69132
+ };
69133
+ };
69134
+ const axisConversions = {
69135
+ x: { axisTo1: "y", axisTo2: "z" },
69136
+ y: { axisTo1: "z", axisTo2: "x" },
69137
+ z: { axisTo1: "x", axisTo2: "y" },
69138
+ };
69139
+ const { axisTo1, axisTo2 } = axisConversions[this.axis];
69140
+ this.nrrd_states.sphereOrigin[axisTo1] = [
69141
+ convertCursor(this.axis, axisTo1).convertCursorNumX,
69142
+ convertCursor(this.axis, axisTo1).convertCursorNumY,
69143
+ convertCursor(this.axis, axisTo1).currentIndex,
69144
+ ];
69145
+ this.nrrd_states.sphereOrigin[axisTo2] = [
69146
+ convertCursor(this.axis, axisTo2).convertCursorNumX,
69147
+ convertCursor(this.axis, axisTo2).convertCursorNumY,
69148
+ convertCursor(this.axis, axisTo2).currentIndex,
69149
+ ];
69150
+ }
69151
+ // for sphere
69152
+ drawSphereCore(ctx, x, y, radius) {
69153
+ ctx.beginPath();
69154
+ ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
69155
+ ctx.fillStyle = this.gui_states.fillColor;
69156
+ ctx.fill();
69157
+ ctx.closePath();
69158
+ }
69159
+ drawSphere(mouseX, mouseY, radius) {
69160
+ let { ctx, canvas } = this.setCurrentLayer();
69161
+ // clear canvas
69162
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
69163
+ this.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
69164
+ this.drawSphereCore(ctx, mouseX, mouseY, radius);
69165
+ this.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69166
+ }
68968
69167
  // need to update
68969
69168
  undoLastPainting() {
68970
69169
  let { ctx, canvas } = this.setCurrentLayer();
@@ -68982,7 +69181,9 @@
68982
69181
  if (layerLen > 0) {
68983
69182
  // const imageSrc = undo.undos[undo.undos.length - 1];
68984
69183
  const image = layerUndos[layerLen - 1];
68985
- ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69184
+ if (!!image) {
69185
+ ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69186
+ }
68986
69187
  }
68987
69188
  if (undo.layers.label1.length > 0) {
68988
69189
  const image = undo.layers.label1[undo.layers.label1.length - 1];
@@ -69006,9 +69207,29 @@
69006
69207
  return item.sliceIndex === this.nrrd_states.currentIndex;
69007
69208
  });
69008
69209
  }
69009
- configMouseWheel(controls) {
69210
+ // drawing canvas mouse shpere wheel
69211
+ configMouseSphereWheel() {
69212
+ const sphereEvent = (e) => {
69213
+ e.preventDefault();
69214
+ if (e.deltaY < 0) {
69215
+ this.nrrd_states.sphereRadius += 1;
69216
+ }
69217
+ else {
69218
+ this.nrrd_states.sphereRadius -= 1;
69219
+ }
69220
+ // limited the radius max and min
69221
+ this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
69222
+ // get mouse position
69223
+ const mouseX = e.offsetX;
69224
+ const mouseY = e.offsetY;
69225
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
69226
+ };
69227
+ return sphereEvent;
69228
+ }
69229
+ // drawing canvas mouse zoom wheel
69230
+ configMouseZoomWheel(controls) {
69010
69231
  let moveDistance = 1;
69011
- const handleWheelMove = (e) => {
69232
+ const handleZoomWheelMove = (e) => {
69012
69233
  if (this.Is_Shift_Pressed) {
69013
69234
  return;
69014
69235
  }
@@ -69044,7 +69265,7 @@
69044
69265
  }
69045
69266
  this.nrrd_states.sizeFoctor = moveDistance;
69046
69267
  };
69047
- return handleWheelMove;
69268
+ return handleZoomWheelMove;
69048
69269
  }
69049
69270
  useEraser() {
69050
69271
  const clearArc = (x, y, radius) => {
@@ -69155,155 +69376,6 @@
69155
69376
  }
69156
69377
  return { ctx, canvas };
69157
69378
  }
69158
- configGui(modeFolder) {
69159
- if (modeFolder.__controllers.length > 0)
69160
- this.removeGuiFolderChilden(modeFolder);
69161
- modeFolder.open();
69162
- const actionsFolder = modeFolder.addFolder("Default Actions");
69163
- actionsFolder
69164
- .add(this.gui_states, "label", ["label1", "label2", "label3"])
69165
- .onChange((val) => {
69166
- if (val === "label1") {
69167
- this.gui_states.fillColor = "#00ff00";
69168
- this.gui_states.brushColor = "#00ff00";
69169
- }
69170
- else if (val === "label2") {
69171
- this.gui_states.fillColor = "#ff0000";
69172
- this.gui_states.brushColor = "#ff0000";
69173
- }
69174
- else if (val === "label3") {
69175
- this.gui_states.fillColor = "#0000ff";
69176
- this.gui_states.brushColor = "#0000ff";
69177
- }
69178
- });
69179
- actionsFolder
69180
- .add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
69181
- .name("cursor icons")
69182
- .onChange((value) => {
69183
- if (value === "crosshair") {
69184
- this.nrrd_states.defaultPaintCursor = "crosshair";
69185
- }
69186
- if (value === "pencil") {
69187
- this.nrrd_states.defaultPaintCursor =
69188
- "url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
69189
- }
69190
- if (value === "dot") {
69191
- this.nrrd_states.defaultPaintCursor =
69192
- "url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
69193
- }
69194
- this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69195
- });
69196
- actionsFolder
69197
- .add(this.gui_states, "mainAreaSize")
69198
- .name("zoom")
69199
- .min(1)
69200
- .max(8)
69201
- .onFinishChange((factor) => {
69202
- this.resetPaintArea();
69203
- this.nrrd_states.sizeFoctor = factor;
69204
- this.resizePaintArea(factor);
69205
- });
69206
- actionsFolder.add(this.gui_states, "resetZoom");
69207
- actionsFolder
69208
- .add(this.gui_states, "globalAlpha")
69209
- .name("opacity")
69210
- .min(0.1)
69211
- .max(1)
69212
- .step(0.01);
69213
- actionsFolder.add(this.gui_states, "segmentation").name("Pencil");
69214
- actionsFolder
69215
- .add(this.gui_states, "brushAndEraserSize")
69216
- .min(5)
69217
- .max(50)
69218
- .step(1)
69219
- .onChange(() => {
69220
- if (this.gui_states.Eraser) {
69221
- this.eraserUrls.length > 0
69222
- ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69223
- : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69224
- }
69225
- });
69226
- actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
69227
- this.gui_states.Eraser = value;
69228
- if (this.gui_states.Eraser) {
69229
- this.eraserUrls.length > 0
69230
- ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69231
- : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69232
- }
69233
- else {
69234
- this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69235
- }
69236
- });
69237
- actionsFolder.add(this.gui_states, "clear");
69238
- actionsFolder.add(this.gui_states, "clearAll");
69239
- actionsFolder.add(this.gui_states, "undo");
69240
- actionsFolder
69241
- .add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69242
- .name("Image contrast")
69243
- .onChange((value) => {
69244
- this.nrrd_states.readyToUpdate = false;
69245
- this.updateSlicesContrast(value, "windowHigh");
69246
- })
69247
- .onFinishChange(() => {
69248
- this.repraintAllContrastSlices();
69249
- this.nrrd_states.readyToUpdate = true;
69250
- });
69251
- actionsFolder.add(this.gui_states, "exportMarks");
69252
- const advanceFolder = modeFolder.addFolder("Advance settings");
69253
- advanceFolder
69254
- .add(this.gui_states, "dragSensitivity")
69255
- .min(1)
69256
- .max(this.nrrd_states.Max_sensitive)
69257
- .step(1);
69258
- const segmentationFolder = advanceFolder.addFolder("Pencil settings");
69259
- segmentationFolder
69260
- .add(this.gui_states, "lineWidth")
69261
- .name("outerLineWidth")
69262
- .min(1.7)
69263
- .max(3)
69264
- .step(0.01);
69265
- segmentationFolder.addColor(this.gui_states, "color");
69266
- segmentationFolder.addColor(this.gui_states, "fillColor");
69267
- const bushFolder = advanceFolder.addFolder("Brush settings");
69268
- bushFolder.addColor(this.gui_states, "brushColor");
69269
- // modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
69270
- advanceFolder.add(this.gui_states, "downloadCurrentMask");
69271
- const contrastFolder = advanceFolder.addFolder("contrast advance settings");
69272
- contrastFolder
69273
- .add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69274
- .name("Lower Threshold")
69275
- .onChange((value) => {
69276
- this.nrrd_states.readyToUpdate = false;
69277
- this.updateSlicesContrast(value, "lowerThreshold");
69278
- })
69279
- .onFinishChange(() => {
69280
- this.repraintAllContrastSlices();
69281
- this.nrrd_states.readyToUpdate = true;
69282
- });
69283
- contrastFolder
69284
- .add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69285
- .name("Upper Threshold")
69286
- .onChange((value) => {
69287
- this.nrrd_states.readyToUpdate = false;
69288
- this.updateSlicesContrast(value, "upperThreshold");
69289
- })
69290
- .onFinishChange(() => {
69291
- this.repraintAllContrastSlices();
69292
- this.nrrd_states.readyToUpdate = true;
69293
- });
69294
- contrastFolder
69295
- .add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69296
- .name("Window Low")
69297
- .onChange((value) => {
69298
- this.nrrd_states.readyToUpdate = false;
69299
- this.updateSlicesContrast(value, "windowLow");
69300
- })
69301
- .onFinishChange(() => {
69302
- this.repraintAllContrastSlices();
69303
- this.nrrd_states.readyToUpdate = true;
69304
- });
69305
- actionsFolder.open();
69306
- }
69307
69379
  updateSlicesContrast(value, flag) {
69308
69380
  switch (flag) {
69309
69381
  case "lowerThreshold":
@@ -69482,12 +69554,15 @@
69482
69554
  delete dic[key];
69483
69555
  }
69484
69556
  }
69557
+ drawImageOnEmptyImage(canvas) {
69558
+ this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69559
+ }
69485
69560
  storeAllImages(index, label) {
69486
69561
  // const image: HTMLImageElement = new Image();
69487
69562
  // resize the drawing image data
69488
- if (!this.nrrd_states.loadMaskJson) {
69563
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
69489
69564
  this.setEmptyCanvasSize();
69490
- this.emptyCtx.drawImage(this.drawingCanvasLayerMaster, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69565
+ this.drawImageOnEmptyImage(this.drawingCanvasLayerMaster);
69491
69566
  }
69492
69567
  let imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69493
69568
  // 1.12.23
@@ -69557,7 +69632,7 @@
69557
69632
  break;
69558
69633
  }
69559
69634
  this.storeImageToAxis(index, this.paintImages, imageData);
69560
- if (!this.nrrd_states.loadMaskJson) {
69635
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
69561
69636
  this.storeEachLayerImage(index, label);
69562
69637
  }
69563
69638
  }
@@ -69592,7 +69667,7 @@
69592
69667
  storeImageToLabel(index, canvas, paintedImages) {
69593
69668
  if (!this.nrrd_states.loadMaskJson) {
69594
69669
  this.setEmptyCanvasSize();
69595
- this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69670
+ this.drawImageOnEmptyImage(canvas);
69596
69671
  }
69597
69672
  const imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69598
69673
  this.storeImageToAxis(index, paintedImages, imageData);
@@ -69814,11 +69889,190 @@
69814
69889
  // }
69815
69890
  // };
69816
69891
  }
69892
+ configGui(modeFolder) {
69893
+ if (modeFolder.__controllers.length > 0)
69894
+ this.removeGuiFolderChilden(modeFolder);
69895
+ modeFolder.open();
69896
+ const actionsFolder = modeFolder.addFolder("Default Actions");
69897
+ actionsFolder
69898
+ .add(this.gui_states, "label", ["label1", "label2", "label3"])
69899
+ .onChange((val) => {
69900
+ if (val === "label1") {
69901
+ this.gui_states.fillColor = "#00ff00";
69902
+ this.gui_states.brushColor = "#00ff00";
69903
+ }
69904
+ else if (val === "label2") {
69905
+ this.gui_states.fillColor = "#ff0000";
69906
+ this.gui_states.brushColor = "#ff0000";
69907
+ }
69908
+ else if (val === "label3") {
69909
+ this.gui_states.fillColor = "#0000ff";
69910
+ this.gui_states.brushColor = "#0000ff";
69911
+ }
69912
+ });
69913
+ actionsFolder
69914
+ .add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
69915
+ .name("cursor icons")
69916
+ .onChange((value) => {
69917
+ if (value === "crosshair") {
69918
+ this.nrrd_states.defaultPaintCursor = "crosshair";
69919
+ }
69920
+ if (value === "pencil") {
69921
+ this.nrrd_states.defaultPaintCursor =
69922
+ "url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
69923
+ }
69924
+ if (value === "dot") {
69925
+ this.nrrd_states.defaultPaintCursor =
69926
+ "url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
69927
+ }
69928
+ this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69929
+ });
69930
+ actionsFolder
69931
+ .add(this.gui_states, "mainAreaSize")
69932
+ .name("zoom")
69933
+ .min(1)
69934
+ .max(8)
69935
+ .onFinishChange((factor) => {
69936
+ this.resetPaintArea();
69937
+ this.nrrd_states.sizeFoctor = factor;
69938
+ this.resizePaintArea(factor);
69939
+ });
69940
+ actionsFolder.add(this.gui_states, "resetZoom");
69941
+ actionsFolder
69942
+ .add(this.gui_states, "globalAlpha")
69943
+ .name("opacity")
69944
+ .min(0.1)
69945
+ .max(1)
69946
+ .step(0.01);
69947
+ actionsFolder
69948
+ .add(this.gui_states, "segmentation")
69949
+ .name("Pencil")
69950
+ .onChange(() => {
69951
+ if (this.gui_states.segmentation) {
69952
+ // add canvas brush circle move event listeners
69953
+ this.drawingCanvas.removeEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69954
+ this.drawingCanvas.removeEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69955
+ }
69956
+ else {
69957
+ // add canvas brush circle move event listeners
69958
+ this.drawingCanvas.addEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69959
+ this.drawingCanvas.addEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69960
+ }
69961
+ });
69962
+ actionsFolder
69963
+ .add(this.gui_states, "sphere")
69964
+ .name("Sphere")
69965
+ .onChange(() => {
69966
+ if (this.gui_states.sphere) {
69967
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
69968
+ this.removeDragMode();
69969
+ }
69970
+ else {
69971
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
69972
+ this.configDragMode();
69973
+ // clear canvas
69974
+ this.clearPaint();
69975
+ this.clearStoreImages();
69976
+ }
69977
+ });
69978
+ actionsFolder
69979
+ .add(this.gui_states, "brushAndEraserSize")
69980
+ .min(5)
69981
+ .max(50)
69982
+ .step(1)
69983
+ .onChange(() => {
69984
+ if (this.gui_states.Eraser) {
69985
+ this.eraserUrls.length > 0
69986
+ ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69987
+ : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69988
+ }
69989
+ });
69990
+ actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
69991
+ this.gui_states.Eraser = value;
69992
+ if (this.gui_states.Eraser) {
69993
+ this.eraserUrls.length > 0
69994
+ ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69995
+ : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69996
+ }
69997
+ else {
69998
+ this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69999
+ }
70000
+ });
70001
+ actionsFolder.add(this.gui_states, "clear");
70002
+ actionsFolder.add(this.gui_states, "clearAll");
70003
+ actionsFolder.add(this.gui_states, "undo");
70004
+ actionsFolder
70005
+ .add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70006
+ .name("Image contrast")
70007
+ .onChange((value) => {
70008
+ this.nrrd_states.readyToUpdate = false;
70009
+ this.updateSlicesContrast(value, "windowHigh");
70010
+ })
70011
+ .onFinishChange(() => {
70012
+ this.repraintAllContrastSlices();
70013
+ this.nrrd_states.readyToUpdate = true;
70014
+ });
70015
+ actionsFolder.add(this.gui_states, "exportMarks");
70016
+ const advanceFolder = modeFolder.addFolder("Advance settings");
70017
+ advanceFolder
70018
+ .add(this.gui_states, "dragSensitivity")
70019
+ .min(1)
70020
+ .max(this.nrrd_states.Max_sensitive)
70021
+ .step(1);
70022
+ const segmentationFolder = advanceFolder.addFolder("Pencil settings");
70023
+ segmentationFolder
70024
+ .add(this.gui_states, "lineWidth")
70025
+ .name("outerLineWidth")
70026
+ .min(1.7)
70027
+ .max(3)
70028
+ .step(0.01);
70029
+ segmentationFolder.addColor(this.gui_states, "color");
70030
+ segmentationFolder.addColor(this.gui_states, "fillColor");
70031
+ const bushFolder = advanceFolder.addFolder("Brush settings");
70032
+ bushFolder.addColor(this.gui_states, "brushColor");
70033
+ // modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
70034
+ advanceFolder.add(this.gui_states, "downloadCurrentMask");
70035
+ const contrastFolder = advanceFolder.addFolder("contrast advance settings");
70036
+ contrastFolder
70037
+ .add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70038
+ .name("Lower Threshold")
70039
+ .onChange((value) => {
70040
+ this.nrrd_states.readyToUpdate = false;
70041
+ this.updateSlicesContrast(value, "lowerThreshold");
70042
+ })
70043
+ .onFinishChange(() => {
70044
+ this.repraintAllContrastSlices();
70045
+ this.nrrd_states.readyToUpdate = true;
70046
+ });
70047
+ contrastFolder
70048
+ .add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70049
+ .name("Upper Threshold")
70050
+ .onChange((value) => {
70051
+ this.nrrd_states.readyToUpdate = false;
70052
+ this.updateSlicesContrast(value, "upperThreshold");
70053
+ })
70054
+ .onFinishChange(() => {
70055
+ this.repraintAllContrastSlices();
70056
+ this.nrrd_states.readyToUpdate = true;
70057
+ });
70058
+ contrastFolder
70059
+ .add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70060
+ .name("Window Low")
70061
+ .onChange((value) => {
70062
+ this.nrrd_states.readyToUpdate = false;
70063
+ this.updateSlicesContrast(value, "windowLow");
70064
+ })
70065
+ .onFinishChange(() => {
70066
+ this.repraintAllContrastSlices();
70067
+ this.nrrd_states.readyToUpdate = true;
70068
+ });
70069
+ actionsFolder.open();
70070
+ }
69817
70071
  }
69818
70072
 
69819
70073
  // import * as kiwrious from "copper3d_plugin_heart_k";
69820
- const REVISION = "v1.15.11";
69821
- console.log("%cCopper3D Visualisation %cBeta:v1.15.11", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70074
+ const REVISION = "v1.15.13";
70075
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.13", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
69822
70076
 
69823
70077
  exports.CameraViewPoint = CameraViewPoint;
69824
70078
  exports.Copper3dTrackballControls = Copper3dTrackballControls;