copper3d 2.0.4 → 2.0.6

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.
@@ -69102,11 +69102,17 @@ function setupGui(configs) {
69102
69102
  };
69103
69103
  const updateGuiSphereState = () => {
69104
69104
  if (configs.gui_states.sphere) {
69105
- configs.drawingCanvas.removeEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69105
+ // configs.drawingCanvas.removeEventListener(
69106
+ // "wheel",
69107
+ // configs.drawingPrameters.handleZoomWheel
69108
+ // );
69106
69109
  configs.removeDragMode();
69107
69110
  }
69108
69111
  else {
69109
- configs.drawingCanvas.addEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69112
+ // configs.drawingCanvas.addEventListener(
69113
+ // "wheel",
69114
+ // configs.drawingPrameters.handleZoomWheel
69115
+ // );
69110
69116
  configs.configDragMode();
69111
69117
  // clear canvas
69112
69118
  configs.clearPaint();
@@ -69992,9 +69998,10 @@ class DrawToolCore extends CommToolsData {
69992
69998
  e.offsetY / this.nrrd_states.sizeFoctor;
69993
69999
  this.enableCrosshair();
69994
70000
  }
69995
- else if (this.gui_states.sphere) {
69996
- let mouseX = e.offsetX;
69997
- let mouseY = e.offsetY;
70001
+ else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
70002
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70003
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70004
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
69998
70005
  // record mouseX,Y, and enable crosshair function
69999
70006
  this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70000
70007
  mouseX,
@@ -70006,7 +70013,7 @@ class DrawToolCore extends CommToolsData {
70006
70013
  this.nrrd_states.cursorPageY = mouseY;
70007
70014
  this.enableCrosshair();
70008
70015
  // draw circle setup width/height for sphere canvas
70009
- this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70016
+ this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
70010
70017
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70011
70018
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70012
70019
  }
@@ -70128,9 +70135,14 @@ class DrawToolCore extends CommToolsData {
70128
70135
  }
70129
70136
  }
70130
70137
  !!this.nrrd_states.getSphere &&
70131
- this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius);
70138
+ this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70139
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70132
70140
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70133
70141
  }
70142
+ else if (this.gui_states.sphere &&
70143
+ this.nrrd_states.enableCursorChoose) {
70144
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70145
+ }
70134
70146
  }
