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.
@@ -69110,11 +69110,17 @@
69110
69110
  };
69111
69111
  const updateGuiSphereState = () => {
69112
69112
  if (configs.gui_states.sphere) {
69113
- configs.drawingCanvas.removeEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69113
+ // configs.drawingCanvas.removeEventListener(
69114
+ // "wheel",
69115
+ // configs.drawingPrameters.handleZoomWheel
69116
+ // );
69114
69117
  configs.removeDragMode();
69115
69118
  }
69116
69119
  else {
69117
- configs.drawingCanvas.addEventListener("wheel", configs.drawingPrameters.handleZoomWheel);
69120
+ // configs.drawingCanvas.addEventListener(
69121
+ // "wheel",
69122
+ // configs.drawingPrameters.handleZoomWheel
69123
+ // );
69118
69124
  configs.configDragMode();
69119
69125
  // clear canvas
69120
69126
  configs.clearPaint();
@@ -70000,9 +70006,10 @@
70000
70006
  e.offsetY / this.nrrd_states.sizeFoctor;
70001
70007
  this.enableCrosshair();
70002
70008
  }
70003
- else if (this.gui_states.sphere) {
70004
- let mouseX = e.offsetX;
70005
- let mouseY = e.offsetY;
70009
+ else if (this.gui_states.sphere && !this.nrrd_states.enableCursorChoose) {
70010
+ this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70011
+ let mouseX = e.offsetX / this.nrrd_states.sizeFoctor;
70012
+ let mouseY = e.offsetY / this.nrrd_states.sizeFoctor;
70006
70013
  // record mouseX,Y, and enable crosshair function
70007
70014
  this.nrrd_states.sphereOrigin[this.protectedData.axis] = [
70008
70015
  mouseX,
@@ -70014,7 +70021,7 @@
70014
70021
  this.nrrd_states.cursorPageY = mouseY;
70015
70022
  this.enableCrosshair();
70016
70023
  // draw circle setup width/height for sphere canvas
70017
- this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70024
+ this.drawSphere(e.offsetX, e.offsetY, this.nrrd_states.sphereRadius);
70018
70025
  this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70019
70026
  this.protectedData.canvases.drawingCanvas.addEventListener("pointerup", this.drawingPrameters.handleOnDrawingMouseUp);
70020
70027
  }
@@ -70136,9 +70143,14 @@
70136
70143
  }
70137
70144
  }
70138
70145
  !!this.nrrd_states.getSphere &&
70139
- this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius);
70146
+ this.nrrd_states.getSphere(this.nrrd_states.sphereOrigin.z, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70147
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70140
70148
  this.protectedData.canvases.drawingCanvas.removeEventListener("wheel", this.drawingPrameters.handleSphereWheel, true);
70141
70149
  }
70150
+ else if (this.gui_states.sphere &&
70151
+ this.nrrd_states.enableCursorChoose) {
70152
+ this.protectedData.canvases.drawingCanvas.addEventListener("wheel", this.drawingPrameters.handleZoomWheel);
70153
+ }
70142
70154
  }
