@ohif/app 3.10.0 → 3.10.2

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 (47) hide show
  1. package/dist/{1919.bundle.fad7cb115701d2afd06f.js → 1919.bundle.6cb4a1f5ea770e504398.js} +2 -2
  2. package/dist/{1927.bundle.83810560c4d3a90eb7cf.js → 1927.bundle.5c25b9084f704a3582d2.js} +1 -1
  3. package/dist/{3396.bundle.858cfdfc5ab560840958.js → 2482.bundle.0947bc67ad4429d5fda3.js} +289 -1353
  4. package/dist/{2701.bundle.f1f15df81406d04851c4.js → 2701.bundle.87301d8d94693b5d5fcc.js} +2 -2
  5. package/dist/{2860.bundle.5d93c30e2df60e382bda.js → 2860.bundle.130f5c83c90c83017101.js} +1368 -28
  6. package/dist/{2914.bundle.a0a5ddfebfc9d429063d.js → 2914.bundle.adefec5b51b4955af1f9.js} +2 -0
  7. package/dist/{2932.bundle.e69c37b969d1844a01d3.js → 2932.bundle.2757ab993a28dab49d56.js} +4 -4
  8. package/dist/{3075.bundle.0624f6bf3f676f30d1b5.js → 3075.bundle.5d83563c3791a0d884df.js} +16 -3
  9. package/dist/{3353.bundle.184ebb9668df2cbebd26.js → 3353.bundle.1b2d3da25de70f5f1042.js} +33 -4
  10. package/dist/{3984.bundle.340254f70eefe76b8133.js → 3984.bundle.1248e382e82ee04eff72.js} +17 -12
  11. package/dist/{4113.bundle.49f82d38be003e19e515.js → 4113.bundle.1a3202dd6a1b2e6b9d5d.js} +5 -5
  12. package/dist/{4526.bundle.fbdd617a934353019be3.js → 4526.bundle.54c0b8f753ed5c39f6c5.js} +2 -2
  13. package/dist/{6029.bundle.c5d0baf943c367e7bcb8.js → 6029.bundle.a4206e2a2e75c7b1ad7b.js} +403 -52
  14. package/dist/{9464.bundle.bc0e50f8b60edfdcb9d4.js → 6066.bundle.89df990e4f257e8ac73b.js} +1603 -44
  15. package/dist/{6201.bundle.83db906635608599520a.js → 6201.bundle.b584d7554570344d9170.js} +4 -4
  16. package/dist/{7197.bundle.e5fa41fa6bfd9a88c7ad.js → 7197.bundle.2032eea26c084877d172.js} +3 -3
  17. package/dist/{810.bundle.4e580dc32bbcd921ff41.js → 810.bundle.8b29de53f9632f0f1bf9.js} +4 -4
  18. package/dist/{8185.bundle.0dde37bbed6dbbf102d3.js → 8185.bundle.c7e0ab58fa8f7070de26.js} +22 -16
  19. package/dist/{8558.bundle.51f082f0c68b3aedf54a.js → 8558.bundle.24bb90c2d5a0857577c5.js} +1 -1
  20. package/dist/{7241.bundle.3ec18bc9a5464d5c5c67.js → 8572.bundle.bd98ac784dae1e224a52.js} +135 -47
  21. package/dist/{3166.bundle.0f97235b970e279a4707.js → 908.bundle.7f901ab4610793bb5ee3.js} +29 -5
  22. package/dist/{934.bundle.33cc4ef2fdfd34987c87.js → 934.bundle.441c775536d8be5029af.js} +2 -2
  23. package/dist/{963.bundle.abae2bcc3d87b9260e6a.js → 963.bundle.4b88a54196fdd1976d6c.js} +2 -2
  24. package/dist/{9890.bundle.37d7ed265c0454337a57.js → 9890.bundle.b4c265e3609512785ae8.js} +2 -2
  25. package/dist/{9977.bundle.071821200c1921021d29.js → 9977.bundle.4f44190c1a5d6a69bc00.js} +3 -1
  26. package/dist/{app.bundle.c8d19c9902cb9ea1bb55.js → app.bundle.223c009cd6f636320f76.js} +2170 -1783
  27. package/dist/app.bundle.css +2 -2
  28. package/dist/{compute.bundle.f0c30502c027d04e94f2.js → compute.bundle.83a75c96620eedca973e.js} +3 -3
  29. package/dist/index.html +1 -1
  30. package/dist/{polySeg.bundle.707e6d9b0342d06ffa49.js → polySeg.bundle.30f6f13491f48e597605.js} +3 -3
  31. package/dist/sw.js +1 -1
  32. package/package.json +19 -19
  33. /package/dist/{1459.bundle.b2f3d51daf0583cbcf0b.js → 1459.bundle.ea2023918c1ef217d23a.js} +0 -0
  34. /package/dist/{1807.bundle.a22cda201e86b973c886.js → 1807.bundle.a04f3486b00cdcc6a305.js} +0 -0
  35. /package/dist/{213.bundle.36febd3a2c038128c92e.js → 213.bundle.e861b773d4779d7d724a.js} +0 -0
  36. /package/dist/{2424.bundle.8e789b3206f967d42032.js → 2424.bundle.425cb2260521f2a23f70.js} +0 -0
  37. /package/dist/{3658.bundle.d8fd1c155e97829ce8ee.js → 3658.bundle.a6a9c2e1b32d92e3b621.js} +0 -0
  38. /package/dist/{4759.bundle.a31dcfd4c3054e2ea980.js → 4759.bundle.d1fdc8e827d54c0f40c9.js} +0 -0
  39. /package/dist/{4991.bundle.f72a01fd158167a94ae8.js → 4991.bundle.8578c7880edc0fbef374.js} +0 -0
  40. /package/dist/{5674.bundle.b9c6a5039c2113262ae5.js → 5674.bundle.49f5a714f733cf20d560.js} +0 -0
  41. /package/dist/{6027.bundle.9f8dfb6fed029717ef3a.js → 6027.bundle.8e1b6021f0d570eb85f5.js} +0 -0
  42. /package/dist/{7639.bundle.a24b3a7b0abb6178e9bd.js → 7639.bundle.b622eafdc74d9bfc1280.js} +0 -0
  43. /package/dist/{8228.bundle.74c8ca5e66a44db80464.js → 8228.bundle.f520ecf3c0a8998e770a.js} +0 -0
  44. /package/dist/{85.bundle.31ab810e6a6779ff067c.js → 85.bundle.a27a1466f85e01adf8e8.js} +0 -0
  45. /package/dist/{8815.bundle.7db9450eac27c6ad9054.js → 8815.bundle.096958a5ae7253911a2e.js} +0 -0
  46. /package/dist/{9026.bundle.37f3be98189966cc21e4.js → 9026.bundle.019d8b4b70096b94302e.js} +0 -0
  47. /package/dist/{9862.bundle.ccb787865a82b9696113.js → 9862.bundle.b0ea941458506379f666.js} +0 -0
