@cornerstonejs/tools 0.11.0 → 0.12.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 (129) hide show
  1. package/dist/cjs/drawingSvg/drawPolyline.d.ts +8 -0
  2. package/dist/cjs/drawingSvg/drawPolyline.js +50 -0
  3. package/dist/cjs/drawingSvg/drawPolyline.js.map +1 -0
  4. package/dist/cjs/drawingSvg/index.d.ts +2 -1
  5. package/dist/cjs/drawingSvg/index.js +3 -1
  6. package/dist/cjs/drawingSvg/index.js.map +1 -1
  7. package/dist/cjs/index.d.ts +2 -2
  8. package/dist/cjs/index.js +2 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/stateManagement/annotation/config/annotationStyle.js +1 -1
  11. package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +32 -0
  12. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +192 -0
  13. package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -0
  14. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts +2 -0
  15. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +216 -0
  16. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -0
  17. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.d.ts +2 -0
  18. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +182 -0
  19. package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -0
  20. package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.d.ts +2 -0
  21. package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js +127 -0
  22. package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -0
  23. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts +2 -0
  24. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +289 -0
  25. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -0
  26. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts +2 -0
  27. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +43 -0
  28. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -0
  29. package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.d.ts +2 -0
  30. package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js +99 -0
  31. package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -0
  32. package/dist/cjs/tools/index.d.ts +2 -1
  33. package/dist/cjs/tools/index.js +3 -1
  34. package/dist/cjs/tools/index.js.map +1 -1
  35. package/dist/cjs/types/AnnotationTypes.d.ts +1 -0
  36. package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +31 -0
  37. package/dist/cjs/utilities/math/index.d.ts +2 -1
  38. package/dist/cjs/utilities/math/index.js +3 -1
  39. package/dist/cjs/utilities/math/index.js.map +1 -1
  40. package/dist/cjs/utilities/math/polyline/addCanvasPointsToArray.d.ts +4 -0
  41. package/dist/cjs/utilities/math/polyline/addCanvasPointsToArray.js +36 -0
  42. package/dist/cjs/utilities/math/polyline/addCanvasPointsToArray.js.map +1 -0
  43. package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.d.ts +2 -0
  44. package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.js +14 -0
  45. package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.js.map +1 -0
  46. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.d.ts +7 -0
  47. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js +110 -0
  48. package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js.map +1 -0
  49. package/dist/cjs/utilities/math/polyline/getSubPixelSpacingAndXYDirections.d.ts +7 -0
  50. package/dist/cjs/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js +67 -0
  51. package/dist/cjs/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js.map +1 -0
  52. package/dist/cjs/utilities/math/polyline/index.d.ts +7 -0
  53. package/dist/cjs/utilities/math/polyline/index.js +20 -0
  54. package/dist/cjs/utilities/math/polyline/index.js.map +1 -0
  55. package/dist/cjs/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts +22 -0
  56. package/dist/cjs/utilities/math/polyline/planarFreehandROIInternalTypes.js +3 -0
  57. package/dist/cjs/utilities/math/polyline/planarFreehandROIInternalTypes.js.map +1 -0
  58. package/dist/cjs/utilities/math/polyline/pointCanProjectOnLine.d.ts +3 -0
  59. package/dist/cjs/utilities/math/polyline/pointCanProjectOnLine.js +35 -0
  60. package/dist/cjs/utilities/math/polyline/pointCanProjectOnLine.js.map +1 -0
  61. package/dist/cjs/utilities/math/polyline/pointsAreWithinCloseContourProximity.d.ts +3 -0
  62. package/dist/cjs/utilities/math/polyline/pointsAreWithinCloseContourProximity.js +8 -0
  63. package/dist/cjs/utilities/math/polyline/pointsAreWithinCloseContourProximity.js.map +1 -0
  64. package/dist/esm/drawingSvg/drawPolyline.d.ts +8 -0
  65. package/dist/esm/drawingSvg/drawPolyline.js +44 -0
  66. package/dist/esm/drawingSvg/drawPolyline.js.map +1 -0
  67. package/dist/esm/drawingSvg/index.d.ts +2 -1
  68. package/dist/esm/drawingSvg/index.js +2 -1
  69. package/dist/esm/drawingSvg/index.js.map +1 -1
  70. package/dist/esm/index.d.ts +2 -2
  71. package/dist/esm/index.js +2 -2
  72. package/dist/esm/index.js.map +1 -1
  73. package/dist/esm/stateManagement/annotation/config/annotationStyle.js +1 -1
  74. package/dist/esm/tools/annotation/PlanarFreehandROITool.d.ts +32 -0
  75. package/dist/esm/tools/annotation/PlanarFreehandROITool.js +187 -0
  76. package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -0
  77. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts +2 -0
  78. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +211 -0
  79. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -0
  80. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.d.ts +2 -0
  81. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +177 -0
  82. package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -0
  83. package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.d.ts +2 -0
  84. package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js +125 -0
  85. package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -0
  86. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts +2 -0
  87. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +284 -0
  88. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -0
  89. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts +2 -0
  90. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +41 -0
  91. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -0
  92. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.d.ts +2 -0
  93. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +97 -0
  94. package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -0
  95. package/dist/esm/tools/index.d.ts +2 -1
  96. package/dist/esm/tools/index.js +2 -1
  97. package/dist/esm/tools/index.js.map +1 -1
  98. package/dist/esm/types/AnnotationTypes.d.ts +1 -0
  99. package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +31 -0
  100. package/dist/esm/utilities/math/index.d.ts +2 -1
  101. package/dist/esm/utilities/math/index.js +2 -1
  102. package/dist/esm/utilities/math/index.js.map +1 -1
  103. package/dist/esm/utilities/math/polyline/addCanvasPointsToArray.d.ts +4 -0
  104. package/dist/esm/utilities/math/polyline/addCanvasPointsToArray.js +34 -0
  105. package/dist/esm/utilities/math/polyline/addCanvasPointsToArray.js.map +1 -0
  106. package/dist/esm/utilities/math/polyline/calculateAreaOfPoints.d.ts +2 -0
  107. package/dist/esm/utilities/math/polyline/calculateAreaOfPoints.js +11 -0
  108. package/dist/esm/utilities/math/polyline/calculateAreaOfPoints.js.map +1 -0
  109. package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.d.ts +7 -0
  110. package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js +106 -0
  111. package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js.map +1 -0
  112. package/dist/esm/utilities/math/polyline/getSubPixelSpacingAndXYDirections.d.ts +7 -0
  113. package/dist/esm/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js +65 -0
  114. package/dist/esm/utilities/math/polyline/getSubPixelSpacingAndXYDirections.js.map +1 -0
  115. package/dist/esm/utilities/math/polyline/index.d.ts +7 -0
  116. package/dist/esm/utilities/math/polyline/index.js +8 -0
  117. package/dist/esm/utilities/math/polyline/index.js.map +1 -0
  118. package/dist/esm/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts +22 -0
  119. package/dist/esm/utilities/math/polyline/planarFreehandROIInternalTypes.js +2 -0
  120. package/dist/esm/utilities/math/polyline/planarFreehandROIInternalTypes.js.map +1 -0
  121. package/dist/esm/utilities/math/polyline/pointCanProjectOnLine.d.ts +3 -0
  122. package/dist/esm/utilities/math/polyline/pointCanProjectOnLine.js +33 -0
  123. package/dist/esm/utilities/math/polyline/pointCanProjectOnLine.js.map +1 -0
  124. package/dist/esm/utilities/math/polyline/pointsAreWithinCloseContourProximity.d.ts +3 -0
  125. package/dist/esm/utilities/math/polyline/pointsAreWithinCloseContourProximity.js +6 -0
  126. package/dist/esm/utilities/math/polyline/pointsAreWithinCloseContourProximity.js.map +1 -0
  127. package/dist/umd/index.js +1 -1
  128. package/dist/umd/index.js.map +1 -1
  129. package/package.json +2 -2
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calculateAreaOfPoints = exports.pointCanProjectOnLine = exports.addCanvasPointsToArray = exports.pointsAreWithinCloseContourProximity = exports.getSubPixelSpacingAndXYDirections = exports.getClosestIntersectionWithPolyline = exports.getFirstIntersectionWithPolyline = void 0;
7
+ const getIntersectionWithPolyline_1 = require("./getIntersectionWithPolyline");
8
+ Object.defineProperty(exports, "getFirstIntersectionWithPolyline", { enumerable: true, get: function () { return getIntersectionWithPolyline_1.getFirstIntersectionWithPolyline; } });
9
+ Object.defineProperty(exports, "getClosestIntersectionWithPolyline", { enumerable: true, get: function () { return getIntersectionWithPolyline_1.getClosestIntersectionWithPolyline; } });
10
+ const getSubPixelSpacingAndXYDirections_1 = __importDefault(require("./getSubPixelSpacingAndXYDirections"));
11
+ exports.getSubPixelSpacingAndXYDirections = getSubPixelSpacingAndXYDirections_1.default;
12
+ const pointsAreWithinCloseContourProximity_1 = __importDefault(require("./pointsAreWithinCloseContourProximity"));
13
+ exports.pointsAreWithinCloseContourProximity = pointsAreWithinCloseContourProximity_1.default;
14
+ const addCanvasPointsToArray_1 = __importDefault(require("./addCanvasPointsToArray"));
15
+ exports.addCanvasPointsToArray = addCanvasPointsToArray_1.default;
16
+ const pointCanProjectOnLine_1 = __importDefault(require("./pointCanProjectOnLine"));
17
+ exports.pointCanProjectOnLine = pointCanProjectOnLine_1.default;
18
+ const calculateAreaOfPoints_1 = __importDefault(require("./calculateAreaOfPoints"));
19
+ exports.calculateAreaOfPoints = calculateAreaOfPoints_1.default;
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/index.ts"],"names":[],"mappings":";;;;;;AAAA,+EAGuC;AAQrC,iHAVA,8DAAgC,OAUA;AAChC,mHAVA,gEAAkC,OAUA;AARpC,4GAAoF;AASlF,4CATK,2CAAiC,CASL;AARnC,kHAA0F;AASxF,+CATK,8CAAoC,CASL;AARtC,sFAA8D;AAS5D,iCATK,gCAAsB,CASL;AARxB,oFAA4D;AAS1D,gCATK,+BAAqB,CASL;AARvB,oFAA4D;AAS1D,gCATK,+BAAqB,CASL"}
@@ -0,0 +1,22 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
3
+ declare type PlanarFreehandROIDrawData = {
4
+ polylineIndex: number;
5
+ canvasPoints: Types.Point2[];
6
+ };
7
+ declare type PlanarFreehandROIEditData = {
8
+ prevCanvasPoints: Types.Point2[];
9
+ editCanvasPoints: Types.Point2[];
10
+ fusedCanvasPoints: Types.Point2[];
11
+ startCrossingIndex?: Types.Point2;
12
+ editIndex: number;
13
+ snapIndex?: number;
14
+ };
15
+ declare type PlanarFreehandROICommonData = {
16
+ annotation: PlanarFreehandROIAnnotation;
17
+ viewportIdsToRender: string[];
18
+ spacing: Types.Point2;
19
+ xDir: Types.Point3;
20
+ yDir: Types.Point3;
21
+ };
22
+ export { PlanarFreehandROIDrawData, PlanarFreehandROIEditData, PlanarFreehandROICommonData, };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=planarFreehandROIInternalTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planarFreehandROIInternalTypes.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/planarFreehandROIInternalTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ declare const pointCanProjectOnLine: (p: Types.Point2, p1: Types.Point2, p2: Types.Point2, proximity: number) => boolean;
3
+ export default pointCanProjectOnLine;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const gl_matrix_1 = require("gl-matrix");
4
+ const pointCanProjectOnLine = (p, p1, p2, proximity) => {
5
+ const p1p = [p[0] - p1[0], p[1] - p1[1]];
6
+ const p1p2 = [p2[0] - p1[0], p2[1] - p1[1]];
7
+ const dot = p1p[0] * p1p2[0] + p1p[1] * p1p2[1];
8
+ if (dot < 0) {
9
+ return false;
10
+ }
11
+ const p1p2Mag = Math.sqrt(p1p2[0] * p1p2[0] + p1p2[1] * p1p2[1]);
12
+ if (p1p2Mag === 0) {
13
+ return false;
14
+ }
15
+ const projectionVectorMag = dot / p1p2Mag;
16
+ const p1p2UnitVector = [p1p2[0] / p1p2Mag, p1p2[1] / p1p2Mag];
17
+ const projectionVector = [
18
+ p1p2UnitVector[0] * projectionVectorMag,
19
+ p1p2UnitVector[1] * projectionVectorMag,
20
+ ];
21
+ const projectionPoint = [
22
+ p1[0] + projectionVector[0],
23
+ p1[1] + projectionVector[1],
24
+ ];
25
+ const distance = gl_matrix_1.vec2.distance(p, projectionPoint);
26
+ if (distance > proximity) {
27
+ return false;
28
+ }
29
+ if (gl_matrix_1.vec2.distance(p1, projectionPoint) > gl_matrix_1.vec2.distance(p1, p2)) {
30
+ return false;
31
+ }
32
+ return true;
33
+ };
34
+ exports.default = pointCanProjectOnLine;
35
+ //# sourceMappingURL=pointCanProjectOnLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointCanProjectOnLine.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/pointCanProjectOnLine.ts"],"names":[],"mappings":";;AACA,yCAAiC;AAMjC,MAAM,qBAAqB,GAAG,CAC5B,CAAe,EACf,EAAgB,EAChB,EAAgB,EAChB,SAAiB,EACR,EAAE;IAEX,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC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;KACd;IAGD,IAAI,gBAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,gBAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE;QAC9D,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ declare const pointsAreWithinCloseContourProximity: (p1: Types.Point2, p2: Types.Point2, closeContourProximity: number) => boolean;
3
+ export default pointsAreWithinCloseContourProximity;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const gl_matrix_1 = require("gl-matrix");
4
+ const pointsAreWithinCloseContourProximity = (p1, p2, closeContourProximity) => {
5
+ return gl_matrix_1.vec2.dist(p1, p2) < closeContourProximity;
6
+ };
7
+ exports.default = pointsAreWithinCloseContourProximity;
8
+ //# sourceMappingURL=pointsAreWithinCloseContourProximity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointsAreWithinCloseContourProximity.js","sourceRoot":"","sources":["../../../../../src/utilities/math/polyline/pointsAreWithinCloseContourProximity.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAMjC,MAAM,oCAAoC,GAAG,CAC3C,EAAgB,EAChB,EAAgB,EAChB,qBAA6B,EACpB,EAAE;IACX,OAAO,gBAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,qBAAqB,CAAC;AACnD,CAAC,CAAC;AAEF,kBAAe,oCAAoC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ export default function drawPolyline(svgDrawingHelper: any, annotationUID: string, polylineUID: string, points: Types.Point2[], options: {
3
+ color?: string;
4
+ width?: number;
5
+ lineWidth?: number;
6
+ lineDash?: string;
7
+ connectLastToFirst?: boolean;
8
+ }): void;
@@ -0,0 +1,44 @@
1
+ import _getHash from './_getHash';
2
+ import _setNewAttributesIfValid from './_setNewAttributesIfValid';
3
+ import _setAttributesIfNecessary from './_setAttributesIfNecessary';
4
+ export default function drawPolyline(svgDrawingHelper, annotationUID, polylineUID, points, options) {
5
+ if (points.length < 2) {
6
+ return;
7
+ }
8
+ const { color, width, lineWidth, lineDash } = Object.assign({
9
+ color: 'dodgerblue',
10
+ width: '2',
11
+ lineWidth: undefined,
12
+ lineDash: undefined,
13
+ connectLastToFirst: false,
14
+ }, options);
15
+ const strokeWidth = lineWidth || width;
16
+ const svgns = 'http://www.w3.org/2000/svg';
17
+ const svgNodeHash = _getHash(annotationUID, 'polyline', polylineUID);
18
+ const existingPolyLine = svgDrawingHelper._getSvgNode(svgNodeHash);
19
+ let pointsAttribute = '';
20
+ for (const point of points) {
21
+ pointsAttribute += `${point[0]}, ${point[1]} `;
22
+ }
23
+ if (options.connectLastToFirst) {
24
+ const firstPoint = points[0];
25
+ pointsAttribute += `${firstPoint[0]}, ${firstPoint[1]}`;
26
+ }
27
+ const attributes = {
28
+ points: pointsAttribute,
29
+ stroke: color,
30
+ fill: 'none',
31
+ 'stroke-width': strokeWidth,
32
+ 'stroke-dasharray': lineDash,
33
+ };
34
+ if (existingPolyLine) {
35
+ _setAttributesIfNecessary(attributes, existingPolyLine);
36
+ svgDrawingHelper._setNodeTouched(svgNodeHash);
37
+ }
38
+ else {
39
+ const newPolyLine = document.createElementNS(svgns, 'polyline');
40
+ _setNewAttributesIfValid(attributes, newPolyLine);
41
+ svgDrawingHelper._appendNode(newPolyLine, svgNodeHash);
42
+ }
43
+ }
44
+ //# sourceMappingURL=drawPolyline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawPolyline.js","sourceRoot":"","sources":["../../../src/drawingSvg/drawPolyline.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,yBAAyB,MAAM,6BA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B,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAExD,gBAAgB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;KAC/C;SAAM;QACL,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAEhE,wBAAwB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAElD,gBAAgB,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;KACxD;AACH,CAAC"}
@@ -3,8 +3,9 @@ import drawCircle from './drawCircle';
3
3
  import drawEllipse from './drawEllipse';