70143
70155
  else if (e.button === 2) {
70144
70156
  rightclicked = false;
@@ -70324,19 +70336,20 @@
70324
70336
  // this.nrrd_states.originWidth;
70325
70337
  const delta = e.detail ? e.detail > 0 : e.wheelDelta < 0;
70326
70338
  this.protectedData.Is_Draw = true;
70327
- const ratioL = (e.clientX -
70339
+ var rect = this.container.getBoundingClientRect();
70340
+ const ratioL = (e.clientX - rect.left -
70328
70341
  this.mainAreaContainer.offsetLeft -
70329
70342
  this.protectedData.canvases.drawingCanvas.offsetLeft) /
70330
70343
  this.protectedData.canvases.drawingCanvas.offsetWidth;
70331
- const ratioT = (e.clientY -
70344
+ const ratioT = (e.clientY - rect.top -
70332
70345
  this.mainAreaContainer.offsetTop -
70333
70346
  this.protectedData.canvases.drawingCanvas.offsetTop) /
70334
70347
  this.protectedData.canvases.drawingCanvas.offsetHeight;
70335
70348
  const ratioDelta = !delta ? 1 + 0.1 : 1 - 0.1;
70336
70349
  const w = this.protectedData.canvases.drawingCanvas.offsetWidth * ratioDelta;
70337
70350
  const h = this.protectedData.canvases.drawingCanvas.offsetHeight * ratioDelta;
70338
- const l = Math.round(e.clientX - this.mainAreaContainer.offsetLeft - w * ratioL);
70339
- const t = Math.round(e.clientY - this.mainAreaContainer.offsetTop - h * ratioT);
70351
+ const l = Math.round(e.clientX - this.mainAreaContainer.offsetLeft - w * ratioL - rect.left);
70352
+ const t = Math.round(e.clientY - this.mainAreaContainer.offsetTop - h * ratioT - rect.top);
70340
70353
  moveDistance = w / this.nrrd_states.originWidth;
70341
70354
  if (moveDistance > 8) {
70342
70355
  moveDistance = 8;
@@ -70394,17 +70407,12 @@
70394
70407
  const nextIndex = originIndex + decay;
70395
70408
  const ctx = this.protectedData.ctxes.drawingSphereCtx;
70396
70409
  const canvas = this.protectedData.canvases.drawingSphereCanvas;
70397
- // if (
70398
- // preIndex < this.nrrd_states.minIndex ||
70399
- // nextIndex > this.nrrd_states.maxIndex
70400
- // )
70401
- // return;
70402
70410
  if (preIndex === nextIndex) {
70403
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius);
70411
+ this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius / this.nrrd_states.sizeFoctor);
70404
70412
  this.storeSphereImages(preIndex, axis);
70405
70413
  }
70406
70414
  else {
70407
- this.drawSphereCore(ctx, mouseX, mouseY, this.nrrd_states.sphereRadius - decay);
70415
+ this.drawSphereCore(ctx, mouseX, mouseY, (this.nrrd_states.sphereRadius - decay) / this.nrrd_states.sizeFoctor);
70408
70416
  this.drawImageOnEmptyImage(canvas);
70409
70417
  this.storeSphereImages(preIndex, axis);
70410
70418
  this.storeSphereImages(nextIndex, axis);
@@ -70413,7 +70421,7 @@
70413
70421
  }
70414
70422
  drawSphereCore(ctx, x, y, radius) {
70415
70423
  ctx.beginPath();
70416
- ctx.arc(x, y, radius * this.nrrd_states.sizeFoctor, 0, 2 * Math.PI);
70424
+ ctx.arc(x, y, radius, 0, 2 * Math.PI);
70417
70425
  ctx.fillStyle = this.gui_states.fillColor;
70418
70426
  ctx.fill();
70419
70427
  ctx.closePath();
@@ -70453,8 +70461,8 @@
70453
70461
  // limited the radius max and min
70454
70462
  this.nrrd_states.sphereRadius = Math.max(1, Math.min(this.nrrd_states.sphereRadius, 50));
70455
70463
  // get mouse position
70456
- const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0];
70457
- const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1];
70464
+ const mouseX = this.nrrd_states.sphereOrigin[this.protectedData.axis][0] * this.nrrd_states.sizeFoctor;
70465
+ const mouseY = this.nrrd_states.sphereOrigin[this.protectedData.axis][1] * this.nrrd_states.sizeFoctor;
70458
70466
  this.drawSphere(mouseX, mouseY, this.nrrd_states.sphereRadius);
70459
70467
  };
70460
70468
  return sphereEvent;
@@ -70471,6 +70479,102 @@
70471
70479
  this.drawSphereCore(ctx, mouseX, mouseY, radius);
70472
70480
  this.protectedData.ctxes.drawingLayerMasterCtx.drawImage(canvas, 0, 0, this.nrrd_states.changedWidth, this.nrrd_states.changedHeight);
70473
70481
  }