@@ -652,6 +652,10 @@ function calculateSUVScalingFactors(instances) {
652
652
  /* harmony export */ zj: () => (/* binding */ getConfig)
653
653
  /* harmony export */ });
654
654
  /* unused harmony export getAddOns */
655
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
656
+ /* harmony import */ var _enums_Events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(94021);
657
+
658
+
655
659
  let config = {};
656
660
  function getConfig() {
657
661
  return config;
@@ -3647,6 +3651,7 @@ __webpack_require__.r(__webpack_exports__);
3647
3651
  /* harmony export */ ScaleOverlayTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.FE),
3648
3652
  /* harmony export */ SculptorTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.N),
3649
3653
  /* harmony export */ SegmentBidirectionalTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.Fz),
3654
+ /* harmony export */ SegmentLabelTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.u9),
3650
3655
  /* harmony export */ SegmentSelectTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.IX),
3651
3656
  /* harmony export */ SegmentationIntersectionTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.cN),
3652
3657
  /* harmony export */ SphereScissorsTool: () => (/* reexport safe */ _tools__WEBPACK_IMPORTED_MODULE_12__.zH),
@@ -4617,6 +4622,7 @@ class ToolStyle {
4617
4622
  textBoxLinkLineDash: '2,3',
4618
4623
  textBoxShadow: true,
4619
4624
  markerSize: '10',
4625
+ angleArcLineDash: '',
4620
4626
  };
4621
4627
  this._initializeConfig(defaultConfig);
4622
4628
  }
@@ -5246,7 +5252,7 @@ const segmentationRenderingEngine = new SegmentationRenderingEngine();
5246
5252
  /* unused harmony export default */
5247
5253
  /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
5248
5254
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99737);
5249
- /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(33739);
5255
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(642);
5250
5256
  /* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(99341);
5251
5257
  /* harmony import */ var _triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(49906);
5252
5258
  /* harmony import */ var _SegmentationStyle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(92686);
@@ -5968,13 +5974,16 @@ function normalizeSegments(segmentsConfig, type, data) {
5968
5974
  const normalizedSegments = {};
5969
5975
  if (segmentsConfig) {
5970
5976
  Object.entries(segmentsConfig).forEach(([segmentIndex, segment]) => {
5971
- normalizedSegments[segmentIndex] = {
5977
+ const { label, locked, cachedStats, active, ...rest } = segment;
5978
+ const normalizedSegment = {
5972
5979
  segmentIndex: Number(segmentIndex),
5973
- label: segment.label ?? `Segment ${segmentIndex}`,
5974
- locked: segment.locked ?? false,
5975
- cachedStats: segment.cachedStats ?? {},
5976
- active: segment.active ?? false,
5980
+ label: label ?? `Segment ${segmentIndex}`,
5981
+ locked: locked ?? false,
5982
+ cachedStats: cachedStats ?? {},
5983
+ active: active ?? false,
5984
+ ...rest,
5977
5985
  };
5986
+ normalizedSegments[segmentIndex] = normalizedSegment;
5978
5987
  });
5979
5988
  }
5980
5989
  else if (type === enums.SegmentationRepresentations.Surface) {
@@ -14763,6 +14772,8 @@ WindowLevelTool.toolName = 'WindowLevel';
14763
14772
  /* harmony import */ var _kitware_vtk_js_Common_Core_Math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(84607);
14764
14773
  /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15327);
14765
14774
  /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(85817);
14775
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(99737);
14776
+
14766
14777
 
14767
14778
 
14768
14779
 
@@ -14879,6 +14890,9 @@ class ZoomTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseTool */ .oS {
14879
14890
  }
14880
14891
  this.mouseDragCallback = this._dragCallback.bind(this);
14881
14892
  }
14893
+ mouseWheelCallback(evt) {
14894
+ this._zoom(evt);
14895
+ }
14882
14896
  _pinchCallback(evt) {
14883
14897
  const pointsList = evt.detail
14884
14898
  .currentPointsList;
@@ -14918,6 +14932,36 @@ class ZoomTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseTool */ .oS {
14918
14932
  }
14919
14933
  viewport.render();
14920
14934
  }
14935
+ _zoom(evt) {
14936
+ const { element, points } = evt.detail;
14937
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_2__.getEnabledElement)(element);
14938
+ const { viewport } = enabledElement;
14939
+ const camera = viewport.getCamera();
14940
+ const wheelData = evt.detail.wheel;
14941
+ const direction = wheelData.direction;
14942
+ const eventDetails = {
14943
+ detail: {
14944
+ element,
14945
+ eventName: _enums__WEBPACK_IMPORTED_MODULE_4__.Events.MOUSE_WHEEL,
14946
+ renderingEngineId: enabledElement.renderingEngineId,
14947
+ viewportId: viewport.id,
14948
+ camera: {},
14949
+ deltaPoints: {
14950
+ page: points.page,
14951
+ client: points.client,
14952
+ world: points.world,
14953
+ canvas: [0, -direction * 5],
14954
+ },
14955
+ startPoints: points,
14956
+ lastPoints: points,
14957
+ currentPoints: points,
14958
+ },
14959
+ };
14960
+ if (viewport.type === _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_2__.Enums.ViewportType.STACK) {
14961
+ this.preMouseDownCallback(eventDetails);
14962
+ }
14963
+ this._dragCallback(eventDetails);
14964
+ }
14921
14965
  _panCallback(evt) {
14922
14966
  const { element, deltaPoints } = evt.detail;
14923
14967
  const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_2__.getEnabledElement)(element);
@@ -14990,6 +15034,8 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
14990
15034
  supportedInteractionTypes: ['Mouse', 'Touch'],
14991
15035
  configuration: {
14992
15036
  shadow: true,
15037
+ showAngleArc: false,
15038
+ arcOffset: 5,
14993
15039
  preventHandleOutsideImage: false,
14994
15040
  getTextLines: defaultGetTextLines,
14995
15041
  },
@@ -15138,6 +15184,7 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15138
15184
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_4__.removeAnnotation)(annotation.annotationUID);
15139
15185
  }