4
4
  import drawHandles from './drawHandles';
5
5
  import drawLine from './drawLine';
6
+ import drawPolyline from './drawPolyline';
6
7
  import drawLinkedTextBox from './drawLinkedTextBox';
7
8
  import drawRect from './drawRect';
8
9
  import drawTextBox from './drawTextBox';
9
10
  import drawArrow from './drawArrow';
10
- export { draw, drawCircle, drawEllipse, drawHandles, drawLine, drawLinkedTextBox, drawRect, drawTextBox, drawArrow, };
11
+ export { draw, drawCircle, drawEllipse, drawHandles, drawLine, drawPolyline, drawLinkedTextBox, drawRect, drawTextBox, drawArrow, };
@@ -3,9 +3,10 @@ import drawCircle from './drawCircle';
3
3
  import drawEllipse from './drawEllipse';
4
4
  import drawHandles from './drawHandles';
5
5
  import drawLine from './drawLine';
6
+ import drawPolyline from './drawPolyline';
6
7
  import drawLinkedTextBox from './drawLinkedTextBox';
7
8
  import drawRect from './drawRect';
8
9
  import drawTextBox from './drawTextBox';
9
10
  import drawArrow from './drawArrow';
10
- export { draw, drawCircle, drawEllipse, drawHandles, drawLine, drawLinkedTextBox, drawRect, drawTextBox, drawArrow, };
11
+ export { draw, drawCircle, drawEllipse, drawHandles, drawLine, drawPolyline, drawLinkedTextBox, drawRect, drawTextBox, drawArrow, };
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawingSvg/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,GACV,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawingSvg/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,GACV,CAAC"}
@@ -8,6 +8,6 @@ import * as cursors from './cursors';
8
8
  import * as Types from './types';
