@cornerstonejs/tools 1.78.3 → 1.80.0

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 (91) hide show
  1. package/dist/cjs/cursors/SVGCursorDescriptor.js +7 -0
  2. package/dist/cjs/cursors/SVGCursorDescriptor.js.map +1 -1
  3. package/dist/cjs/drawingSvg/drawHeight.d.ts +3 -0
  4. package/dist/cjs/drawingSvg/drawHeight.js +49 -0
  5. package/dist/cjs/drawingSvg/drawHeight.js.map +1 -0
  6. package/dist/cjs/drawingSvg/index.d.ts +2 -1
  7. package/dist/cjs/drawingSvg/index.js +3 -1
  8. package/dist/cjs/drawingSvg/index.js.map +1 -1
  9. package/dist/cjs/index.d.ts +2 -2
  10. package/dist/cjs/index.js +3 -2
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/tools/annotation/HeightTool.d.ts +40 -0
  13. package/dist/cjs/tools/annotation/HeightTool.js +463 -0
  14. package/dist/cjs/tools/annotation/HeightTool.js.map +1 -0
  15. package/dist/cjs/tools/index.d.ts +2 -1
  16. package/dist/cjs/tools/index.js +4 -2
  17. package/dist/cjs/tools/index.js.map +1 -1
  18. package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.d.ts +15 -8
  19. package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.js +189 -62
  20. package/dist/cjs/tools/segmentation/CircleROIStartEndThresholdTool.js.map +1 -1
  21. package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +17 -7
  22. package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js +167 -52
  23. package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
  24. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +26 -4
  25. package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.d.ts +3 -0
  26. package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.js +31 -0
  27. package/dist/cjs/utilities/planar/filterAnnotationsWithinPlane.js.map +1 -0
  28. package/dist/cjs/utilities/planar/index.d.ts +3 -1
  29. package/dist/cjs/utilities/planar/index.js +4 -1
  30. package/dist/cjs/utilities/planar/index.js.map +1 -1
  31. package/dist/cjs/utilities/viewport/isViewportPreScaled.js +1 -4
  32. package/dist/cjs/utilities/viewport/isViewportPreScaled.js.map +1 -1
  33. package/dist/esm/cursors/SVGCursorDescriptor.js +7 -0
  34. package/dist/esm/cursors/SVGCursorDescriptor.js.map +1 -1
  35. package/dist/esm/drawingSvg/drawHeight.js +43 -0
  36. package/dist/esm/drawingSvg/drawHeight.js.map +1 -0
  37. package/dist/esm/drawingSvg/index.js +2 -1
  38. package/dist/esm/drawingSvg/index.js.map +1 -1
  39. package/dist/esm/index.js +2 -2
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/tools/annotation/HeightTool.js +439 -0
  42. package/dist/esm/tools/annotation/HeightTool.js.map +1 -0
  43. package/dist/esm/tools/index.js +2 -1
  44. package/dist/esm/tools/index.js.map +1 -1
  45. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +192 -66
  46. package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js.map +1 -1
  47. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +168 -54
  48. package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
  49. package/dist/esm/utilities/planar/filterAnnotationsWithinPlane.js +27 -0
  50. package/dist/esm/utilities/planar/filterAnnotationsWithinPlane.js.map +1 -0
  51. package/dist/esm/utilities/planar/index.js +3 -1
  52. package/dist/esm/utilities/planar/index.js.map +1 -1
  53. package/dist/esm/utilities/viewport/isViewportPreScaled.js +2 -5
  54. package/dist/esm/utilities/viewport/isViewportPreScaled.js.map +1 -1
  55. package/dist/types/cursors/SVGCursorDescriptor.d.ts.map +1 -1
  56. package/dist/types/drawingSvg/drawHeight.d.ts +4 -0
  57. package/dist/types/drawingSvg/drawHeight.d.ts.map +1 -0
  58. package/dist/types/drawingSvg/index.d.ts +2 -1
  59. package/dist/types/drawingSvg/index.d.ts.map +1 -1
  60. package/dist/types/index.d.ts +2 -2
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/tools/annotation/HeightTool.d.ts +41 -0
  63. package/dist/types/tools/annotation/HeightTool.d.ts.map +1 -0
  64. package/dist/types/tools/index.d.ts +2 -1
  65. package/dist/types/tools/index.d.ts.map +1 -1
  66. package/dist/types/tools/segmentation/CircleROIStartEndThresholdTool.d.ts +15 -8
  67. package/dist/types/tools/segmentation/CircleROIStartEndThresholdTool.d.ts.map +1 -1
  68. package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +17 -7
  69. package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts.map +1 -1
  70. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +26 -4
  71. package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
  72. package/dist/types/utilities/planar/filterAnnotationsWithinPlane.d.ts +4 -0
  73. package/dist/types/utilities/planar/filterAnnotationsWithinPlane.d.ts.map +1 -0
  74. package/dist/types/utilities/planar/index.d.ts +3 -1
  75. package/dist/types/utilities/planar/index.d.ts.map +1 -1
  76. package/dist/types/utilities/viewport/isViewportPreScaled.d.ts.map +1 -1
  77. package/dist/umd/index.js +1 -1
  78. package/dist/umd/index.js.map +1 -1
  79. package/package.json +3 -3
  80. package/src/cursors/SVGCursorDescriptor.ts +7 -0
  81. package/src/drawingSvg/drawHeight.ts +90 -0
  82. package/src/drawingSvg/index.ts +2 -0
  83. package/src/index.ts +2 -0
  84. package/src/tools/annotation/HeightTool.ts +882 -0
  85. package/src/tools/index.ts +2 -0
  86. package/src/tools/segmentation/CircleROIStartEndThresholdTool.ts +310 -102
  87. package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +287 -77
  88. package/src/types/ToolSpecificAnnotationTypes.ts +26 -4
  89. package/src/utilities/planar/filterAnnotationsWithinPlane.ts +76 -0
  90. package/src/utilities/planar/index.ts +3 -0
  91. package/src/utilities/viewport/isViewportPreScaled.ts +2 -5