15140
15186
  (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
15187
+ this.doneEditMemo();
15141
15188
  if (newAnnotation) {
15142
15189
  (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_12__.triggerAnnotationCompleted)(annotation);
15143
15190
  }
@@ -15148,8 +15195,9 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15148
15195
  this.isDrawing = true;
15149
15196
  const eventDetail = evt.detail;
15150
15197
  const { element } = eventDetail;
15151
- const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
15198
+ const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
15152
15199
  const { data } = annotation;
15200
+ this.createMemo(element, annotation, { newAnnotation });
15153
15201
  if (movingTextBox) {
15154
15202
  const { deltaPoints } = eventDetail;
15155
15203
  const worldPosDelta = deltaPoints.world;
@@ -15266,7 +15314,7 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15266
15314
  const { annotationUID, data } = annotation;
15267
15315
  const { points, activeHandleIndex } = data.handles;
15268
15316
  styleSpecifier.annotationUID = annotationUID;
15269
- const { color, lineWidth, lineDash } = this.getAnnotationStyle({
15317
+ const { color, lineWidth, lineDash, angleArcLineDash } = this.getAnnotationStyle({
15270
15318
  annotation,
15271
15319
  styleSpecifier,
15272
15320
  });
@@ -15318,6 +15366,36 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15318
15366
  width: lineWidth,
15319
15367
  lineDash,
15320
15368
  });
15369
+ if (this.configuration.showAngleArc) {
15370
+ const center = canvasCoordinates[1];
15371
+ const offset = this.configuration.arcOffset;
15372
+ const radius = Math.min(_utilities_math_line__WEBPACK_IMPORTED_MODULE_6__.distanceToPoint([center[0], center[1]], [canvasCoordinates[0][0], canvasCoordinates[0][1]], [canvasCoordinates[2][0], canvasCoordinates[2][1]]), _utilities_math_line__WEBPACK_IMPORTED_MODULE_6__.distanceToPoint([center[0], center[1]], [canvasCoordinates[2][0], canvasCoordinates[2][1]], [canvasCoordinates[0][0], canvasCoordinates[0][1]])) / offset;
15373
+ const anglePoints = [];
15374
+ let startAngle = Math.atan2(canvasCoordinates[0][1] - center[1], canvasCoordinates[0][0] - center[0]);
15375
+ let endAngle = Math.atan2(canvasCoordinates[2][1] - center[1], canvasCoordinates[2][0] - center[0]);
15376
+ if (endAngle < startAngle) {
15377
+ endAngle += 2 * Math.PI;
15378
+ }
15379
+ const angleDifference = endAngle - startAngle;
15380
+ if (angleDifference > Math.PI) {
15381
+ const temp = startAngle;
15382
+ startAngle = endAngle;
15383
+ endAngle = temp + 2 * Math.PI;
15384
+ }
15385
+ const segments = 32;
15386
+ for (let i = 0; i <= segments; i++) {
15387
+ const angle = startAngle + (i / segments) * (endAngle - startAngle);
15388
+ anglePoints.push([
15389
+ center[0] + radius * Math.cos(angle),
15390
+ center[1] + radius * Math.sin(angle),
15391
+ ]);
15392
+ }
15393
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_8__.drawPath)(svgDrawingHelper, annotationUID, '3', anglePoints, {
15394
+ color: color,
15395
+ width: lineWidth,
15396
+ lineDash: angleArcLineDash,
15397
+ });
15398
+ }
15321
15399
  if (!data.cachedStats[targetId]?.angle) {
15322
15400
  continue;
15323
15401
  }
@@ -15362,6 +15440,7 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15362
15440
  return;
15363
15441
  }
15364
15442
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(AngleTool, enabledElement, points, options);
15443
+ const { toolInstance, ...serializableOptions } = options || {};
15365
15444
  const annotation = {
15366
15445
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
15367
15446
  data: {
@@ -15379,7 +15458,7 @@ class AngleTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
15379
15458
  viewPlaneNormal,
15380
15459
  FrameOfReferenceUID,
15381
15460
  referencedImageId,
15382
- ...options,
15461
+ ...serializableOptions,
15383
15462
  },
15384
15463
  };
15385
15464
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_4__.addAnnotation)(annotation, viewport.element);
@@ -15879,6 +15958,7 @@ class ArrowAnnotateTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .Annotation
15879
15958
  return;
15880
15959
  }
15881
15960
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(ArrowAnnotateTool, enabledElement, points, options);
15961
+ const { toolInstance, ...serializableOptions } = options || {};
15882
15962
  const annotation = {
15883
15963
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
15884
15964
  data: {
@@ -15897,7 +15977,7 @@ class ArrowAnnotateTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .Annotation
15897
15977
  viewPlaneNormal,
15898
15978
  FrameOfReferenceUID,
15899
15979
  referencedImageId,
15900
- ...options,
15980
+ ...serializableOptions,
15901
15981
  },
15902
15982
  };
15903
15983
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_3__.addAnnotation)(annotation, viewport.element);
@@ -16701,6 +16781,7 @@ class BidirectionalTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .Annotation
16701
16781
  const [major0, major1] = majorAxis;
16702
16782
  const [minor0, minor1] = minorAxis;
16703
16783
  const points = [major0, major1, minor0, minor1];
16784
+ const { toolInstance, ...serializableOptions } = options || {};
16704
16785
  const annotation = {
16705
16786
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
16706
16787
  data: {
@@ -16730,7 +16811,7 @@ class BidirectionalTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .Annotation
16730
16811
  viewPlaneNormal,
16731
16812
  FrameOfReferenceUID,
16732
16813
  referencedImageId,
16733
- ...options,
16814
+ ...serializableOptions,
16734
16815
  },
16735
16816
  };
16736
16817
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.addAnnotation)(annotation, viewport.element);
@@ -17373,6 +17454,7 @@ class CircleROITool extends _base__WEBPACK_IMPORTED_MODULE_0__/* .AnnotationTool
17373
17454
  return;
17374
17455
  }
17375
17456
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(CircleROITool, enabledElement, points, options);
17457
+ const { toolInstance, ...serializableOptions } = options || {};
17376
17458
  const annotation = {
17377
17459
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
17378
17460
  data: {
@@ -17403,7 +17485,7 @@ class CircleROITool extends _base__WEBPACK_IMPORTED_MODULE_0__/* .AnnotationTool
17403
17485
  viewPlaneNormal,
17404
17486
  FrameOfReferenceUID,
17405
17487
  referencedImageId,
17406
- ...options,
17488
+ ...serializableOptions,
17407
17489
  },
17408
17490
  };
17409
17491
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_4__.addAnnotation)(annotation, viewport.element);
@@ -19379,6 +19461,7 @@ class EllipticalROITool extends _base__WEBPACK_IMPORTED_MODULE_0__/* .Annotation
19379
19461
  return;
19380
19462
  }
19381
19463
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(EllipticalROITool, enabledElement, points, options);
19464
+ const { toolInstance, ...serializableOptions } = options || {};
19382
19465
  const annotation = {
19383
19466
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
19384
19467
  data: {
@@ -19399,7 +19482,7 @@ class EllipticalROITool extends _base__WEBPACK_IMPORTED_MODULE_0__/* .Annotation
19399
19482
  viewPlaneNormal,
19400
19483
  FrameOfReferenceUID,
19401
19484
  referencedImageId,
19402
- ...options,
19485
+ ...serializableOptions,
19403
19486
  },
19404
19487
  };
19405
19488
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_4__.addAnnotation)(annotation, viewport.element);
@@ -20953,6 +21036,7 @@ class LengthTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .AnnotationTool */
20953
21036
  return;
20954
21037
  }