9
9
  import * as annotation from './stateManagement/annotation';
10
10
  import * as segmentation from './stateManagement/segmentation';
11
- import { BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, ArrowTool, CrosshairsTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, SegmentationDisplayTool, BrushTool } from './tools';
11
+ import { BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, PlanarFreehandROITool, ArrowTool, CrosshairsTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, SegmentationDisplayTool, BrushTool } from './tools';
12
12
  import * as Enums from './enums';
13
- export { init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, ArrowTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, BrushTool, synchronizers, Synchronizer, SynchronizerManager, Types, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
13
+ export { init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, PlanarFreehandROITool, ArrowTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, BrushTool, synchronizers, Synchronizer, SynchronizerManager, Types, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
package/dist/esm/index.js CHANGED
@@ -8,7 +8,7 @@ import * as cursors from './cursors';
8
8
  import * as Types from './types';
9
9
  import * as annotation from './stateManagement/annotation';
10
10
  import * as segmentation from './stateManagement/segmentation';
11
- import { BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, ArrowTool, CrosshairsTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, SegmentationDisplayTool, BrushTool, } from './tools';
11
+ import { BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, PlanarFreehandROITool, ArrowTool, CrosshairsTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, SegmentationDisplayTool, BrushTool, } from './tools';
12
12
  import * as Enums from './enums';
13
- export { init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, ArrowTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, BrushTool, synchronizers, Synchronizer, SynchronizerManager, Types, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
13
+ export { init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, PanTool, WindowLevelTool, ZoomTool, StackScrollTool, StackScrollMouseWheelTool, VolumeRotateMouseWheelTool, MIPJumpToClickTool, LengthTool, CrosshairsTool, ProbeTool, RectangleROITool, EllipticalROITool, BidirectionalTool, PlanarFreehandROITool, ArrowTool, SegmentationDisplayTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, BrushTool, synchronizers, Synchronizer, SynchronizerManager, Types, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,EACR,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,kBA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AAgC,CAAC;AAE/D,OAAO,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,eAAe,EACf,QAAQ,EACR,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,uBAAuB,EACvB,SAAS,GACV,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,EAEL,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,yBAAyB,EAEzB,QAAQ,EACR,cAAc,EAEd,OAAO,EACP,eAAe,EACf,QAAQ,EACR,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAElB,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,EAET,uBAAuB,EAEvB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,SAAS,EAET,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,KAAK,EAEL,gBAAgB,EAEhB,KAAK,EAEL,SAAS,EAET,OAAO,EAEP,UAAU,EAEV,YAAY,EAEZ,SAAS,EACT,OAAO,GACR,CAAC"}
@@ -3,7 +3,7 @@ import { ToolModes, AnnotationStyleStates } from '../../../enums';
3
3
  Settings.getDefaultSettings().set('tool.style', {
4
4
  color: 'rgb(255, 255, 0)',
5
5
  colorHighlighted: 'rgb(0, 255, 0)',
6
- colorSelected: 'rgb(0, 255, 0)',
6
+ colorSelected: 'rgb(0, 220, 0)',
7
7
  colorLocked: 'rgb(255, 255, 0)',
8
8
  lineWidth: '1',
9
9
  lineDash: '',
@@ -0,0 +1,32 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { AnnotationTool } from '../base';
3
+ import { EventTypes, ToolHandle, PublicToolProps, ToolProps, InteractionTypes } from '../../types';
4
+ import { PlanarFreehandROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
5
+ declare class PlanarFreehandROITool extends AnnotationTool {
6
+ static toolName: string;
7
+ touchDragCallback: any;
8
+ mouseDragCallback: any;
9
+ _throttledCalculateCachedStats: any;
10
+ private commonData?;
11
+ isDrawing: boolean;
12
+ isEditingClosed: boolean;
13
+ isEditingOpen: boolean;
14
+ private activateDraw;
15
+ private activateClosedContourEdit;
16
+ private activateOpenContourEdit;
17
+ private activateOpenContourEndEdit;
18
+ private renderContour;
19
+ private renderContourBeingDrawn;
20
+ private renderClosedContourBeingEdited;
21
+ private renderOpenContourBeingEdited;
22
+ constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
23
+ addNewAnnotation: (evt: EventTypes.MouseDownActivateEventType) => PlanarFreehandROIAnnotation;
24
+ handleSelectedCallback: (evt: EventTypes.MouseDownEventType, annotation: PlanarFreehandROIAnnotation, handle: ToolHandle, interactionType?: string) => void;
25
+ toolSelectedCallback: (evt: EventTypes.MouseDownEventType, annotation: PlanarFreehandROIAnnotation, interactionType: InteractionTypes) => void;
26
+ isPointNearTool: (element: HTMLDivElement, annotation: PlanarFreehandROIAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
27
+ cancel: (element: HTMLDivElement) => void;
28
+ triggerAnnotationModified: (annotation: PlanarFreehandROIAnnotation, enabledElement: Types.IEnabledElement) => void;
29
+ triggerAnnotationCompleted: (annotation: PlanarFreehandROIAnnotation) => void;
30
+ renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: any) => void;
31
+ }
32
+ export default PlanarFreehandROITool;
@@ -0,0 +1,187 @@
1
+ import { getEnabledElement, triggerEvent, eventTarget, Settings, } from '@cornerstonejs/core';
2
+ import { Events } from '../../enums';
3
+ import { AnnotationTool } from '../base';
4
+ import { addAnnotation, getAnnotations, } from '../../stateManagement/annotation/annotationState';
5
+ import { polyline } from '../../utilities/math';
6
+ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
7
+ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
8
+ import registerDrawLoop from './planarFreehandROITool/drawLoop';
9
+ import registerEditLoopCommon from './planarFreehandROITool/editLoopCommon';
10
+ import registerClosedContourEditLoop from './planarFreehandROITool/closedContourEditLoop';
11
+ import registerOpenContourEditLoop from './planarFreehandROITool/openContourEditLoop';
12
+ import registerOpenContourEndEditLoop from './planarFreehandROITool/openContourEndEditLoop';
13
+ import registerRenderMethods from './planarFreehandROITool/renderMethods';
14
+ const { pointCanProjectOnLine } = polyline;
15
+ class PlanarFreehandROITool extends AnnotationTool {
16
+ constructor(toolProps = {}, defaultToolProps = {
17
+ supportedInteractionTypes: ['Mouse', 'Touch'],
18
+ configuration: {
19
+ shadow: true,
20
+ preventHandleOutsideImage: false,
21
+ allowOpenContours: true,
22
+ closeContourProximity: 10,
23
+ checkCanvasEditFallbackProximity: 6,
24
+ subPixelResolution: 4,
25
+ },
26
+ }) {
27
+ super(toolProps, defaultToolProps);
28
+ this.isDrawing = false;
29
+ this.isEditingClosed = false;
30
+ this.isEditingOpen = false;
31
+ this.addNewAnnotation = (evt) => {
32
+ const eventDetail = evt.detail;
33
+ const { currentPoints, element } = eventDetail;
34
+ const worldPos = currentPoints.world;
35
+ const enabledElement = getEnabledElement(element);
36
+ const { viewport, renderingEngine } = enabledElement;
37
+ const camera = viewport.getCamera();
38
+ const { viewPlaneNormal, viewUp } = camera;
39
+ const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
40
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
41
+ const annotation = {
42
+ highlighted: true,
43
+ invalidated: true,
44
+ metadata: {
45
+ viewPlaneNormal: [...viewPlaneNormal],
46
+ viewUp: [...viewUp],
47
+ FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
48
+ referencedImageId,
49
+ toolName: this.getToolName(),
50
+ },
51
+ data: {
52
+ handles: {
53
+ points: [],
54
+ activeHandleIndex: null,
55
+ textBox: {
56
+ hasMoved: false,
57
+ worldPosition: [0, 0, 0],
58
+ worldBoundingBox: {
59
+ topLeft: [0, 0, 0],
60
+ topRight: [0, 0, 0],
61
+ bottomLeft: [0, 0, 0],
62
+ bottomRight: [0, 0, 0],
63
+ },
64
+ },
65
+ },
66
+ polyline: [[...worldPos]],
67
+ label: '',
68
+ },
69
+ };
70
+ Settings.getObjectSettings(annotation, PlanarFreehandROITool);
71
+ addAnnotation(element, annotation);
72
+ this.activateDraw(evt, annotation, viewportIdsToRender);
73
+ evt.preventDefault();
74
+ triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
75
+ return annotation;
76
+ };
77
+ this.handleSelectedCallback = (evt, annotation, handle, interactionType = 'mouse') => {
78
+ const eventDetail = evt.detail;
79
+ const { element } = eventDetail;
80
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
81
+ this.activateOpenContourEndEdit(evt, annotation, viewportIdsToRender);
82
+ };
83
+ this.toolSelectedCallback = (evt, annotation, interactionType) => {
84
+ const eventDetail = evt.detail;
85
+ const { element } = eventDetail;
86
+ const viewportIdsToRender = getViewportIdsWithToolToRender(element, this.getToolName());
87
+ if (annotation.data.isOpenContour) {
88
+ this.activateOpenContourEdit(evt, annotation, viewportIdsToRender);
89
+ }
90
+ else {
91
+ this.activateClosedContourEdit(evt, annotation, viewportIdsToRender);
92
+ }
93
+ };
94
+ this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
95
+ const enabledElement = getEnabledElement(element);
96
+ const { viewport } = enabledElement;
97
+ const points = annotation.data.polyline;
98
+ let previousPoint = viewport.worldToCanvas(points[0]);
99
+ for (let i = 1; i < points.length; i++) {
100
+ const p1 = previousPoint;
101
+ const p2 = viewport.worldToCanvas(points[i]);
102
+ const distance = pointCanProjectOnLine(canvasCoords, p1, p2, proximity);
103
+ if (distance === true) {
104
+ return true;
105
+ }
106
+ previousPoint = p2;
107
+ }
108
+ if (annotation.data.isOpenContour) {
109
+ return false;
110
+ }
111
+ const pStart = viewport.worldToCanvas(points[0]);
112
+ const pEnd = viewport.worldToCanvas(points[points.length - 1]);
113
+ const distance = pointCanProjectOnLine(canvasCoords, pStart, pEnd, proximity);
114
+ if (distance === true) {
115
+ return true;
116
+ }
117
+ return false;
118
+ };
119
+ this.cancel = (element) => {
120
+ };
121
+ this.triggerAnnotationModified = (annotation, enabledElement) => {
122
+ const { viewportId, renderingEngineId } = enabledElement;
123
+ const eventType = Events.ANNOTATION_MODIFIED;
124
+ const eventDetail = {
125
+ annotation,
126
+ viewportId,
127
+ renderingEngineId,
128
+ };
129
+ triggerEvent(eventTarget, eventType, eventDetail);
130
+ };
131
+ this.triggerAnnotationCompleted = (annotation) => {
132
+ const eventType = Events.ANNOTATION_COMPLETED;
133
+ const eventDetail = {
134
+ annotation,
135
+ };
136
+ triggerEvent(eventTarget, eventType, eventDetail);
137
+ };
138
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
139
+ const { viewport } = enabledElement;
140
+ const { element } = viewport;
141
+ let annotations = (getAnnotations(element, this.getToolName()));
142
+ if (!annotations?.length) {
143
+ return;
144
+ }
145
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
146
+ if (!annotations?.length) {
147
+ return;
148
+ }
149
+ const isDrawing = this.isDrawing;
150
+ const isEditingOpen = this.isEditingOpen;
151
+ const isEditingClosed = this.isEditingClosed;
152
+ if (!(isDrawing || isEditingOpen || isEditingClosed)) {
153
+ annotations.forEach((annotation) => this.renderContour(enabledElement, svgDrawingHelper, annotation));
154
+ return;
155
+ }
156
+ const activeAnnotationUID = this.commonData.annotation.annotationUID;
157
+ annotations.forEach((annotation) => {
158
+ if (annotation.annotationUID === activeAnnotationUID) {
159
+ if (isDrawing) {
160
+ this.renderContourBeingDrawn(enabledElement, svgDrawingHelper, annotation);
161
+ }
162
+ else if (isEditingClosed) {
163
+ this.renderClosedContourBeingEdited(enabledElement, svgDrawingHelper, annotation);
164
+ }
165
+ else if (isEditingOpen) {
166
+ this.renderOpenContourBeingEdited(enabledElement, svgDrawingHelper, annotation);
167
+ }
168
+ else {
169
+ throw new Error(`Unknown ${this.getToolName()} annotation rendering state`);
170
+ }
171
+ }
172
+ else {
173
+ this.renderContour(enabledElement, svgDrawingHelper, annotation);
174
+ }
175
+ });
176
+ };
177
+ registerDrawLoop(this);
178
+ registerEditLoopCommon(this);
179
+ registerClosedContourEditLoop(this);
180
+ registerOpenContourEditLoop(this);
181
+ registerOpenContourEndEditLoop(this);
182
+ registerRenderMethods(this);
183
+ }
184
+ }
185
+ PlanarFreehandROITool.toolName = 'PlanarFreehandROI';
186
+ export default PlanarFreehandROITool;
187
+ //# sourceMappingURL=PlanarFreehandROITool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanarFreehandROITool.js","sourceRoot":"","sources":["../../../../src/tools/annotation/PlanarFreehandROITool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EACL,aAAa,EACb,cAAc,GACf,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,qCAAqC,MAAM,uDAAuD,CAAC;AAC1G,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,6BAA6B,MAAM,+CAA+C,CAAC;AAC1F,OAAO,2BAA2B,M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aAAa,KAAK,mBAAmB,EAAE;oBACpD,IAAI,SAAS,EAAE;wBACb,IAAI,CAAC,uBAAuB,CAC1B,cAAc,EACd,gBAAgB,EAChB,UAAU,CACX,CAAC;qBACH;yBAAM,IAAI,eAAe,EAAE;wBAC1B,IAAI,CAAC,8BAA8B,CACjC,cAAc,EACd,gBAAgB,EAChB,UAAU,CACX,CAAC;qBACH;yBAAM,IAAI,aAAa,EAAE;wBACxB,IAAI,CAAC,4BAA4B,CAC/B,cAAc,EACd,gBAAgB,EAChB,UAAU,CACX,CAAC;qBACH;yBAAM;wBACL,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,CAAC,WAAW,EAAE,6BAA6B,CAC3D,CAAC;qBACH;iBACF;qBAAM;oBACL,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;iBAClE;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QApTA,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC7B,6BAA6B,CAAC,IAAI,CAAC,CAAC;QACpC,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAClC,8BAA8B,CAAC,IAAI,CAAC,CAAC;QACrC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;;AArFM,8BAAQ,GAAG,mBAAmB,CAAC;AAsYxC,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare function registerClosedContourEditLoop(toolInstance: any): void;
2
+ export default registerClosedContourEditLoop;