@ohif/app 3.8.0-beta.23 → 3.8.0-beta.25

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.
Files changed (38) hide show
  1. package/dist/{663.bundle.eae1939c22b73ea4c29f.js → 170.bundle.ba2b6bb9a1910e348f9c.js} +11 -20
  2. package/dist/{181.bundle.bce8ecb8af857b2513df.js → 181.bundle.8bbcaf31270dd56cad1f.js} +4 -4
  3. package/dist/{563.bundle.4debceb80aee325eec86.js → 185.bundle.4a026a3eda76e8d34517.js} +4 -11
  4. package/dist/{126.bundle.0ebe6d5227b3e9481532.js → 199.bundle.d8b92b7ec7c7dd91d160.js} +4 -11
  5. package/dist/{202.bundle.ec714227032b22d4fa24.js → 202.bundle.07442d396db3161ee7f3.js} +336 -328
  6. package/dist/20fc4c659b85ccd2a9c0.wasm +0 -0
  7. package/dist/{250.bundle.6ca102e0e62885294c23.js → 250.bundle.de8df38690c1305b2f8a.js} +2 -2
  8. package/dist/{575.bundle.b400797624d717956cfb.js → 420.bundle.d2a09d89c3e8177bc0d9.js} +7 -16
  9. package/dist/{221.bundle.cf2ed62de0a9445c9239.js → 466.bundle.fd2557fe99960d7ee96b.js} +6 -13
  10. package/dist/{47.bundle.01d2751a9fd67b3d5390.js → 47.bundle.3217b1b873983a6aaa43.js} +341 -266
  11. package/dist/{788.bundle.57fbc328e3554d9f4659.js → 483.bundle.067bce093473b53dd0f7.js} +6 -13
  12. package/dist/{82.bundle.122d1b58bc3e22439dd9.js → 544.bundle.b2b65dd140e9854cb129.js} +1228 -829
  13. package/dist/{738.bundle.e03f4127b014ff8ab5a5.js → 738.bundle.5b64bfcded95e22063af.js} +2 -2
  14. package/dist/{822.bundle.4f0424bd1dc0308bb489.js → 822.bundle.1f4c9e059e87914fc12a.js} +2 -2
  15. package/dist/{236.bundle.19118b0e7881c6359804.js → 965.bundle.9b78983e1a5791031169.js} +3 -10
  16. package/dist/{app.bundle.e18399dc0b54a4851b2d.js → app.bundle.2406c53a19408fc29486.js} +82227 -806
  17. package/dist/cornerstoneDICOMImageLoader.min.js +1 -1
  18. package/dist/cornerstoneDICOMImageLoader.min.js.map +1 -1
  19. package/dist/index.html +1 -1
  20. package/dist/{index.worker.e62ecca63f1a2e124230.worker.js → index.worker.64c896c4316fcd506666.worker.js} +2 -2
  21. package/dist/index.worker.64c896c4316fcd506666.worker.js.map +1 -0
  22. package/dist/sw.js +1 -1
  23. package/package.json +18 -18
  24. package/dist/231.bundle.8aad229e39e23731d6c1.js +0 -79023
  25. package/dist/75788f12450d4c5ed494.wasm +0 -0
  26. package/dist/775.bundle.2285e7e0e67878948c0d.js +0 -1009
  27. package/dist/index.worker.e62ecca63f1a2e124230.worker.js.map +0 -1
  28. /package/dist/{12.bundle.c3dc58d8dff2e83ce920.js → 12.bundle.37529fdf74d10cccda3d.js} +0 -0
  29. /package/dist/{19.bundle.60717b06985980e0a237.js → 19.bundle.706b1020e6d744b4a772.js} +0 -0
  30. /package/dist/{281.bundle.93c845676e4645263c8d.js → 281.bundle.bfa24595c2dcbcfc227a.js} +0 -0
  31. /package/dist/{359.bundle.94a407fdbfcb299f2dc2.js → 359.bundle.eabc596f016eb73fa622.js} +0 -0
  32. /package/dist/{410.bundle.116f4a42e6b76e0a2bcb.js → 410.bundle.1736835db3336e98c495.js} +0 -0
  33. /package/dist/{575.css → 420.css} +0 -0
  34. /package/dist/{221.css → 466.css} +0 -0
  35. /package/dist/{506.bundle.20af254ec61a959452cc.js → 506.bundle.ca89ebd941bebab77590.js} +0 -0
  36. /package/dist/{613.bundle.59befe43e90034b4d879.js → 613.bundle.40f071699be75c012842.js} +0 -0
  37. /package/dist/{687.bundle.60a8d6ae5f913c189168.js → 687.bundle.2ac3cd797e3d5be5f053.js} +0 -0
  38. /package/dist/{814.bundle.4b853464ad249a249029.js → 814.bundle.1328537fe47b9a202135.js} +0 -0