70482
+ /**
70483
+ * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
70484
+ * 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.
70485
+ *
70486
+ * 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.
70487
+ *
70488
+ * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
70489
+ *
70490
+ * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
70491
+ * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
70492
+ * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
70493
+ * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
70494
+ * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
70495
+ * @returns
70496
+ */
70497
+ convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
70498
+ const nrrd = this.nrrd_states;
70499
+ const dimensions = nrrd.dimensions;
70500
+ const ratios = nrrd.ratios;
70501
+ const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
70502
+ let currentIndex = 0;
70503
+ let oldIndex = 0;
70504
+ let convertCursorNumX = 0;
70505
+ let convertCursorNumY = 0;
70506
+ const convertIndex = {
70507
+ x: {
70508
+ y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70509
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70510
+ },
70511
+ y: {
70512
+ x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70513
+ z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
70514
+ },
70515
+ z: {
70516
+ x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
70517
+ y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
70518
+ },
70519
+ };
70520
+ const convertCursor = {
70521
+ x: {
70522
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70523
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
70524
+ },
70525
+ y: {
70526
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70527
+ z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
70528
+ },
70529
+ z: {
70530
+ x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70531
+ y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
70532
+ },
70533
+ };
70534
+ if (from === to) {
70535
+ return;
70536
+ }
70537
+ if (from === "z" && to === "x") {
70538
+ currentIndex = convertIndex[from][to](cursorNumX);
70539
+ oldIndex = currentIndex * ratios[to];
70540
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70541
+ convertCursorNumY = cursorNumY;
70542
+ }
70543
+ else if (from === "y" && to === "x") {
70544
+ currentIndex = convertIndex[from][to](cursorNumX);
70545
+ oldIndex = currentIndex * ratios.x;
70546
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70547
+ convertCursorNumX = cursorNumY;
70548
+ }
70549
+ else if (from === "z" && to === "y") {
70550
+ currentIndex = convertIndex[from][to](cursorNumY);
70551
+ oldIndex = currentIndex * ratios[to];
70552
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70553
+ convertCursorNumX = cursorNumX;
70554
+ }
70555
+ else if (from === "x" && to === "y") {
70556
+ currentIndex = convertIndex[from][to](cursorNumY);
70557
+ oldIndex = currentIndex * ratios[to];
70558
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70559
+ convertCursorNumY = cursorNumX;
70560
+ }
70561
+ else if (from === "x" && to === "z") {
70562
+ currentIndex = convertIndex[from][to](cursorNumX);
70563
+ oldIndex = currentIndex * ratios[to];
70564
+ convertCursorNumX = convertCursor[from][to](currentSliceIndex);
70565
+ convertCursorNumY = cursorNumY;
70566
+ }
70567
+ else if (from === "y" && to === "z") {
70568
+ currentIndex = convertIndex[from][to](cursorNumY);
70569
+ oldIndex = currentIndex * ratios.z;
70570
+ convertCursorNumY = convertCursor[from][to](currentSliceIndex);
70571
+ convertCursorNumX = cursorNumX;
70572
+ }
70573
+ else {
70574
+ return;
70575
+ }
70576
+ return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
70577
+ }
70474
70578
  setUpSphereOrigins(mouseX, mouseY) {
70475
70579
  const convertCursor = (from, to) => {
70476
70580
  const convertObj = this.convertCursorPoint(from, to, mouseX, mouseY, this.nrrd_states.currentIndex);
@@ -70951,6 +71055,22 @@
70951
71055
  flipDisplayImageByAxis: this.flipDisplayImageByAxis,
70952
71056
  filterDrawedImage: this.filterDrawedImage,
70953
71057
  setEmptyCanvasSize: this.setEmptyCanvasSize,
71058
+ storeAllImages: this.storeAllImages,
71059
+ drawImageOnEmptyImage: this.drawImageOnEmptyImage,
71060
+ checkSharedPlaceSlice: this.checkSharedPlaceSlice,
71061
+ replaceArray: this.replaceArray,
71062
+ findSliceInSharedPlace: this.findSliceInSharedPlace,
71063
+ sliceArrayH: this.sliceArrayH,
71064
+ sliceArrayV: this.sliceArrayV,
71065
+ storeImageToAxis: this.storeImageToAxis,
71066
+ replaceVerticalColPixels: this.replaceVerticalColPixels,
71067
+ replaceHorizontalRowPixels: this.replaceHorizontalRowPixels,
71068
+ storeEachLayerImage: this.storeEachLayerImage,
71069
+ storeImageToLabel: this.storeImageToLabel,
71070
+ getRestLabel: this.getRestLabel,
71071
+ setIsDrawFalse: this.setIsDrawFalse,
71072
+ initPaintImages: this.initPaintImages,
71073
+ createEmptyPaintImage: this.createEmptyPaintImage,
70954
71074
  };
70955
71075
  this.guiParameterSettings = setupGui(guiOptions);
70956
71076
  }