20955
21038
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, instance, viewport, } = this.hydrateBase(LengthTool, enabledElement, points, options);
21039
+ const { toolInstance, ...serializableOptions } = options || {};
20956
21040
  const annotation = {
20957
21041
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
20958
21042
  data: {
@@ -20970,7 +21054,7 @@ class LengthTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .AnnotationTool */
20970
21054
  viewPlaneNormal,
20971
21055
  FrameOfReferenceUID,
20972
21056
  referencedImageId,
20973
- ...options,
21057
+ ...serializableOptions,
20974
21058
  },
20975
21059
  };
20976
21060
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.addAnnotation)(annotation, viewport.element);
@@ -21878,9 +21962,11 @@ function defaultGetTextLines(data, targetId) {
21878
21962
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(99737);
21879
21963
  /* harmony import */ var _utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(60810);
21880
21964
  /* harmony import */ var _cursors_elementCursor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(7001);
21881
- /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(58640);
21882
- /* harmony import */ var _utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(40634);
21883
- /* harmony import */ var _utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(18990);
21965
+ /* harmony import */ var _stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(29601);
21966
+ /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(58640);
21967
+ /* harmony import */ var _utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(40634);
21968
+ /* harmony import */ var _utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(18990);
21969
+
21884
21970
 
21885
21971
 
21886
21972
 
@@ -21905,6 +21991,10 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
21905
21991
  preventHandleOutsideImage: false,
21906
21992
  getTextLines: defaultGetTextLines,
21907
21993
  handleRadius: '6',
21994
+ textCanvasOffset: {
21995
+ x: 6,
21996
+ y: -6,
21997
+ },
21908
21998
  },
21909
21999
  }; }
21910
22000
  constructor(toolProps = {}, defaultToolProps) {
@@ -21931,7 +22021,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
21931
22021
  this._activateModify(element);
21932
22022
  (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_10__.hideElementCursor)(element);
21933
22023
  evt.preventDefault();
21934
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
22024
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
21935
22025
  return annotation;
21936
22026
  };
21937
22027
  this._endCallback = (evt) => {
@@ -21955,7 +22045,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
21955
22045
  this.configuration.preventHandleOutsideImage) {
21956
22046
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_3__.removeAnnotation)(annotation.annotationUID);
21957
22047
  }
21958
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
22048
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
21959
22049
  if (newAnnotation) {
21960
22050
  (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_4__.triggerAnnotationCompleted)(annotation);
21961
22051
  }
@@ -21970,7 +22060,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
21970
22060
  this.createMemo(element, annotation, { newAnnotation });
21971
22061
  data.handles.points[0] = [...worldPos];
21972
22062
  annotation.invalidated = true;
21973
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
22063
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
21974
22064
  };
21975
22065
  this.cancel = (element) => {
21976
22066
  if (this.isDrawing) {
@@ -21981,7 +22071,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
21981
22071
  const { data } = annotation;
21982
22072
  annotation.highlighted = false;
21983
22073
  data.handles.activeHandleIndex = null;
21984
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
22074
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
21985
22075
  if (newAnnotation) {
21986
22076
  (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_4__.triggerAnnotationCompleted)(annotation);
21987
22077
  }
@@ -22073,6 +22163,9 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22073
22163
  console.warn('Rendering Engine has been destroyed');
22074
22164
  return renderStatus;
22075
22165
  }
22166
+ if (!(0,_stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_11__.isAnnotationVisible)(annotationUID)) {
22167
+ continue;
22168
+ }
22076
22169
  const handleGroupUID = '0';
22077
22170
  (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_6__.drawHandles)(svgDrawingHelper, annotationUID, handleGroupUID, [canvasCoordinates], { color, lineWidth, handleRadius: this.configuration.handleRadius });
22078
22171
  renderStatus = true;
@@ -22083,8 +22176,8 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22083
22176
  const textLines = this.configuration.getTextLines(data, targetId);
22084
22177
  if (textLines) {
22085
22178
  const textCanvasCoordinates = [
22086
- canvasCoordinates[0] + 6,
22087
- canvasCoordinates[1] - 6,
22179
+ canvasCoordinates[0] + this.configuration.textCanvasOffset.x,
22180
+ canvasCoordinates[1] + this.configuration.textCanvasOffset.y,
22088
22181
  ];
22089
22182
  const textUID = '0';
22090
22183
  (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_6__.drawTextBox)(svgDrawingHelper, annotationUID, textUID, textLines, [textCanvasCoordinates[0], textCanvasCoordinates[1]], options);
@@ -22108,6 +22201,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22108
22201
  return;
22109
22202
  }
22110
22203
  const { FrameOfReferenceUID, referencedImageId, viewPlaneNormal, viewUp, instance, viewport, } = this.hydrateBase(ProbeTool, enabledElement, points, options);
22204
+ const { toolInstance, ...serializableOptions } = options || {};
22111
22205
  const annotation = {
22112
22206
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.uuidv4(),
22113
22207
  data: {
@@ -22125,11 +22219,11 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22125
22219
  viewPlaneNormal,
22126
22220
  FrameOfReferenceUID,
22127
22221
  referencedImageId,
22128
- ...options,
22222
+ ...serializableOptions,
22129
22223
  },
22130
22224
  };
22131
22225
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_3__.addAnnotation)(annotation, viewport.element);
22132
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)([viewport.id]);
22226
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)([viewport.id]);
22133
22227
  }; }
22134
22228
  getHandleNearImagePoint(element, annotation, canvasCoords, proximity) {
22135
22229
  const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
@@ -22153,7 +22247,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22153
22247
  };
22154
22248
  this._activateModify(element);
22155
22249
  (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_10__.hideElementCursor)(element);
22156
- (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .A)(viewportIdsToRender);
22250
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
22157
22251
  evt.preventDefault();
22158
22252
  }