70135
70147
  else if (e.button === 2) {
70136
70148
  rightclicked = false;
@@ -70316,19 +70328,20 @@ class DrawToolCore extends CommToolsData {
70316
70328
  // this.nrrd_states.originWidth;
70317
70329
  const delta = e.detail ? e.detail > 0 : e.wheelDelta < 0;
70318
70330
  this.protectedData.Is_Draw = true;
70319
- const ratioL = (e.clientX -
70331
+ var rect = this.container.getBoundingClientRect();
70332
+ const ratioL = (e.clientX - rect.left -
70320
70333
  this.mainAreaContainer.offsetLeft -
70321
70334
  this.protectedData.canvases.drawingCanvas.offsetLeft) /
70322
70335
  this.protectedData.canvases.drawingCanvas.offsetWidth;
70323
- const ratioT = (e.clientY -
70336
+ const ratioT = (e.clientY - rect.top -
70324
70337
  this.mainAreaContainer.offsetTop -
70325
70338
  this.protectedData.canvases.drawingCanvas.offsetTop) /
70326
70339
  this.protectedData.canvases.drawingCanvas.offsetHeight;
70327
70340
  const ratioDelta = !delta ? 1 + 0.1 : 1 - 0.1;
70328
70341
  const w = this.protectedData.canvases.drawingCanvas.offsetWidth * ratioDelta;
70329
70342
  const h = this.protectedData.canvases.drawingCanvas.offsetHeight * ratioDelta;
70330
- const l = Math.round(e.clientX - this.mainAreaContainer.offsetLeft - w * ratioL);
70331
- const t = Math.round(e.clientY - this.mainAreaContainer.offsetTop - h * ratioT);
70343
+ const l = Math.round(e.clientX - this.mainAreaContainer.offsetLeft - w * ratioL - rect.left);
70344
+ const t = Math.round(e.clientY - this.mainAreaContainer.offsetTop - h * ratioT - rect.top);
70332
70345
  moveDistance = w / this.nrrd_states.originWidth;
70333
70346
  if (moveDistance > 8) {
70334
70347
  moveDistance = 8;
@@ -70386,17 +70399,12 @@ class DrawToolCore extends CommToolsData {
70386
70399
  const nextIndex = originIndex + decay;
70387
70400
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
70388
70401
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
70389
- // if (
70390
- // preIndex < this.nrrd_states.minIndex ||
70391
- // nextIndex > this.nrrd_states.maxIndex
70392
- // )
70393
- // return;
70394
70402
  if (preIndex === nextIndex) {
70395
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
70403
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70396
70404
  this.storeSphereImages(preIndex, axis);
70397
70405
  }
70398
70406
  else {
70399
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - decay);
70407
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
70400
70408
  this.drawImageOnEmptyImage(canvas);
70401
70409
  this.storeSphereImages(preIndex, axis);
70402
70410
  this.storeSphereImages(nextIndex, axis);
@@ -70405,7 +70413,7 @@ class DrawToolCore extends CommToolsData {
70405
70413
  }
70406
70414
  drawSphereCore(ctx, x, y, radius) {
70407
70415
  ctx.beginPath();
70408
- ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
70416
+ ctx.arc(x, y, radius, 0, 2 * Math.PI);
70409
70417
  ctx.fillStyle = this.gui_states.fillColor;
70410
70418
  ctx.fill();
70411
70419
  ctx.closePath();
@@ -70445,8 +70453,8 @@ class DrawToolCore extends CommToolsData {
70445
70453
  // limited the radius max and min
70446
70454
  this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
70447
70455
  // get mouse position
70448
- const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0];
70449
- const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1];
70456
+ const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] * this.nrrd_states.sizeFoctor;
70457
+ const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1] * this.nrrd_states.sizeFoctor;
70450
70458
  this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70451
70459
  };
70452
70460
  return sphereEvent;
@@ -70463,6 +70471,102 @@ class DrawToolCore extends CommToolsData {
70463
70471
  this.drawSphereCore(ctx, mouseX, mouseY, radius);
70464
70472
  this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
70465
70473
  }
70474
+ /**
70475
+ * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
70476
+ * So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
70477
+ *
70478
+ * When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
70479
+ *
70480
+ * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
70481
+ *
70482
+ * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
70483
+ * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
70484
+ * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
70485
+ * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
70486
+ * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
70487
+ * @returns
70488
+ */
70489
+ convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
70490
+ const nrrd = this.nrrd_states;
70491
+ const dimensions = nrrd.dimensions;
70492
+ const ratios = nrrd.ratios;
70493
+ const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
70494
+ let currentIndex = 0;
70495
+ let oldIndex = 0;
70496
+ let convertCursorNumX = 0;
70497
+ let convertCursorNumY = 0;
70498
+ const convertIndex = {
70499
+ x: {
70500
+ y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70501
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70502
+ },
70503
+ y: {
70504
+ x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70505
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70506
+ },
70507
+ z: {
70508
+ x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70509
+ y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70510
+ },
70511
+ };
70512
+ const convertCursor = {
70513
+ x: {
70514
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70515
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70516
+ },
70517
+ y: {
70518
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70519
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70520
+ },
70521
+ z: {
70522
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70523
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70524
+ },
70525
+ };
70526
+ if (from === to) {
70527
+ return;
70528
+ }
70529
+ if (from === "z" && to === "x") {
70530
+ currentIndex = convertIndex[from][to](cursorNumX);
70531
+ oldIndex = currentIndex * ratios[to];
70532
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70533
+ convertCursorNumY = cursorNumY;
70534
+ }
70535
+ else if (from === "y" && to === "x") {
70536
+ currentIndex = convertIndex[from][to](cursorNumX);
70537
+ oldIndex = currentIndex * ratios.x;
70538
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70539
+ convertCursorNumX = cursorNumY;
70540
+ }
70541
+ else if (from === "z" && to === "y") {
70542
+ currentIndex = convertIndex[from][to](cursorNumY);
70543
+ oldIndex = currentIndex * ratios[to];
70544
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70545
+ convertCursorNumX = cursorNumX;
70546
+ }
70547
+ else if (from === "x" && to === "y") {
70548
+ currentIndex = convertIndex[from][to](cursorNumY);
70549
+ oldIndex = currentIndex * ratios[to];
70550
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70551
+ convertCursorNumY = cursorNumX;
70552
+ }
70553
+ else if (from === "x" && to === "z") {
70554
+ currentIndex = convertIndex[from][to](cursorNumX);
70555
+ oldIndex = currentIndex * ratios[to];
70556
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70557
+ convertCursorNumY = cursorNumY;
70558
+ }
70559
+ else if (from === "y" && to === "z") {
70560
+ currentIndex = convertIndex[from][to](cursorNumY);
70561
+ oldIndex = currentIndex * ratios.z;
70562
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70563
+ convertCursorNumX = cursorNumX;
70564
+ }
70565
+ else {
70566
+ return;
70567
+ }
70568
+ return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
70569
+ }
70466
70570
  setUpSphereOrigins(mouseX, mouseY) {
70467
70571
  const convertCursor = (from, to) => {
70468
70572
  const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
@@ -70943,6 +71047,22 @@ class NrrdTools extends DrawToolCore {
70943
71047
  flipDisplayImageByAxis: this.flipDisplayImageByAxis,
70944
71048
  filterDrawedImage: this.filterDrawedImage,
70945
71049
  setEmptyCanvasSize: this.setEmptyCanvasSize,
71050
+ storeAllImages: this.storeAllImages,
71051
+ drawImageOnEmptyImage: this.drawImageOnEmptyImage,
71052
+ checkSharedPlaceSlice: this.checkSharedPlaceSlice,
71053
+ replaceArray: this.replaceArray,
71054
+ findSliceInSharedPlace: this.findSliceInSharedPlace,
71055
+ sliceArrayH: this.sliceArrayH,
71056
+ sliceArrayV: this.sliceArrayV,
71057
+ storeImageToAxis: this.storeImageToAxis,
71058
+ replaceVerticalColPixels: this.replaceVerticalColPixels,
71059
+ replaceHorizontalRowPixels: this.replaceHorizontalRowPixels,
71060
+ storeEachLayerImage: this.storeEachLayerImage,
71061
+ storeImageToLabel: this.storeImageToLabel,
71062
+ getRestLabel: this.getRestLabel,
71063
+ setIsDrawFalse: this.setIsDrawFalse,
71064
+ initPaintImages: this.initPaintImages,
71065
+ createEmptyPaintImage: this.createEmptyPaintImage,
70946
71066
  };
70947
71067
  this.guiParameterSettings = setupGui(guiOptions);
70948
71068
  }
@@ -71127,102 +71247,6 @@ class NrrdTools extends DrawToolCore {
71127
71247
  paintImages.z.push(initMark_z);
71128
71248
  }
71129
71249
  }
71130
- /**
71131
- * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
71132
- * So, the index munber on each axis (sagittal, axial, coronal) is the slice's depth in mm distance. And the width and height displayed on screen is the slice's width and height in pixel distance.
71133
- *
71134
- * When we switch into different axis' views, we need to convert current view's the depth to the pixel distance in other views width or height, and convert the current view's width or height from pixel distance to mm distance as other views' depth (slice index) in general.
71135
- *
71136
- * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
71137
- *
71138
- * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
71139
- * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
71140
- * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
71141
- * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
71142
- * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
71143
- * @returns
71144
- */
71145
- convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
71146
- const nrrd = this.nrrd_states;
71147
- const dimensions = nrrd.dimensions;
71148
- const ratios = nrrd.ratios;
71149
- const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
71150
- let currentIndex = 0;
71151
- let oldIndex = 0;
71152
- let convertCursorNumX = 0;
71153
- let convertCursorNumY = 0;
71154
- const convertIndex = {
71155
- x: {
71156
- y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71157
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71158
- },
71159
- y: {
71160
- x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71161
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71162
- },
71163
- z: {
71164
- x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71165
- y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71166
- },
71167
- };
71168
- const convertCursor = {
71169
- x: {
71170
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71171
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71172
- },
71173
- y: {
71174
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71175
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71176
- },
71177
- z: {
71178
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71179
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71180
- },
71181
- };
71182
- if (from === to) {
71183
- return;
71184
- }
71185
- if (from === "z" && to === "x") {
71186
- currentIndex = convertIndex[from][to](cursorNumX);
71187
- oldIndex = currentIndex * ratios[to];
71188
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71189
- convertCursorNumY = cursorNumY;
71190
- }
71191
- else if (from === "y" && to === "x") {
71192
- currentIndex = convertIndex[from][to](cursorNumX);
71193
- oldIndex = currentIndex * ratios.x;
71194
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71195
- convertCursorNumX = cursorNumY;
71196
- }
71197
- else if (from === "z" && to === "y") {
71198
- currentIndex = convertIndex[from][to](cursorNumY);
71199
- oldIndex = currentIndex * ratios[to];
71200
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71201
- convertCursorNumX = cursorNumX;
71202
- }
71203
- else if (from === "x" && to === "y") {
71204
- currentIndex = convertIndex[from][to](cursorNumY);
71205
- oldIndex = currentIndex * ratios[to];
71206
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71207
- convertCursorNumY = cursorNumX;
71208
- }
71209
- else if (from === "x" && to === "z") {
71210
- currentIndex = convertIndex[from][to](cursorNumX);
71211
- oldIndex = currentIndex * ratios[to];
71212
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71213
- convertCursorNumY = cursorNumY;
71214
- }
71215
- else if (from === "y" && to === "z") {
71216
- currentIndex = convertIndex[from][to](cursorNumY);
71217
- oldIndex = currentIndex * ratios.z;
71218
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71219
- convertCursorNumX = cursorNumX;
71220
- }
71221
- else {
71222
- return;
71223
- }
71224
- return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71225
- }
71226
71250
  /**
71227
71251
  * Switch all contrast slices' orientation
71228
71252
  * @param {string} aixs:"x" | "y" | "z"
@@ -71335,7 +71359,7 @@ class NrrdTools extends DrawToolCore {
71335
71359
  this.resetDisplaySlicesStatus();
71336
71360
  // for sphere plan a
71337
71361
  if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
71338
- this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
71362
+ this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereOrigin[axisTo][1] * this.nrrd_states.sizeFoctor, this.nrrd_states.sphereRadius);
71339
71363
  }
71340
71364
  }
71341
71365
  addSkip(index) {
@@ -72030,7 +72054,7 @@ function evaluateElement(element, weights) {
72030
72054
  }
72031
72055
 
72032
72056
  // import * as kiwrious from "copper3d_plugin_heart_k";
72033
- const REVISION = "v2.0.4";
72034
- console.log("%cCopper3D Visualisation %cBeta:v2.0.4", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72057
+ const REVISION = "v2.0.6";
72058
+ console.log("%cCopper3D Visualisation %cBeta:v2.0.6", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72035
72059
 
72036
72060
  export { CameraViewPoint, Copper3dTrackballControls, MeshNodeTool, NrrdTools, REVISION, addBoxHelper, addLabelToScene, configKiwriousHeart, convert3DPostoScreenPos, convertScreenPosto3DPos, copperMScene, copperMSceneRenderer, copperRenderer, copperRendererOnDemond, copperScene, copperSceneOnDemond, createTexture2D_NRRD, fullScreenListenner, kiwrious, loading, removeGuiFolderChilden, setHDRFilePath, throttle };