@@ -71135,102 +71255,6 @@
71135
71255
  paintImages.z.push(initMark_z);
71136
71256
  }
71137
71257
  }
71138
- /**
71139
- * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
71140
- * 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.
71141
- *
71142
- * 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.
71143
- *
71144
- * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
71145
- *
71146
- * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
71147
- * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
71148
- * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
71149
- * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
71150
- * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
71151
- * @returns
71152
- */
71153
- convertCursorPoint(from, to, cursorNumX, cursorNumY, currentSliceIndex) {
71154
- const nrrd = this.nrrd_states;
71155
- const dimensions = nrrd.dimensions;
71156
- const ratios = nrrd.ratios;
71157
- const { nrrd_x_mm, nrrd_y_mm, nrrd_z_mm } = nrrd;
71158
- let currentIndex = 0;
71159
- let oldIndex = 0;
71160
- let convertCursorNumX = 0;
71161
- let convertCursorNumY = 0;
71162
- const convertIndex = {
71163
- x: {
71164
- y: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71165
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71166
- },
71167
- y: {
71168
- x: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71169
- z: (val) => Math.ceil((val / nrrd_z_mm) * dimensions[2]),
71170
- },
71171
- z: {
71172
- x: (val) => Math.ceil((val / nrrd_x_mm) * dimensions[0]),
71173
- y: (val) => Math.ceil((val / nrrd_y_mm) * dimensions[1]),
71174
- },
71175
- };
71176
- const convertCursor = {
71177
- x: {
71178
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71179
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[0]) * nrrd_x_mm),
71180
- },
71181
- y: {
71182
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71183
- z: (sliceIndex) => Math.ceil((sliceIndex / dimensions[1]) * nrrd_y_mm),
71184
- },
71185
- z: {
71186
- x: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71187
- y: (sliceIndex) => Math.ceil((sliceIndex / dimensions[2]) * nrrd_z_mm),
71188
- },
71189
- };
71190
- if (from === to) {
71191
- return;
71192
- }
71193
- if (from === "z" && to === "x") {
71194
- currentIndex = convertIndex[from][to](cursorNumX);
71195
- oldIndex = currentIndex * ratios[to];
71196
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71197
- convertCursorNumY = cursorNumY;
71198
- }
71199
- else if (from === "y" && to === "x") {
71200
- currentIndex = convertIndex[from][to](cursorNumX);
71201
- oldIndex = currentIndex * ratios.x;
71202
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71203
- convertCursorNumX = cursorNumY;
71204
- }
71205
- else if (from === "z" && to === "y") {
71206
- currentIndex = convertIndex[from][to](cursorNumY);
71207
- oldIndex = currentIndex * ratios[to];
71208
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71209
- convertCursorNumX = cursorNumX;
71210
- }
71211
- else if (from === "x" && to === "y") {
71212
- currentIndex = convertIndex[from][to](cursorNumY);
71213
- oldIndex = currentIndex * ratios[to];
71214
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71215
- convertCursorNumY = cursorNumX;
71216
- }
71217
- else if (from === "x" && to === "z") {
71218
- currentIndex = convertIndex[from][to](cursorNumX);
71219
- oldIndex = currentIndex * ratios[to];
71220
- convertCursorNumX = convertCursor[from][to](currentSliceIndex);
71221
- convertCursorNumY = cursorNumY;
71222
- }
71223
- else if (from === "y" && to === "z") {
71224
- currentIndex = convertIndex[from][to](cursorNumY);
71225
- oldIndex = currentIndex * ratios.z;
71226
- convertCursorNumY = convertCursor[from][to](currentSliceIndex);
71227
- convertCursorNumX = cursorNumX;
71228
- }
71229
- else {
71230
- return;
71231
- }
71232
- return { currentIndex, oldIndex, convertCursorNumX, convertCursorNumY };
71233
- }
71234
71258
  /**
71235
71259
  * Switch all contrast slices' orientation
71236
71260
  * @param {string} aixs:"x" | "y" | "z"
@@ -71343,7 +71367,7 @@
71343
71367
  this.resetDisplaySlicesStatus();
71344
71368
  // for sphere plan a
71345
71369
  if (this.gui_states.sphere && !this.nrrd_states.spherePlanB) {
71346
- this.drawSphere(this.nrrd_states.sphereOrigin[axisTo][0], this.nrrd_states.sphereOrigin[axisTo][1], this.nrrd_states.sphereRadius);
71370
+ 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);
71347
71371
  }
71348
71372
  }
71349
71373
  addSkip(index) {
@@ -72038,8 +72062,8 @@
72038
72062
  }
72039
72063
 
72040
72064
  // import * as kiwrious from "copper3d_plugin_heart_k";
72041
- const REVISION = "v2.0.4";
72042
- console.log("%cCopper3D Visualisation %cBeta:v2.0.4", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72065
+ const REVISION = "v2.0.6";
72066
+ console.log("%cCopper3D Visualisation %cBeta:v2.0.6", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
72043
72067
 
72044
72068
  exports.CameraViewPoint = CameraViewPoint;
72045
72069
  exports.Copper3dTrackballControls = Copper3dTrackballControls;
package/dist/index.d.ts CHANGED
@@ -19,6 +19,6 @@ import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
19
19
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader } from "./types/types";
20
20
  import { IPaintImage } from "./Utils/segmentation/coreTools/coreType";
21
21
  import "./css/style.css";
22
- export declare const REVISION = "v2.0.4";
22
+ export declare const REVISION = "v2.0.6";
23
23
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
24
24
  export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, };
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import { Copper3dTrackballControls } from "./Controls/Copper3dTrackballControls"
18
18
  import { MeshNodeTool } from "./Utils/MeshNodeTool";
19
19
  import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
20
20
  import "./css/style.css";
21
- export const REVISION = "v2.0.4";
22
- console.log("%cCopper3D Visualisation %cBeta:v2.0.4", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
21
+ export const REVISION = "v2.0.6";
22
+ console.log("%cCopper3D Visualisation %cBeta:v2.0.6", "padding: 3px;color:white; background:#023047", "padding: 3px;color:white; background:#f50a25");
23
23
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
24
24
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { IDrawingEvents, IDrawOpts, IUndoType } from "./coreTools/coreType";
1
+ import { IDrawingEvents, IDrawOpts, IPaintImage, IPaintImages, IUndoType } from "./coreTools/coreType";
2
2
  import { CommToolsData } from "./CommToolsData";
3
3
  export declare class DrawToolCore extends CommToolsData {
4
4
  container: HTMLElement;
@@ -23,7 +23,7 @@ export declare class DrawToolCore extends CommToolsData {
23
23
  private useEraser;
24
24
  private configMouseZoomWheel;
25
25
  private enableCrosshair;
26
- private drawImageOnEmptyImage;
26
+ drawImageOnEmptyImage(canvas: HTMLCanvasElement): void;
27
27
  /****************************Sphere functions****************************************************/