22159
22253
  _calculateCachedStats(annotation, renderingEngine, enabledElement, changeType = _enums__WEBPACK_IMPORTED_MODULE_8__.ChangeTypes.StatsUpdated) {
@@ -22166,7 +22260,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22166
22260
  for (let i = 0; i < targetIds.length; i++) {
22167
22261
  const targetId = targetIds[i];
22168
22262
  const pixelUnitsOptions = {
22169
- isPreScaled: (0,_utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_13__/* .isViewportPreScaled */ .u)(viewport, targetId),
22263
+ isPreScaled: (0,_utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_14__/* .isViewportPreScaled */ .u)(viewport, targetId),
22170
22264
  isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
22171
22265
  };
22172
22266
  const image = this.getTargetImageData(targetId);
@@ -22199,7 +22293,7 @@ class ProbeTool extends _base__WEBPACK_IMPORTED_MODULE_2__/* .AnnotationTool */
22199
22293
  : 'raw';
22200
22294
  }
22201
22295
  else {
22202
- modalityUnit = (0,_utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_12__/* .getPixelValueUnits */ .j)(modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
22296
+ modalityUnit = (0,_utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_13__/* .getPixelValueUnits */ .j)(modality, annotation.metadata.referencedImageId, pixelUnitsOptions);
22203
22297
  }
22204
22298
  cachedStats[targetId] = {
22205
22299
  index: ijk,
@@ -23307,6 +23401,7 @@ class SplineROITool extends _base_ContourSegmentationBaseTool__WEBPACK_IMPORTED_
23307
23401
  const splineConfig = instance._getSplineConfig(splineType);
23308
23402
  const SplineClass = splineConfig.Class;
23309
23403
  const splineInstance = new SplineClass();
23404
+ const { toolInstance, ...serializableOptions } = options || {};
23310
23405
  const annotation = {
23311
23406
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.uuidv4(),
23312
23407
  data: {
@@ -23333,7 +23428,7 @@ class SplineROITool extends _base_ContourSegmentationBaseTool__WEBPACK_IMPORTED_
23333
23428
  viewPlaneNormal,
23334
23429
  FrameOfReferenceUID,
23335
23430
  referencedImageId,
23336
- ...options,
23431
+ ...serializableOptions,
23337
23432
  },
23338
23433
  };
23339
23434
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_2__.addAnnotation)(annotation, viewport.element);
@@ -25656,6 +25751,9 @@ BaseTool.toolName = 'BaseTool';
25656
25751
  /* harmony import */ var _removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(87420);
25657
25752
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(36625);
25658
25753
  /* harmony import */ var _utilities_segmentation_computeAndAddRepresentation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(27479);
25754
+ /* harmony import */ var _utilities_segmentation_getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(25758);
25755
+ /* harmony import */ var _stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(82056);
25756
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3823);
25659
25757
 
25660
25758
 
25661
25759
 
@@ -25663,7 +25761,10 @@ BaseTool.toolName = 'BaseTool';
25663
25761
 
25664
25762
 
25665
25763
 
25666
- let polySegConversionInProgress = false;
25764
+
25765
+
25766
+
25767
+ const polySegConversionInProgressForViewportId = new Map();
25667
25768
  const processedViewportSegmentations = new Map();
25668
25769
  function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
25669
25770
  const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElementByViewportId)(viewportId);
@@ -25671,10 +25772,10 @@ function removeRepresentation(viewportId, segmentationId, renderImmediate = fals
25671
25772
  return;
25672
25773
  }
25673
25774
  const { viewport } = enabledElement;
