copper3d 1.15.10 → 1.15.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47405,7 +47405,7 @@ class baseScene extends commonScene {
47405
47405
  this.container.clientWidth / this.container.clientHeight;
47406
47406
  this.camera.updateProjectionMatrix();
47407
47407
  }
47408
- render() {
47408
+ render(time) {
47409
47409
  // this.onWindowResize();
47410
47410
  this.renderer.render(this.scene, this.camera);
47411
47411
  }
@@ -56518,14 +56518,17 @@ class copperScene extends baseScene {
56518
56518
  }
56519
56519
  this.camera.updateProjectionMatrix();
56520
56520
  }
56521
- render() {
56521
+ render(time) {
56522
56522
  this.controls.update();
56523
56523
  if (this.modelReady) {
56524
56524
  this.mixer && this.mixer.update(this.clock.getDelta() * this.playRate);
56525
+ // this.mixer && this.mixer.update((time as number) * this.playRate);
56526
+ }
56527
+ if (this.preRenderCallbackFunctions.cache.length > 0) {
56528
+ Object.values(this.preRenderCallbackFunctions.cache).forEach((item) => {
56529
+ item && item.call(null);
56530
+ });
56525
56531
  }
56526
- Object.values(this.preRenderCallbackFunctions.cache).forEach((item) => {
56527
- item && item.call(null);
56528
- });
56529
56532
  if (this.subDiv && this.subCamera && this.subRender) {
56530
56533
  this.subCamera.aspect =
56531
56534
  this.subDiv.clientWidth / this.subDiv.clientHeight;
@@ -56543,16 +56546,49 @@ class copperRenderer extends baseRenderer {
56543
56546
  constructor(container, options) {
56544
56547
  super(container, options);
56545
56548
  this.sceneMap = {};
56549
+ this.fps = 30;
56550
+ this.renderClock = new Clock();
56551
+ this.delta = 0;
56552
+ this.interval = 1 / this.fps;
56546
56553
  this.preRenderCallbackFunctions = [];
56547
- this.animate = () => {
56548
- this.render();
56549
- this.stats.update();
56550
- requestAnimationFrame(this.animate);
56554
+ this.animate = (time) => {
56555
+ // if (this.start) {
56556
+ // this.fpsCap = createFpsCap(this.render, 10);
56557
+ // this.start = false;
56558
+ // }
56559
+ var _a, _b, _c;
56560
+ switch ((_a = this.options) === null || _a === void 0 ? void 0 : _a.fpsMode) {
56561
+ case "1":
56562
+ // fpsControl one: 30fps
56563
+ setTimeout(() => {
56564
+ requestAnimationFrame(this.animate);
56565
+ }, 1000 / this.fps);
56566
+ this.render();
56567
+ if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.performanceGui)
56568
+ this.stats.update();
56569
+ break;
56570
+ default:
56571
+ // fpsControl two: 30fps
56572
+ requestAnimationFrame(this.animate);
56573
+ if (this.delta === 0) {
56574
+ this.render();
56575
+ }
56576
+ this.delta += this.renderClock.getDelta();
56577
+ if (this.delta > this.interval) {
56578
+ this.render();
56579
+ if ((_c = this.options) === null || _c === void 0 ? void 0 : _c.performanceGui)
56580
+ this.stats.update();
56581
+ this.delta = this.delta % this.interval;
56582
+ }
56583
+ }
56551
56584
  };
56552
56585
  }
56553
56586
  getSceneByName(name) {
56554
56587
  return this.sceneMap[name];
56555
56588
  }
56589
+ setFPS(fps) {
56590
+ this.fps = fps;
56591
+ }
56556
56592
  setCurrentScene(sceneIn) {
56557
56593
  var _a;
56558
56594
  if (sceneIn) {
@@ -67604,6 +67640,7 @@ class nrrd_tools {
67604
67640
  label2: this.paintImagesLabel2,
67605
67641
  label3: this.paintImagesLabel3,
67606
67642
  };
67643
+ // used to store display marks with multiple labels
67607
67644
  this.paintImages = { x: [], y: [], z: [] };
67608
67645
  // store all contrast slices, include x, y, z orientation
67609
67646
  this.allSlicesArray = [];
@@ -67631,7 +67668,6 @@ class nrrd_tools {
67631
67668
  this.Is_Shift_Pressed = false;
67632
67669
  this.Is_Draw = false;
67633
67670
  this.sensitiveArray = [];
67634
- this.handleWheelMove = () => { };
67635
67671
  this.start = () => { };
67636
67672
  this.undoArray = [];
67637
67673
  this.initState = true;
@@ -67667,6 +67703,10 @@ class nrrd_tools {
67667
67703
  isCursorSelect: false,
67668
67704
  cursorPageX: 0,
67669
67705
  cursorPageY: 0,
67706
+ // x: [cursorX, cursorY, sliceIndex]
67707
+ sphereOrigin: { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] },
67708
+ spherePlanB: false,
67709
+ sphereRadius: 10,
67670
67710
  Mouse_Over_x: 0,
67671
67711
  Mouse_Over_y: 0,
67672
67712
  Mouse_Over: false,
@@ -67716,12 +67756,9 @@ class nrrd_tools {
67716
67756
  brushAndEraserSize: 15,
67717
67757
  cursor: "dot",
67718
67758
  label: "label1",
67759
+ sphere: false,
67719
67760
  // EraserSize: 25,
67720
67761
  clear: () => {
67721
- // const text = "Are you sure remove annotations on Current slice?";
67722
- // if (confirm(text) === true) {
67723
- // this.clearPaint();
67724
- // }
67725
67762
  this.clearPaint();
67726
67763
  },
67727
67764
  clearAll: () => {
@@ -67755,6 +67792,36 @@ class nrrd_tools {
67755
67792
  this.exportData();
67756
67793
  },
67757
67794
  };
67795
+ this.dragPrameters = {
67796
+ move: 0,
67797
+ y: 0,
67798
+ h: 0,
67799
+ sensivity: 1,
67800
+ handleOnDragMouseUp: (ev) => { },
67801
+ handleOnDragMouseDown: (ev) => { },
67802
+ handleOnDragMouseMove: (ev) => { },
67803
+ };
67804
+ this.drawingPrameters = {
67805
+ handleOnDrawingMouseDown: (ev) => { },
67806
+ handleOnDrawingMouseMove: (ev) => { },
67807
+ handleOnPanMouseMove: (ev) => { },
67808
+ handleOnDrawingMouseUp: (ev) => { },
67809
+ handleOnDrawingMouseLeave: (ev) => { },
67810
+ handleOnDrawingBrushCricleMove: (ev) => { },
67811
+ handleZoomWheel: (e) => { },
67812
+ handleSphereWheel: (e) => { },
67813
+ };
67814
+ this.configDragMode = () => {
67815
+ this.container.style.cursor = "pointer";
67816
+ this.container.addEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
67817
+ this.container.addEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
67818
+ };
67819
+ this.removeDragMode = () => {
67820
+ this.container.style.cursor = "";
67821
+ this.container.removeEventListener("pointerdown", this.dragPrameters.handleOnDragMouseDown, true);
67822
+ this.container.removeEventListener("pointerup", this.dragPrameters.handleOnDragMouseUp, true);
67823
+ this.setIsDrawFalse(1000);
67824
+ };
67758
67825
  this.drawLine = (x1, y1, x2, y2) => {
67759
67826
  this.drawingCtx.beginPath();
67760
67827
  this.drawingCtx.moveTo(x1, y1);
@@ -67787,7 +67854,7 @@ class nrrd_tools {
67787
67854
  this.sensitiveArray.push((i + 1) / 20);
67788
67855
  }
67789
67856
  this.container.addEventListener("keydown", (ev) => {
67790
- if (ev.key === "Shift") {
67857
+ if (ev.key === "Shift" && !this.gui_states.sphere) {
67791
67858
  this.Is_Shift_Pressed = true;
67792
67859
  this.nrrd_states.enableCursorChoose = false;
67793
67860
  }
@@ -67967,12 +68034,94 @@ class nrrd_tools {
67967
68034
  paintImages.z.push(initMark_z);
67968
68035
  }
67969
68036
  }
68037
+ convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
68038
+ const nrrd = this.nrrd_states;
68039
+ const dimensions = nrrd.dimensions;
68040
+ const ratios = nrrd.ratios;
68041
+ const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
68042
+ let currentIndex = 0;
68043
+ let oldIndex = 0;
68044
+ let convertCursorNumX = 0;
68045
+ let convertCursorNumY = 0;
68046
+ const convertIndex = {
68047
+ x: {
68048
+ y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
68049
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
68050
+ },
68051
+ y: {
68052
+ x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
68053
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
68054
+ },
68055
+ z: {
68056
+ x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
68057
+ y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
68058
+ },
68059
+ };
68060
+ const convertCursor = {
68061
+ x: {
68062
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
68063
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
68064
+ },
68065
+ y: {
68066
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
68067
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
68068
+ },
68069
+ z: {
68070
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
68071
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
68072
+ },
68073
+ };
68074
+ if (from === to) {
68075
+ return;
68076
+ }
68077
+ if (from === "z" && to === "x") {
68078
+ currentIndex = convertIndex[from][to](cursorNumX);
68079
+ oldIndex = currentIndex * ratios[to];
68080
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
68081
+ convertCursorNumY = cursorNumY;
68082
+ }
68083
+ else if (from === "y" && to === "x") {
68084
+ currentIndex = convertIndex[from][to](cursorNumX);
68085
+ oldIndex = currentIndex * ratios.x;
68086
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
68087
+ convertCursorNumX = cursorNumY;
68088
+ }
68089
+ else if (from === "z" && to === "y") {
68090
+ currentIndex = convertIndex[from][to](cursorNumY);
68091
+ oldIndex = currentIndex * ratios[to];
68092
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
68093
+ convertCursorNumX = cursorNumX;
68094
+ }
68095
+ else if (from === "x" && to === "y") {
68096
+ currentIndex = convertIndex[from][to](cursorNumY);
68097
+ oldIndex = currentIndex * ratios[to];
68098
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
68099
+ convertCursorNumY = cursorNumX;
68100
+ }
68101
+ else if (from === "x" && to === "z") {
68102
+ currentIndex = convertIndex[from][to](cursorNumX);
68103
+ oldIndex = currentIndex * ratios[to];
68104
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
68105
+ convertCursorNumY = cursorNumY;
68106
+ }
68107
+ else if (from === "y" && to === "z") {
68108
+ currentIndex = convertIndex[from][to](cursorNumY);
68109
+ oldIndex = currentIndex * ratios.z;
68110
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
68111
+ convertCursorNumX = cursorNumX;
68112
+ }
68113
+ else {
68114
+ return;
68115
+ }
68116
+ return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
68117
+ }
67970
68118
  /**
67971
68119
  * Switch all contrast slices' orientation
67972
68120
  * @param {string} aixs:"x" | "y" | "z"
67973
68121
  * */
67974
- setSliceOrientation(axis) {
67975
- if (this.nrrd_states.enableCursorChoose) {
68122
+ setSliceOrientation(axisTo) {
68123
+ let convetObj;
68124
+ if (this.nrrd_states.enableCursorChoose || this.gui_states.sphere) {
67976
68125
  if (this.axis === "z") {
67977
68126
  this.cursorPage.z.index = this.nrrd_states.currentIndex;
67978
68127
  this.cursorPage.z.cursorPageX = this.nrrd_states.cursorPageX;
@@ -67988,27 +68137,19 @@ class nrrd_tools {
67988
68137
  this.cursorPage.y.cursorPageX = this.nrrd_states.cursorPageX;
67989
68138
  this.cursorPage.y.cursorPageY = this.nrrd_states.cursorPageY;
67990
68139
  }
67991
- if (axis === "z") {
68140
+ if (axisTo === "z") {
67992
68141
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.z.updated) {
67993
68142
  if (this.axis === "x") {
67994
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.x.cursorPageX / this.nrrd_states.nrrd_z_mm) *
67995
- this.nrrd_states.dimensions[2]);
67996
- this.nrrd_states.oldIndex =
67997
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
67998
- this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
67999
- this.nrrd_states.nrrd_x_mm);
68143
+ // convert x to z
68144
+ convetObj = this.convertCursorPoint("x", "z", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
68000
68145
  }
68001
68146
  if (this.axis === "y") {
68002
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.y.cursorPageY / this.nrrd_states.nrrd_z_mm) *
68003
- this.nrrd_states.dimensions[2]);
68004
- this.nrrd_states.oldIndex =
68005
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.z;
68006
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
68007
- this.nrrd_states.nrrd_y_mm);
68147
+ // convert y to z
68148
+ convetObj = this.convertCursorPoint("y", "z", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
68008
68149
  }
68009
- this.cursorPage.z.updated = true;
68010
68150
  }
68011
68151
  else {
68152
+ // not cursor select, freedom to switch x -> z or y -> z and z -> x or z -> y
68012
68153
  this.nrrd_states.currentIndex = this.cursorPage.z.index;
68013
68154
  this.nrrd_states.oldIndex =
68014
68155
  this.cursorPage.z.index * this.nrrd_states.ratios.z;
@@ -68016,28 +68157,19 @@ class nrrd_tools {
68016
68157
  this.nrrd_states.cursorPageY = this.cursorPage.z.cursorPageY;
68017
68158
  }
68018
68159
  }
68019
- else if (axis === "x") {
68160
+ else if (axisTo === "x") {
68020
68161
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.x.updated) {
68021
68162
  if (this.axis === "z") {
68022
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.z.cursorPageX / this.nrrd_states.nrrd_x_mm) *
68023
- this.nrrd_states.dimensions[0]);
68024
- this.nrrd_states.oldIndex =
68025
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
68026
- this.nrrd_states.cursorPageX = Math.floor((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
68027
- this.nrrd_states.nrrd_z_mm);
68163
+ // convert z to x
68164
+ convetObj = this.convertCursorPoint("z", "x", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
68028
68165
  }
68029
68166
  if (this.axis === "y") {
68030
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.y.cursorPageX / this.nrrd_states.nrrd_y_mm) *
68031
- this.nrrd_states.dimensions[1]);
68032
- this.nrrd_states.oldIndex =
68033
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.x;
68034
- this.nrrd_states.cursorPageX = this.cursorPage.y.cursorPageY;
68035
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.y.index / this.nrrd_states.dimensions[1]) *
68036
- this.nrrd_states.nrrd_y_mm);
68167
+ // convert y to x
68168
+ convetObj = this.convertCursorPoint("y", "x", this.cursorPage.y.cursorPageX, this.cursorPage.y.cursorPageY, this.cursorPage.y.index);
68037
68169
  }
68038
- this.cursorPage.x.updated = true;
68039
68170
  }
68040
68171
  else {
68172
+ // not cursor select, freedom to switch z -> x or y -> x and x -> z or x -> y
68041
68173
  this.nrrd_states.currentIndex = this.cursorPage.x.index;
68042
68174
  this.nrrd_states.oldIndex =
68043
68175
  this.cursorPage.x.index * this.nrrd_states.ratios.x;
@@ -68045,28 +68177,19 @@ class nrrd_tools {
68045
68177
  this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageY;
68046
68178
  }
68047
68179
  }
68048
- else if (axis === "y") {
68180
+ else if (axisTo === "y") {
68049
68181
  if (this.nrrd_states.isCursorSelect && !this.cursorPage.y.updated) {
68050
68182
  if (this.axis === "z") {
68051
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.z.cursorPageY / this.nrrd_states.nrrd_y_mm) *
68052
- this.nrrd_states.dimensions[1]);
68053
- this.nrrd_states.oldIndex =
68054
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
68055
- this.nrrd_states.cursorPageY = Math.ceil((this.cursorPage.z.index / this.nrrd_states.dimensions[2]) *
68056
- this.nrrd_states.nrrd_z_mm);
68183
+ // convert z to y
68184
+ convetObj = this.convertCursorPoint("z", "y", this.cursorPage.z.cursorPageX, this.cursorPage.z.cursorPageY, this.cursorPage.z.index);
68057
68185
  }
68058
68186
  if (this.axis === "x") {
68059
- this.nrrd_states.currentIndex = Math.ceil((this.cursorPage.x.cursorPageY / this.nrrd_states.nrrd_x_mm) *
68060
- this.nrrd_states.dimensions[0]);
68061
- this.nrrd_states.oldIndex =
68062
- this.nrrd_states.currentIndex * this.nrrd_states.ratios.y;
68063
- this.nrrd_states.cursorPageX = Math.ceil((this.cursorPage.x.index / this.nrrd_states.dimensions[0]) *
68064
- this.nrrd_states.nrrd_x_mm);
68065
- this.nrrd_states.cursorPageY = this.cursorPage.x.cursorPageX;
68187
+ // convert x to y
68188
+ convetObj = this.convertCursorPoint("x", "y", this.cursorPage.x.cursorPageX, this.cursorPage.x.cursorPageY, this.cursorPage.x.index);
68066
68189
  }
68067
- this.cursorPage.y.updated = true;
68068
68190
  }
68069
68191
  else {
68192
+ // not cursor select, freedom to switch z -> y or x -> y and y -> z or y -> x
68070
68193
  this.nrrd_states.currentIndex = this.cursorPage.y.index;
68071
68194
  this.nrrd_states.oldIndex =
68072
68195
  this.cursorPage.y.index * this.nrrd_states.ratios.y;
@@ -68074,14 +68197,38 @@ class nrrd_tools {
68074
68197
  this.nrrd_states.cursorPageY = this.cursorPage.y.cursorPageY;
68075
68198
  }
68076
68199
  }
68200
+ if (convetObj) {
68201
+ // update convert cursor point, when cursor select
68202
+ this.nrrd_states.currentIndex = convetObj.currentIndex;
68203
+ this.nrrd_states.oldIndex = convetObj.oldIndex;
68204
+ this.nrrd_states.cursorPageX = convetObj.convertCursorNumX;
68205
+ this.nrrd_states.cursorPageY = convetObj.convertCursorNumY;
68206
+ convetObj = undefined;
68207
+ switch (axisTo) {
68208
+ case "x":
68209
+ this.cursorPage.x.updated = true;
68210
+ break;
68211
+ case "y":
68212
+ this.cursorPage.y.updated = true;
68213
+ break;
68214
+ case "z":
68215
+ this.cursorPage.z.updated = true;
68216
+ break;
68217
+ }
68218
+ }
68077
68219
  if (this.cursorPage.x.updated &&
68078
68220
  this.cursorPage.y.updated &&
68079
68221
  this.cursorPage.z.updated) {
68222
+ // one point convert to all axis, reset all updated status
68080
68223
  this.nrrd_states.isCursorSelect = false;
68081
68224
  }
68082
68225
  }
68083
- this.axis = axis;
68226
+ this.axis = axisTo;
68084
68227
  this.resetDisplaySlicesStatus();
68228
+ // for sphere plan a
68229
+ if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
68230
+ this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
68231
+ }
68085
68232
  }
68086
68233
  addSkip(index) {
68087
68234
  this.skipSlicesDic[index] = this.backUpDisplaySlices[index];
@@ -68158,6 +68305,15 @@ class nrrd_tools {
68158
68305
  this.resetPaintArea();
68159
68306
  this.setIsDrawFalse(1000);
68160
68307
  }
68308
+ getContainer() {
68309
+ return this.mainAreaContainer;
68310
+ }
68311
+ getDrawingCanvas() {
68312
+ return this.drawingCanvas;
68313
+ }
68314
+ getNrrdToolsSettings() {
68315
+ return this.nrrd_states;
68316
+ }
68161
68317
  getMaxSliceNum() {
68162
68318
  if (this.nrrd_states.showContrast) {
68163
68319
  return [
@@ -68398,62 +68554,51 @@ class nrrd_tools {
68398
68554
  this.mainAreaContainer.appendChild(loadingbar);
68399
68555
  }
68400
68556
  drag(opts) {
68401
- let move;
68402
- let y;
68403
- let h = this.container.offsetHeight;
68404
- let sensivity = 1;
68405
- let handleOnMouseUp;
68406
- let handleOnMouseDown;
68407
- let handleOnMouseMove;
68557
+ this.dragPrameters.h = this.container.offsetHeight;
68408
68558
  this.sensitiveArray.reverse();
68409
68559
  if (opts === null || opts === void 0 ? void 0 : opts.showNumber) {
68410
68560
  this.container.appendChild(this.showDragNumberDiv);
68411
68561
  }
68412
- handleOnMouseDown = (ev) => {
68562
+ this.dragPrameters.handleOnDragMouseDown = (ev) => {
68413
68563
  // before start drag event, remove wheel event.
68414
- this.drawingCanvas.removeEventListener("wheel", this.handleWheelMove);
68564
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68415
68565
  if (ev.button === 0) {
68416
68566
  // this.setSyncsliceNum();
68417
- y = ev.offsetY / h;
68418
- this.container.addEventListener("pointermove", handleOnMouseMove, false);
68419
- sensivity = this.sensitiveArray[this.gui_states.dragSensitivity - 1];
68567
+ this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
68568
+ this.container.addEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
68569
+ this.dragPrameters.sensivity =
68570
+ this.sensitiveArray[this.gui_states.dragSensitivity - 1];
68420
68571
  }
68421
68572
  };
68422
- handleOnMouseMove = throttle((ev) => {
68423
- if (y - ev.offsetY / h >= 0) {
68424
- move = -Math.ceil(((y - ev.offsetY / h) * 10) / sensivity);
68573
+ this.dragPrameters.handleOnDragMouseMove = throttle((ev) => {
68574
+ if (this.dragPrameters.y - ev.offsetY / this.dragPrameters.h >= 0) {
68575
+ this.dragPrameters.move = -Math.ceil(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
68576
+ this.dragPrameters.sensivity);
68425
68577
  }
68426
68578
  else {
68427
- move = -Math.floor(((y - ev.offsetY / h) * 10) / sensivity);
68579
+ this.dragPrameters.move = -Math.floor(((this.dragPrameters.y - ev.offsetY / this.dragPrameters.h) * 10) /
68580
+ this.dragPrameters.sensivity);
68428
68581
  }
68429
- this.updateIndex(move);
68582
+ this.updateIndex(this.dragPrameters.move);
68430
68583
  (opts === null || opts === void 0 ? void 0 : opts.getSliceNum) &&
68431
68584
  opts.getSliceNum(this.nrrd_states.currentIndex, this.nrrd_states.contrastNum);
68432
- y = ev.offsetY / h;
68433
- }, sensivity * 200);
68434
- handleOnMouseUp = (ev) => {
68585
+ this.dragPrameters.y = ev.offsetY / this.dragPrameters.h;
68586
+ }, this.dragPrameters.sensivity * 200);
68587
+ this.dragPrameters.handleOnDragMouseUp = (ev) => {
68435
68588
  // after drag, add the wheel event
68436
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove);
68589
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68437
68590
  this.setSyncsliceNum();
68438
- this.container.removeEventListener("pointermove", handleOnMouseMove, false);
68591
+ this.container.removeEventListener("pointermove", this.dragPrameters.handleOnDragMouseMove, false);
68439
68592
  };
68440
- const configDragMode = () => {
68441
- this.container.style.cursor = "pointer";
68442
- this.container.addEventListener("pointerdown", handleOnMouseDown, true);
68443
- this.container.addEventListener("pointerup", handleOnMouseUp, true);
68444
- };
68445
- configDragMode();
68593
+ this.configDragMode();
68446
68594
  this.container.addEventListener("keydown", (ev) => {
68447
68595
  if (ev.key === "Shift") {
68448
- this.container.style.cursor = "";
68449
- this.container.removeEventListener("pointerdown", handleOnMouseDown, true);
68450
- this.container.removeEventListener("pointerup", handleOnMouseUp, false);
68451
- this.setIsDrawFalse(1000);
68596
+ this.removeDragMode();
68452
68597
  }
68453
68598
  });
68454
68599
  this.container.addEventListener("keyup", (ev) => {
68455
- if (ev.key === "Shift") {
68456
- configDragMode();
68600
+ if (ev.key === "Shift" && !this.gui_states.sphere) {
68601
+ this.configDragMode();
68457
68602
  }
68458
68603
  });
68459
68604
  }
@@ -68611,6 +68756,7 @@ class nrrd_tools {
68611
68756
  // draw lines starts position
68612
68757
  let Is_Painting = false;
68613
68758
  let lines = [];
68759
+ const clearArc = this.useEraser();
68614
68760
  this.updateOriginAndChangedWH();
68615
68761
  this.initAllCanvas();
68616
68762
  this.configGui(modeFolder);
@@ -68620,12 +68766,15 @@ class nrrd_tools {
68620
68766
  (_c = this.displayCtx) === null || _c === void 0 ? void 0 : _c.restore();
68621
68767
  this.previousDrawingImage = this.drawingCtx.getImageData(0, 0, this.drawingCanvas.width, this.drawingCanvas.height);
68622
68768
  // let a global variable to store the wheel move event
68623
- this.handleWheelMove = this.configMouseWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
68769
+ this.drawingPrameters.handleZoomWheel = this.configMouseZoomWheel((_d = this.sceneIn) === null || _d === void 0 ? void 0 : _d.controls);
68624
68770
  // init to add it
68625
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
68771
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
68626
68772
  passive: false,
68627
68773
  });
68628
- const handleDragPaintPanel = (e) => {
68774
+ // sphere Wheel
68775
+ this.drawingPrameters.handleSphereWheel = this.configMouseSphereWheel();
68776
+ // pan move
68777
+ this.drawingPrameters.handleOnPanMouseMove = (e) => {
68629
68778
  this.drawingCanvas.style.cursor = "grabbing";
68630
68779
  this.nrrd_states.previousPanelL = e.clientX - panelMoveInnerX;
68631
68780
  this.nrrd_states.previousPanelT = e.clientY - panelMoveInnerY;
@@ -68634,8 +68783,9 @@ class nrrd_tools {
68634
68783
  this.displayCanvas.style.top = this.drawingCanvas.style.top =
68635
68784
  this.nrrd_states.previousPanelT + "px";
68636
68785
  };
68637
- // throttle(, 80);
68638
- const handleDisplayMouseMove = (e) => {
68786
+ // brush circle move
68787
+ this.drawingPrameters.handleOnDrawingBrushCricleMove = (e) => {
68788
+ e.preventDefault();
68639
68789
  this.nrrd_states.Mouse_Over_x = e.offsetX;
68640
68790
  this.nrrd_states.Mouse_Over_y = e.offsetY;
68641
68791
  if (this.nrrd_states.Mouse_Over_x === undefined) {
@@ -68644,21 +68794,31 @@ class nrrd_tools {
68644
68794
  }
68645
68795
  if (e.type === "mouseout") {
68646
68796
  this.nrrd_states.Mouse_Over = false;
68647
- this.drawingCanvas.removeEventListener("mousemove", handleDisplayMouseMove);
68797
+ this.drawingCanvas.removeEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
68648
68798
  }
68649
68799
  else if (e.type === "mouseover") {
68650
68800
  this.nrrd_states.Mouse_Over = true;
68651
- this.drawingCanvas.addEventListener("mousemove", handleDisplayMouseMove);
68801
+ this.drawingCanvas.addEventListener("mousemove", this.drawingPrameters.handleOnDrawingBrushCricleMove);
68652
68802
  }
68653
- e.preventDefault();
68654
68803
  };
68655
- // add canvas event listeners
68656
- this.drawingCanvas.addEventListener("mouseover", handleDisplayMouseMove);
68657
- this.drawingCanvas.addEventListener("mouseout", handleDisplayMouseMove);
68658
- // disable browser right click menu
68659
- this.drawingCanvas.addEventListener("pointerdown", (e) => {
68804
+ // drawing move
68805
+ this.drawingPrameters.handleOnDrawingMouseMove = (e) => {
68806
+ this.Is_Draw = true;
68807
+ if (Is_Painting) {
68808
+ if (this.gui_states.Eraser) {
68809
+ this.nrrd_states.stepClear = 1;
68810
+ // drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
68811
+ clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
68812
+ }
68813
+ else {
68814
+ lines.push({ x: e.offsetX, y: e.offsetY });
68815
+ this.paintOnCanvasLayer(e.offsetX, e.offsetY);
68816
+ }
68817
+ }
68818
+ };
68819
+ this.drawingPrameters.handleOnDrawingMouseDown = (e) => {
68660
68820
  if (leftclicked || rightclicked) {
68661
- this.drawingCanvas.removeEventListener("pointerup", handlePointerUp);
68821
+ this.drawingCanvas.removeEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68662
68822
  this.drawingLayerMasterCtx.closePath();
68663
68823
  return;
68664
68824
  }
@@ -68669,7 +68829,7 @@ class nrrd_tools {
68669
68829
  currentSliceIndex = this.mainPreSlice.index;
68670
68830
  }
68671
68831
  // remove it when mouse click down
68672
- this.drawingCanvas.removeEventListener("wheel", this.handleWheelMove);
68832
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
68673
68833
  if (e.button === 0) {
68674
68834
  if (this.Is_Shift_Pressed) {
68675
68835
  leftclicked = true;
@@ -68689,32 +68849,24 @@ class nrrd_tools {
68689
68849
  }
68690
68850
  this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
68691
68851
  // this.drawingLayerMasterCtx.beginPath();
68692
- this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
68693
- this.drawingCanvas.addEventListener("pointermove", handleOnPainterMove);
68852
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68853
+ this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
68694
68854
  }
68695
68855
  else if (this.nrrd_states.enableCursorChoose) {
68696
68856
  this.nrrd_states.cursorPageX =
68697
68857
  e.offsetX / this.nrrd_states.sizeFoctor;
68698
68858
  this.nrrd_states.cursorPageY =
68699
68859
  e.offsetY / this.nrrd_states.sizeFoctor;
68700
- this.nrrd_states.isCursorSelect = true;
68701
- switch (this.axis) {
68702
- case "x":
68703
- this.cursorPage.x.updated = true;
68704
- this.cursorPage.y.updated = false;
68705
- this.cursorPage.z.updated = false;
68706
- break;
68707
- case "y":
68708
- this.cursorPage.x.updated = false;
68709
- this.cursorPage.y.updated = true;
68710
- this.cursorPage.z.updated = false;
68711
- break;
68712
- case "z":
68713
- this.cursorPage.x.updated = false;
68714
- this.cursorPage.y.updated = false;
68715
- this.cursorPage.z.updated = true;
68716
- break;
68717
- }
68860
+ this.enableCrosshair();
68861
+ }
68862
+ else if (this.gui_states.sphere) {
68863
+ console.log("sphere down");
68864
+ let mouseX = e.offsetX;
68865
+ let mouseY = e.offsetY;
68866
+ // draw circle
68867
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
68868
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68869
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68718
68870
  }
68719
68871
  }
68720
68872
  else if (e.button === 2) {
@@ -68726,28 +68878,15 @@ class nrrd_tools {
68726
68878
  panelMoveInnerX = e.clientX - offsetX;
68727
68879
  panelMoveInnerY = e.clientY - offsetY;
68728
68880
  this.drawingCanvas.style.cursor = "grab";
68729
- this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
68730
- this.drawingCanvas.addEventListener("pointermove", handleDragPaintPanel);
68881
+ this.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
68882
+ this.drawingCanvas.addEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68731
68883
  }
68732
68884
  else {
68733
68885
  return;
68734
68886
  }
68735
- }, true);
68736
- const clearArc = this.useEraser();
68737
- const handleOnPainterMove = (e) => {
68738
- this.Is_Draw = true;
68739
- if (Is_Painting) {
68740
- if (this.gui_states.Eraser) {
68741
- this.nrrd_states.stepClear = 1;
68742
- // drawingCtx.clearRect(e.offsetX - 5, e.offsetY - 5, 25, 25);
68743
- clearArc(e.offsetX, e.offsetY, this.gui_states.brushAndEraserSize);
68744
- }
68745
- else {
68746
- lines.push({ x: e.offsetX, y: e.offsetY });
68747
- this.paintOnCanvasLayer(e.offsetX, e.offsetY);
68748
- }
68749
- }
68750
68887
  };
68888
+ // disable browser right click menu
68889
+ this.drawingCanvas.addEventListener("pointerdown", this.drawingPrameters.handleOnDrawingMouseDown, true);
68751
68890
  const redrawPreviousImageToLabelCtx = (ctx, label = "default") => {
68752
68891
  var _a;
68753
68892
  let paintImages;
@@ -68774,13 +68913,13 @@ class nrrd_tools {
68774
68913
  // draw privous image
68775
68914
  ctx.drawImage(this.emptyCanvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
68776
68915
  };
68777
- const handlePointerUp = (e) => {
68916
+ this.drawingPrameters.handleOnDrawingMouseUp = (e) => {
68778
68917
  if (e.button === 0) {
68779
68918
  if (this.Is_Shift_Pressed || Is_Painting) {
68780
68919
  leftclicked = false;
68781
68920
  let { ctx, canvas } = this.setCurrentLayer();
68782
68921
  ctx.closePath();
68783
- this.drawingCanvas.removeEventListener("pointermove", handleOnPainterMove);
68922
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
68784
68923
  if (!this.gui_states.Eraser) {
68785
68924
  if (this.gui_states.segmentation) {
68786
68925
  this.drawingCanvasLayerMaster.width =
@@ -68828,20 +68967,66 @@ class nrrd_tools {
68828
68967
  undoObj.layers[this.gui_states.label].push(image);
68829
68968
  this.undoArray.push(undoObj);
68830
68969
  }
68970
+ // add wheel after pointer up
68971
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel, {
68972
+ passive: false,
68973
+ });
68974
+ }
68975
+ else if (this.gui_states.sphere &&
68976
+ !this.nrrd_states.enableCursorChoose) {
68977
+ console.log("sphere up");
68978
+ let { ctx, canvas } = this.setCurrentLayer();
68979
+ let mouseX = e.offsetX;
68980
+ let mouseY = e.offsetY;
68981
+ this.nrrd_states.sphereOrigin[this.axis] = [
68982
+ mouseX,
68983
+ mouseY,
68984
+ this.nrrd_states.currentIndex,
68985
+ ];
68986
+ /************ */
68987
+ this.setUpSphereOrigins(mouseX, mouseY);
68988
+ console.log(this.nrrd_states.sphereOrigin);
68989
+ this.nrrd_states.cursorPageX = mouseX;
68990
+ this.nrrd_states.cursorPageY = mouseY;
68991
+ this.enableCrosshair();
68992
+ // plan B
68993
+ // findout all index in the sphere radius range in Axial view
68994
+ if (this.nrrd_states.spherePlanB) {
68995
+ // clear stroe images
68996
+ this.clearStoreImages();
68997
+ for (let i = 0; i < this.nrrd_states.sphereRadius; i++) {
68998
+ this.setEmptyCanvasSize();
68999
+ const preIndex = this.nrrd_states.currentIndex - i;
69000
+ const nextIndex = this.nrrd_states.currentIndex + i;
69001
+ if (preIndex < this.nrrd_states.minIndex ||
69002
+ nextIndex > this.nrrd_states.maxIndex)
69003
+ return;
69004
+ if (preIndex === nextIndex) {
69005
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
69006
+ this.drawImageOnEmptyImage(canvas);
69007
+ this.storeAllImages(preIndex, "");
69008
+ }
69009
+ else {
69010
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - i);
69011
+ this.drawImageOnEmptyImage(canvas);
69012
+ this.storeAllImages(preIndex, "");
69013
+ this.storeAllImages(nextIndex, "");
69014
+ }
69015
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
69016
+ }
69017
+ }
69018
+ console.log(this.nrrd_states.sphereRadius);
69019
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68831
69020
  }
68832
69021
  }
68833
69022
  else if (e.button === 2) {
68834
69023
  rightclicked = false;
68835
69024
  this.drawingCanvas.style.cursor = "grab";
68836
- this.drawingCanvas.removeEventListener("pointermove", handleDragPaintPanel);
69025
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68837
69026
  }
68838
69027
  else {
68839
69028
  return;
68840
69029
  }
68841
- // add wheel after pointer up
68842
- this.drawingCanvas.addEventListener("wheel", this.handleWheelMove, {
68843
- passive: false,
68844
- });
68845
69030
  if (!this.gui_states.segmentation) {
68846
69031
  this.setIsDrawFalse(100);
68847
69032
  }
@@ -68852,12 +69037,13 @@ class nrrd_tools {
68852
69037
  if (leftclicked) {
68853
69038
  leftclicked = false;
68854
69039
  this.drawingLayerMasterCtx.closePath();
68855
- this.drawingCanvas.removeEventListener("pointermove", handleOnPainterMove);
69040
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnDrawingMouseMove);
69041
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
68856
69042
  }
68857
69043
  if (rightclicked) {
68858
69044
  rightclicked = false;
68859
69045
  this.drawingCanvas.style.cursor = "grab";
68860
- this.drawingCanvas.removeEventListener("pointermove", handleDragPaintPanel);
69046
+ this.drawingCanvas.removeEventListener("pointermove", this.drawingPrameters.handleOnPanMouseMove);
68861
69047
  }
68862
69048
  this.setIsDrawFalse(100);
68863
69049
  if (this.gui_states.segmentation) {
@@ -68912,6 +69098,68 @@ class nrrd_tools {
68912
69098
  }
68913
69099
  });
68914
69100
  }
69101
+ enableCrosshair() {
69102
+ this.nrrd_states.isCursorSelect = true;
69103
+ switch (this.axis) {
69104
+ case "x":
69105
+ this.cursorPage.x.updated = true;
69106
+ this.cursorPage.y.updated = false;
69107
+ this.cursorPage.z.updated = false;
69108
+ break;
69109
+ case "y":
69110
+ this.cursorPage.x.updated = false;
69111
+ this.cursorPage.y.updated = true;
69112
+ this.cursorPage.z.updated = false;
69113
+ break;
69114
+ case "z":
69115
+ this.cursorPage.x.updated = false;
69116
+ this.cursorPage.y.updated = false;
69117
+ this.cursorPage.z.updated = true;
69118
+ break;
69119
+ }
69120
+ }
69121
+ setUpSphereOrigins(mouseX, mouseY) {
69122
+ const convertCursor = (from, to) => {
69123
+ const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
69124
+ return {
69125
+ convertCursorNumX: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumX,
69126
+ convertCursorNumY: convertObj === null || convertObj === void 0 ? void 0 : convertObj.convertCursorNumY,
69127
+ currentIndex: convertObj === null || convertObj === void 0 ? void 0 : convertObj.currentIndex,
69128
+ };
69129
+ };
69130
+ const axisConversions = {
69131
+ x: { axisTo1: "y", axisTo2: "z" },
69132
+ y: { axisTo1: "z", axisTo2: "x" },
69133
+ z: { axisTo1: "x", axisTo2: "y" },
69134
+ };
69135
+ const { axisTo1, axisTo2 } = axisConversions[this.axis];
69136
+ this.nrrd_states.sphereOrigin[axisTo1] = [
69137
+ convertCursor(this.axis, axisTo1).convertCursorNumX,
69138
+ convertCursor(this.axis, axisTo1).convertCursorNumY,
69139
+ convertCursor(this.axis, axisTo1).currentIndex,
69140
+ ];
69141
+ this.nrrd_states.sphereOrigin[axisTo2] = [
69142
+ convertCursor(this.axis, axisTo2).convertCursorNumX,
69143
+ convertCursor(this.axis, axisTo2).convertCursorNumY,
69144
+ convertCursor(this.axis, axisTo2).currentIndex,
69145
+ ];
69146
+ }
69147
+ // for sphere
69148
+ drawSphereCore(ctx, x, y, radius) {
69149
+ ctx.beginPath();
69150
+ ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
69151
+ ctx.fillStyle = this.gui_states.fillColor;
69152
+ ctx.fill();
69153
+ ctx.closePath();
69154
+ }
69155
+ drawSphere(mouseX, mouseY, radius) {
69156
+ let { ctx, canvas } = this.setCurrentLayer();
69157
+ // clear canvas
69158
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
69159
+ this.drawingLayerMasterCtx.clearRect(0, 0, canvas.width, canvas.height);
69160
+ this.drawSphereCore(ctx, mouseX, mouseY, radius);
69161
+ this.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69162
+ }
68915
69163
  // need to update
68916
69164
  undoLastPainting() {
68917
69165
  let { ctx, canvas } = this.setCurrentLayer();
@@ -68929,7 +69177,9 @@ class nrrd_tools {
68929
69177
  if (layerLen > 0) {
68930
69178
  // const imageSrc = undo.undos[undo.undos.length - 1];
68931
69179
  const image = layerUndos[layerLen - 1];
68932
- ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69180
+ if (!!image) {
69181
+ ctx.drawImage(image, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
69182
+ }
68933
69183
  }
68934
69184
  if (undo.layers.label1.length > 0) {
68935
69185
  const image = undo.layers.label1[undo.layers.label1.length - 1];
@@ -68953,9 +69203,29 @@ class nrrd_tools {
68953
69203
  return item.sliceIndex === this.nrrd_states.currentIndex;
68954
69204
  });
68955
69205
  }
68956
- configMouseWheel(controls) {
69206
+ // drawing canvas mouse shpere wheel
69207
+ configMouseSphereWheel() {
69208
+ const sphereEvent = (e) => {
69209
+ e.preventDefault();
69210
+ if (e.deltaY < 0) {
69211
+ this.nrrd_states.sphereRadius += 1;
69212
+ }
69213
+ else {
69214
+ this.nrrd_states.sphereRadius -= 1;
69215
+ }
69216
+ // limited the radius max and min
69217
+ this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
69218
+ // get mouse position
69219
+ const mouseX = e.offsetX;
69220
+ const mouseY = e.offsetY;
69221
+ this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
69222
+ };
69223
+ return sphereEvent;
69224
+ }
69225
+ // drawing canvas mouse zoom wheel
69226
+ configMouseZoomWheel(controls) {
68957
69227
  let moveDistance = 1;
68958
- const handleWheelMove = (e) => {
69228
+ const handleZoomWheelMove = (e) => {
68959
69229
  if (this.Is_Shift_Pressed) {
68960
69230
  return;
68961
69231
  }
@@ -68991,7 +69261,7 @@ class nrrd_tools {
68991
69261
  }
68992
69262
  this.nrrd_states.sizeFoctor = moveDistance;
68993
69263
  };
68994
- return handleWheelMove;
69264
+ return handleZoomWheelMove;
68995
69265
  }
68996
69266
  useEraser() {
68997
69267
  const clearArc = (x, y, radius) => {
@@ -69102,155 +69372,6 @@ class nrrd_tools {
69102
69372
  }
69103
69373
  return { ctx, canvas };
69104
69374
  }
69105
- configGui(modeFolder) {
69106
- if (modeFolder.__controllers.length > 0)
69107
- this.removeGuiFolderChilden(modeFolder);
69108
- modeFolder.open();
69109
- const actionsFolder = modeFolder.addFolder("Default Actions");
69110
- actionsFolder
69111
- .add(this.gui_states, "label", ["label1", "label2", "label3"])
69112
- .onChange((val) => {
69113
- if (val === "label1") {
69114
- this.gui_states.fillColor = "#00ff00";
69115
- this.gui_states.brushColor = "#00ff00";
69116
- }
69117
- else if (val === "label2") {
69118
- this.gui_states.fillColor = "#ff0000";
69119
- this.gui_states.brushColor = "#ff0000";
69120
- }
69121
- else if (val === "label3") {
69122
- this.gui_states.fillColor = "#0000ff";
69123
- this.gui_states.brushColor = "#0000ff";
69124
- }
69125
- });
69126
- actionsFolder
69127
- .add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
69128
- .name("cursor icons")
69129
- .onChange((value) => {
69130
- if (value === "crosshair") {
69131
- this.nrrd_states.defaultPaintCursor = "crosshair";
69132
- }
69133
- if (value === "pencil") {
69134
- this.nrrd_states.defaultPaintCursor =
69135
- "url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
69136
- }
69137
- if (value === "dot") {
69138
- this.nrrd_states.defaultPaintCursor =
69139
- "url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
69140
- }
69141
- this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69142
- });
69143
- actionsFolder
69144
- .add(this.gui_states, "mainAreaSize")
69145
- .name("zoom")
69146
- .min(1)
69147
- .max(8)
69148
- .onFinishChange((factor) => {
69149
- this.resetPaintArea();
69150
- this.nrrd_states.sizeFoctor = factor;
69151
- this.resizePaintArea(factor);
69152
- });
69153
- actionsFolder.add(this.gui_states, "resetZoom");
69154
- actionsFolder
69155
- .add(this.gui_states, "globalAlpha")
69156
- .name("opacity")
69157
- .min(0.1)
69158
- .max(1)
69159
- .step(0.01);
69160
- actionsFolder.add(this.gui_states, "segmentation").name("Pencil");
69161
- actionsFolder
69162
- .add(this.gui_states, "brushAndEraserSize")
69163
- .min(5)
69164
- .max(50)
69165
- .step(1)
69166
- .onChange(() => {
69167
- if (this.gui_states.Eraser) {
69168
- this.eraserUrls.length > 0
69169
- ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69170
- : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69171
- }
69172
- });
69173
- actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
69174
- this.gui_states.Eraser = value;
69175
- if (this.gui_states.Eraser) {
69176
- this.eraserUrls.length > 0
69177
- ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69178
- : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69179
- }
69180
- else {
69181
- this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69182
- }
69183
- });
69184
- actionsFolder.add(this.gui_states, "clear");
69185
- actionsFolder.add(this.gui_states, "clearAll");
69186
- actionsFolder.add(this.gui_states, "undo");
69187
- actionsFolder
69188
- .add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69189
- .name("Image contrast")
69190
- .onChange((value) => {
69191
- this.nrrd_states.readyToUpdate = false;
69192
- this.updateSlicesContrast(value, "windowHigh");
69193
- })
69194
- .onFinishChange(() => {
69195
- this.repraintAllContrastSlices();
69196
- this.nrrd_states.readyToUpdate = true;
69197
- });
69198
- actionsFolder.add(this.gui_states, "exportMarks");
69199
- const advanceFolder = modeFolder.addFolder("Advance settings");
69200
- advanceFolder
69201
- .add(this.gui_states, "dragSensitivity")
69202
- .min(1)
69203
- .max(this.nrrd_states.Max_sensitive)
69204
- .step(1);
69205
- const segmentationFolder = advanceFolder.addFolder("Pencil settings");
69206
- segmentationFolder
69207
- .add(this.gui_states, "lineWidth")
69208
- .name("outerLineWidth")
69209
- .min(1.7)
69210
- .max(3)
69211
- .step(0.01);
69212
- segmentationFolder.addColor(this.gui_states, "color");
69213
- segmentationFolder.addColor(this.gui_states, "fillColor");
69214
- const bushFolder = advanceFolder.addFolder("Brush settings");
69215
- bushFolder.addColor(this.gui_states, "brushColor");
69216
- // modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
69217
- advanceFolder.add(this.gui_states, "downloadCurrentMask");
69218
- const contrastFolder = advanceFolder.addFolder("contrast advance settings");
69219
- contrastFolder
69220
- .add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69221
- .name("Lower Threshold")
69222
- .onChange((value) => {
69223
- this.nrrd_states.readyToUpdate = false;
69224
- this.updateSlicesContrast(value, "lowerThreshold");
69225
- })
69226
- .onFinishChange(() => {
69227
- this.repraintAllContrastSlices();
69228
- this.nrrd_states.readyToUpdate = true;
69229
- });
69230
- contrastFolder
69231
- .add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69232
- .name("Upper Threshold")
69233
- .onChange((value) => {
69234
- this.nrrd_states.readyToUpdate = false;
69235
- this.updateSlicesContrast(value, "upperThreshold");
69236
- })
69237
- .onFinishChange(() => {
69238
- this.repraintAllContrastSlices();
69239
- this.nrrd_states.readyToUpdate = true;
69240
- });
69241
- contrastFolder
69242
- .add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69243
- .name("Window Low")
69244
- .onChange((value) => {
69245
- this.nrrd_states.readyToUpdate = false;
69246
- this.updateSlicesContrast(value, "windowLow");
69247
- })
69248
- .onFinishChange(() => {
69249
- this.repraintAllContrastSlices();
69250
- this.nrrd_states.readyToUpdate = true;
69251
- });
69252
- actionsFolder.open();
69253
- }
69254
69375
  updateSlicesContrast(value, flag) {
69255
69376
  switch (flag) {
69256
69377
  case "lowerThreshold":
@@ -69429,12 +69550,15 @@ class nrrd_tools {
69429
69550
  delete dic[key];
69430
69551
  }
69431
69552
  }
69553
+ drawImageOnEmptyImage(canvas) {
69554
+ this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69555
+ }
69432
69556
  storeAllImages(index, label) {
69433
69557
  // const image: HTMLImageElement = new Image();
69434
69558
  // resize the drawing image data
69435
- if (!this.nrrd_states.loadMaskJson) {
69559
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
69436
69560
  this.setEmptyCanvasSize();
69437
- this.emptyCtx.drawImage(this.drawingCanvasLayerMaster, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69561
+ this.drawImageOnEmptyImage(this.drawingCanvasLayerMaster);
69438
69562
  }
69439
69563
  let imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69440
69564
  // 1.12.23
@@ -69504,7 +69628,7 @@ class nrrd_tools {
69504
69628
  break;
69505
69629
  }
69506
69630
  this.storeImageToAxis(index, this.paintImages, imageData);
69507
- if (!this.nrrd_states.loadMaskJson) {
69631
+ if (!this.nrrd_states.loadMaskJson && !this.gui_states.sphere) {
69508
69632
  this.storeEachLayerImage(index, label);
69509
69633
  }
69510
69634
  }
@@ -69539,7 +69663,7 @@ class nrrd_tools {
69539
69663
  storeImageToLabel(index, canvas, paintedImages) {
69540
69664
  if (!this.nrrd_states.loadMaskJson) {
69541
69665
  this.setEmptyCanvasSize();
69542
- this.emptyCtx.drawImage(canvas, 0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69666
+ this.drawImageOnEmptyImage(canvas);
69543
69667
  }
69544
69668
  const imageData = this.emptyCtx.getImageData(0, 0, this.emptyCanvas.width, this.emptyCanvas.height);
69545
69669
  this.storeImageToAxis(index, paintedImages, imageData);
@@ -69761,10 +69885,186 @@ class nrrd_tools {
69761
69885
  // }
69762
69886
  // };
69763
69887
  }
69888
+ configGui(modeFolder) {
69889
+ if (modeFolder.__controllers.length > 0)
69890
+ this.removeGuiFolderChilden(modeFolder);
69891
+ modeFolder.open();
69892
+ const actionsFolder = modeFolder.addFolder("Default Actions");
69893
+ actionsFolder
69894
+ .add(this.gui_states, "label", ["label1", "label2", "label3"])
69895
+ .onChange((val) => {
69896
+ if (val === "label1") {
69897
+ this.gui_states.fillColor = "#00ff00";
69898
+ this.gui_states.brushColor = "#00ff00";
69899
+ }
69900
+ else if (val === "label2") {
69901
+ this.gui_states.fillColor = "#ff0000";
69902
+ this.gui_states.brushColor = "#ff0000";
69903
+ }
69904
+ else if (val === "label3") {
69905
+ this.gui_states.fillColor = "#0000ff";
69906
+ this.gui_states.brushColor = "#0000ff";
69907
+ }
69908
+ });
69909
+ actionsFolder
69910
+ .add(this.gui_states, "cursor", ["crosshair", "pencil", "dot"])
69911
+ .name("cursor icons")
69912
+ .onChange((value) => {
69913
+ if (value === "crosshair") {
69914
+ this.nrrd_states.defaultPaintCursor = "crosshair";
69915
+ }
69916
+ if (value === "pencil") {
69917
+ this.nrrd_states.defaultPaintCursor =
69918
+ "url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/pencil-black.svg), auto";
69919
+ }
69920
+ if (value === "dot") {
69921
+ this.nrrd_states.defaultPaintCursor =
69922
+ "url(https://raw.githubusercontent.com/LinkunGao/copper3d-datasets/main/icons/dot.svg) 12 12,auto";
69923
+ }
69924
+ this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69925
+ });
69926
+ actionsFolder
69927
+ .add(this.gui_states, "mainAreaSize")
69928
+ .name("zoom")
69929
+ .min(1)
69930
+ .max(8)
69931
+ .onFinishChange((factor) => {
69932
+ this.resetPaintArea();
69933
+ this.nrrd_states.sizeFoctor = factor;
69934
+ this.resizePaintArea(factor);
69935
+ });
69936
+ actionsFolder.add(this.gui_states, "resetZoom");
69937
+ actionsFolder
69938
+ .add(this.gui_states, "globalAlpha")
69939
+ .name("opacity")
69940
+ .min(0.1)
69941
+ .max(1)
69942
+ .step(0.01);
69943
+ actionsFolder
69944
+ .add(this.gui_states, "segmentation")
69945
+ .name("Pencil")
69946
+ .onChange(() => {
69947
+ if (this.gui_states.segmentation) {
69948
+ // add canvas brush circle move event listeners
69949
+ this.drawingCanvas.removeEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69950
+ this.drawingCanvas.removeEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69951
+ }
69952
+ else {
69953
+ // add canvas brush circle move event listeners
69954
+ this.drawingCanvas.addEventListener("mouseover", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69955
+ this.drawingCanvas.addEventListener("mouseout", this.drawingPrameters.handleOnDrawingBrushCricleMove);
69956
+ }
69957
+ });
69958
+ actionsFolder
69959
+ .add(this.gui_states, "sphere")
69960
+ .name("Sphere")
69961
+ .onChange(() => {
69962
+ if (this.gui_states.sphere) {
69963
+ this.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
69964
+ this.removeDragMode();
69965
+ }
69966
+ else {
69967
+ this.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
69968
+ this.configDragMode();
69969
+ }
69970
+ });
69971
+ actionsFolder
69972
+ .add(this.gui_states, "brushAndEraserSize")
69973
+ .min(5)
69974
+ .max(50)
69975
+ .step(1)
69976
+ .onChange(() => {
69977
+ if (this.gui_states.Eraser) {
69978
+ this.eraserUrls.length > 0
69979
+ ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69980
+ : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69981
+ }
69982
+ });
69983
+ actionsFolder.add(this.gui_states, "Eraser").onChange((value) => {
69984
+ this.gui_states.Eraser = value;
69985
+ if (this.gui_states.Eraser) {
69986
+ this.eraserUrls.length > 0
69987
+ ? (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize, this.eraserUrls))
69988
+ : (this.drawingCanvas.style.cursor = switchEraserSize(this.gui_states.brushAndEraserSize));
69989
+ }
69990
+ else {
69991
+ this.drawingCanvas.style.cursor = this.nrrd_states.defaultPaintCursor;
69992
+ }
69993
+ });
69994
+ actionsFolder.add(this.gui_states, "clear");
69995
+ actionsFolder.add(this.gui_states, "clearAll");
69996
+ actionsFolder.add(this.gui_states, "undo");
69997
+ actionsFolder
69998
+ .add(this.mainPreSlice.volume, "windowHigh", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
69999
+ .name("Image contrast")
70000
+ .onChange((value) => {
70001
+ this.nrrd_states.readyToUpdate = false;
70002
+ this.updateSlicesContrast(value, "windowHigh");
70003
+ })
70004
+ .onFinishChange(() => {
70005
+ this.repraintAllContrastSlices();
70006
+ this.nrrd_states.readyToUpdate = true;
70007
+ });
70008
+ actionsFolder.add(this.gui_states, "exportMarks");
70009
+ const advanceFolder = modeFolder.addFolder("Advance settings");
70010
+ advanceFolder
70011
+ .add(this.gui_states, "dragSensitivity")
70012
+ .min(1)
70013
+ .max(this.nrrd_states.Max_sensitive)
70014
+ .step(1);
70015
+ const segmentationFolder = advanceFolder.addFolder("Pencil settings");
70016
+ segmentationFolder
70017
+ .add(this.gui_states, "lineWidth")
70018
+ .name("outerLineWidth")
70019
+ .min(1.7)
70020
+ .max(3)
70021
+ .step(0.01);
70022
+ segmentationFolder.addColor(this.gui_states, "color");
70023
+ segmentationFolder.addColor(this.gui_states, "fillColor");
70024
+ const bushFolder = advanceFolder.addFolder("Brush settings");
70025
+ bushFolder.addColor(this.gui_states, "brushColor");
70026
+ // modeFolder.add(this.stateMode, "EraserSize").min(1).max(50).step(1);
70027
+ advanceFolder.add(this.gui_states, "downloadCurrentMask");
70028
+ const contrastFolder = advanceFolder.addFolder("contrast advance settings");
70029
+ contrastFolder
70030
+ .add(this.mainPreSlice.volume, "lowerThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70031
+ .name("Lower Threshold")
70032
+ .onChange((value) => {
70033
+ this.nrrd_states.readyToUpdate = false;
70034
+ this.updateSlicesContrast(value, "lowerThreshold");
70035
+ })
70036
+ .onFinishChange(() => {
70037
+ this.repraintAllContrastSlices();
70038
+ this.nrrd_states.readyToUpdate = true;
70039
+ });
70040
+ contrastFolder
70041
+ .add(this.mainPreSlice.volume, "upperThreshold", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70042
+ .name("Upper Threshold")
70043
+ .onChange((value) => {
70044
+ this.nrrd_states.readyToUpdate = false;
70045
+ this.updateSlicesContrast(value, "upperThreshold");
70046
+ })
70047
+ .onFinishChange(() => {
70048
+ this.repraintAllContrastSlices();
70049
+ this.nrrd_states.readyToUpdate = true;
70050
+ });
70051
+ contrastFolder
70052
+ .add(this.mainPreSlice.volume, "windowLow", this.mainPreSlice.volume.min, this.mainPreSlice.volume.max, 1)
70053
+ .name("Window Low")
70054
+ .onChange((value) => {
70055
+ this.nrrd_states.readyToUpdate = false;
70056
+ this.updateSlicesContrast(value, "windowLow");
70057
+ })
70058
+ .onFinishChange(() => {
70059
+ this.repraintAllContrastSlices();
70060
+ this.nrrd_states.readyToUpdate = true;
70061
+ });
70062
+ actionsFolder.open();
70063
+ }
69764
70064
  }
69765
70065
 
69766
70066
  // import * as kiwrious from "copper3d_plugin_heart_k";
69767
- const REVISION = "v1.15.10";
69768
- console.log("%cCopper3D Visualisation %cBeta:v1.15.10", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
70067
+ const REVISION = "v1.15.12";
70068
+ console.log("%cCopper3D Visualisation %cBeta:v1.15.12", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
69769
70069
 
69770
70070
  export { CameraViewPoint, Copper3dTrackballControls, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, nrrd_tools, setHDRFilePath };