28
28
  private storeSphereImages;
29
29
  private drawSphereOnEachViews;
@@ -31,9 +31,30 @@ export declare class DrawToolCore extends CommToolsData {
31
31
  private setSphereCanvasSize;
32
32
  private configMouseSphereWheel;
33
33
  drawSphere(mouseX: number, mouseY: number, radius: number): void;
34
+ /**
35
+ * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
36
+ * 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.
37
+ *
38
+ * 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.
39
+ *
40
+ * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
41
+ *
42
+ * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
43
+ * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
44
+ * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
45
+ * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
46
+ * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
47
+ * @returns
48
+ */
49
+ convertCursorPoint(from: "x" | "y" | "z", to: "x" | "y" | "z", cursorNumX: number, cursorNumY: number, currentSliceIndex: number): {
50
+ currentIndex: number;
51
+ oldIndex: number;
52
+ convertCursorNumX: number;
53
+ convertCursorNumY: number;
54
+ } | undefined;
34
55
  private setUpSphereOrigins;
35
56
  /****************************label div controls****************************************************/
36
- private getRestLabel;
57
+ getRestLabel(): ("label1" | "label2" | "label3")[];
37
58
  /**************************** Undo clear functions****************************************************/
38
59
  private getCurrentUndo;
39
60
  /**
@@ -42,12 +63,12 @@ export declare class DrawToolCore extends CommToolsData {
42
63
  clearPaint(): void;
43
64
  undoLastPainting(): void;
44
65
  /****************************Store images****************************************************/
45
- private storeImageToAxis;
66
+ storeImageToAxis(index: number, paintedImages: IPaintImages, imageData: ImageData, axis?: "x" | "y" | "z"): void;
46
67
  storeAllImages(index: number, label: string): void;
47
- private storeImageToLabel;
68
+ storeImageToLabel(index: number, canvas: HTMLCanvasElement, paintedImages: IPaintImages): ImageData;
48
69
  storeEachLayerImage(index: number, label: string): void;
49
- private sliceArrayH;
50
- private sliceArrayV;
70
+ sliceArrayH(arr: Uint8ClampedArray, row: number, col: number): Uint8ClampedArray[];
71
+ sliceArrayV(arr: Uint8ClampedArray, row: number, col: number): number[][];
51
72
  /**
52
73
  *
53
74
  * @param paintImageArray : the target view slice's marked images array
@@ -57,7 +78,7 @@ export declare class DrawToolCore extends CommToolsData {
57
78
  * @param targetWidth : the target image width
58
79
  * @param convertIndex : Mapping current image's index to target slice image's width/height pixel start point
59
80
  */
60
- private replaceVerticalColPixels;
81
+ replaceVerticalColPixels(paintImageArray: IPaintImage[], length: number, ratio: number, markedArr: number[][] | Uint8ClampedArray[], targetWidth: number, convertIndex: number): void;
61
82
  /**
62
83
  *
63
84
  * @param paintImageArray : the target view slice's marked images array
@@ -67,11 +88,11 @@ export declare class DrawToolCore extends CommToolsData {
67
88
  * @param targetWidth : the target image width
68
89
  * @param convertIndex : Mapping current image's index to target slice image's width/height pixel start point
69
90
  */
70
- private replaceHorizontalRowPixels;
91
+ replaceHorizontalRowPixels(paintImageArray: IPaintImage[], length: number, ratio: number, markedArr: number[][] | Uint8ClampedArray[], targetWidth: number, convertIndex: number): void;
71
92
  /****************************** Utils for store image and itksnap core **************************************/
72
- private checkSharedPlaceSlice;
73
- private replaceArray;
74
- private findSliceInSharedPlace;
93
+ checkSharedPlaceSlice(width: number, height: number, imageData: ImageData): Uint8ClampedArray;
94
+ replaceArray(mainArr: number[] | Uint8ClampedArray, replaceArr: number[] | Uint8ClampedArray): void;
95
+ findSliceInSharedPlace(): ImageData[];
75
96
  /******************************** Utils gui related functions ***************************************/
76
97
  updateSlicesContrast(value: number, flag: string): void;
77
98
  repraintCurrentContrastSlice(): void;
@@ -63,27 +63,6 @@ export declare class NrrdTools extends DrawToolCore {
63
63
  */
64
64
  private initPaintImages;
65
65
  private createEmptyPaintImage;
66
- /**
67
- * We generate the MRI slice from threejs based on mm, but when we display it is based on pixel size/distance.
68
- * 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.
69
- *
70
- * 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.
71
- *
72
- * Then as for the crosshair (Cursor Inspector), we also need to convert the cursor point (x, y, z) to other views' (x, y, z).
73
- *
74
- * @param from "x" | "y" | "z", current view axis, "x: sagittle, y: coronal, z: axial".
75
- * @param to "x" | "y" | "z", target view axis (where you want jump to), "x: sagittle, y: coronal, z: axial".
76
- * @param cursorNumX number, cursor point x on current axis's slice. (pixel distance)
77
- * @param cursorNumY number, cursor point y on current axis's slice. (pixel distance)
78
- * @param currentSliceIndex number, current axis's slice's index/depth. (mm distance)
79
- * @returns
80
- */
81
- convertCursorPoint(from: "x" | "y" | "z", to: "x" | "y" | "z", cursorNumX: number, cursorNumY: number, currentSliceIndex: number): {
82
- currentIndex: number;
83
- oldIndex: number;
84
- convertCursorNumX: number;
85
- convertCursorNumY: number;
86
- } | undefined;
87
66
  /**
88
67
  * Switch all contrast slices' orientation
89
68
  * @param {string} aixs:"x" | "y" | "z"
@@ -28,6 +28,22 @@ interface IConfigGUI {
28
28
  flipDisplayImageByAxis: () => void;
29
29
  filterDrawedImage: (axis: "x" | "y" | "z", sliceIndex: number, paintedImages: IPaintImages) => IPaintImage;
30
30
  setEmptyCanvasSize: (axis?: "x" | "y" | "z") => void;
31
+ storeAllImages: (index: number, label: string) => void;
32
+ drawImageOnEmptyImage: (canvas: HTMLCanvasElement) => void;
33
+ checkSharedPlaceSlice: (width: number, height: number, imageData: ImageData) => Uint8ClampedArray;
34
+ replaceArray: (mainArr: number[] | Uint8ClampedArray, replaceArr: number[] | Uint8ClampedArray) => void;
35
+ findSliceInSharedPlace: () => ImageData[];
36
+ sliceArrayH: (arr: Uint8ClampedArray, row: number, col: number) => Uint8ClampedArray[];
37
+ sliceArrayV: (arr: Uint8ClampedArray, row: number, col: number) => number[][];
38
+ storeImageToAxis: (index: number, paintedImages: IPaintImages, imageData: ImageData, axis?: "x" | "y" | "z") => void;
39
+ replaceVerticalColPixels: (paintImageArray: IPaintImage[], length: number, ratio: number, markedArr: number[][] | Uint8ClampedArray[], targetWidth: number, convertIndex: number) => void;
40
+ replaceHorizontalRowPixels: (paintImageArray: IPaintImage[], length: number, ratio: number, markedArr: number[][] | Uint8ClampedArray[], targetWidth: number, convertIndex: number) => void;
41
+ storeEachLayerImage: (index: number, label: string) => void;
42
+ storeImageToLabel: (index: number, canvas: HTMLCanvasElement, paintedImages: IPaintImages) => ImageData;
43
+ getRestLabel: () => ("label1" | "label2" | "label3")[];
44
+ setIsDrawFalse: (target: number) => void;
45
+ initPaintImages: (dimensions: Array<number>) => void;
46
+ createEmptyPaintImage: (dimensions: Array<number>, paintImages: IPaintImages) => void;
31
47
  }
32
48
  declare function setupGui(configs: IConfigGUI): {
33
49
  globalAlpha: {
@@ -19,6 +19,6 @@ import { removeGuiFolderChilden } from "./Utils/segmentation/coreTools/gui";
19
19
  import { nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, exportPaintImageType, IOptVTKLoader } from "./types/types";
20
20
  import { IPaintImage } from "./Utils/segmentation/coreTools/coreType";
21
21
  import "./css/style.css";
22
- export declare const REVISION = "v2.0.4";
22
+ export declare const REVISION = "v2.0.6";
23
23
  export { copperRenderer, copperRendererOnDemond, copperMSceneRenderer, setHDRFilePath, addLabelToScene, convert3DPostoScreenPos, convertScreenPosto3DPos, addBoxHelper, fullScreenListenner, configKiwriousHeart, copperScene, copperSceneOnDemond, copperMScene, CameraViewPoint, kiwrious, NrrdTools, loading, Copper3dTrackballControls, createTexture2D_NRRD, MeshNodeTool, throttle, removeGuiFolderChilden, };
24
24
  export type { positionType, screenPosType, optsType, nrrdMeshesType, nrrdSliceType, SensorDecodedValue_kiwrious, SensorReadResult_kiwrious, HeartRateResult_kiwrious, loadingBarType, IPaintImage, exportPaintImageType, IOptVTKLoader, };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "copper3d",
3
3
  "description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "main": "dist/bundle.umd.js",
6
6
  "moudle": "dist/bundle.esm.js",
7
7
  "types": "dist/types/index.d.ts",