25775
+ (0,_removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(viewportId, segmentationId);
25674
25776
  if (!renderImmediate) {
25675
25777
  return;
25676
25778
  }
25677
- (0,_removeContourFromElement__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(viewportId, segmentationId);
25678
25779
  viewport.render();
25679
25780
  }
25680
25781
  async function render(viewport, contourRepresentation) {
@@ -25684,13 +25785,13 @@ async function render(viewport, contourRepresentation) {
25684
25785
  return;
25685
25786
  }
25686
25787
  let contourData = segmentation.representationData[_enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour];
25788
+ const polySeg = (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)();
25687
25789
  if (!contourData &&
25688
25790
  (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)()?.canComputeRequestedRepresentation(segmentationId, _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour) &&
25689
- !polySegConversionInProgress) {
25690
- polySegConversionInProgress = true;
25691
- const polySeg = (0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)();
25791
+ !polySegConversionInProgressForViewportId.get(viewport.id)) {
25792
+ polySegConversionInProgressForViewportId.set(viewport.id, true);
25692
25793
  contourData = await (0,_utilities_segmentation_computeAndAddRepresentation__WEBPACK_IMPORTED_MODULE_6__/* .computeAndAddRepresentation */ .d)(segmentationId, _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Contour, () => polySeg.computeContourData(segmentationId, { viewport }), () => undefined);
25693
- polySegConversionInProgress = false;
25794
+ polySegConversionInProgressForViewportId.set(viewport.id, false);
25694
25795
  }
25695
25796
  else if (!contourData && !(0,_config__WEBPACK_IMPORTED_MODULE_5__/* .getPolySeg */ .Qy)()) {
25696
25797
  console.debug(`No contour data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to contour. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
@@ -25701,8 +25802,101 @@ async function render(viewport, contourRepresentation) {
25701
25802
  if (!contourData.geometryIds?.length) {
25702
25803
  return;
25703
25804
  }
25805
+ let hasContourDataButNotMatchingViewport = false;
25806
+ const viewportNormal = viewport.getCamera().viewPlaneNormal;
25807
+ if (contourData.annotationUIDsMap) {
25808
+ hasContourDataButNotMatchingViewport = !_checkContourNormalsMatchViewport(contourData.annotationUIDsMap, viewportNormal);
25809
+ }
25810
+ if (contourData.geometryIds.length > 0) {
25811
+ hasContourDataButNotMatchingViewport = !_checkContourGeometryMatchViewport(contourData.geometryIds, viewportNormal);
25812
+ }
25813
+ const viewportProcessed = processedViewportSegmentations.get(viewport.id) || new Set();
25814
+ if (hasContourDataButNotMatchingViewport &&
25815
+ !polySegConversionInProgressForViewportId.get(viewport.id) &&
25816
+ !viewportProcessed.has(segmentationId) &&
25817
+ viewport.viewportStatus === _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.Enums.ViewportStatus.RENDERED) {
25818
+ polySegConversionInProgressForViewportId.set(viewport.id, true);
25819
+ const segmentIndices = (0,_utilities_segmentation_getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_7__/* .getUniqueSegmentIndices */ .O)(segmentationId);
25820
+ const surfacesInfo = await polySeg.computeSurfaceData(segmentationId, {
25821
+ segmentIndices,
25822
+ viewport,
25823
+ });
25824
+ const geometryIds = surfacesInfo.geometryIds;
25825
+ const pointsAndPolys = [];
25826
+ for (const geometryId of geometryIds.values()) {
25827
+ const geometry = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getGeometry(geometryId);
25828
+ const data = geometry.data;
25829
+ pointsAndPolys.push({
25830
+ points: data.points,
25831
+ polys: data.polys,
25832
+ segmentIndex: data.segmentIndex,
25833
+ id: data.segmentIndex,
25834
+ });
25835
+ }
25836
+ const polyDataCache = await polySeg.clipAndCacheSurfacesForViewport(pointsAndPolys, viewport);
25837
+ const rawResults = polySeg.extractContourData(polyDataCache);
25838
+ const annotationUIDsMap = polySeg.createAndAddContourSegmentationsFromClippedSurfaces(rawResults, viewport, segmentationId);
25839
+ contourData.annotationUIDsMap = new Map([
25840
+ ...contourData.annotationUIDsMap,
25841
+ ...annotationUIDsMap,
25842
+ ]);
25843
+ viewportProcessed.add(segmentationId);
25844
+ processedViewportSegmentations.set(viewport.id, viewportProcessed);
25845
+ polySegConversionInProgressForViewportId.set(viewport.id, false);
25846
+ }
25704
25847
  (0,_contourHandler_handleContourSegmentation__WEBPACK_IMPORTED_MODULE_2__/* .handleContourSegmentation */ .d)(viewport, contourData.geometryIds, contourData.annotationUIDsMap, contourRepresentation);
25705
25848
  }
25849
+ function _checkContourGeometryMatchViewport(geometryIds, viewportNormal) {
25850
+ let validGeometry = null;
25851
+ let geometryData = null;
25852
+ for (const geometryId of geometryIds) {
25853
+ const geometry = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getGeometry(geometryId);
25854
+ if (!geometry) {
25855
+ continue;
25856
+ }
25857
+ const data = geometry.data;
25858
+ if (data.contours?.[0]?.points?.length >= 3) {
25859
+ validGeometry = geometry;
25860
+ geometryData = data;
25861
+ break;
25862
+ }
25863
+ }
25864
+ if (!validGeometry || !geometryData) {
25865
+ return false;
25866
+ }
25867
+ const contours = geometryData.contours;
25868
+ const points = contours[0].points;
25869
+ const point1 = points[0];
25870
+ const point2 = points[1];
25871
+ const point3 = points[2];
25872
+ let normal = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), point2, point1), gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), point3, point1));
25873
+ normal = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.normalize */ .eR.normalize(gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.create */ .eR.create(), normal);
25874
+ const dotProduct = gl_matrix__WEBPACK_IMPORTED_MODULE_9__/* .vec3.dot */ .eR.dot(normal, viewportNormal);
25875
+ return Math.abs(dotProduct) > 0.9;
25876
+ }
25877
+ function _checkContourNormalsMatchViewport(annotationUIDsMap, viewportNormal) {
25878
+ const annotationUIDs = Array.from(annotationUIDsMap.values())
25879
+ .flat()
25880
+ .map((uidSet) => Array.from(uidSet))
25881
+ .flat();
25882
+ const randomAnnotationUIDs = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getRandomSampleFromArray(annotationUIDs, 3);
25883
+ for (const annotationUID of randomAnnotationUIDs) {
25884
+ const annotation = (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_8__.getAnnotation)(annotationUID);
25885
+ if (annotation?.metadata) {
25886
+ if (!annotation.metadata.viewPlaneNormal) {
25887
+ continue;
25888
+ }
25889
+ const annotationNormal = annotation.metadata.viewPlaneNormal;
25890
+ const dotProduct = Math.abs(viewportNormal[0] * annotationNormal[0] +
25891
+ viewportNormal[1] * annotationNormal[1] +
25892
+ viewportNormal[2] * annotationNormal[2]);
25893
+ if (Math.abs(dotProduct - 1) > 0.01) {
25894
+ return false;
25895
+ }
25896
+ }
25897
+ }
25898
+ return true;
25899
+ }
25706
25900
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
25707
25901
  render,
25708
25902
  removeRepresentation,
@@ -26165,6 +26359,7 @@ async function render(viewport, representation) {
26165
26359
  /* harmony export */ qi: () => (/* reexport safe */ _annotation_PlanarFreehandContourSegmentationTool__WEBPACK_IMPORTED_MODULE_32__.A),
26166
26360
  /* harmony export */ sR: () => (/* reexport safe */ _annotation_RegionSegmentPlusTool__WEBPACK_IMPORTED_MODULE_42__.A),
26167
26361
  /* harmony export */ td: () => (/* reexport safe */ _segmentation_RectangleScissorsTool__WEBPACK_IMPORTED_MODULE_45__.A),
26362
+ /* harmony export */ u9: () => (/* reexport safe */ _segmentation_SegmentLabelTool__WEBPACK_IMPORTED_MODULE_57__.A),
26168
26363
  /* harmony export */ uJ: () => (/* reexport safe */ _MIPJumpToClickTool__WEBPACK_IMPORTED_MODULE_8__.A),
26169
26364
  /* harmony export */ wR: () => (/* reexport safe */ _annotation_RegionSegmentTool__WEBPACK_IMPORTED_MODULE_41__.A),
26170
26365
  /* harmony export */ wh: () => (/* reexport safe */ _base__WEBPACK_IMPORTED_MODULE_0__.wh),
@@ -26229,6 +26424,8 @@ async function render(viewport, representation) {
26229
26424
  /* harmony import */ var _segmentation_SegmentSelectTool__WEBPACK_IMPORTED_MODULE_54__ = __webpack_require__(12905);
26230
26425
  /* harmony import */ var _segmentation_SegmentBidirectionalTool__WEBPACK_IMPORTED_MODULE_55__ = __webpack_require__(38502);
26231
26426
  /* harmony import */ var _segmentation_strategies__WEBPACK_IMPORTED_MODULE_56__ = __webpack_require__(99522);
26427
+ /* harmony import */ var _segmentation_SegmentLabelTool__WEBPACK_IMPORTED_MODULE_57__ = __webpack_require__(987);
26428
+
26232
26429
 
26233
26430
 
26234
26431
 
@@ -26612,6 +26809,9 @@ class BrushTool extends _LabelmapBaseTool__WEBPACK_IMPORTED_MODULE_10__/* ["defa
26612
26809
  }
26613
26810
  this.doneEditMemo();
26614
26811
  const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
26812
+ if (!enabledElement) {
26813
+ return;
26814
+ }
26615
26815
  this.applyActiveStrategyCallback(enabledElement, this.getOperationData(element), _enums__WEBPACK_IMPORTED_MODULE_2__.StrategyCallbacks.RejectPreview);
26616
26816
  this._previewData.preview = null;
26617
26817
  this._previewData.isDrag = false;
@@ -28127,9 +28327,6 @@ class RectangleROIStartEndThresholdTool extends _annotation_RectangleROITool__WE
28127
28327
  if (this.configuration.calculatePointsInsideVolume) {
28128
28328
  this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
28129
28329
  }
28130
- if (this.configuration.calculatePointsInsideVolume) {
28131
- this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
28132
- }
28133
28330
  annotation.invalidated = false;
28134
28331
  (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_13__.triggerAnnotationModified)(annotation, viewport.element);
28135
28332
  return cachedStats;
@@ -28834,6 +29031,7 @@ class SegmentBidirectionalTool extends _annotation_BidirectionalTool__WEBPACK_IM
28834
29031
  const [major0, major1] = majorAxis;
28835
29032
  const [minor0, minor1] = minorAxis;
28836
29033
  const points = [major0, major1, minor0, minor1];
29034
+ const { toolInstance, ...serializableOptions } = options || {};
28837
29035
  const annotation = {
28838
29036
  annotationUID: options?.annotationUID || _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.uuidv4(),
28839
29037
  data: {
@@ -28865,7 +29063,7 @@ class SegmentBidirectionalTool extends _annotation_BidirectionalTool__WEBPACK_IM
28865
29063
  viewPlaneNormal,
28866
29064
  FrameOfReferenceUID,
28867
29065
  referencedImageId,
28868
- ...options,
29066
+ ...serializableOptions,
28869
29067
  },
28870
29068
  };
28871
29069
  (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_1__.addAnnotation)(annotation, viewport.element);
@@ -28878,7 +29076,7 @@ class SegmentBidirectionalTool extends _annotation_BidirectionalTool__WEBPACK_IM
28878
29076
 
28879
29077
  /***/ }),
28880
29078
 
28881
- /***/ 12905:
29079
+ /***/ 987:
28882
29080
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
28883
29081
 
28884
29082
  "use strict";
@@ -28890,13 +29088,162 @@ class SegmentBidirectionalTool extends _annotation_BidirectionalTool__WEBPACK_IM
28890
29088
  /* harmony import */ var _stateManagement_segmentation_triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(49906);
28891
29089
  /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58640);
28892
29090
  /* harmony import */ var _stateManagement_segmentation_activeSegmentation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26228);
28893
- /* harmony import */ var _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(18682);
28894
- /* harmony import */ var _stateManagement_segmentation_segmentIndex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(70930);
28895
- /* harmony import */ var _utilities_segmentation__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(93759);
28896
- /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(85204);
28897
- /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(99737);
29091
+ /* harmony import */ var _utilities_segmentation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(93759);
29092
+ /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(85204);
29093
+ /* harmony import */ var _drawingSvg__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(17328);
29094
+
29095
+
29096
+
29097
+
29098
+
29099
+
29100
+
29101
+
29102
+ class SegmentLabelTool extends _base__WEBPACK_IMPORTED_MODULE_1__/* .BaseTool */ .oS {
29103
+ constructor(toolProps = {
29104
+ data: {
29105
+ handles: {
29106
+ textBox: {
29107
+ worldPosition: [0, 0, 0],
29108
+ worldBoundingBox: {
29109
+ topLeft: [0, 0, 0],
29110
+ topRight: [0, 0, 0],
29111
+ bottomLeft: [0, 0, 0],
29112
+ bottomRight: [0, 0, 0],
29113
+ },
29114
+ },
29115
+ },
29116
+ },
29117
+ }, defaultToolProps = {
29118
+ supportedInteractionTypes: ['Mouse', 'Touch'],
29119
+ configuration: {
29120
+ hoverTimeout: 100,
29121
+ searchRadius: 6,
29122
+ },
29123
+ }) {
29124
+ super(toolProps, defaultToolProps);
29125
+ this.mouseMoveCallback = (evt) => {
29126
+ if (this.hoverTimer) {
29127
+ clearTimeout(this.hoverTimer);
29128
+ }
29129
+ this.hoverTimer = setTimeout(() => {
29130
+ this._setHoveredSegment(evt);
29131
+ this.hoverTimer = null;
29132
+ }, this.configuration.hoverTimeout);
29133
+ return true;
29134
+ };
29135
+ this.onSetToolEnabled = () => {
29136
+ this.onSetToolActive();
29137
+ };
29138
+ this.onSetToolActive = () => {
29139
+ this.hoverTimer = null;
29140
+ };
29141
+ this.onSetToolDisabled = () => {
29142
+ this.hoverTimer = null;
29143
+ };
29144
+ this.data = toolProps.data ?? {
29145
+ handles: {
29146
+ textBox: {
29147
+ worldPosition: [0, 0, 0],
29148
+ worldBoundingBox: {
29149
+ topLeft: [0, 0, 0],
29150
+ topRight: [0, 0, 0],
29151
+ bottomLeft: [0, 0, 0],
29152
+ bottomRight: [0, 0, 0],
29153
+ },
29154
+ },
29155
+ },
29156
+ };
29157
+ this.hoverTimer = null;
29158
+ }
29159
+ _setHoveredSegment(evt = {}) {
29160
+ if (_store_state__WEBPACK_IMPORTED_MODULE_6__/* .state */ .wk.isInteractingWithTool) {
29161
+ return;
29162
+ }
29163
+ const { element, currentPoints } = evt.detail;
29164
+ const worldPoint = currentPoints.world;
29165
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
29166
+ if (!enabledElement) {
29167
+ return;
29168
+ }
29169
+ const { viewport } = enabledElement;
29170
+ const activeSegmentation = (0,_stateManagement_segmentation_activeSegmentation__WEBPACK_IMPORTED_MODULE_4__.getActiveSegmentation)(viewport.id);
29171
+ if (!activeSegmentation) {
29172
+ return;
29173
+ }
29174
+ this._setHoveredSegmentForType(activeSegmentation, worldPoint, viewport);
29175
+ }
29176
+ _setHoveredSegmentForType(activeSegmentation, worldPoint, viewport) {
29177
+ const imageDataInfo = viewport.getImageData();
29178
+ if (!imageDataInfo) {
29179
+ return;
29180
+ }
29181
+ const { segmentationId } = activeSegmentation;
29182
+ const hoveredSegmentIndex = (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_5__.getSegmentIndexAtWorldPoint)(segmentationId, worldPoint, {
29183
+ viewport,
29184
+ });
29185
+ const segment = activeSegmentation.segments[hoveredSegmentIndex];
29186
+ const label = segment?.label;
29187
+ const canvasCoordinates = viewport.worldToCanvas(worldPoint);
29188
+ this._editData = {
29189
+ hoveredSegmentIndex,
29190
+ hoveredSegmentLabel: label,
29191
+ canvasCoordinates,
29192
+ worldPoint,
29193
+ };
29194
+ if (!hoveredSegmentIndex || hoveredSegmentIndex === 0) {
29195
+ return;
29196
+ }
29197
+ const renderingEngine = viewport.getRenderingEngine();
29198
+ const viewportIds = renderingEngine.getViewports().map((v) => v.id);
29199
+ (0,_stateManagement_segmentation_triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_2__.triggerSegmentationModified)(segmentationId);
29200
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A)(viewportIds);
29201
+ }
29202
+ renderAnnotation(enabledElement, svgDrawingHelper) {
29203
+ if (!this._editData) {
29204
+ return;
29205
+ }
29206
+ const { viewport } = enabledElement;
29207
+ const { hoveredSegmentIndex, hoveredSegmentLabel, canvasCoordinates, worldPoint, } = this._editData;
29208
+ if (!hoveredSegmentIndex) {
29209
+ return;
29210
+ }
29211
+ const textBoxPosition = viewport.worldToCanvas(worldPoint);
29212
+ const boundingBox = (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_7__.drawLinkedTextBox)(svgDrawingHelper, 'segmentSelectLabelAnnotation', 'segmentSelectLabelTextBox', [hoveredSegmentLabel ? hoveredSegmentLabel : '(unnamed segment)'], textBoxPosition, [canvasCoordinates], {}, {});
29213
+ const left = canvasCoordinates[0];
29214
+ const top = canvasCoordinates[1];
29215
+ const { width, height } = boundingBox;
29216
+ this.data.handles.textBox.worldBoundingBox = {
29217
+ topLeft: viewport.canvasToWorld([left, top]),
29218
+ topRight: viewport.canvasToWorld([left + width, top]),
29219
+ bottomLeft: viewport.canvasToWorld([left, top + height]),
29220
+ bottomRight: viewport.canvasToWorld([left + width, top + height]),
29221
+ };
29222
+ }
29223
+ }
29224
+ SegmentLabelTool.toolName = 'SegmentLabelTool';
29225
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SegmentLabelTool);
28898
29226
 
28899
29227
 
29228
+ /***/ }),
29229
+
29230
+ /***/ 12905:
29231
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
29232
+
29233
+ "use strict";
29234
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
29235
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
29236
+ /* harmony export */ });
29237
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15327);
29238
+ /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(85817);
29239
+ /* harmony import */ var _stateManagement_segmentation_triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(49906);
29240
+ /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58640);
29241
+ /* harmony import */ var _stateManagement_segmentation_activeSegmentation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26228);
29242
+ /* harmony import */ var _stateManagement_segmentation_segmentIndex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(70930);
29243
+ /* harmony import */ var _utilities_segmentation__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(93759);
29244
+ /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(85204);
29245
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(99737);
29246
+
28900
29247
 
28901
29248
 
28902
29249
 
@@ -28920,7 +29267,7 @@ class SegmentSelectTool extends _base__WEBPACK_IMPORTED_MODULE_1__/* .BaseTool *
28920
29267
  }) {
28921
29268
  super(toolProps, defaultToolProps);
28922
29269
  this.mouseMoveCallback = (evt) => {
28923
- if (this.mode !== _enums__WEBPACK_IMPORTED_MODULE_9__.ToolModes.Active) {
29270
+ if (this.mode !== _enums__WEBPACK_IMPORTED_MODULE_8__.ToolModes.Active) {
28924
29271
  return;
28925
29272
  }
28926
29273
  if (this.hoverTimer) {
@@ -28944,7 +29291,7 @@ class SegmentSelectTool extends _base__WEBPACK_IMPORTED_MODULE_1__/* .BaseTool *
28944
29291
  this.hoverTimer = null;
28945
29292
  }
28946
29293
  _setActiveSegment(evt = {}) {
28947
- if (_store_state__WEBPACK_IMPORTED_MODULE_8__/* .state */ .wk.isInteractingWithTool) {
29294
+ if (_store_state__WEBPACK_IMPORTED_MODULE_7__/* .state */ .wk.isInteractingWithTool) {
28948
29295
  return;
28949
29296
  }
28950
29297
  const { element, currentPoints } = evt.detail;
@@ -28968,20 +29315,20 @@ class SegmentSelectTool extends _base__WEBPACK_IMPORTED_MODULE_1__/* .BaseTool *
28968
29315
  const { segmentationId, representationData } = activeSegmentation;
28969
29316
  let hoveredSegmentIndex;
28970
29317
  if (this.configuration.mode === SegmentSelectTool.SelectMode.Inside) {
28971
- hoveredSegmentIndex = (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_7__.getSegmentIndexAtWorldPoint)(segmentationId, worldPoint, {
29318
+ hoveredSegmentIndex = (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_6__.getSegmentIndexAtWorldPoint)(segmentationId, worldPoint, {
28972
29319
  viewport,
28973
29320
  });
28974
29321
  }
28975
29322
  else {
28976
29323
  if (representationData.Labelmap) {
28977
- hoveredSegmentIndex = (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_7__.getSegmentIndexAtLabelmapBorder)(segmentationId, worldPoint, {
29324
+ hoveredSegmentIndex = (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_6__.getSegmentIndexAtLabelmapBorder)(segmentationId, worldPoint, {
28978
29325
  viewport,
28979
29326
  searchRadius: this.configuration.searchRadius,
28980
29327
  });
28981
29328
  }
28982
29329
  else if (representationData.Contour) {
28983
29330
  hoveredSegmentIndex =
28984
- (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_7__.getHoveredContourSegmentationAnnotation)(segmentationId);
29331
+ (0,_utilities_segmentation__WEBPACK_IMPORTED_MODULE_6__.getHoveredContourSegmentationAnnotation)(segmentationId);
28985
29332
  }
28986
29333
  else if (representationData.Surface) {
28987
29334
  }
@@ -28989,7 +29336,7 @@ class SegmentSelectTool extends _base__WEBPACK_IMPORTED_MODULE_1__/* .BaseTool *
28989
29336
  if (!hoveredSegmentIndex || hoveredSegmentIndex === 0) {
28990
29337
  return;
28991
29338
  }
28992
- (0,_stateManagement_segmentation_segmentIndex__WEBPACK_IMPORTED_MODULE_6__.setActiveSegmentIndex)(segmentationId, hoveredSegmentIndex);
29339
+ (0,_stateManagement_segmentation_segmentIndex__WEBPACK_IMPORTED_MODULE_5__.setActiveSegmentIndex)(segmentationId, hoveredSegmentIndex);
28993
29340
  const renderingEngine = viewport.getRenderingEngine();
28994
29341
  const viewportIds = renderingEngine.getViewports().map((v) => v.id);
28995
29342
  (0,_stateManagement_segmentation_triggerSegmentationEvents__WEBPACK_IMPORTED_MODULE_2__.triggerSegmentationModified)(segmentationId);
@@ -34045,10 +34392,14 @@ async function calculateVolumeStatistics({ operationData, indices, unit, mode, }
34045
34392
  origin: imageData.getOrigin(),
34046
34393
  direction: imageData.getDirection(),
34047
34394
  };
34395
+ if (!imageInfo.scalarData?.length) {
34396
+ return;
34397
+ }
34048
34398
  const stats = await (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getWebWorkerManager)().executeTask('compute', 'calculateSegmentsStatisticsVolume', {
34049
34399
  segmentationInfo,
34050
34400
  imageInfo,
34051
34401
  indices,
34402
+ unit,
34052
34403
  mode,
34053
34404
  });
34054
34405
  (0,_utilsForWorker__WEBPACK_IMPORTED_MODULE_1__/* .triggerWorkerProgress */ .sg)(_enums__WEBPACK_IMPORTED_MODULE_4__.WorkerTypes.COMPUTE_STATISTICS, 100);
@@ -36323,7 +36674,7 @@ const getImageReferenceInfo = (segVolumeId, segImageIds) => {
36323
36674
  const refImage = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getImage(refImageId);
36324
36675
  const scalingModule = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.metaData.get('scalingModule', refImageId);
36325
36676
  const modalityUnitOptions = {
36326
- isPreScaled: Boolean(refImage.preScale?.scaled),
36677
+ isPreScaled: Boolean(refImage?.preScale?.scaled),
36327
36678
  isSuvScaled: typeof scalingModule?.suvbw === 'number',
36328
36679
  };
36329
36680
  return { refImageId, modalityUnitOptions };