@@ -0,0 +1,76 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import { CONSTANTS, metaData } from '@cornerstonejs/core';
3
+ import type { Types } from '@cornerstonejs/core';
4
+ import { Annotations, Annotation } from '../../types';
5
+
6
+ const { EPSILON } = CONSTANTS;
7
+
8
+ const PARALLEL_THRESHOLD = 1 - EPSILON;
9
+
10
+ /**
11
+ * given some `Annotations`, and the slice defined by the camera's normal
12
+ * direction and the spacing in the normal, filter the `Annotations` which
13
+ * is within the slice.
14
+ *
15
+ * @param annotations - Annotations
16
+ * @param camera - The camera
17
+ * @param spacingInNormalDirection - The spacing in the normal direction
18
+ * @returns The filtered `Annotations`.
19
+ */
20
+ export function filterAnnotationsWithinSamePlane(
21
+ annotations: Annotations,
22
+ camera: Types.ICamera
23
+ ): Annotations {
24
+ const { viewPlaneNormal } = camera;
25
+
26
+ // The reason we use parallel normals instead of actual orientation is that
27
+ // flipped action is done through camera API, so we can't rely on the
28
+ // orientation (viewplaneNormal and viewUp) since even the same image and
29
+ // same slice if flipped will have different orientation, but still rendering
30
+ // the same slice. Instead, we choose to use the parallel normals to filter
31
+ // the annotations and later we fine tune it with the annotation within slice
32
+ // logic down below.
33
+ const annotationsWithParallelNormals = annotations.filter(
34
+ (td: Annotation) => {
35
+ let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
36
+
37
+ if (!annotationViewPlaneNormal) {
38
+ // This code is run to set the annotation view plane normal
39
+ // for historical data which was saved without the normal.
40
+ const { referencedImageId } = td.metadata;
41
+ const { imageOrientationPatient } = metaData.get(
42
+ 'imagePlaneModule',
43
+ referencedImageId
44
+ );
45
+ const rowCosineVec = vec3.fromValues(
46
+ imageOrientationPatient[0],
47
+ imageOrientationPatient[1],
48
+ imageOrientationPatient[2]
49
+ );
50
+
51
+ const colCosineVec = vec3.fromValues(
52
+ imageOrientationPatient[3],
53
+ imageOrientationPatient[4],
54
+ imageOrientationPatient[5]
55
+ );
56
+
57
+ annotationViewPlaneNormal = vec3.create() as Types.Point3;
58
+
59
+ vec3.cross(annotationViewPlaneNormal, rowCosineVec, colCosineVec);
60
+ td.metadata.viewPlaneNormal = annotationViewPlaneNormal;
61
+ }
62
+ const isParallel =
63
+ Math.abs(vec3.dot(viewPlaneNormal, annotationViewPlaneNormal)) >
64
+ PARALLEL_THRESHOLD;
65
+
66
+ return annotationViewPlaneNormal && isParallel;
67
+ }
68
+ );
69
+
70
+ // No in plane annotations.
71
+ if (!annotationsWithParallelNormals.length) {
72
+ return [];
73
+ }
74
+
75
+ return annotationsWithParallelNormals;
76
+ }
@@ -3,6 +3,7 @@ import getWorldWidthAndHeightFromCorners from './getWorldWidthAndHeightFromCorne
3
3
  import filterAnnotationsForDisplay from './filterAnnotationsForDisplay';
4
4
  import getPointInLineOfSightWithCriteria from './getPointInLineOfSightWithCriteria';
5
5
  import { isPlaneIntersectingAABB } from './isPlaneIntersectingAABB';
6
+ import { filterAnnotationsWithinSamePlane } from './filterAnnotationsWithinPlane';
6
7
 
7
8
  export default {
8
9
  filterAnnotationsWithinSlice,
@@ -10,6 +11,7 @@ export default {
10
11
  filterAnnotationsForDisplay,
11
12
  getPointInLineOfSightWithCriteria,
12
13
  isPlaneIntersectingAABB,
14
+ filterAnnotationsWithinSamePlane,
13
15
  };
14
16
 
15
17
  export {
@@ -18,4 +20,5 @@ export {
18
20
  filterAnnotationsForDisplay,
19
21
  getPointInLineOfSightWithCriteria,
20
22
  isPlaneIntersectingAABB,
23
+ filterAnnotationsWithinSamePlane,
21
24
  };
@@ -3,6 +3,7 @@ import {
3
3
  StackViewport,
4
4
  Types,
5
5
  BaseVolumeViewport,
6
+ utilities,
6
7
  } from '@cornerstonejs/core';
7
8
 
8
9
  function isViewportPreScaled(
@@ -10,11 +11,7 @@ function isViewportPreScaled(
10
11
  targetId: string
11
12
  ): boolean {
12
13
  if (viewport instanceof BaseVolumeViewport) {
13
- const targetIdTokens = targetId.split('volumeId:');
14
- const volumeId =
15
- targetIdTokens.length > 1
16
- ? targetIdTokens[1].split('?')[0]
17
- : targetIdTokens[0];
14
+ const volumeId = utilities.getVolumeId(targetId);
18
15
  const volume = cache.getVolume(volumeId);
19
16
  return !!volume?.scaling && Object.keys(volume.scaling).length > 0;
20
17
  } else if (viewport instanceof StackViewport) {