@@ -1,6 +1,6 @@
1
- (self["webpackChunk"] = self["webpackChunk"] || []).push([[82],{
1
+ (self["webpackChunk"] = self["webpackChunk"] || []).push([[544],{
2
2
 
3
- /***/ 28082:
3
+ /***/ 91544:
4
4
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5
5
 
6
6
  "use strict";
@@ -25,6 +25,7 @@ __webpack_require__.d(__webpack_exports__, {
25
25
  DragProbeTool: () => (/* reexport */ annotation_DragProbeTool),
26
26
  EllipticalROITool: () => (/* reexport */ annotation_EllipticalROITool),
27
27
  Enums: () => (/* reexport */ enums_namespaceObject),
28
+ KeyImageTool: () => (/* reexport */ annotation_KeyImageTool),
28
29
  LengthTool: () => (/* reexport */ annotation_LengthTool),
29
30
  MIPJumpToClickTool: () => (/* reexport */ tools_MIPJumpToClickTool),
30
31
  MagnifyTool: () => (/* reexport */ tools_MagnifyTool),
@@ -321,6 +322,7 @@ __webpack_require__.d(elementCursor_namespaceObject, {
321
322
  var annotation_namespaceObject = {};
322
323
  __webpack_require__.r(annotation_namespaceObject);
323
324
  __webpack_require__.d(annotation_namespaceObject, {
325
+ AnnotationGroup: () => (AnnotationGroup),
324
326
  FrameOfReferenceSpecificAnnotationManager: () => (annotation_FrameOfReferenceSpecificAnnotationManager),
325
327
  config: () => (annotation_config_namespaceObject),
326
328
  locking: () => (annotationLocking_namespaceObject),
@@ -528,6 +530,7 @@ __webpack_require__.d(voi_namespaceObject, {
528
530
  var esm_utilities_namespaceObject = {};
529
531
  __webpack_require__.r(esm_utilities_namespaceObject);
530
532
  __webpack_require__.d(esm_utilities_namespaceObject, {
533
+ annotationFrameRange: () => (AnnotationFrameRange),
531
534
  boundingBox: () => (boundingBox_namespaceObject),
532
535
  calibrateImageSpacing: () => (calibrateImageSpacing),
533
536
  cine: () => (cine_namespaceObject),
@@ -537,6 +540,8 @@ __webpack_require__.d(esm_utilities_namespaceObject, {
537
540
  dynamicVolume: () => (dynamicVolume_namespaceObject),
538
541
  getAnnotationNearPoint: () => (getAnnotationNearPoint),
539
542
  getAnnotationNearPointOnEnabledElement: () => (getAnnotationNearPointOnEnabledElement),
543
+ getCalibratedLengthUnits: () => (getCalibratedUnits),
544
+ getCalibratedScale: () => (getCalibratedScale),
540
545
  isObject: () => (utilities_isObject),
541
546
  jumpToSlice: () => (viewport_jumpToSlice),
542
547
  math: () => (math_namespaceObject),
@@ -624,8 +629,8 @@ __webpack_require__.d(synchronizers_namespaceObject, {
624
629
  var types_namespaceObject = {};
625
630
  __webpack_require__.r(types_namespaceObject);
626
631
 
627
- // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 344 modules
628
- var esm = __webpack_require__(62231);
632
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 356 modules
633
+ var esm = __webpack_require__(63442);
629
634
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/enums/ToolBindings.js
630
635
  var MouseBindings;
631
636
  (function (MouseBindings) {
@@ -9432,6 +9437,14 @@ class BaseTool {
9432
9437
  }
9433
9438
  return viewports[0].getImageData();
9434
9439
  }
9440
+ else if (targetId.startsWith('videoId:')) {
9441
+ const imageURI = esm.utilities.imageIdToURI(targetId);
9442
+ const viewports = esm.utilities.getViewportsWithImageURI(imageURI, renderingEngine.id);
9443
+ if (!viewports || !viewports.length) {
9444
+ return;
9445
+ }
9446
+ return viewports[0].getImageData();
9447
+ }
9435
9448
  else {
9436
9449
  throw new Error('getTargetIdImage: targetId must start with "imageId:" or "volumeId:"');
9437
9450
  }
@@ -9444,7 +9457,7 @@ class BaseTool {
9444
9457
  return `volumeId:${this.getTargetVolumeId(viewport)}`;
9445
9458
  }
9446
9459
  else if (viewport instanceof esm.VideoViewport) {
9447
- return '';
9460
+ return `videoId:${viewport.getCurrentImageId()}`;
9448
9461
  }
9449
9462
  else {
9450
9463
  throw new Error('getTargetId: viewport must be a StackViewport or VolumeViewport');
@@ -10331,9 +10344,55 @@ function filterAnnotationsWithinSlice(annotations, camera, spacingInNormalDirect
10331
10344
  return annotationsWithinSlice;
10332
10345
  }
10333
10346
 
10347
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/annotationFrameRange.js
10348
+
10349
+
10350
+ class AnnotationFrameRange {
10351
+ static { this.frameRangeExtractor = /(\/frames\/|[&?]frameNumber=)([^/&?]*)/i; }
10352
+ static imageIdToFrames(imageId) {
10353
+ const match = imageId.match(this.frameRangeExtractor);
10354
+ if (!match || !match[2]) {
10355
+ return null;
10356
+ }
10357
+ const range = match[2].split('-').map((it) => Number(it));
10358
+ if (range.length === 1) {
10359
+ return range[0];
10360
+ }
10361
+ return range;
10362
+ }
10363
+ static framesToString(range) {
10364
+ if (Array.isArray(range)) {
10365
+ return `${range[0]}-${range[1]}`;
10366
+ }
10367
+ return String(range);
10368
+ }
10369
+ static framesToImageId(imageId, range) {
10370
+ const match = imageId.match(this.frameRangeExtractor);
10371
+ if (!match || !match[2]) {
10372
+ return null;
10373
+ }
10374
+ const newRangeString = this.framesToString(range);
10375
+ return imageId.replace(this.frameRangeExtractor, `${match[1]}${newRangeString}`);
10376
+ }
10377
+ static setFrameRange(annotation, range, eventBase) {
10378
+ const { referencedImageId } = annotation.metadata;
10379
+ annotation.metadata.referencedImageId = this.framesToImageId(referencedImageId, range);
10380
+ const eventDetail = {
10381
+ ...eventBase,
10382
+ annotation,
10383
+ };
10384
+ (0,esm.triggerEvent)(esm.eventTarget, enums_Events.ANNOTATION_MODIFIED, eventDetail);
10385
+ }
10386
+ static getFrameRange(annotation) {
10387
+ return this.imageIdToFrames(annotation.metadata.referencedImageId);
10388
+ }
10389
+ }
10390
+
10334
10391
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/planar/filterAnnotationsForDisplay.js
10335
10392
 
10336
10393
 
10394
+
10395
+ const baseUrlExtractor = /(videoId:|imageId:|volumeId:)([a-zA-Z]*:)/;
10337
10396
  function filterAnnotationsForDisplay(viewport, annotations) {
10338
10397
  if (viewport instanceof esm.StackViewport) {
10339
10398
  const imageId = viewport.getCurrentImageId();
@@ -10354,8 +10413,23 @@ function filterAnnotationsForDisplay(viewport, annotations) {
10354
10413
  }
10355
10414
  else if (viewport instanceof esm.VideoViewport) {
10356
10415
  const frameOfReferenceUID = viewport.getFrameOfReferenceUID();
10357
- return annotations.filter((toolData) => {
10358
- return toolData.metadata.FrameOfReferenceUID === frameOfReferenceUID;
10416
+ return annotations.filter((annotation) => {
10417
+ if (!annotation.isVisible) {
10418
+ return false;
10419
+ }
10420
+ if (annotation.metadata.FrameOfReferenceUID !== frameOfReferenceUID) {
10421
+ return false;
10422
+ }
10423
+ const testURI = annotation.metadata.referencedImageId.replace(baseUrlExtractor, '');
10424
+ if (!viewport.hasImageURI(testURI)) {
10425
+ return false;
10426
+ }
10427
+ const range = AnnotationFrameRange.getFrameRange(annotation);
10428
+ const frameNumber = viewport.getFrameNumber();
10429
+ if (Array.isArray(range)) {
10430
+ return frameNumber >= range[0] && frameNumber <= range[1];
10431
+ }
10432
+ return Math.abs(frameNumber - range) <= 5;
10359
10433
  });
10360
10434
  }
10361
10435
  else if (viewport instanceof esm.VolumeViewport) {
@@ -10447,40 +10521,45 @@ class ToolStyle {
10447
10521
  }
10448
10522
  _getToolStyle(property, annotationUID, viewportId, toolGroupId, toolName) {
10449
10523
  if (annotationUID) {
10450
- const styles = this.getAnnotationToolStyles(annotationUID);
10451
- if (styles) {
10452
- if (styles[property]) {
10453
- return styles[property];
10524
+ const annotationToolStyles = this.getAnnotationToolStyles(annotationUID);
10525
+ if (annotationToolStyles) {
10526
+ if (annotationToolStyles[property] !== undefined) {
10527
+ return annotationToolStyles[property];
10454
10528
  }
10455
10529
  }
10456
10530
  }
10457
10531
  if (viewportId) {
10458
- const styles = this.getViewportToolStyles(viewportId);
10459
- if (styles) {
10460
- if (styles[toolName] && styles[toolName][property]) {
10461
- return styles[toolName][property];
10532
+ const viewportToolStyles = this.getViewportToolStyles(viewportId);
10533
+ if (viewportToolStyles) {
10534
+ if (viewportToolStyles[toolName] &&
10535
+ viewportToolStyles[toolName][property] !== undefined) {
10536
+ return viewportToolStyles[toolName][property];
10462
10537
  }
10463
- if (styles.global && styles.global[property]) {
10464
- return styles.global[property];
10538
+ if (viewportToolStyles.global &&
10539
+ viewportToolStyles.global[property] !== undefined) {
10540
+ return viewportToolStyles.global[property];
10465
10541
  }
10466
10542
  }
10467
10543
  }
10468
10544
  if (toolGroupId) {
10469
- const styles = this.getToolGroupToolStyles(toolGroupId);
10470
- if (styles) {
10471
- if (styles[toolName] && styles[toolName][property]) {
10472
- return styles[toolName][property];
10545
+ const toolGroupToolStyles = this.getToolGroupToolStyles(toolGroupId);
10546
+ if (toolGroupToolStyles) {
10547
+ if (toolGroupToolStyles[toolName] &&
10548
+ toolGroupToolStyles[toolName][property] !== undefined) {
10549
+ return toolGroupToolStyles[toolName][property];
10473
10550
  }
10474
- if (styles.global && styles.global[property]) {
10475
- return styles.global[property];
10551
+ if (toolGroupToolStyles.global &&
10552
+ toolGroupToolStyles.global[property] !== undefined) {
10553
+ return toolGroupToolStyles.global[property];
10476
10554
  }
10477
10555
  }
10478
10556
  }
10479
10557
  const globalStyles = this.getDefaultToolStyles();
10480
- if (globalStyles[toolName] && globalStyles[toolName][property]) {
10558
+ if (globalStyles[toolName] &&
10559
+ globalStyles[toolName][property] !== undefined) {
10481
10560
  return globalStyles[toolName][property];
10482
10561
  }
10483
- if (globalStyles.global && globalStyles.global[property]) {
10562
+ if (globalStyles.global && globalStyles.global[property] !== undefined) {
10484
10563
  return globalStyles.global[property];
10485
10564
  }
10486
10565
  }
@@ -10604,10 +10683,12 @@ class AnnotationDisplayTool extends base_BaseTool {
10604
10683
  getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp) {
10605
10684
  const targetId = this.getTargetId(viewport);
10606
10685
  let referencedImageId;
10607
- if (viewport instanceof esm.StackViewport ||
10608
- viewport instanceof esm.VideoViewport) {
10686
+ if (viewport instanceof esm.StackViewport) {
10609
10687
  referencedImageId = targetId.split('imageId:')[1];
10610
10688
  }
10689
+ else if (viewport instanceof esm.VideoViewport) {
10690
+ referencedImageId = targetId.split('videoId:')[1];
10691
+ }
10611
10692
  else {
10612
10693
  const volumeId = targetId.split('volumeId:')[1];
10613
10694
  const imageVolume = esm.cache.getVolume(volumeId);
@@ -10721,13 +10802,8 @@ class AnnotationTool extends base_AnnotationDisplayTool {
10721
10802
  const volume = esm.cache.getVolume(volumeId);
10722
10803
  return volume.scaling?.PT !== undefined;
10723
10804
  }
10724
- else if (viewport instanceof esm.StackViewport) {
10725
- const scalingModule = imageId && esm.metaData.get('scalingModule', imageId);
10726
- return typeof scalingModule?.suvbw === 'number';
10727
- }
10728
- else {
10729
- throw new Error('Viewport is not a valid type');
10730
- }
10805
+ const scalingModule = imageId && esm.metaData.get('scalingModule', imageId);
10806
+ return typeof scalingModule?.suvbw === 'number';
10731
10807
  }
10732
10808
  _imagePointNearToolOrHandle(element, annotation, canvasCoords, proximity) {
10733
10809
  const handleNearImagePoint = this.getHandleNearImagePoint(element, annotation, canvasCoords, proximity);
@@ -11242,6 +11318,41 @@ function calibrateImageSpacing(imageId, renderingEngine, calibrationOrScale) {
11242
11318
  });
11243
11319
  }
11244
11320
 
11321
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getCalibratedUnits.js
11322
+
11323
+ const { CalibrationTypes } = esm.Enums;
11324
+ const PIXEL_UNITS = 'px';
11325
+ const getCalibratedLengthUnits = (handles, image) => {
11326
+ const { calibration, hasPixelSpacing } = image;
11327
+ const units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
11328
+ if (!calibration || !calibration.type) {
11329
+ return units;
11330
+ }
11331
+ if (calibration.type === CalibrationTypes.UNCALIBRATED) {
11332
+ return PIXEL_UNITS;
11333
+ }
11334
+ if (calibration.SequenceOfUltrasoundRegions) {
11335
+ return 'US Region';
11336
+ }
11337
+ return `${units} ${calibration.type}`;
11338
+ };
11339
+ const SQUARE = '\xb2';
11340
+ const getCalibratedAreaUnits = (handles, image) => {
11341
+ const { calibration, hasPixelSpacing } = image;
11342
+ const units = (hasPixelSpacing ? 'mm' : PIXEL_UNITS) + SQUARE;
11343
+ if (!calibration || !calibration.type) {
11344
+ return units;
11345
+ }
11346
+ if (calibration.SequenceOfUltrasoundRegions) {
11347
+ return 'US Region';
11348
+ }
11349
+ return `${units} ${calibration.type}`;
11350
+ };
11351
+ const getCalibratedScale = (image) => image.calibration?.scale || 1;
11352
+ const getCalibratedAspect = (image) => image.calibration?.aspect || 1;
11353
+ /* harmony default export */ const getCalibratedUnits = (getCalibratedLengthUnits);
11354
+
11355
+
11245
11356
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js
11246
11357
 
11247
11358
  function triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender) {
@@ -11385,41 +11496,42 @@ function pointInShapeCallback(imageData, pointInShapeFn, callback, boundsIJK) {
11385
11496
  const rowStep = gl_matrix_esm/* vec3.fromValues */.R3.fromValues(rowCosines[0] * rowSpacing, rowCosines[1] * rowSpacing, rowCosines[2] * rowSpacing);
11386
11497
  const columnStep = gl_matrix_esm/* vec3.fromValues */.R3.fromValues(columnCosines[0] * columnSpacing, columnCosines[1] * columnSpacing, columnCosines[2] * columnSpacing);
11387
11498
  const scanAxisStep = gl_matrix_esm/* vec3.fromValues */.R3.fromValues(scanAxisNormal[0] * scanAxisSpacing, scanAxisNormal[1] * scanAxisSpacing, scanAxisNormal[2] * scanAxisSpacing);
11388
- const yMultiple = dimensions[0];
11389
- const zMultiple = dimensions[0] * dimensions[1];
11499
+ const xMultiple = scalarData.length / dimensions[2] / dimensions[1] / dimensions[0];
11500
+ const yMultiple = dimensions[0] * xMultiple;
11501
+ const zMultiple = dimensions[1] * yMultiple;
11390
11502
  const pointsInShape = [];
11503
+ const currentPos = gl_matrix_esm/* vec3.clone */.R3.clone(worldPosStart);
11391
11504
  for (let k = kMin; k <= kMax; k++) {
11505
+ const startPosJ = gl_matrix_esm/* vec3.clone */.R3.clone(currentPos);
11392
11506
  for (let j = jMin; j <= jMax; j++) {
11507
+ const startPosI = gl_matrix_esm/* vec3.clone */.R3.clone(currentPos);
11393
11508
  for (let i = iMin; i <= iMax; i++) {
11394
11509
  const pointIJK = [i, j, k];
11395
- const dI = i - iMin;
11396
- const dJ = j - jMin;
11397
- const dK = k - kMin;
11398
- const startWorld = worldPosStart;
11399
- const pointLPS = [
11400
- startWorld[0] +
11401
- dI * rowStep[0] +
11402
- dJ * columnStep[0] +
11403
- dK * scanAxisStep[0],
11404
- startWorld[1] +
11405
- dI * rowStep[1] +
11406
- dJ * columnStep[1] +
11407
- dK * scanAxisStep[1],
11408
- startWorld[2] +
11409
- dI * rowStep[2] +
11410
- dJ * columnStep[2] +
11411
- dK * scanAxisStep[2],
11412
- ];
11413
- if (pointInShapeFn(pointLPS, pointIJK)) {
11414
- const index = k * zMultiple + j * yMultiple + i;
11415
- const value = scalarData[index];
11416
- pointsInShape.push({ value, index, pointIJK, pointLPS });
11417
- if (callback !== null) {
11418
- callback({ value, index, pointIJK, pointLPS });
11510
+ if (pointInShapeFn(currentPos, currentPos)) {
11511
+ const index = k * zMultiple + j * yMultiple + i * xMultiple;
11512
+ let value;
11513
+ if (xMultiple > 2) {
11514
+ value = [
11515
+ scalarData[index],
11516
+ scalarData[index + 1],
11517
+ scalarData[index + 2],
11518
+ ];
11519
+ }
11520
+ else {
11521
+ value = scalarData[index];
11522
+ }
11523
+ pointsInShape.push({ value, index, pointIJK, pointLPS: currentPos });
11524
+ if (callback) {
11525
+ callback({ value, index, pointIJK, pointLPS: currentPos });
11419
11526
  }
11420
11527
  }
11528
+ gl_matrix_esm/* vec3.add */.R3.add(currentPos, currentPos, rowStep);
11421
11529
  }
11530
+ gl_matrix_esm/* vec3.copy */.R3.copy(currentPos, startPosI);
11531
+ gl_matrix_esm/* vec3.add */.R3.add(currentPos, currentPos, columnStep);
11422
11532
  }
11533
+ gl_matrix_esm/* vec3.copy */.R3.copy(currentPos, startPosJ);
11534
+ gl_matrix_esm/* vec3.add */.R3.add(currentPos, currentPos, scanAxisStep);
11423
11535
  }
11424
11536
  return pointsInShape;
11425
11537
  }
@@ -11427,9 +11539,9 @@ function pointInShapeCallback(imageData, pointInShapeFn, callback, boundsIJK) {
11427
11539
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/sphere/pointInSphere.js
11428
11540
  function pointInSphere(sphere, pointLPS) {
11429
11541
  const { center, radius } = sphere;
11430
- return ((pointLPS[0] - center[0]) ** 2 +
11431
- (pointLPS[1] - center[1]) ** 2 +
11432
- (pointLPS[2] - center[2]) ** 2 <=
11542
+ return ((pointLPS[0] - center[0]) * (pointLPS[0] - center[0]) +
11543
+ (pointLPS[1] - center[1]) * (pointLPS[1] - center[1]) +
11544
+ (pointLPS[2] - center[2]) * (pointLPS[2] - center[2]) <=
11433
11545
  radius ** 2);
11434
11546
  }
11435
11547
 
@@ -11560,6 +11672,9 @@ function _computeBoundsIJKWithCamera(imageData, viewport, circlePoints, centerWo
11560
11672
 
11561
11673
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/roundNumber.js
11562
11674
  function roundNumber(value, precision = 2) {
11675
+ if (Array.isArray(value)) {
11676
+ return value.map((v) => roundNumber(v, precision)).join(', ');
11677
+ }
11563
11678
  if (value === undefined || value === null || value === '') {
11564
11679
  return 'NaN';
11565
11680
  }
@@ -12845,6 +12960,77 @@ function thresholdVolumeByRange(segmentationVolume, thresholdVolumeInformation,
12845
12960
  }
12846
12961
  /* harmony default export */ const segmentation_thresholdVolumeByRange = (thresholdVolumeByRange);
12847
12962
 
12963
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/stateManagement/annotation/AnnotationGroup.js
12964
+
12965
+
12966
+
12967
+ class AnnotationGroup {
12968
+ constructor() {
12969
+ this.annotationUIDs = new Set();
12970
+ this._isVisible = true;
12971
+ this.visibleFilter = this.unboundVisibleFilter.bind(this);
12972
+ }
12973
+ unboundVisibleFilter(uid) {
12974
+ return !this._isVisible || !this.annotationUIDs.has(uid);
12975
+ }
12976
+ has(uid) {
12977
+ return this.annotationUIDs.has(uid);
12978
+ }
12979
+ setVisible(isVisible = true, baseEvent, filter) {
12980
+ if (this._isVisible === isVisible) {
12981
+ return;
12982
+ }
12983
+ this._isVisible = isVisible;
12984
+ this.annotationUIDs.forEach((uid) => {
12985
+ const annotation = getAnnotation(uid);
12986
+ if (!annotation) {
12987
+ this.annotationUIDs.delete(uid);
12988
+ return;
12989
+ }
12990
+ if (annotation.isVisible === isVisible) {
12991
+ return;
12992
+ }
12993
+ if (!isVisible && filter?.(uid) === false) {
12994
+ return;
12995
+ }
12996
+ annotation.isVisible = isVisible;
12997
+ const eventDetail = {
12998
+ ...baseEvent,
12999
+ annotation,
13000
+ };
13001
+ (0,esm.triggerEvent)(esm.eventTarget, enums_Events.ANNOTATION_MODIFIED, eventDetail);
13002
+ });
13003
+ }
13004
+ get isVisible() {
13005
+ return this._isVisible;
13006
+ }
13007
+ findNearby(uid, direction) {
13008
+ const uids = [...this.annotationUIDs];
13009
+ if (uids.length === 0) {
13010
+ return null;
13011
+ }
13012
+ if (!uid) {
13013
+ return uids[direction === 1 ? 0 : uids.length - 1];
13014
+ }
13015
+ const index = uids.indexOf(uid);
13016
+ if (index === -1 ||
13017
+ index + direction < 0 ||
13018
+ index + direction >= uids.length) {
13019
+ return null;
13020
+ }
13021
+ return uids[index + direction];
13022
+ }
13023
+ add(...annotationUIDs) {
13024
+ annotationUIDs.forEach((annotationUID) => this.annotationUIDs.add(annotationUID));
13025
+ }
13026
+ remove(...annotationUIDs) {
13027
+ annotationUIDs.forEach((annotationUID) => this.annotationUIDs.delete(annotationUID));
13028
+ }
13029
+ clear() {
13030
+ this.annotationUIDs.clear();
13031
+ }
13032
+ }
13033
+
12848
13034
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/stateManagement/annotation/index.js
12849
13035
 
12850
13036
 
@@ -12854,6 +13040,7 @@ function thresholdVolumeByRange(segmentationVolume, thresholdVolumeInformation,
12854
13040
 
12855
13041
 
12856
13042
 
13043
+
12857
13044
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/PanTool.js
12858
13045
 
12859
13046
 
@@ -13046,21 +13233,23 @@ class WindowLevelTool extends base_BaseTool {
13046
13233
  const { renderingEngine, viewport } = enabledElement;
13047
13234
  let volumeId, lower, upper, modality, newRange, viewportsContainingVolumeUID;
13048
13235
  let isPreScaled = false;
13236
+ const properties = viewport.getProperties();
13049
13237
  if (viewport instanceof esm.VolumeViewport) {
13050
13238
  const targetId = this.getTargetId(viewport);
13051
13239
  volumeId = targetId.split('volumeId:')[1];
13052
13240
  viewportsContainingVolumeUID = esm.utilities.getViewportsWithVolumeId(volumeId, renderingEngine.id);
13053
- const properties = viewport.getProperties();
13054
13241
  ({ lower, upper } = properties.voiRange);
13055
13242
  const volume = esm.cache.getVolume(volumeId);
13243
+ if (!volume) {
13244
+ throw new Error('Volume not found ' + volumeId);
13245
+ }
13056
13246
  modality = volume.metadata.Modality;
13057
13247
  isPreScaled = volume.scaling && Object.keys(volume.scaling).length > 0;
13058
13248
  }
13059
- else if (viewport instanceof esm.StackViewport) {
13060
- const properties = viewport.getProperties();
13249
+ else if (properties.voiRange) {
13061
13250
  modality = viewport.modality;
13062
13251
  ({ lower, upper } = properties.voiRange);
13063
- const { preScale } = viewport.getImageData();
13252
+ const { preScale = { scaled: false } } = viewport.getImageData?.() || {};
13064
13253
  isPreScaled =
13065
13254
  preScale.scaled && preScale.scalingParameters?.suvbw !== undefined;
13066
13255
  }
@@ -13087,19 +13276,15 @@ class WindowLevelTool extends base_BaseTool {
13087
13276
  upper,
13088
13277
  });
13089
13278
  }
13090
- if (viewport instanceof esm.StackViewport) {
13091
- viewport.setProperties({
13092
- voiRange: newRange,
13093
- });
13094
- viewport.render();
13095
- return;
13096
- }
13279
+ viewport.setProperties({
13280
+ voiRange: newRange,
13281
+ });
13282
+ viewport.render();
13097
13283
  if (viewport instanceof esm.VolumeViewport) {
13098
- viewport.setProperties({
13099
- voiRange: newRange,
13100
- });
13101
13284
  viewportsContainingVolumeUID.forEach((vp) => {
13102
- vp.render();
13285
+ if (viewport !== vp) {
13286
+ vp.render();
13287
+ }
13103
13288
  });
13104
13289
  return;
13105
13290
  }
@@ -13155,6 +13340,9 @@ class WindowLevelTool extends base_BaseTool {
13155
13340
  _getImageDynamicRangeFromViewport(viewport) {
13156
13341
  const { imageData } = viewport.getImageData();
13157
13342
  const dimensions = imageData.getDimensions();
13343
+ if (imageData.getRange) {
13344
+ return imageData.getRange();
13345
+ }
13158
13346
  let scalarData;
13159
13347
  if (imageData.getScalarData) {
13160
13348
  scalarData = imageData.getScalarData();
@@ -13246,18 +13434,9 @@ class StackScrollTool extends base_BaseTool {
13246
13434
  }
13247
13435
  _getPixelPerImage(viewport) {
13248
13436
  const { element } = viewport;
13249
- const numberOfSlices = this._getNumberOfSlices(viewport);
13437
+ const numberOfSlices = viewport.getNumberOfSlices();
13250
13438
  return Math.max(2, element.offsetHeight / Math.max(numberOfSlices, 8));
13251
13439
  }
13252
- _getNumberOfSlices(viewport) {
13253
- if (viewport instanceof esm.VolumeViewport) {
13254
- const { numberOfSlices } = esm.utilities.getImageSliceDataForVolumeViewport(viewport);
13255
- return numberOfSlices;
13256
- }
13257
- else if (viewport instanceof esm.StackViewport) {
13258
- return viewport.getImageIds().length;
13259
- }
13260
- }
13261
13440
  }
13262
13441
  StackScrollTool.toolName = 'StackScroll';
13263
13442
  /* harmony default export */ const tools_StackScrollTool = (StackScrollTool);
@@ -14646,7 +14825,13 @@ class CrosshairsTool extends base_AnnotationTool {
14646
14825
  };
14647
14826
  this._getAnnotations = (enabledElement) => {
14648
14827
  const { viewport } = enabledElement;
14649
- return getAnnotations(this.getToolName(), viewport.element);
14828
+ const annotations = getAnnotations(this.getToolName(), viewport.element) || [];
14829
+ const viewportIds = this._getViewportsInfo().map(({ viewportId }) => viewportId);
14830
+ const toolGroupAnnotations = annotations.filter((annotation) => {
14831
+ const { data } = annotation;
14832
+ return viewportIds.includes(data.viewportId);
14833
+ });
14834
+ return toolGroupAnnotations;
14650
14835
  };
14651
14836
  this._onNewVolume = (e) => {
14652
14837
  const viewportsInfo = this._getViewportsInfo();
@@ -17114,41 +17299,712 @@ function removeExtraPoints(viewport, worldPointsSet) {
17114
17299
  SegmentationIntersectionTool.toolName = 'SegmentationIntersection';
17115
17300
  /* harmony default export */ const tools_SegmentationIntersectionTool = (SegmentationIntersectionTool);
17116
17301
 
17117
- ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getCalibratedUnits.js
17302
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/ReferenceCursors.js
17118
17303
 
17119
- const { CalibrationTypes } = esm.Enums;
17120
- const PIXEL_UNITS = 'px';
17121
- const getCalibratedLengthUnits = (handles, image) => {
17122
- const { calibration, hasPixelSpacing } = image;
17123
- const units = hasPixelSpacing ? 'mm' : PIXEL_UNITS;
17124
- if (!calibration || !calibration.type) {
17125
- return units;
17304
+
17305
+
17306
+
17307
+
17308
+
17309
+
17310
+
17311
+
17312
+
17313
+
17314
+ class ReferenceCursors extends base_AnnotationDisplayTool {
17315
+ constructor(toolProps = {}, defaultToolProps = {
17316
+ supportedInteractionTypes: ['Mouse', 'Touch'],
17317
+ configuration: {
17318
+ shadow: true,
17319
+ preventHandleOutsideImage: false,
17320
+ displayThreshold: 5,
17321
+ positionSync: true,
17322
+ disableCursor: false,
17323
+ },
17324
+ }) {
17325
+ super(toolProps, defaultToolProps);
17326
+ this.isDrawing = false;
17327
+ this.isHandleOutsideImage = false;
17328
+ this._elementWithCursor = null;
17329
+ this._currentCursorWorldPosition = null;
17330
+ this._currentCanvasPosition = null;
17331
+ this._disableCursorEnabled = false;
17332
+ this.mouseMoveCallback = (evt) => {
17333
+ const { detail } = evt;
17334
+ const { element, currentPoints } = detail;
17335
+ this._currentCursorWorldPosition = currentPoints.world;
17336
+ this._currentCanvasPosition = currentPoints.canvas;
17337
+ this._elementWithCursor = element;
17338
+ const annotation = this.getActiveAnnotation(element);
17339
+ if (annotation === null) {
17340
+ this.createInitialAnnotation(currentPoints.world, element);
17341
+ return false;
17342
+ }
17343
+ this.updateAnnotationPosition(element, annotation);
17344
+ return false;
17345
+ };
17346
+ this.createInitialAnnotation = (worldPos, element) => {
17347
+ const enabledElement = (0,esm.getEnabledElement)(element);
17348
+ if (!enabledElement) {
17349
+ throw new Error('No enabled element found');
17350
+ }
17351
+ const { viewport, renderingEngine } = enabledElement;
17352
+ this.isDrawing = true;
17353
+ const camera = viewport.getCamera();
17354
+ const { viewPlaneNormal, viewUp } = camera;
17355
+ if (!viewPlaneNormal || !viewUp) {
17356
+ throw new Error('Camera not found');
17357
+ }
17358
+ const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
17359
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
17360
+ const annotation = {
17361
+ highlighted: true,
17362
+ invalidated: true,
17363
+ metadata: {
17364
+ toolName: this.getToolName(),
17365
+ viewPlaneNormal: [...viewPlaneNormal],
17366
+ viewUp: [...viewUp],
17367
+ FrameOfReferenceUID,
17368
+ referencedImageId,
17369
+ },
17370
+ data: {
17371
+ label: '',
17372
+ handles: {
17373
+ points: [[...worldPos]],
17374
+ activeHandleIndex: null,
17375
+ textBox: {
17376
+ hasMoved: false,
17377
+ worldPosition: [0, 0, 0],
17378
+ worldBoundingBox: {
17379
+ topLeft: [0, 0, 0],
17380
+ topRight: [0, 0, 0],
17381
+ bottomLeft: [0, 0, 0],
17382
+ bottomRight: [0, 0, 0],
17383
+ },
17384
+ },
17385
+ },
17386
+ },
17387
+ };
17388
+ const annotations = getAnnotations(this.getToolName(), element);
17389
+ if (annotations.length > 0) {
17390
+ return null;
17391
+ }
17392
+ const annotationId = addAnnotation(annotation, element);
17393
+ if (annotationId === null) {
17394
+ return;
17395
+ }
17396
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName(), false);
17397
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
17398
+ };
17399
+ this.onCameraModified = (evt) => {
17400
+ const eventDetail = evt.detail;
17401
+ const { element, previousCamera, camera } = eventDetail;
17402
+ const enabledElement = (0,esm.getEnabledElement)(element);
17403
+ const viewport = enabledElement.viewport;
17404
+ if (element !== this._elementWithCursor) {
17405
+ return;
17406
+ }
17407
+ const oldFocalPoint = previousCamera.focalPoint;
17408
+ const cameraNormal = camera.viewPlaneNormal;
17409
+ const newFocalPoint = camera.focalPoint;
17410
+ const deltaCameraFocalPoint = [0, 0, 0];
17411
+ Common_Core_Math/* default.subtract */.ZP.subtract(newFocalPoint, oldFocalPoint, deltaCameraFocalPoint);
17412
+ if (deltaCameraFocalPoint.reduce((a, b) => a + b, 0) === 0) {
17413
+ return;
17414
+ }
17415
+ const dotProduct = Common_Core_Math/* default.dot */.ZP.dot(deltaCameraFocalPoint, cameraNormal);
17416
+ if (Math.abs(dotProduct) < 1e-2) {
17417
+ return;
17418
+ }
17419
+ if (!this._currentCanvasPosition) {
17420
+ return;
17421
+ }
17422
+ const newWorldPos = viewport.canvasToWorld(this._currentCanvasPosition);
17423
+ this._currentCursorWorldPosition = newWorldPos;
17424
+ this.updateAnnotationPosition(element, this.getActiveAnnotation(element));
17425
+ };
17426
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
17427
+ let renderStatus = false;
17428
+ const { viewport, FrameOfReferenceUID } = enabledElement;
17429
+ const isElementWithCursor = this._elementWithCursor === viewport.element;
17430
+ if (this.configuration.positionSync && !isElementWithCursor) {
17431
+ this.updateViewportImage(viewport);
17432
+ }
17433
+ const { element } = viewport;
17434
+ let annotations = getAnnotations(this.getToolName(), element);
17435
+ if (!annotations?.length) {
17436
+ return renderStatus;
17437
+ }
17438
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
17439
+ if (!annotations?.length) {
17440
+ return renderStatus;
17441
+ }
17442
+ const styleSpecifier = {
17443
+ toolGroupId: this.toolGroupId,
17444
+ toolName: this.getToolName(),
17445
+ viewportId: enabledElement.viewport.id,
17446
+ };
17447
+ for (let i = 0; i < annotations.length; i++) {
17448
+ const annotation = annotations[i];
17449
+ const { annotationUID, data } = annotation;
17450
+ const { handles } = data;
17451
+ const { points } = handles;
17452
+ if (!annotationUID) {
17453
+ return renderStatus;
17454
+ }
17455
+ styleSpecifier.annotationUID = annotationUID;
17456
+ const lineWidthBase = parseFloat(this.getStyle('lineWidth', styleSpecifier, annotation));
17457
+ const lineWidth = typeof lineWidthBase === 'number' && isElementWithCursor
17458
+ ? lineWidthBase
17459
+ : lineWidthBase;
17460
+ const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
17461
+ const color = this.getStyle('color', styleSpecifier, annotation);
17462
+ if (points[0].some((e) => isNaN(e))) {
17463
+ return renderStatus;
17464
+ }
17465
+ const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
17466
+ if (!viewport.getRenderingEngine()) {
17467
+ console.warn('Rendering Engine has been destroyed');
17468
+ return renderStatus;
17469
+ }
17470
+ if (!isAnnotationVisible(annotationUID)) {
17471
+ continue;
17472
+ }
17473
+ const crosshairUIDs = {
17474
+ upper: 'upper',
17475
+ right: 'right',
17476
+ lower: 'lower',
17477
+ left: 'left',
17478
+ };
17479
+ const [x, y] = canvasCoordinates[0];
17480
+ const centerSpace = isElementWithCursor ? 20 : 7;
17481
+ const lineLength = isElementWithCursor ? 5 : 7;
17482
+ drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.upper, [x, y - (centerSpace / 2 + lineLength)], [x, y - centerSpace / 2], { color, lineDash, lineWidth });
17483
+ drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.lower, [x, y + (centerSpace / 2 + lineLength)], [x, y + centerSpace / 2], { color, lineDash, lineWidth });
17484
+ drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.right, [x + (centerSpace / 2 + lineLength), y], [x + centerSpace / 2, y], { color, lineDash, lineWidth });
17485
+ drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.left, [x - (centerSpace / 2 + lineLength), y], [x - centerSpace / 2, y], { color, lineDash, lineWidth });
17486
+ renderStatus = true;
17487
+ }
17488
+ return renderStatus;
17489
+ };
17490
+ this._disableCursorEnabled = this.configuration.disableCursor;
17126
17491
  }
17127
- if (calibration.type === CalibrationTypes.UNCALIBRATED) {
17128
- return PIXEL_UNITS;
17492
+ onSetToolActive() {
17493
+ this._disableCursorEnabled = this.configuration.disableCursor;
17494
+ if (!this._disableCursorEnabled) {
17495
+ return;
17496
+ }
17497
+ const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
17498
+ if (!viewportIds) {
17499
+ return;
17500
+ }
17501
+ const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
17502
+ enabledElements.forEach((element) => {
17503
+ if (element) {
17504
+ hideElementCursor(element.viewport.element);
17505
+ }
17506
+ });
17129
17507
  }
17130
- if (calibration.SequenceOfUltrasoundRegions) {
17131
- return 'US Region';
17508
+ onSetToolDisabled() {
17509
+ if (!this._disableCursorEnabled) {
17510
+ return;
17511
+ }
17512
+ const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
17513
+ if (!viewportIds) {
17514
+ return;
17515
+ }
17516
+ const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
17517
+ enabledElements.forEach((element) => {
17518
+ if (element) {
17519
+ resetElementCursor(element.viewport.element);
17520
+ }
17521
+ });
17132
17522
  }
17133
- return `${units} ${calibration.type}`;
17134
- };
17135
- const SQUARE = '\xb2';
17136
- const getCalibratedAreaUnits = (handles, image) => {
17137
- const { calibration, hasPixelSpacing } = image;
17138
- const units = (hasPixelSpacing ? 'mm' : PIXEL_UNITS) + SQUARE;
17139
- if (!calibration || !calibration.type) {
17140
- return units;
17523
+ getActiveAnnotation(element) {
17524
+ const annotations = getAnnotations(this.getToolName(), element);
17525
+ if (!annotations.length) {
17526
+ return null;
17527
+ }
17528
+ const targetAnnotation = annotations[0];
17529
+ return targetAnnotation;
17141
17530
  }
17142
- if (calibration.SequenceOfUltrasoundRegions) {
17143
- return 'US Region';
17531
+ updateAnnotationPosition(element, annotation) {
17532
+ const worldPos = this._currentCursorWorldPosition;
17533
+ if (!worldPos) {
17534
+ return;
17535
+ }
17536
+ if (!annotation.data?.handles?.points) {
17537
+ return;
17538
+ }
17539
+ annotation.data.handles.points = [[...worldPos]];
17540
+ annotation.invalidated = true;
17541
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName(), false);
17542
+ const enabledElement = (0,esm.getEnabledElement)(element);
17543
+ if (!enabledElement) {
17544
+ return;
17545
+ }
17546
+ const { renderingEngine } = enabledElement;
17547
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
17144
17548
  }
17145
- return `${units} ${calibration.type}`;
17146
- };
17147
- const getCalibratedScale = (image) => image.calibration?.scale || 1;
17148
- const getCalibratedAspect = (image) => image.calibration?.aspect || 1;
17149
- /* harmony default export */ const getCalibratedUnits = ((/* unused pure expression or super */ null && (getCalibratedLengthUnits)));
17549
+ filterInteractableAnnotationsForElement(element, annotations) {
17550
+ if (!(annotations instanceof Array) || annotations.length === 0) {
17551
+ return [];
17552
+ }
17553
+ const annotation = annotations[0];
17554
+ const viewport = (0,esm.getEnabledElement)(element)?.viewport;
17555
+ if (!viewport) {
17556
+ return [];
17557
+ }
17558
+ const camera = viewport.getCamera();
17559
+ const { viewPlaneNormal, focalPoint } = camera;
17560
+ if (!viewPlaneNormal || !focalPoint) {
17561
+ return [];
17562
+ }
17563
+ const points = annotation.data?.handles?.points;
17564
+ if (!(points instanceof Array) || points.length !== 1) {
17565
+ return [];
17566
+ }
17567
+ const worldPos = points[0];
17568
+ const plane = esm.utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
17569
+ const distance = esm.utilities.planar.planeDistanceToPoint(plane, worldPos);
17570
+ return distance < this.configuration.displayThreshold ? [annotation] : [];
17571
+ }
17572
+ updateViewportImage(viewport) {
17573
+ const currentMousePosition = this._currentCursorWorldPosition;
17574
+ if (!currentMousePosition || currentMousePosition.some((e) => isNaN(e))) {
17575
+ return;
17576
+ }
17577
+ if (viewport instanceof esm.StackViewport) {
17578
+ const closestIndex = esm.utilities.getClosestStackImageIndexForPoint(currentMousePosition, viewport);
17579
+ if (closestIndex === null) {
17580
+ return;
17581
+ }
17582
+ if (closestIndex !== viewport.getCurrentImageIdIndex()) {
17583
+ viewport.setImageIdIndex(closestIndex);
17584
+ }
17585
+ }
17586
+ else if (viewport instanceof esm.VolumeViewport) {
17587
+ const { focalPoint, viewPlaneNormal } = viewport.getCamera();
17588
+ if (!focalPoint || !viewPlaneNormal) {
17589
+ return;
17590
+ }
17591
+ const plane = esm.utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
17592
+ const currentDistance = esm.utilities.planar.planeDistanceToPoint(plane, currentMousePosition, true);
17593
+ if (Math.abs(currentDistance) < 0.5) {
17594
+ return;
17595
+ }
17596
+ const normalizedViewPlane = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), gl_matrix_esm/* vec3.fromValues */.R3.fromValues(...viewPlaneNormal));
17597
+ const scaledPlaneNormal = gl_matrix_esm/* vec3.scale */.R3.scale(gl_matrix_esm/* vec3.create */.R3.create(), normalizedViewPlane, currentDistance);
17598
+ const newFocalPoint = gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), gl_matrix_esm/* vec3.fromValues */.R3.fromValues(...focalPoint), scaledPlaneNormal);
17599
+ const isInBounds = true;
17600
+ if (isInBounds) {
17601
+ viewport.setCamera({ focalPoint: newFocalPoint });
17602
+ const renderingEngine = viewport.getRenderingEngine();
17603
+ if (renderingEngine) {
17604
+ renderingEngine.renderViewport(viewport.id);
17605
+ }
17606
+ }
17607
+ }
17608
+ }
17609
+ }
17610
+ ReferenceCursors.toolName = 'ReferenceCursors';
17611
+ /* harmony default export */ const tools_ReferenceCursors = (ReferenceCursors);
17612
+
17613
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/ScaleOverlayTool.js
17614
+
17615
+
17616
+
17150
17617
 
17151
17618
 
17619
+
17620
+ const SCALEOVERLAYTOOL_ID = 'scaleoverlay-viewport';
17621
+ const viewportsWithAnnotations = [];
17622
+ class ScaleOverlayTool extends base_AnnotationDisplayTool {
17623
+ constructor(toolProps = {}, defaultToolProps = {
17624
+ configuration: {
17625
+ viewportId: '',
17626
+ scaleLocation: 'bottom',
17627
+ },
17628
+ }) {
17629
+ super(toolProps, defaultToolProps);
17630
+ this.editData = {};
17631
+ this._init = () => {
17632
+ const renderingEngines = (0,esm.getRenderingEngines)();
17633
+ const renderingEngine = renderingEngines[0];
17634
+ if (!renderingEngine) {
17635
+ return;
17636
+ }
17637
+ const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
17638
+ if (!viewportIds) {
17639
+ return;
17640
+ }
17641
+ const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
17642
+ let { viewport } = enabledElements[0];
17643
+ const { FrameOfReferenceUID } = enabledElements[0];
17644
+ if (this.configuration.viewportId) {
17645
+ enabledElements.forEach((element) => {
17646
+ if (element.viewport.id == this.configuration.viewportId) {
17647
+ viewport = element.viewport;
17648
+ }
17649
+ });
17650
+ }
17651
+ if (!viewport) {
17652
+ return;
17653
+ }
17654
+ const { viewUp, viewPlaneNormal } = viewport.getCamera();
17655
+ const viewportCanvasCornersInWorld = esm.utilities.getViewportImageCornersInWorld(viewport);
17656
+ let annotation = this.editData.annotation;
17657
+ const annotations = getAnnotations(this.getToolName(), viewport.element);
17658
+ if (annotations.length) {
17659
+ annotation = annotations.filter((thisAnnotation) => thisAnnotation.data.viewportId == viewport.id)[0];
17660
+ }
17661
+ if (!viewportsWithAnnotations.includes(viewport.id)) {
17662
+ const newAnnotation = {
17663
+ metadata: {
17664
+ toolName: this.getToolName(),
17665
+ viewPlaneNormal: [...viewPlaneNormal],
17666
+ viewUp: [...viewUp],
17667
+ FrameOfReferenceUID,
17668
+ referencedImageId: null,
17669
+ },
17670
+ data: {
17671
+ handles: {
17672
+ points: viewportCanvasCornersInWorld,
17673
+ },
17674
+ viewportId: viewport.id,
17675
+ },
17676
+ };
17677
+ viewportsWithAnnotations.push(viewport.id);
17678
+ addAnnotation(newAnnotation, viewport.element);
17679
+ annotation = newAnnotation;
17680
+ }
17681
+ else if (this.editData.annotation.data.viewportId == viewport.id) {
17682
+ this.editData.annotation.data.handles.points =
17683
+ viewportCanvasCornersInWorld;
17684
+ this.editData.annotation.data.viewportId = viewport.id;
17685
+ }
17686
+ this.editData = {
17687
+ viewport,
17688
+ renderingEngine,
17689
+ annotation,
17690
+ };
17691
+ };
17692
+ this.onSetToolEnabled = () => {
17693
+ this._init();
17694
+ };
17695
+ this.onCameraModified = (evt) => {
17696
+ this.configuration.viewportId = evt.detail.viewportId;
17697
+ this._init();
17698
+ };
17699
+ this.computeScaleSize = (worldWidthViewport, worldHeightViewport, location) => {
17700
+ const scaleSizes = [
17701
+ 16000, 8000, 4000, 2000, 1000, 500, 250, 100, 50, 25, 10, 5, 2,
17702
+ ];
17703
+ let currentScaleSize;
17704
+ if (location == 'top' || location == 'bottom') {
17705
+ currentScaleSize = scaleSizes.filter((scaleSize) => scaleSize < worldWidthViewport * 0.6 &&
17706
+ scaleSize > worldWidthViewport * 0.2);
17707
+ }
17708
+ else {
17709
+ currentScaleSize = scaleSizes.filter((scaleSize) => scaleSize < worldHeightViewport * 0.6 &&
17710
+ scaleSize > worldHeightViewport * 0.2);
17711
+ }
17712
+ return currentScaleSize[0];
17713
+ };
17714
+ this.computeEndScaleTicks = (canvasCoordinates, location) => {
17715
+ const locationTickOffset = {
17716
+ bottom: [
17717
+ [0, -10],
17718
+ [0, -10],
17719
+ ],
17720
+ top: [
17721
+ [0, 10],
17722
+ [0, 10],
17723
+ ],
17724
+ left: [
17725
+ [0, 0],
17726
+ [10, 0],
17727
+ ],
17728
+ right: [
17729
+ [0, 0],
17730
+ [-10, 0],
17731
+ ],
17732
+ };
17733
+ const endTick1 = [
17734
+ [
17735
+ canvasCoordinates[1][0] + locationTickOffset[location][0][0],
17736
+ canvasCoordinates[1][1] + locationTickOffset[location][0][0],
17737
+ ],
17738
+ [
17739
+ canvasCoordinates[1][0] + locationTickOffset[location][1][0],
17740
+ canvasCoordinates[1][1] + locationTickOffset[location][1][1],
17741
+ ],
17742
+ ];
17743
+ const endTick2 = [
17744
+ [
17745
+ canvasCoordinates[0][0] + locationTickOffset[location][0][0],
17746
+ canvasCoordinates[0][1] + locationTickOffset[location][0][0],
17747
+ ],
17748
+ [
17749
+ canvasCoordinates[0][0] + locationTickOffset[location][1][0],
17750
+ canvasCoordinates[0][1] + locationTickOffset[location][1][1],
17751
+ ],
17752
+ ];
17753
+ return {
17754
+ endTick1: endTick1,
17755
+ endTick2: endTick2,
17756
+ };
17757
+ };
17758
+ this.computeInnerScaleTicks = (scaleSize, location, annotationUID, leftTick, rightTick) => {
17759
+ let canvasScaleSize;
17760
+ if (location == 'bottom' || location == 'top') {
17761
+ canvasScaleSize = rightTick[0][0] - leftTick[0][0];
17762
+ }
17763
+ else if (location == 'left' || location == 'right') {
17764
+ canvasScaleSize = rightTick[0][1] - leftTick[0][1];
17765
+ }
17766
+ const tickIds = [];
17767
+ const tickUIDs = [];
17768
+ const tickCoordinates = [];
17769
+ let numberSmallTicks = scaleSize;
17770
+ if (scaleSize >= 50) {
17771
+ numberSmallTicks = scaleSize / 10;
17772
+ }
17773
+ const tickSpacing = canvasScaleSize / numberSmallTicks;
17774
+ for (let i = 0; i < numberSmallTicks - 1; i++) {
17775
+ const locationOffset = {
17776
+ bottom: [
17777
+ [tickSpacing * (i + 1), 0],
17778
+ [tickSpacing * (i + 1), 5],
17779
+ ],
17780
+ top: [
17781
+ [tickSpacing * (i + 1), 0],
17782
+ [tickSpacing * (i + 1), -5],
17783
+ ],
17784
+ left: [
17785
+ [0, tickSpacing * (i + 1)],
17786
+ [-5, tickSpacing * (i + 1)],
17787
+ ],
17788
+ right: [
17789
+ [0, tickSpacing * (i + 1)],
17790
+ [5, tickSpacing * (i + 1)],
17791
+ ],
17792
+ };
17793
+ tickIds.push(`${annotationUID}-tick${i}`);
17794
+ tickUIDs.push(`tick${i}`);
17795
+ if ((i + 1) % 5 == 0) {
17796
+ tickCoordinates.push([
17797
+ [
17798
+ leftTick[0][0] + locationOffset[location][0][0],
17799
+ leftTick[0][1] + locationOffset[location][0][1],
17800
+ ],
17801
+ [
17802
+ leftTick[1][0] + locationOffset[location][0][0],
17803
+ leftTick[1][1] + locationOffset[location][0][1],
17804
+ ],
17805
+ ]);
17806
+ }
17807
+ else {
17808
+ tickCoordinates.push([
17809
+ [
17810
+ leftTick[0][0] + locationOffset[location][0][0],
17811
+ leftTick[0][1] + locationOffset[location][0][1],
17812
+ ],
17813
+ [
17814
+ leftTick[1][0] + locationOffset[location][1][0],
17815
+ leftTick[1][1] + locationOffset[location][1][1],
17816
+ ],
17817
+ ]);
17818
+ }
17819
+ }
17820
+ return { tickIds, tickUIDs, tickCoordinates };
17821
+ };
17822
+ this.computeWorldScaleCoordinates = (scaleSize, location, pointSet) => {
17823
+ let worldCoordinates;
17824
+ let topBottomVec = gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), pointSet[0], pointSet[1]);
17825
+ topBottomVec = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), topBottomVec);
17826
+ let topRightVec = gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), pointSet[2], pointSet[0]);
17827
+ topRightVec = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), topRightVec);
17828
+ const midpointLocation = {
17829
+ bottom: [pointSet[1], pointSet[2]],
17830
+ top: [pointSet[0], pointSet[3]],
17831
+ right: [pointSet[2], pointSet[3]],
17832
+ left: [pointSet[0], pointSet[1]],
17833
+ };
17834
+ const midpoint = gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpointLocation[location][0], midpointLocation[location][0])
17835
+ .map((i) => i / 2);
17836
+ const offset = scaleSize /
17837
+ 2 /
17838
+ Math.sqrt(Math.pow(topBottomVec[0], 2) +
17839
+ Math.pow(topBottomVec[1], 2) +
17840
+ Math.pow(topBottomVec[2], 2));
17841
+ if (location == 'top' || location == 'bottom') {
17842
+ worldCoordinates = [
17843
+ gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topRightVec.map((i) => i * offset)),
17844
+ gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topRightVec.map((i) => i * offset)),
17845
+ ];
17846
+ }
17847
+ else if (location == 'left' || location == 'right') {
17848
+ worldCoordinates = [
17849
+ gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topBottomVec.map((i) => i * offset)),
17850
+ gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topBottomVec.map((i) => i * offset)),
17851
+ ];
17852
+ }
17853
+ return worldCoordinates;
17854
+ };
17855
+ this.computeCanvasScaleCoordinates = (canvasSize, canvasCoordinates, vscaleBounds, hscaleBounds, location) => {
17856
+ let scaleCanvasCoordinates;
17857
+ if (location == 'top' || location == 'bottom') {
17858
+ const worldDistanceOnCanvas = canvasCoordinates[0][0] - canvasCoordinates[1][0];
17859
+ scaleCanvasCoordinates = [
17860
+ [canvasSize.width / 2 - worldDistanceOnCanvas / 2, vscaleBounds.height],
17861
+ [canvasSize.width / 2 + worldDistanceOnCanvas / 2, vscaleBounds.height],
17862
+ ];
17863
+ }
17864
+ else if (location == 'left' || location == 'right') {
17865
+ const worldDistanceOnCanvas = canvasCoordinates[0][1] - canvasCoordinates[1][1];
17866
+ scaleCanvasCoordinates = [
17867
+ [hscaleBounds.width, canvasSize.height / 2 - worldDistanceOnCanvas / 2],
17868
+ [hscaleBounds.width, canvasSize.height / 2 + worldDistanceOnCanvas / 2],
17869
+ ];
17870
+ }
17871
+ return scaleCanvasCoordinates;
17872
+ };
17873
+ this.computeScaleBounds = (canvasSize, horizontalReduction, verticalReduction, location) => {
17874
+ const hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
17875
+ const vReduction = verticalReduction * Math.min(1000, canvasSize.height);
17876
+ const locationBounds = {
17877
+ bottom: [-vReduction, -hReduction],
17878
+ top: [vReduction, hReduction],
17879
+ left: [vReduction, hReduction],
17880
+ right: [-vReduction, -hReduction],
17881
+ };
17882
+ const canvasBounds = {
17883
+ bottom: [canvasSize.height, canvasSize.width],
17884
+ top: [0, canvasSize.width],
17885
+ left: [canvasSize.height, 0],
17886
+ right: [canvasSize.height, canvasSize.width],
17887
+ };
17888
+ return {
17889
+ height: canvasBounds[location][0] + locationBounds[location][0],
17890
+ width: canvasBounds[location][1] + locationBounds[location][1],
17891
+ };
17892
+ };
17893
+ }
17894
+ renderAnnotation(enabledElement, svgDrawingHelper) {
17895
+ if (!this.editData.viewport) {
17896
+ return;
17897
+ }
17898
+ const location = this.configuration.scaleLocation;
17899
+ const { viewport } = enabledElement;
17900
+ const annotations = getAnnotations(this.getToolName(), viewport.element);
17901
+ const annotation = annotations.filter((thisAnnotation) => thisAnnotation.data.viewportId == viewport.id)[0];
17902
+ const canvas = enabledElement.viewport.canvas;
17903
+ const renderStatus = false;
17904
+ if (!viewport) {
17905
+ return renderStatus;
17906
+ }
17907
+ const styleSpecifier = {
17908
+ toolGroupId: this.toolGroupId,
17909
+ toolName: this.getToolName(),
17910
+ viewportId: enabledElement.viewport.id,
17911
+ };
17912
+ const canvasSize = {
17913
+ width: canvas.width,
17914
+ height: canvas.height,
17915
+ };
17916
+ const topLeft = annotation.data.handles.points[0];
17917
+ const topRight = annotation.data.handles.points[1];
17918
+ const bottomLeft = annotation.data.handles.points[2];
17919
+ const bottomRight = annotation.data.handles.points[3];
17920
+ const pointSet1 = [topLeft, bottomLeft, topRight, bottomRight];
17921
+ const worldWidthViewport = gl_matrix_esm/* vec3.distance */.R3.distance(bottomLeft, bottomRight);
17922
+ const worldHeightViewport = gl_matrix_esm/* vec3.distance */.R3.distance(topLeft, bottomLeft);
17923
+ const hscaleBounds = this.computeScaleBounds(canvasSize, 0.05, 0.05, location);
17924
+ const vscaleBounds = this.computeScaleBounds(canvasSize, 0.05, 0.05, location);
17925
+ const scaleSize = this.computeScaleSize(worldWidthViewport, worldHeightViewport, location);
17926
+ const canvasCoordinates = this.computeWorldScaleCoordinates(scaleSize, location, pointSet1).map((world) => viewport.worldToCanvas(world));
17927
+ const scaleCanvasCoordinates = this.computeCanvasScaleCoordinates(canvasSize, canvasCoordinates, vscaleBounds, hscaleBounds, location);
17928
+ const scaleTicks = this.computeEndScaleTicks(scaleCanvasCoordinates, location);
17929
+ const { annotationUID } = annotation;
17930
+ styleSpecifier.annotationUID = annotationUID;
17931
+ const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
17932
+ const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
17933
+ const color = this.getStyle('color', styleSpecifier, annotation);
17934
+ const shadow = this.getStyle('shadow', styleSpecifier, annotation);
17935
+ const scaleId = `${annotationUID}-scaleline`;
17936
+ const scaleLineUID = '1';
17937
+ drawLine(svgDrawingHelper, annotationUID, scaleLineUID, scaleCanvasCoordinates[0], scaleCanvasCoordinates[1], {
17938
+ color,
17939
+ width: lineWidth,
17940
+ lineDash,
17941
+ shadow,
17942
+ }, scaleId);
17943
+ const leftTickId = `${annotationUID}-left`;
17944
+ const leftTickUID = '2';
17945
+ drawLine(svgDrawingHelper, annotationUID, leftTickUID, scaleTicks.endTick1[0], scaleTicks.endTick1[1], {
17946
+ color,
17947
+ width: lineWidth,
17948
+ lineDash,
17949
+ shadow,
17950
+ }, leftTickId);
17951
+ const rightTickId = `${annotationUID}-right`;
17952
+ const rightTickUID = '3';
17953
+ drawLine(svgDrawingHelper, annotationUID, rightTickUID, scaleTicks.endTick2[0], scaleTicks.endTick2[1], {
17954
+ color,
17955
+ width: lineWidth,
17956
+ lineDash,
17957
+ shadow,
17958
+ }, rightTickId);
17959
+ const locationTextOffest = {
17960
+ bottom: [-10, -42],
17961
+ top: [-12, -35],
17962
+ left: [-40, -20],
17963
+ right: [-50, -20],
17964
+ };
17965
+ const textCanvasCoordinates = [
17966
+ scaleCanvasCoordinates[0][0] + locationTextOffest[location][0],
17967
+ scaleCanvasCoordinates[0][1] + locationTextOffest[location][1],
17968
+ ];
17969
+ const textBoxLines = this._getTextLines(scaleSize);
17970
+ const { tickIds, tickUIDs, tickCoordinates } = this.computeInnerScaleTicks(scaleSize, location, annotationUID, scaleTicks.endTick1, scaleTicks.endTick2);
17971
+ for (let i = 0; i < tickUIDs.length; i++) {
17972
+ drawLine(svgDrawingHelper, annotationUID, tickUIDs[i], tickCoordinates[i][0], tickCoordinates[i][1], {
17973
+ color,
17974
+ width: lineWidth,
17975
+ lineDash,
17976
+ shadow,
17977
+ }, tickIds[i]);
17978
+ }
17979
+ const textUID = 'text0';
17980
+ drawingSvg_drawTextBox(svgDrawingHelper, annotationUID, textUID, textBoxLines, [textCanvasCoordinates[0], textCanvasCoordinates[1]], {
17981
+ fontFamily: 'Helvetica Neue, Helvetica, Arial, sans-serif',
17982
+ fontSize: '14px',
17983
+ lineDash: '2,3',
17984
+ lineWidth: '1',
17985
+ shadow: true,
17986
+ color: color,
17987
+ });
17988
+ return renderStatus;
17989
+ }
17990
+ _getTextLines(scaleSize) {
17991
+ let scaleSizeDisplayValue;
17992
+ let scaleSizeUnits;
17993
+ if (scaleSize >= 50) {
17994
+ scaleSizeDisplayValue = scaleSize / 10;
17995
+ scaleSizeUnits = ' cm';
17996
+ }
17997
+ else {
17998
+ scaleSizeDisplayValue = scaleSize;
17999
+ scaleSizeUnits = ' mm';
18000
+ }
18001
+ const textLines = [scaleSizeDisplayValue.toString().concat(scaleSizeUnits)];
18002
+ return textLines;
18003
+ }
18004
+ }
18005
+ ScaleOverlayTool.toolName = 'ScaleOverlay';
18006
+ /* harmony default export */ const tools_ScaleOverlayTool = (ScaleOverlayTool);
18007
+
17152
18008
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.js
17153
18009
  function getTextBoxCoordsCanvas(annotationCanvasPoints) {
17154
18010
  const corners = _determineCorners(annotationCanvasPoints);
@@ -18402,7 +19258,7 @@ function isViewportPreScaled(viewport, targetId) {
18402
19258
  return !!preScale?.scaled;
18403
19259
  }
18404
19260
  else {
18405
- throw new Error('Viewport is not a valid type');
19261
+ return false;
18406
19262
  }
18407
19263
  }
18408
19264
 
@@ -18420,6 +19276,7 @@ function isViewportPreScaled(viewport, targetId) {
18420
19276
 
18421
19277
 
18422
19278
 
19279
+
18423
19280
  const { transformWorldToIndex: ProbeTool_transformWorldToIndex } = esm.utilities;
18424
19281
  class ProbeTool extends base_AnnotationTool {
18425
19282
  constructor(toolProps = {}, defaultToolProps = {
@@ -18687,11 +19544,21 @@ class ProbeTool extends base_AnnotationTool {
18687
19544
  index[0] = Math.round(index[0]);
18688
19545
  index[1] = Math.round(index[1]);
18689
19546
  index[2] = Math.round(index[2]);
19547
+ const samplesPerPixel = scalarData.length / dimensions[2] / dimensions[1] / dimensions[0];
18690
19548
  if (esm.utilities.indexWithinDimensions(index, dimensions)) {
18691
19549
  this.isHandleOutsideImage = false;
18692
- const yMultiple = dimensions[0];
18693
- const zMultiple = dimensions[0] * dimensions[1];
18694
- const value = scalarData[index[2] * zMultiple + index[1] * yMultiple + index[0]];
19550
+ const yMultiple = dimensions[0] * samplesPerPixel;
19551
+ const zMultiple = dimensions[0] * dimensions[1] * samplesPerPixel;
19552
+ const baseIndex = index[2] * zMultiple +
19553
+ index[1] * yMultiple +
19554
+ index[0] * samplesPerPixel;
19555
+ const value = samplesPerPixel > 2
19556
+ ? [
19557
+ scalarData[baseIndex],
19558
+ scalarData[baseIndex + 1],
19559
+ scalarData[baseIndex + 2],
19560
+ ]
19561
+ : scalarData[baseIndex];
18695
19562
  if (targetId.startsWith('imageId:')) {
18696
19563
  const imageId = targetId.split('imageId:')[1];
18697
19564
  const imageURI = esm.utilities.imageIdToURI(imageId);
@@ -18734,7 +19601,7 @@ function ProbeTool_defaultGetTextLines(data, targetId) {
18734
19601
  }
18735
19602
  const textLines = [];
18736
19603
  textLines.push(`(${index[0]}, ${index[1]}, ${index[2]})`);
18737
- textLines.push(`${value.toFixed(2)} ${modalityUnit}`);
19604
+ textLines.push(`${utilities_roundNumber(value)} ${modalityUnit}`);
18738
19605
  return textLines;
18739
19606
  }
18740
19607
  ProbeTool.toolName = 'Probe';
@@ -18930,39 +19797,52 @@ class Calculator {
18930
19797
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/basic/BasicStatsCalculator.js
18931
19798
 
18932
19799
  class BasicStatsCalculator extends basic_Calculator {
18933
- static { this.max = -Infinity; }
18934
- static { this.currentMax = 0; }
18935
- static { this.sum = 0; }
18936
- static { this.sumSquares = 0; }
18937
- static { this.squaredDiffSum = 0; }
19800
+ static { this.max = [-Infinity]; }
19801
+ static { this.sum = [0]; }
19802
+ static { this.sumSquares = [0]; }
19803
+ static { this.squaredDiffSum = [0]; }
18938
19804
  static { this.count = 0; }
18939
19805
  static { this.statsCallback = ({ value: newValue }) => {
18940
- if (newValue > this.max) {
18941
- this.max = newValue;
18942
- this.currentMax = newValue;
18943
- }
19806
+ if (Array.isArray(newValue) &&
19807
+ newValue.length > 1 &&
19808
+ this.max.length === 1) {
19809
+ this.max.push(this.max[0], this.max[0]);
19810
+ this.sum.push(this.sum[0], this.sum[0]);
19811
+ this.sumSquares.push(this.sumSquares[0], this.sumSquares[0]);
19812
+ this.squaredDiffSum.push(this.squaredDiffSum[0], this.squaredDiffSum[0]);
19813
+ }
19814
+ const newArray = Array.isArray(newValue) ? newValue : [newValue];
18944
19815
  this.count += 1;
18945
- this.sum += newValue;
18946
- this.sumSquares += newValue ** 2;
18947
- this.squaredDiffSum += Math.pow(newValue - this.sum / this.count, 2);
19816
+ this.max.forEach((it, idx) => (this.max[idx] = Math.max(it, newArray[idx])));
19817
+ this.sum.map((it, idx) => (this.sum[idx] += newArray[idx]));
19818
+ this.sumSquares.map((it, idx) => (this.sumSquares[idx] += newArray[idx] ** 2));
19819
+ this.squaredDiffSum.map((it, idx) => (this.squaredDiffSum[idx] += Math.pow(newArray[idx] - this.sum[idx] / this.count, 2)));
18948
19820
  }; }
18949
19821
  static { this.getStatistics = () => {
18950
- const mean = this.sum / this.count;
18951
- const stdDev = Math.sqrt(this.squaredDiffSum / this.count);
18952
- const stdDevWithSumSquare = Math.sqrt(this.sumSquares / this.count - mean ** 2);
18953
- this.max = -Infinity;
18954
- this.sum = 0;
18955
- this.sumSquares = 0;
18956
- this.squaredDiffSum = 0;
19822
+ const mean = this.sum.map((sum) => sum / this.count);
19823
+ const stdDev = this.squaredDiffSum.map((squaredDiffSum) => Math.sqrt(squaredDiffSum / this.count));
19824
+ const stdDevWithSumSquare = this.sumSquares.map((it, idx) => Math.sqrt(this.sumSquares[idx] / this.count - mean[idx] ** 2));
19825
+ const currentMax = this.max;
19826
+ this.max = [-Infinity];
19827
+ this.sum = [0];
19828
+ this.sumSquares = [0];
19829
+ this.squaredDiffSum = [0];
18957
19830
  this.count = 0;
18958
19831
  return [
18959
- { name: 'max', value: this.currentMax, unit: null },
18960
- { name: 'mean', value: mean, unit: null },
18961
- { name: 'stdDev', value: stdDev, unit: null },
18962
- { name: 'stdDevWithSumSquare', value: stdDevWithSumSquare, unit: null },
19832
+ { name: 'max', value: singleArrayAsNumber(currentMax), unit: null },
19833
+ { name: 'mean', value: singleArrayAsNumber(mean), unit: null },
19834
+ { name: 'stdDev', value: singleArrayAsNumber(stdDev), unit: null },
19835
+ {
19836
+ name: 'stdDevWithSumSquare',
19837
+ value: singleArrayAsNumber(stdDevWithSumSquare),
19838
+ unit: null,
19839
+ },
18963
19840
  ];
18964
19841
  }; }
18965
19842
  }
19843
+ function singleArrayAsNumber(val) {
19844
+ return val.length === 1 ? val[0] : val;
19845
+ }
18966
19846
 
18967
19847
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/basic/index.js
18968
19848
 
@@ -22987,16 +23867,13 @@ class PlanarFreehandROITool extends base_AnnotationTool {
22987
23867
  const enabledElement = (0,esm.getEnabledElement)(element);
22988
23868
  const { viewport } = enabledElement;
22989
23869
  let annotationsToDisplay;
22990
- if (viewport instanceof esm.StackViewport) {
22991
- annotationsToDisplay = filterAnnotationsForDisplay(viewport, annotations);
22992
- }
22993
- else if (viewport instanceof esm.VolumeViewport) {
23870
+ if (viewport instanceof esm.VolumeViewport) {
22994
23871
  const camera = viewport.getCamera();
22995
23872
  const { spacingInNormalDirection } = esm.utilities.getTargetVolumeAndSpacingInNormalDir(viewport, camera);
22996
23873
  annotationsToDisplay = this.filterAnnotationsWithinSlice(annotations, camera, spacingInNormalDirection);
22997
23874
  }
22998
23875
  else {
22999
- throw new Error(`Viewport Type ${viewport.type} not supported`);
23876
+ annotationsToDisplay = filterAnnotationsForDisplay(viewport, annotations);
23000
23877
  }
23001
23878
  return annotationsToDisplay;
23002
23879
  }
@@ -24662,711 +25539,213 @@ function CobbAngleTool_defaultGetTextLines(data, targetId) {
24662
25539
  CobbAngleTool.toolName = 'CobbAngle';
24663
25540
  /* harmony default export */ const annotation_CobbAngleTool = (CobbAngleTool);
24664
25541
 
24665
- ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/ReferenceCursors.js
24666
-
24667
-
24668
-
24669
-
24670
-
24671
-
24672
-
24673
-
24674
-
24675
-
24676
-
24677
- class ReferenceCursors extends base_AnnotationDisplayTool {
24678
- constructor(toolProps = {}, defaultToolProps = {
24679
- supportedInteractionTypes: ['Mouse', 'Touch'],
24680
- configuration: {
24681
- shadow: true,
24682
- preventHandleOutsideImage: false,
24683
- displayThreshold: 5,
24684
- positionSync: true,
24685
- disableCursor: false,
24686
- },
24687
- }) {
24688
- super(toolProps, defaultToolProps);
24689
- this.isDrawing = false;
24690
- this.isHandleOutsideImage = false;
24691
- this._elementWithCursor = null;
24692
- this._currentCursorWorldPosition = null;
24693
- this._currentCanvasPosition = null;
24694
- this._disableCursorEnabled = false;
24695
- this.mouseMoveCallback = (evt) => {
24696
- const { detail } = evt;
24697
- const { element, currentPoints } = detail;
24698
- this._currentCursorWorldPosition = currentPoints.world;
24699
- this._currentCanvasPosition = currentPoints.canvas;
24700
- this._elementWithCursor = element;
24701
- const annotation = this.getActiveAnnotation(element);
24702
- if (annotation === null) {
24703
- this.createInitialAnnotation(currentPoints.world, element);
24704
- return false;
24705
- }
24706
- this.updateAnnotationPosition(element, annotation);
24707
- return false;
24708
- };
24709
- this.createInitialAnnotation = (worldPos, element) => {
24710
- const enabledElement = (0,esm.getEnabledElement)(element);
24711
- if (!enabledElement) {
24712
- throw new Error('No enabled element found');
24713
- }
24714
- const { viewport, renderingEngine } = enabledElement;
24715
- this.isDrawing = true;
24716
- const camera = viewport.getCamera();
24717
- const { viewPlaneNormal, viewUp } = camera;
24718
- if (!viewPlaneNormal || !viewUp) {
24719
- throw new Error('Camera not found');
24720
- }
24721
- const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
24722
- const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
24723
- const annotation = {
24724
- highlighted: true,
24725
- invalidated: true,
24726
- metadata: {
24727
- toolName: this.getToolName(),
24728
- viewPlaneNormal: [...viewPlaneNormal],
24729
- viewUp: [...viewUp],
24730
- FrameOfReferenceUID,
24731
- referencedImageId,
24732
- },
24733
- data: {
24734
- label: '',
24735
- handles: {
24736
- points: [[...worldPos]],
24737
- activeHandleIndex: null,
24738
- textBox: {
24739
- hasMoved: false,
24740
- worldPosition: [0, 0, 0],
24741
- worldBoundingBox: {
24742
- topLeft: [0, 0, 0],
24743
- topRight: [0, 0, 0],
24744
- bottomLeft: [0, 0, 0],
24745
- bottomRight: [0, 0, 0],
24746
- },
24747
- },
24748
- },
24749
- },
24750
- };
24751
- const annotations = getAnnotations(this.getToolName(), element);
24752
- if (annotations.length > 0) {
24753
- return null;
24754
- }
24755
- const annotationId = addAnnotation(annotation, element);
24756
- if (annotationId === null) {
24757
- return;
24758
- }
24759
- const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName(), false);
24760
- utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
24761
- };
24762
- this.onCameraModified = (evt) => {
24763
- const eventDetail = evt.detail;
24764
- const { element, previousCamera, camera } = eventDetail;
24765
- const enabledElement = (0,esm.getEnabledElement)(element);
24766
- const viewport = enabledElement.viewport;
24767
- if (element !== this._elementWithCursor) {
24768
- return;
24769
- }
24770
- const oldFocalPoint = previousCamera.focalPoint;
24771
- const cameraNormal = camera.viewPlaneNormal;
24772
- const newFocalPoint = camera.focalPoint;
24773
- const deltaCameraFocalPoint = [0, 0, 0];
24774
- Common_Core_Math/* default.subtract */.ZP.subtract(newFocalPoint, oldFocalPoint, deltaCameraFocalPoint);
24775
- if (deltaCameraFocalPoint.reduce((a, b) => a + b, 0) === 0) {
24776
- return;
24777
- }
24778
- const dotProduct = Common_Core_Math/* default.dot */.ZP.dot(deltaCameraFocalPoint, cameraNormal);
24779
- if (Math.abs(dotProduct) < 1e-2) {
24780
- return;
24781
- }
24782
- if (!this._currentCanvasPosition) {
24783
- return;
24784
- }
24785
- const newWorldPos = viewport.canvasToWorld(this._currentCanvasPosition);
24786
- this._currentCursorWorldPosition = newWorldPos;
24787
- this.updateAnnotationPosition(element, this.getActiveAnnotation(element));
24788
- };
24789
- this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
24790
- let renderStatus = false;
24791
- const { viewport, FrameOfReferenceUID } = enabledElement;
24792
- const isElementWithCursor = this._elementWithCursor === viewport.element;
24793
- if (this.configuration.positionSync && !isElementWithCursor) {
24794
- this.updateViewportImage(viewport);
24795
- }
24796
- const { element } = viewport;
24797
- let annotations = getAnnotations(this.getToolName(), element);
24798
- if (!annotations?.length) {
24799
- return renderStatus;
24800
- }
24801
- annotations = this.filterInteractableAnnotationsForElement(element, annotations);
24802
- if (!annotations?.length) {
24803
- return renderStatus;
24804
- }
24805
- const styleSpecifier = {
24806
- toolGroupId: this.toolGroupId,
24807
- toolName: this.getToolName(),
24808
- viewportId: enabledElement.viewport.id,
24809
- };
24810
- for (let i = 0; i < annotations.length; i++) {
24811
- const annotation = annotations[i];
24812
- const { annotationUID, data } = annotation;
24813
- const { handles } = data;
24814
- const { points } = handles;
24815
- if (!annotationUID) {
24816
- return renderStatus;
24817
- }
24818
- styleSpecifier.annotationUID = annotationUID;
24819
- const lineWidthBase = parseFloat(this.getStyle('lineWidth', styleSpecifier, annotation));
24820
- const lineWidth = typeof lineWidthBase === 'number' && isElementWithCursor
24821
- ? lineWidthBase
24822
- : lineWidthBase;
24823
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
24824
- const color = this.getStyle('color', styleSpecifier, annotation);
24825
- if (points[0].some((e) => isNaN(e))) {
24826
- return renderStatus;
24827
- }
24828
- const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
24829
- if (!viewport.getRenderingEngine()) {
24830
- console.warn('Rendering Engine has been destroyed');
24831
- return renderStatus;
24832
- }
24833
- if (!isAnnotationVisible(annotationUID)) {
24834
- continue;
24835
- }
24836
- const crosshairUIDs = {
24837
- upper: 'upper',
24838
- right: 'right',
24839
- lower: 'lower',
24840
- left: 'left',
24841
- };
24842
- const [x, y] = canvasCoordinates[0];
24843
- const centerSpace = isElementWithCursor ? 20 : 7;
24844
- const lineLength = isElementWithCursor ? 5 : 7;
24845
- drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.upper, [x, y - (centerSpace / 2 + lineLength)], [x, y - centerSpace / 2], { color, lineDash, lineWidth });
24846
- drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.lower, [x, y + (centerSpace / 2 + lineLength)], [x, y + centerSpace / 2], { color, lineDash, lineWidth });
24847
- drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.right, [x + (centerSpace / 2 + lineLength), y], [x + centerSpace / 2, y], { color, lineDash, lineWidth });
24848
- drawLine(svgDrawingHelper, annotationUID, crosshairUIDs.left, [x - (centerSpace / 2 + lineLength), y], [x - centerSpace / 2, y], { color, lineDash, lineWidth });
24849
- renderStatus = true;
24850
- }
24851
- return renderStatus;
24852
- };
24853
- this._disableCursorEnabled = this.configuration.disableCursor;
24854
- }
24855
- onSetToolActive() {
24856
- this._disableCursorEnabled = this.configuration.disableCursor;
24857
- if (!this._disableCursorEnabled) {
24858
- return;
24859
- }
24860
- const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
24861
- if (!viewportIds) {
24862
- return;
24863
- }
24864
- const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
24865
- enabledElements.forEach((element) => {
24866
- if (element) {
24867
- hideElementCursor(element.viewport.element);
24868
- }
24869
- });
24870
- }
24871
- onSetToolDisabled() {
24872
- if (!this._disableCursorEnabled) {
24873
- return;
24874
- }
24875
- const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
24876
- if (!viewportIds) {
24877
- return;
24878
- }
24879
- const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
24880
- enabledElements.forEach((element) => {
24881
- if (element) {
24882
- resetElementCursor(element.viewport.element);
24883
- }
24884
- });
24885
- }
24886
- getActiveAnnotation(element) {
24887
- const annotations = getAnnotations(this.getToolName(), element);
24888
- if (!annotations.length) {
24889
- return null;
24890
- }
24891
- const targetAnnotation = annotations[0];
24892
- return targetAnnotation;
24893
- }
24894
- updateAnnotationPosition(element, annotation) {
24895
- const worldPos = this._currentCursorWorldPosition;
24896
- if (!worldPos) {
24897
- return;
24898
- }
24899
- if (!annotation.data?.handles?.points) {
24900
- return;
24901
- }
24902
- annotation.data.handles.points = [[...worldPos]];
24903
- annotation.invalidated = true;
24904
- const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName(), false);
24905
- const enabledElement = (0,esm.getEnabledElement)(element);
24906
- if (!enabledElement) {
24907
- return;
24908
- }
24909
- const { renderingEngine } = enabledElement;
24910
- utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
24911
- }
24912
- filterInteractableAnnotationsForElement(element, annotations) {
24913
- if (!(annotations instanceof Array) || annotations.length === 0) {
24914
- return [];
24915
- }
24916
- const annotation = annotations[0];
24917
- const viewport = (0,esm.getEnabledElement)(element)?.viewport;
24918
- if (!viewport) {
24919
- return [];
24920
- }
24921
- const camera = viewport.getCamera();
24922
- const { viewPlaneNormal, focalPoint } = camera;
24923
- if (!viewPlaneNormal || !focalPoint) {
24924
- return [];
24925
- }
24926
- const points = annotation.data?.handles?.points;
24927
- if (!(points instanceof Array) || points.length !== 1) {
24928
- return [];
24929
- }
24930
- const worldPos = points[0];
24931
- const plane = esm.utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
24932
- const distance = esm.utilities.planar.planeDistanceToPoint(plane, worldPos);
24933
- return distance < this.configuration.displayThreshold ? [annotation] : [];
24934
- }
24935
- updateViewportImage(viewport) {
24936
- const currentMousePosition = this._currentCursorWorldPosition;
24937
- if (!currentMousePosition || currentMousePosition.some((e) => isNaN(e))) {
24938
- return;
24939
- }
24940
- if (viewport instanceof esm.StackViewport) {
24941
- const closestIndex = esm.utilities.getClosestStackImageIndexForPoint(currentMousePosition, viewport);
24942
- if (closestIndex === null) {
24943
- return;
24944
- }
24945
- if (closestIndex !== viewport.getCurrentImageIdIndex()) {
24946
- viewport.setImageIdIndex(closestIndex);
24947
- }
24948
- }
24949
- else if (viewport instanceof esm.VolumeViewport) {
24950
- const { focalPoint, viewPlaneNormal } = viewport.getCamera();
24951
- if (!focalPoint || !viewPlaneNormal) {
24952
- return;
24953
- }
24954
- const plane = esm.utilities.planar.planeEquation(viewPlaneNormal, focalPoint);
24955
- const currentDistance = esm.utilities.planar.planeDistanceToPoint(plane, currentMousePosition, true);
24956
- if (Math.abs(currentDistance) < 0.5) {
24957
- return;
24958
- }
24959
- const normalizedViewPlane = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), gl_matrix_esm/* vec3.fromValues */.R3.fromValues(...viewPlaneNormal));
24960
- const scaledPlaneNormal = gl_matrix_esm/* vec3.scale */.R3.scale(gl_matrix_esm/* vec3.create */.R3.create(), normalizedViewPlane, currentDistance);
24961
- const newFocalPoint = gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), gl_matrix_esm/* vec3.fromValues */.R3.fromValues(...focalPoint), scaledPlaneNormal);
24962
- const isInBounds = true;
24963
- if (isInBounds) {
24964
- viewport.setCamera({ focalPoint: newFocalPoint });
24965
- const renderingEngine = viewport.getRenderingEngine();
24966
- if (renderingEngine) {
24967
- renderingEngine.renderViewport(viewport.id);
24968
- }
24969
- }
24970
- }
24971
- }
24972
- }
24973
- ReferenceCursors.toolName = 'ReferenceCursors';
24974
- /* harmony default export */ const tools_ReferenceCursors = (ReferenceCursors);
25542
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/annotation/KeyImageTool.js
24975
25543
 
24976
- ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/ScaleOverlayTool.js
24977
25544
 
24978
25545
 
24979
25546
 
24980
25547
 
24981
25548
 
24982
25549
 
24983
- const SCALEOVERLAYTOOL_ID = 'scaleoverlay-viewport';
24984
- const viewportsWithAnnotations = [];
24985
- class ScaleOverlayTool extends base_AnnotationDisplayTool {
25550
+
25551
+
25552
+ class KeyImageTool extends base_AnnotationTool {
24986
25553
  constructor(toolProps = {}, defaultToolProps = {
25554
+ supportedInteractionTypes: ['Mouse', 'Touch'],
24987
25555
  configuration: {
24988
- viewportId: '',
24989
- scaleLocation: 'bottom',
25556
+ getTextCallback: KeyImageTool_getTextCallback,
25557
+ changeTextCallback: KeyImageTool_changeTextCallback,
25558
+ canvasPosition: [10, 10],
25559
+ canvasSize: 10,
24990
25560
  },
24991
25561
  }) {
24992
25562
  super(toolProps, defaultToolProps);
24993
- this.editData = {};
24994
- this._init = () => {
24995
- const renderingEngines = (0,esm.getRenderingEngines)();
24996
- const renderingEngine = renderingEngines[0];
24997
- if (!renderingEngine) {
24998
- return;
24999
- }
25000
- const viewportIds = ToolGroupManager_getToolGroup(this.toolGroupId).viewportsInfo;
25001
- if (!viewportIds) {
25002
- return;
25003
- }
25004
- const enabledElements = viewportIds.map((e) => (0,esm.getEnabledElementByIds)(e.viewportId, e.renderingEngineId));
25005
- let { viewport } = enabledElements[0];
25006
- const { FrameOfReferenceUID } = enabledElements[0];
25007
- if (this.configuration.viewportId) {
25008
- enabledElements.forEach((element) => {
25009
- if (element.viewport.id == this.configuration.viewportId) {
25010
- viewport = element.viewport;
25011
- }
25012
- });
25013
- }
25014
- if (!viewport) {
25015
- return;
25016
- }
25017
- const { viewUp, viewPlaneNormal } = viewport.getCamera();
25018
- const viewportCanvasCornersInWorld = esm.utilities.getViewportImageCornersInWorld(viewport);
25019
- let annotation = this.editData.annotation;
25020
- const annotations = getAnnotations(this.getToolName(), viewport.element);
25021
- if (annotations.length) {
25022
- annotation = annotations.filter((thisAnnotation) => thisAnnotation.data.viewportId == viewport.id)[0];
25023
- }
25024
- if (!viewportsWithAnnotations.includes(viewport.id)) {
25025
- const newAnnotation = {
25026
- metadata: {
25027
- toolName: this.getToolName(),
25028
- viewPlaneNormal: [...viewPlaneNormal],
25029
- viewUp: [...viewUp],
25030
- FrameOfReferenceUID,
25031
- referencedImageId: null,
25032
- },
25033
- data: {
25034
- handles: {
25035
- points: viewportCanvasCornersInWorld,
25563
+ this.addNewAnnotation = (evt) => {
25564
+ const eventDetail = evt.detail;
25565
+ const { currentPoints, element } = eventDetail;
25566
+ const worldPos = currentPoints.world;
25567
+ const enabledElement = (0,esm.getEnabledElement)(element);
25568
+ const { viewport, renderingEngine } = enabledElement;
25569
+ const camera = viewport.getCamera();
25570
+ const { viewPlaneNormal, viewUp } = camera;
25571
+ const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
25572
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
25573
+ const annotation = {
25574
+ annotationUID: null,
25575
+ highlighted: true,
25576
+ invalidated: true,
25577
+ metadata: {
25578
+ toolName: this.getToolName(),
25579
+ viewPlaneNormal: [...viewPlaneNormal],
25580
+ viewUp: [...viewUp],
25581
+ FrameOfReferenceUID,
25582
+ referencedImageId,
25583
+ },
25584
+ data: {
25585
+ text: '',
25586
+ handles: {
25587
+ points: new Array(),
25588
+ textBox: {
25589
+ hasMoved: false,
25590
+ worldPosition: [0, 0, 0],
25591
+ worldBoundingBox: {
25592
+ topLeft: [0, 0, 0],
25593
+ topRight: [0, 0, 0],
25594
+ bottomLeft: [0, 0, 0],
25595
+ bottomRight: [0, 0, 0],
25596
+ },
25036
25597
  },
25037
- viewportId: viewport.id,
25038
25598
  },
25599
+ label: '',
25600
+ },
25601
+ };
25602
+ addAnnotation(annotation, element);
25603
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
25604
+ evt.preventDefault();
25605
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
25606
+ this.configuration.getTextCallback((text) => {
25607
+ if (!text) {
25608
+ annotationState_removeAnnotation(annotation.annotationUID);
25609
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
25610
+ this.isDrawing = false;
25611
+ return;
25612
+ }
25613
+ annotation.data.text = text;
25614
+ const eventType = enums_Events.ANNOTATION_COMPLETED;
25615
+ const eventDetail = {
25616
+ annotation,
25039
25617
  };
25040
- viewportsWithAnnotations.push(viewport.id);
25041
- addAnnotation(newAnnotation, viewport.element);
25042
- annotation = newAnnotation;
25618
+ (0,esm.triggerEvent)(esm.eventTarget, eventType, eventDetail);
25619
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
25620
+ });
25621
+ return annotation;
25622
+ };
25623
+ this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
25624
+ const enabledElement = (0,esm.getEnabledElement)(element);
25625
+ const { viewport } = enabledElement;
25626
+ const { data } = annotation;
25627
+ const { canvasPosition, canvasSize } = this.configuration;
25628
+ if (!canvasPosition?.length) {
25629
+ return false;
25043
25630
  }
25044
- else if (this.editData.annotation.data.viewportId == viewport.id) {
25045
- this.editData.annotation.data.handles.points =
25046
- viewportCanvasCornersInWorld;
25047
- this.editData.annotation.data.viewportId = viewport.id;
25631
+ if (Math.abs(canvasCoords[0] - canvasPosition[0] + canvasSize / 2) <=
25632
+ canvasSize / 2 &&
25633
+ Math.abs(canvasCoords[1] - canvasPosition[1] + canvasSize / 2) <=
25634
+ canvasSize / 2) {
25635
+ return true;
25048
25636
  }
25049
- this.editData = {
25050
- viewport,
25051
- renderingEngine,
25052
- annotation,
25053
- };
25637
+ return false;
25054
25638
  };
25055
- this.onSetToolEnabled = () => {
25056
- this._init();
25639
+ this.toolSelectedCallback = (evt, annotation) => {
25640
+ annotation.highlighted = true;
25641
+ evt.preventDefault();
25057
25642
  };
25058
- this.onCameraModified = (evt) => {
25059
- this.configuration.viewportId = evt.detail.viewportId;
25060
- this._init();
25643
+ this._endCallback = (evt) => {
25644
+ const eventDetail = evt.detail;
25645
+ const { element } = eventDetail;
25646
+ this._deactivateModify(element);
25647
+ resetElementCursor(element);
25061
25648
  };
25062
- this.computeScaleSize = (worldWidthViewport, worldHeightViewport, location) => {
25063
- const scaleSizes = [
25064
- 16000, 8000, 4000, 2000, 1000, 500, 250, 100, 50, 25, 10, 5, 2,
25065
- ];
25066
- let currentScaleSize;
25067
- if (location == 'top' || location == 'bottom') {
25068
- currentScaleSize = scaleSizes.filter((scaleSize) => scaleSize < worldWidthViewport * 0.6 &&
25069
- scaleSize > worldWidthViewport * 0.2);
25649
+ this.doubleClickCallback = (evt) => {
25650
+ const eventDetail = evt.detail;
25651
+ const { element } = eventDetail;
25652
+ let annotations = getAnnotations(this.getToolName(), element);
25653
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
25654
+ if (!annotations?.length) {
25655
+ return;
25070
25656
  }
25071
- else {
25072
- currentScaleSize = scaleSizes.filter((scaleSize) => scaleSize < worldHeightViewport * 0.6 &&
25073
- scaleSize > worldHeightViewport * 0.2);
25657
+ const clickedAnnotation = annotations.find((annotation) => this.isPointNearTool(element, annotation, eventDetail.currentPoints.canvas, 6));
25658
+ if (!clickedAnnotation) {
25659
+ return;
25074
25660
  }
25075
- return currentScaleSize[0];
25661
+ const annotation = clickedAnnotation;
25662
+ this.configuration.changeTextCallback(clickedAnnotation, evt.detail, this._doneChangingTextCallback.bind(this, element, annotation));
25663
+ this.isDrawing = false;
25664
+ evt.stopImmediatePropagation();
25665
+ evt.preventDefault();
25076
25666
  };
25077
- this.computeEndScaleTicks = (canvasCoordinates, location) => {
25078
- const locationTickOffset = {
25079
- bottom: [
25080
- [0, -10],
25081
- [0, -10],
25082
- ],
25083
- top: [
25084
- [0, 10],
25085
- [0, 10],
25086
- ],
25087
- left: [
25088
- [0, 0],
25089
- [10, 0],
25090
- ],
25091
- right: [
25092
- [0, 0],
25093
- [-10, 0],
25094
- ],
25095
- };
25096
- const endTick1 = [
25097
- [
25098
- canvasCoordinates[1][0] + locationTickOffset[location][0][0],
25099
- canvasCoordinates[1][1] + locationTickOffset[location][0][0],
25100
- ],
25101
- [
25102
- canvasCoordinates[1][0] + locationTickOffset[location][1][0],
25103
- canvasCoordinates[1][1] + locationTickOffset[location][1][1],
25104
- ],
25105
- ];
25106
- const endTick2 = [
25107
- [
25108
- canvasCoordinates[0][0] + locationTickOffset[location][0][0],
25109
- canvasCoordinates[0][1] + locationTickOffset[location][0][0],
25110
- ],
25111
- [
25112
- canvasCoordinates[0][0] + locationTickOffset[location][1][0],
25113
- canvasCoordinates[0][1] + locationTickOffset[location][1][1],
25114
- ],
25115
- ];
25116
- return {
25117
- endTick1: endTick1,
25118
- endTick2: endTick2,
25119
- };
25667
+ this._activateModify = (element) => {
25668
+ state.isInteractingWithTool = true;
25669
+ element.addEventListener(enums_Events.MOUSE_UP, this._endCallback);
25670
+ element.addEventListener(enums_Events.MOUSE_CLICK, this._endCallback);
25671
+ element.addEventListener(enums_Events.TOUCH_TAP, this._endCallback);
25672
+ element.addEventListener(enums_Events.TOUCH_END, this._endCallback);
25120
25673
  };
25121
- this.computeInnerScaleTicks = (scaleSize, location, annotationUID, leftTick, rightTick) => {
25122
- let canvasScaleSize;
25123
- if (location == 'bottom' || location == 'top') {
25124
- canvasScaleSize = rightTick[0][0] - leftTick[0][0];
25125
- }
25126
- else if (location == 'left' || location == 'right') {
25127
- canvasScaleSize = rightTick[0][1] - leftTick[0][1];
25674
+ this._deactivateModify = (element) => {
25675
+ state.isInteractingWithTool = false;
25676
+ element.removeEventListener(enums_Events.MOUSE_UP, this._endCallback);
25677
+ element.removeEventListener(enums_Events.MOUSE_CLICK, this._endCallback);
25678
+ element.removeEventListener(enums_Events.TOUCH_TAP, this._endCallback);
25679
+ element.removeEventListener(enums_Events.TOUCH_END, this._endCallback);
25680
+ };
25681
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
25682
+ let renderStatus = false;
25683
+ const { viewport } = enabledElement;
25684
+ const { element } = viewport;
25685
+ let annotations = getAnnotations(this.getToolName(), element);
25686
+ if (!annotations?.length) {
25687
+ return renderStatus;
25128
25688
  }
25129
- const tickIds = [];
25130
- const tickUIDs = [];
25131
- const tickCoordinates = [];
25132
- let numberSmallTicks = scaleSize;
25133
- if (scaleSize >= 50) {
25134
- numberSmallTicks = scaleSize / 10;
25689
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
25690
+ if (!annotations?.length) {
25691
+ return renderStatus;
25135
25692
  }
25136
- const tickSpacing = canvasScaleSize / numberSmallTicks;
25137
- for (let i = 0; i < numberSmallTicks - 1; i++) {
25138
- const locationOffset = {
25139
- bottom: [
25140
- [tickSpacing * (i + 1), 0],
25141
- [tickSpacing * (i + 1), 5],
25142
- ],
25143
- top: [
25144
- [tickSpacing * (i + 1), 0],
25145
- [tickSpacing * (i + 1), -5],
25146
- ],
25147
- left: [
25148
- [0, tickSpacing * (i + 1)],
25149
- [-5, tickSpacing * (i + 1)],
25150
- ],
25151
- right: [
25152
- [0, tickSpacing * (i + 1)],
25153
- [5, tickSpacing * (i + 1)],
25154
- ],
25155
- };
25156
- tickIds.push(`${annotationUID}-tick${i}`);
25157
- tickUIDs.push(`tick${i}`);
25158
- if ((i + 1) % 5 == 0) {
25159
- tickCoordinates.push([
25160
- [
25161
- leftTick[0][0] + locationOffset[location][0][0],
25162
- leftTick[0][1] + locationOffset[location][0][1],
25163
- ],
25164
- [
25165
- leftTick[1][0] + locationOffset[location][0][0],
25166
- leftTick[1][1] + locationOffset[location][0][1],
25167
- ],
25168
- ]);
25693
+ const styleSpecifier = {
25694
+ toolGroupId: this.toolGroupId,
25695
+ toolName: this.getToolName(),
25696
+ viewportId: enabledElement.viewport.id,
25697
+ };
25698
+ for (let i = 0; i < annotations.length; i++) {
25699
+ const annotation = annotations[i];
25700
+ const { annotationUID } = annotation;
25701
+ styleSpecifier.annotationUID = annotationUID;
25702
+ const color = this.getStyle('color', styleSpecifier, annotation);
25703
+ const { canvasPosition, canvasSize } = this.configuration;
25704
+ if (canvasPosition?.length) {
25705
+ const arrowUID = '1';
25706
+ drawArrow(svgDrawingHelper, annotationUID, arrowUID, canvasPosition.map((it) => it + canvasSize), canvasPosition, {
25707
+ color,
25708
+ width: 1,
25709
+ });
25169
25710
  }
25170
- else {
25171
- tickCoordinates.push([
25172
- [
25173
- leftTick[0][0] + locationOffset[location][0][0],
25174
- leftTick[0][1] + locationOffset[location][0][1],
25175
- ],
25176
- [
25177
- leftTick[1][0] + locationOffset[location][1][0],
25178
- leftTick[1][1] + locationOffset[location][1][1],
25179
- ],
25180
- ]);
25711
+ renderStatus = true;
25712
+ if (!viewport.getRenderingEngine()) {
25713
+ console.warn('Rendering Engine has been destroyed');
25714
+ return renderStatus;
25181
25715
  }
25182
25716
  }
25183
- return { tickIds, tickUIDs, tickCoordinates };
25184
- };
25185
- this.computeWorldScaleCoordinates = (scaleSize, location, pointSet) => {
25186
- let worldCoordinates;
25187
- let topBottomVec = gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), pointSet[0], pointSet[1]);
25188
- topBottomVec = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), topBottomVec);
25189
- let topRightVec = gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), pointSet[2], pointSet[0]);
25190
- topRightVec = gl_matrix_esm/* vec3.normalize */.R3.normalize(gl_matrix_esm/* vec3.create */.R3.create(), topRightVec);
25191
- const midpointLocation = {
25192
- bottom: [pointSet[1], pointSet[2]],
25193
- top: [pointSet[0], pointSet[3]],
25194
- right: [pointSet[2], pointSet[3]],
25195
- left: [pointSet[0], pointSet[1]],
25196
- };
25197
- const midpoint = gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpointLocation[location][0], midpointLocation[location][0])
25198
- .map((i) => i / 2);
25199
- const offset = scaleSize /
25200
- 2 /
25201
- Math.sqrt(Math.pow(topBottomVec[0], 2) +
25202
- Math.pow(topBottomVec[1], 2) +
25203
- Math.pow(topBottomVec[2], 2));
25204
- if (location == 'top' || location == 'bottom') {
25205
- worldCoordinates = [
25206
- gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topRightVec.map((i) => i * offset)),
25207
- gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topRightVec.map((i) => i * offset)),
25208
- ];
25209
- }
25210
- else if (location == 'left' || location == 'right') {
25211
- worldCoordinates = [
25212
- gl_matrix_esm/* vec3.add */.R3.add(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topBottomVec.map((i) => i * offset)),
25213
- gl_matrix_esm/* vec3.subtract */.R3.subtract(gl_matrix_esm/* vec3.create */.R3.create(), midpoint, topBottomVec.map((i) => i * offset)),
25214
- ];
25215
- }
25216
- return worldCoordinates;
25217
- };
25218
- this.computeCanvasScaleCoordinates = (canvasSize, canvasCoordinates, vscaleBounds, hscaleBounds, location) => {
25219
- let scaleCanvasCoordinates;
25220
- if (location == 'top' || location == 'bottom') {
25221
- const worldDistanceOnCanvas = canvasCoordinates[0][0] - canvasCoordinates[1][0];
25222
- scaleCanvasCoordinates = [
25223
- [canvasSize.width / 2 - worldDistanceOnCanvas / 2, vscaleBounds.height],
25224
- [canvasSize.width / 2 + worldDistanceOnCanvas / 2, vscaleBounds.height],
25225
- ];
25226
- }
25227
- else if (location == 'left' || location == 'right') {
25228
- const worldDistanceOnCanvas = canvasCoordinates[0][1] - canvasCoordinates[1][1];
25229
- scaleCanvasCoordinates = [
25230
- [hscaleBounds.width, canvasSize.height / 2 - worldDistanceOnCanvas / 2],
25231
- [hscaleBounds.width, canvasSize.height / 2 + worldDistanceOnCanvas / 2],
25232
- ];
25233
- }
25234
- return scaleCanvasCoordinates;
25235
- };
25236
- this.computeScaleBounds = (canvasSize, horizontalReduction, verticalReduction, location) => {
25237
- const hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
25238
- const vReduction = verticalReduction * Math.min(1000, canvasSize.height);
25239
- const locationBounds = {
25240
- bottom: [-vReduction, -hReduction],
25241
- top: [vReduction, hReduction],
25242
- left: [vReduction, hReduction],
25243
- right: [-vReduction, -hReduction],
25244
- };
25245
- const canvasBounds = {
25246
- bottom: [canvasSize.height, canvasSize.width],
25247
- top: [0, canvasSize.width],
25248
- left: [canvasSize.height, 0],
25249
- right: [canvasSize.height, canvasSize.width],
25250
- };
25251
- return {
25252
- height: canvasBounds[location][0] + locationBounds[location][0],
25253
- width: canvasBounds[location][1] + locationBounds[location][1],
25254
- };
25255
- };
25256
- }
25257
- renderAnnotation(enabledElement, svgDrawingHelper) {
25258
- if (!this.editData.viewport) {
25259
- return;
25260
- }
25261
- const location = this.configuration.scaleLocation;
25262
- const { viewport } = enabledElement;
25263
- const annotations = getAnnotations(this.getToolName(), viewport.element);
25264
- const annotation = annotations.filter((thisAnnotation) => thisAnnotation.data.viewportId == viewport.id)[0];
25265
- const canvas = enabledElement.viewport.canvas;
25266
- const renderStatus = false;
25267
- if (!viewport) {
25268
25717
  return renderStatus;
25269
- }
25270
- const styleSpecifier = {
25271
- toolGroupId: this.toolGroupId,
25272
- toolName: this.getToolName(),
25273
- viewportId: enabledElement.viewport.id,
25274
- };
25275
- const canvasSize = {
25276
- width: canvas.width,
25277
- height: canvas.height,
25278
- };
25279
- const topLeft = annotation.data.handles.points[0];
25280
- const topRight = annotation.data.handles.points[1];
25281
- const bottomLeft = annotation.data.handles.points[2];
25282
- const bottomRight = annotation.data.handles.points[3];
25283
- const pointSet1 = [topLeft, bottomLeft, topRight, bottomRight];
25284
- const worldWidthViewport = gl_matrix_esm/* vec3.distance */.R3.distance(bottomLeft, bottomRight);
25285
- const worldHeightViewport = gl_matrix_esm/* vec3.distance */.R3.distance(topLeft, bottomLeft);
25286
- const hscaleBounds = this.computeScaleBounds(canvasSize, 0.05, 0.05, location);
25287
- const vscaleBounds = this.computeScaleBounds(canvasSize, 0.05, 0.05, location);
25288
- const scaleSize = this.computeScaleSize(worldWidthViewport, worldHeightViewport, location);
25289
- const canvasCoordinates = this.computeWorldScaleCoordinates(scaleSize, location, pointSet1).map((world) => viewport.worldToCanvas(world));
25290
- const scaleCanvasCoordinates = this.computeCanvasScaleCoordinates(canvasSize, canvasCoordinates, vscaleBounds, hscaleBounds, location);
25291
- const scaleTicks = this.computeEndScaleTicks(scaleCanvasCoordinates, location);
25292
- const { annotationUID } = annotation;
25293
- styleSpecifier.annotationUID = annotationUID;
25294
- const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
25295
- const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
25296
- const color = this.getStyle('color', styleSpecifier, annotation);
25297
- const shadow = this.getStyle('shadow', styleSpecifier, annotation);
25298
- const scaleId = `${annotationUID}-scaleline`;
25299
- const scaleLineUID = '1';
25300
- drawLine(svgDrawingHelper, annotationUID, scaleLineUID, scaleCanvasCoordinates[0], scaleCanvasCoordinates[1], {
25301
- color,
25302
- width: lineWidth,
25303
- lineDash,
25304
- shadow,
25305
- }, scaleId);
25306
- const leftTickId = `${annotationUID}-left`;
25307
- const leftTickUID = '2';
25308
- drawLine(svgDrawingHelper, annotationUID, leftTickUID, scaleTicks.endTick1[0], scaleTicks.endTick1[1], {
25309
- color,
25310
- width: lineWidth,
25311
- lineDash,
25312
- shadow,
25313
- }, leftTickId);
25314
- const rightTickId = `${annotationUID}-right`;
25315
- const rightTickUID = '3';
25316
- drawLine(svgDrawingHelper, annotationUID, rightTickUID, scaleTicks.endTick2[0], scaleTicks.endTick2[1], {
25317
- color,
25318
- width: lineWidth,
25319
- lineDash,
25320
- shadow,
25321
- }, rightTickId);
25322
- const locationTextOffest = {
25323
- bottom: [-10, -42],
25324
- top: [-12, -35],
25325
- left: [-40, -20],
25326
- right: [-50, -20],
25327
25718
  };
25328
- const textCanvasCoordinates = [
25329
- scaleCanvasCoordinates[0][0] + locationTextOffest[location][0],
25330
- scaleCanvasCoordinates[0][1] + locationTextOffest[location][1],
25331
- ];
25332
- const textBoxLines = this._getTextLines(scaleSize);
25333
- const { tickIds, tickUIDs, tickCoordinates } = this.computeInnerScaleTicks(scaleSize, location, annotationUID, scaleTicks.endTick1, scaleTicks.endTick2);
25334
- for (let i = 0; i < tickUIDs.length; i++) {
25335
- drawLine(svgDrawingHelper, annotationUID, tickUIDs[i], tickCoordinates[i][0], tickCoordinates[i][1], {
25336
- color,
25337
- width: lineWidth,
25338
- lineDash,
25339
- shadow,
25340
- }, tickIds[i]);
25341
- }
25342
- const textUID = 'text0';
25343
- drawingSvg_drawTextBox(svgDrawingHelper, annotationUID, textUID, textBoxLines, [textCanvasCoordinates[0], textCanvasCoordinates[1]], {
25344
- fontFamily: 'Helvetica Neue, Helvetica, Arial, sans-serif',
25345
- fontSize: '14px',
25346
- lineDash: '2,3',
25347
- lineWidth: '1',
25348
- shadow: true,
25349
- color: color,
25719
+ }
25720
+ cancel() {
25721
+ }
25722
+ handleSelectedCallback(evt, annotation, handle) {
25723
+ }
25724
+ _doneChangingTextCallback(element, annotation, updatedText) {
25725
+ annotation.data.text = updatedText;
25726
+ const { renderingEngine, viewportId, renderingEngineId } = (0,esm.getEnabledElement)(element);
25727
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
25728
+ utilities_triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
25729
+ const eventType = enums_Events.ANNOTATION_MODIFIED;
25730
+ (0,esm.triggerEvent)(esm.eventTarget, eventType, {
25731
+ annotation,
25732
+ viewportId,
25733
+ renderingEngineId,
25350
25734
  });
25351
- return renderStatus;
25352
25735
  }
25353
- _getTextLines(scaleSize) {
25354
- let scaleSizeDisplayValue;
25355
- let scaleSizeUnits;
25356
- if (scaleSize >= 50) {
25357
- scaleSizeDisplayValue = scaleSize / 10;
25358
- scaleSizeUnits = ' cm';
25359
- }
25360
- else {
25361
- scaleSizeDisplayValue = scaleSize;
25362
- scaleSizeUnits = ' mm';
25363
- }
25364
- const textLines = [scaleSizeDisplayValue.toString().concat(scaleSizeUnits)];
25365
- return textLines;
25736
+ _isInsideVolume(index1, index2, dimensions) {
25737
+ return (esm.utilities.indexWithinDimensions(index1, dimensions) &&
25738
+ esm.utilities.indexWithinDimensions(index2, dimensions));
25366
25739
  }
25367
25740
  }
25368
- ScaleOverlayTool.toolName = 'ScaleOverlay';
25369
- /* harmony default export */ const tools_ScaleOverlayTool = (ScaleOverlayTool);
25741
+ function KeyImageTool_getTextCallback(doneChangingTextCallback) {
25742
+ return doneChangingTextCallback(prompt('Enter your annotation:'));
25743
+ }
25744
+ function KeyImageTool_changeTextCallback(data, eventData, doneChangingTextCallback) {
25745
+ return doneChangingTextCallback(prompt('Enter your annotation:'));
25746
+ }
25747
+ KeyImageTool.toolName = 'KeyImage';
25748
+ /* harmony default export */ const annotation_KeyImageTool = (KeyImageTool);
25370
25749
 
25371
25750
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/tools/segmentation/strategies/fillRectangle.js
25372
25751
 
@@ -32082,6 +32461,7 @@ OrientationMarkerTool.toolName = 'OrientationMarker';
32082
32461
 
32083
32462
 
32084
32463
 
32464
+
32085
32465
 
32086
32466
 
32087
32467
  ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.js
@@ -33329,8 +33709,8 @@ function getDataInTime(dynamicVolume, options) {
33329
33709
  }
33330
33710
  if (options.maskVolumeId) {
33331
33711
  const segmentationVolume = esm.cache.getVolume(options.maskVolumeId);
33332
- const dataInTime = _getTimePointDataMask(frames, dynamicVolume, segmentationVolume);
33333
- return dataInTime;
33712
+ const [dataInTime, ijkCoords] = _getTimePointDataMask(frames, dynamicVolume, segmentationVolume);
33713
+ return [dataInTime, ijkCoords];
33334
33714
  }
33335
33715
  if (options.imageCoordinate) {
33336
33716
  const dataInTime = _getTimePointDataCoordinate(frames, options.imageCoordinate, dynamicVolume);
@@ -33364,9 +33744,16 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
33364
33744
  const len = segScalarData.length;
33365
33745
  const nonZeroVoxelIndices = [];
33366
33746
  nonZeroVoxelIndices.length = len;
33747
+ const ijkCoords = [];
33748
+ const dimensions = segmentationVolume.dimensions;
33367
33749
  let actualLen = 0;
33368
33750
  for (let i = 0, len = segScalarData.length; i < len; i++) {
33369
33751
  if (segScalarData[i] !== 0) {
33752
+ ijkCoords.push([
33753
+ i % dimensions[0],
33754
+ Math.floor((i / dimensions[0]) % dimensions[1]),
33755
+ Math.floor(i / (dimensions[0] * dimensions[1])),
33756
+ ]);
33370
33757
  nonZeroVoxelIndices[actualLen++] = i;
33371
33758
  }
33372
33759
  }
@@ -33385,9 +33772,9 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
33385
33772
  });
33386
33773
  values.push(indexValues);
33387
33774
  }
33388
- return values;
33775
+ return [values, ijkCoords];
33389
33776
  }
33390
- const callback = ({ pointLPS: segPointLPS, value: segValue }) => {
33777
+ const callback = ({ pointLPS: segPointLPS, value: segValue, pointIJK: segPointIJK, }) => {
33391
33778
  if (segValue === 0) {
33392
33779
  return;
33393
33780
  }
@@ -33408,10 +33795,11 @@ function _getTimePointDataMask(frames, dynamicVolume, segmentationVolume) {
33408
33795
  perFrameSum.forEach((sum) => {
33409
33796
  averageValues.push(sum / count);
33410
33797
  });
33798
+ ijkCoords.push(segPointIJK);
33411
33799
  values.push(averageValues);
33412
33800
  };
33413
33801
  pointInShapeCallback(maskImageData, () => true, callback);
33414
- return values;
33802
+ return [values, ijkCoords];
33415
33803
  }
33416
33804
  /* harmony default export */ const dynamicVolume_getDataInTime = (getDataInTime);
33417
33805
 
@@ -34539,6 +34927,9 @@ class ViewportColorbar extends Colorbar {
34539
34927
 
34540
34928
 
34541
34929
 
34930
+
34931
+
34932
+
34542
34933
 
34543
34934
 
34544
34935
 
@@ -35771,7 +36162,10 @@ class Synchronizer {
35771
36162
  if (targetIsSource) {
35772
36163
  continue;
35773
36164
  }
35774
- promises.push(this._eventHandler(this, sourceViewport, targetViewport, sourceEvent, this._options));
36165
+ const result = this._eventHandler(this, sourceViewport, targetViewport, sourceEvent, this._options);
36166
+ if (result instanceof Promise) {
36167
+ promises.push(result);
36168
+ }
35775
36169
  }
35776
36170
  }
35777
36171
  catch (ex) {
@@ -35925,6 +36319,7 @@ class ToolGroup {
35925
36319
  constructor(id) {
35926
36320
  this.viewportsInfo = [];
35927
36321
  this.toolOptions = {};
36322
+ this.restoreToolOptions = {};
35928
36323
  this._toolInstances = {};
35929
36324
  this.id = id;
35930
36325
  }
@@ -36035,7 +36430,7 @@ class ToolGroup {
36035
36430
  return;
36036
36431
  }
36037
36432
  if (mode === enums_ToolModes.Active) {
36038
- this.setToolActive(toolName, options);
36433
+ this.setToolActive(toolName, options || this.restoreToolOptions[toolName]);
36039
36434
  return;
36040
36435
  }
36041
36436
  if (mode === enums_ToolModes.Passive) {
@@ -36162,6 +36557,7 @@ class ToolGroup {
36162
36557
  bindings: [],
36163
36558
  mode: Disabled,
36164
36559
  };
36560
+ this.restoreToolOptions[toolName] = this.toolOptions[toolName];
36165
36561
  this.toolOptions[toolName] = toolOptions;
36166
36562
  toolInstance.mode = Disabled;
36167
36563
  if (typeof toolInstance.onSetToolDisabled === 'function') {
@@ -36450,7 +36846,7 @@ function getAnnotations(toolName, annotationGroupSelector) {
36450
36846
  return manager.getAnnotations(groupKey, toolName);
36451
36847
  }
36452
36848
  function addAnnotation(annotation, annotationGroupSelector) {
36453
- if (annotation.annotationUID === undefined) {
36849
+ if (!annotation.annotationUID) {
36454
36850
  annotation.annotationUID = esm.utilities.uuidv4();
36455
36851
  }
36456
36852
  const manager = getAnnotationManager();
@@ -36666,7 +37062,7 @@ function areViewportsCoplanar(viewport1, viewport2) {
36666
37062
 
36667
37063
 
36668
37064
 
36669
- const getSpatialRegistration = (targetId, sourceId) => esm.utilities.spatialRegistrationMetadataProvider.get('spatialRegistrationModule', [targetId, sourceId]);
37065
+ const getSpatialRegistration = (targetId, sourceId) => esm.utilities.spatialRegistrationMetadataProvider.get('spatialRegistrationModule', targetId, sourceId);
36670
37066
  async function stackImageSyncCallback(synchronizerInstance, sourceViewport, targetViewport) {
36671
37067
  const renderingEngine = (0,esm.getRenderingEngine)(targetViewport.renderingEngineId);
36672
37068
  if (!renderingEngine) {
@@ -36774,12 +37170,15 @@ class VideoRedactionTool extends base_AnnotationTool {
36774
37170
  const enabledElement = (0,esm.getEnabledElement)(element);
36775
37171
  const { viewport, renderingEngine } = enabledElement;
36776
37172
  this.isDrawing = true;
37173
+ const camera = viewport.getCamera();
37174
+ const { viewPlaneNormal, viewUp } = camera;
37175
+ const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
36777
37176
  const annotation = {
36778
37177
  metadata: {
36779
37178
  viewPlaneNormal: [0, 0, 1],
36780
37179
  viewUp: [0, 1, 0],
36781
37180
  FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
36782
- referencedImageId: viewport.getFrameOfReferenceUID(),
37181
+ referencedImageId,
36783
37182
  toolName: this.getToolName(),
36784
37183
  },
36785
37184
  data: {