@cornerstonejs/tools 1.43.6 → 1.44.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.
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +7 -2
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js +23 -9
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +14 -1
- package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
- package/dist/cjs/tools/annotation/AngleTool.js +4 -3
- package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +4 -3
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +4 -4
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +4 -3
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/CobbAngleTool.js +4 -3
- package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/DragProbeTool.js +4 -1
- package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +4 -3
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/KeyImageTool.js +4 -1
- package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LengthTool.js +4 -4
- package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.d.ts +6 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js +14 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +14 -5
- package/dist/cjs/tools/annotation/LivewireContourTool.js +126 -159
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +8 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +24 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +104 -134
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/RectangleROITool.js +4 -3
- package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.d.ts +8 -0
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js +23 -0
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/SplineROITool.d.ts +15 -8
- package/dist/cjs/tools/annotation/SplineROITool.js +168 -240
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.d.ts +15 -0
- package/dist/cjs/tools/base/AnnotationTool.js +24 -0
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.d.ts +19 -0
- package/dist/cjs/tools/base/ContourBaseTool.js +130 -0
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.d.ts +18 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +139 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/index.d.ts +4 -1
- package/dist/cjs/tools/index.js +7 -1
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/cjs/types/ContourAnnotation.d.ts +11 -0
- package/dist/cjs/types/ContourAnnotation.js +3 -0
- package/dist/cjs/types/ContourAnnotation.js.map +1 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +11 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.js +3 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.js.map +1 -0
- package/dist/cjs/types/ContourTypes.d.ts +4 -1
- package/dist/cjs/types/SegmentationStateTypes.d.ts +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +11 -52
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/cjs/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.d.ts +4 -0
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.js +70 -0
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +7 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +20 -7
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -1
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
- package/dist/esm/tools/annotation/AngleTool.js +4 -3
- package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +4 -3
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +4 -4
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +4 -3
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/CobbAngleTool.js +4 -3
- package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/DragProbeTool.js +4 -1
- package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +4 -3
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +4 -1
- package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/esm/tools/annotation/LengthTool.js +4 -4
- package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +9 -0
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/LivewireContourTool.js +123 -160
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +19 -0
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +104 -134
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +4 -3
- package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +18 -0
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/SplineROITool.js +153 -227
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.js +24 -0
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js +122 -0
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +131 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +1 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/index.js +4 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/types/ContourAnnotation.js +2 -0
- package/dist/esm/types/ContourAnnotation.js.map +1 -0
- package/dist/esm/types/ContourSegmentationAnnotation.js +2 -0
- package/dist/esm/types/ContourSegmentationAnnotation.js.map +1 -0
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js +64 -0
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
- package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/helpers/normalizeSegmentationInput.d.ts.map +1 -1
- package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/DragProbeTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts +7 -0
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +14 -5
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +9 -0
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts +9 -0
- package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/SplineROITool.d.ts +15 -8
- package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/renderMethods.d.ts.map +1 -1
- package/dist/types/tools/base/AnnotationTool.d.ts +15 -0
- package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourBaseTool.d.ts +20 -0
- package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -0
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +19 -0
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -0
- package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
- package/dist/types/tools/index.d.ts +4 -1
- package/dist/types/tools/index.d.ts.map +1 -1
- package/dist/types/types/ContourAnnotation.d.ts +12 -0
- package/dist/types/types/ContourAnnotation.d.ts.map +1 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts +12 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -0
- package/dist/types/types/ContourTypes.d.ts +4 -1
- package/dist/types/types/ContourTypes.d.ts.map +1 -1
- package/dist/types/types/SegmentationStateTypes.d.ts +1 -1
- package/dist/types/types/SegmentationStateTypes.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +11 -52
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
- package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts +5 -0
- package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +6 -0
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +11 -2
- package/src/stateManagement/segmentation/config/segmentationVisibility.ts +52 -6
- package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +27 -1
- package/src/tools/annotation/AngleTool.ts +4 -3
- package/src/tools/annotation/ArrowAnnotateTool.ts +4 -3
- package/src/tools/annotation/BidirectionalTool.ts +4 -4
- package/src/tools/annotation/CircleROITool.ts +4 -3
- package/src/tools/annotation/CobbAngleTool.ts +4 -3
- package/src/tools/annotation/DragProbeTool.ts +4 -1
- package/src/tools/annotation/EllipticalROITool.ts +4 -3
- package/src/tools/annotation/KeyImageTool.ts +4 -1
- package/src/tools/annotation/LengthTool.ts +4 -5
- package/src/tools/annotation/LivewireContourSegmentationTool.ts +13 -0
- package/src/tools/annotation/LivewireContourTool.ts +75 -150
- package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +30 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +153 -187
- package/src/tools/annotation/ProbeTool.ts +1 -1
- package/src/tools/annotation/RectangleROITool.ts +4 -3
- package/src/tools/annotation/SplineContourSegmentationTool.ts +28 -0
- package/src/tools/annotation/SplineROITool.ts +172 -282
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +7 -5
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +4 -4
- package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +3 -1
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +12 -9
- package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +5 -2
- package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +19 -14
- package/src/tools/base/AnnotationTool.ts +35 -0
- package/src/tools/base/ContourBaseTool.ts +226 -0
- package/src/tools/base/ContourSegmentationBaseTool.ts +276 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +1 -0
- package/src/tools/index.ts +6 -0
- package/src/types/ContourAnnotation.ts +13 -0
- package/src/types/ContourSegmentationAnnotation.ts +14 -0
- package/src/types/ContourTypes.ts +8 -1
- package/src/types/SegmentationStateTypes.ts +1 -1
- package/src/types/ToolSpecificAnnotationTypes.ts +17 -53
- package/src/types/index.ts +12 -0
- package/src/utilities/pointInSurroundingSphereCallback.ts +188 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
3
2
|
import {
|
|
4
3
|
getEnabledElement,
|
|
5
4
|
eventTarget,
|
|
@@ -7,13 +6,7 @@ import {
|
|
|
7
6
|
} from '@cornerstonejs/core';
|
|
8
7
|
import type { Types } from '@cornerstonejs/core';
|
|
9
8
|
import { vec3 } from 'gl-matrix';
|
|
10
|
-
import {
|
|
11
|
-
addAnnotation,
|
|
12
|
-
getAnnotations,
|
|
13
|
-
removeAnnotation,
|
|
14
|
-
} from '../../stateManagement/annotation/annotationState';
|
|
15
|
-
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
16
|
-
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
9
|
+
import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
|
|
17
10
|
import {
|
|
18
11
|
drawHandles as drawHandlesSvg,
|
|
19
12
|
drawPolyline as drawPolylineSvg,
|
|
@@ -23,6 +16,7 @@ import { state } from '../../store';
|
|
|
23
16
|
import { Events, MouseBindings, KeyboardBindings } from '../../enums';
|
|
24
17
|
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
25
18
|
import {
|
|
19
|
+
Annotation,
|
|
26
20
|
EventTypes,
|
|
27
21
|
ToolHandle,
|
|
28
22
|
TextBoxHandle,
|
|
@@ -46,12 +40,12 @@ import {
|
|
|
46
40
|
AnnotationCompletedEventDetail,
|
|
47
41
|
AnnotationModifiedEventDetail,
|
|
48
42
|
} from '../../types/EventTypes';
|
|
49
|
-
import { StyleSpecifier } from '../../types/AnnotationStyle';
|
|
50
43
|
import { ISpline } from '../../types/ISpline';
|
|
51
44
|
import { CardinalSpline } from './splines/CardinalSpline';
|
|
52
45
|
import { LinearSpline } from './splines/LinearSpline';
|
|
53
46
|
import { CatmullRomSpline } from './splines/CatmullRomSpline';
|
|
54
47
|
import { BSpline } from './splines/BSpline';
|
|
48
|
+
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
55
49
|
|
|
56
50
|
const SPLINE_MIN_POINTS = 3;
|
|
57
51
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
@@ -77,7 +71,7 @@ enum SplineToolActions {
|
|
|
77
71
|
DeleteControlPoint = 'deleteControlPoint',
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
class SplineROITool extends
|
|
74
|
+
class SplineROITool extends ContourSegmentationBaseTool {
|
|
81
75
|
static toolName;
|
|
82
76
|
static SplineTypes = SplineTypesEnum;
|
|
83
77
|
static Actions = SplineToolActions;
|
|
@@ -168,71 +162,17 @@ class SplineROITool extends AnnotationTool {
|
|
|
168
162
|
* @returns The annotation object.
|
|
169
163
|
*
|
|
170
164
|
*/
|
|
171
|
-
addNewAnnotation
|
|
172
|
-
evt: EventTypes.InteractionEventType
|
|
173
|
-
): SplineROIAnnotation => {
|
|
165
|
+
addNewAnnotation(evt: EventTypes.InteractionEventType): SplineROIAnnotation {
|
|
174
166
|
const eventDetail = evt.detail;
|
|
175
167
|
const { currentPoints, element } = eventDetail;
|
|
176
|
-
const {
|
|
168
|
+
const { canvas: canvasPos } = currentPoints;
|
|
177
169
|
|
|
178
170
|
const enabledElement = getEnabledElement(element);
|
|
179
|
-
const {
|
|
171
|
+
const { renderingEngine } = enabledElement;
|
|
172
|
+
const annotation = this.createAnnotation(evt) as SplineROIAnnotation;
|
|
180
173
|
|
|
181
174
|
this.isDrawing = true;
|
|
182
|
-
|
|
183
|
-
const camera = viewport.getCamera();
|
|
184
|
-
const { viewPlaneNormal, viewUp } = camera;
|
|
185
|
-
|
|
186
|
-
const { type: splineType } = this.configuration.spline;
|
|
187
|
-
const splineConfig = this._getSplineConfig(splineType);
|
|
188
|
-
const spline = new splineConfig.Class();
|
|
189
|
-
|
|
190
|
-
const referencedImageId = this.getReferencedImageId(
|
|
191
|
-
viewport,
|
|
192
|
-
worldPos,
|
|
193
|
-
viewPlaneNormal,
|
|
194
|
-
viewUp
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
198
|
-
|
|
199
|
-
const annotation: SplineROIAnnotation = {
|
|
200
|
-
highlighted: true,
|
|
201
|
-
invalidated: true,
|
|
202
|
-
metadata: {
|
|
203
|
-
toolName: this.getToolName(),
|
|
204
|
-
viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
|
|
205
|
-
viewUp: <Types.Point3>[...viewUp],
|
|
206
|
-
FrameOfReferenceUID,
|
|
207
|
-
referencedImageId,
|
|
208
|
-
},
|
|
209
|
-
data: {
|
|
210
|
-
handles: {
|
|
211
|
-
textBox: {
|
|
212
|
-
hasMoved: false,
|
|
213
|
-
worldPosition: <Types.Point3>[0, 0, 0],
|
|
214
|
-
worldBoundingBox: {
|
|
215
|
-
topLeft: <Types.Point3>[0, 0, 0],
|
|
216
|
-
topRight: <Types.Point3>[0, 0, 0],
|
|
217
|
-
bottomLeft: <Types.Point3>[0, 0, 0],
|
|
218
|
-
bottomRight: <Types.Point3>[0, 0, 0],
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
points: [[...worldPos]],
|
|
222
|
-
activeHandleIndex: null,
|
|
223
|
-
},
|
|
224
|
-
spline: {
|
|
225
|
-
type: splineConfig.type,
|
|
226
|
-
instance: spline,
|
|
227
|
-
resolution: splineConfig.resolution,
|
|
228
|
-
closed: false,
|
|
229
|
-
polyline: [],
|
|
230
|
-
},
|
|
231
|
-
cachedStats: {},
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
addAnnotation(annotation, element);
|
|
175
|
+
this.addAnnotation(annotation, element);
|
|
236
176
|
|
|
237
177
|
const viewportIdsToRender = getViewportIdsWithToolToRender(
|
|
238
178
|
element,
|
|
@@ -253,7 +193,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
253
193
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
254
194
|
|
|
255
195
|
return annotation;
|
|
256
|
-
}
|
|
196
|
+
}
|
|
257
197
|
|
|
258
198
|
/**
|
|
259
199
|
* It returns if the canvas point is near the provided annotation in the provided
|
|
@@ -438,7 +378,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
438
378
|
const { annotation, viewportIdsToRender } = this.editData;
|
|
439
379
|
const { data } = annotation;
|
|
440
380
|
|
|
441
|
-
if (data.
|
|
381
|
+
if (data.contour.closed) {
|
|
442
382
|
return;
|
|
443
383
|
}
|
|
444
384
|
|
|
@@ -448,7 +388,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
448
388
|
const { canvas: canvasPoint, world: worldPoint } = currentPoints;
|
|
449
389
|
const enabledElement = getEnabledElement(element);
|
|
450
390
|
const { renderingEngine } = enabledElement;
|
|
451
|
-
let
|
|
391
|
+
let closeContour = data.handles.points.length >= 2 && doubleClick;
|
|
452
392
|
let addNewPoint = true;
|
|
453
393
|
|
|
454
394
|
// Check if user clicked on the first point to close the curve
|
|
@@ -461,7 +401,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
461
401
|
|
|
462
402
|
if (closestControlPoint?.index === 0) {
|
|
463
403
|
addNewPoint = false;
|
|
464
|
-
|
|
404
|
+
closeContour = true;
|
|
465
405
|
}
|
|
466
406
|
}
|
|
467
407
|
|
|
@@ -469,11 +409,11 @@ class SplineROITool extends AnnotationTool {
|
|
|
469
409
|
data.handles.points.push(worldPoint);
|
|
470
410
|
}
|
|
471
411
|
|
|
472
|
-
data.
|
|
412
|
+
data.contour.closed = data.contour.closed || closeContour;
|
|
473
413
|
annotation.invalidated = true;
|
|
474
414
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
475
415
|
|
|
476
|
-
if (data.
|
|
416
|
+
if (data.contour.closed) {
|
|
477
417
|
this._endCallback(evt);
|
|
478
418
|
}
|
|
479
419
|
|
|
@@ -532,7 +472,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
532
472
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
533
473
|
};
|
|
534
474
|
|
|
535
|
-
cancel
|
|
475
|
+
cancel(element: HTMLDivElement) {
|
|
536
476
|
// If it is not in mid-draw or mid-modify
|
|
537
477
|
if (!this.isDrawing) {
|
|
538
478
|
return;
|
|
@@ -549,6 +489,8 @@ class SplineROITool extends AnnotationTool {
|
|
|
549
489
|
removeAnnotation(annotation.annotationUID);
|
|
550
490
|
}
|
|
551
491
|
|
|
492
|
+
super.cancelAnnotation(annotation);
|
|
493
|
+
|
|
552
494
|
const enabledElement = getEnabledElement(element);
|
|
553
495
|
const { renderingEngine } = enabledElement;
|
|
554
496
|
|
|
@@ -556,7 +498,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
556
498
|
|
|
557
499
|
this.editData = null;
|
|
558
500
|
return annotation.annotationUID;
|
|
559
|
-
}
|
|
501
|
+
}
|
|
560
502
|
|
|
561
503
|
/**
|
|
562
504
|
* Triggers an annotation modified event.
|
|
@@ -629,226 +571,191 @@ class SplineROITool extends AnnotationTool {
|
|
|
629
571
|
element.removeEventListener(Events.TOUCH_TAP, this._mouseDownCallback);
|
|
630
572
|
};
|
|
631
573
|
|
|
574
|
+
protected isContourSegmentationTool(): boolean {
|
|
575
|
+
// Disable contour segmenatation behavior because it shall be activated only
|
|
576
|
+
// for SplineContourSegmentationTool
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
|
|
632
580
|
/**
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
* @param enabledElement - The Cornerstone's enabledElement.
|
|
638
|
-
* @param svgDrawingHelper - The svgDrawingHelper providing the context for drawing.
|
|
581
|
+
* Render an annotation instance
|
|
582
|
+
* @param renderContext - Render context that contains the annotation, enabledElement, etc.
|
|
583
|
+
* @returns True if the annotation is rendered or false otherwise
|
|
639
584
|
*/
|
|
640
|
-
|
|
641
|
-
enabledElement: Types.IEnabledElement
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
585
|
+
protected renderAnnotationInstance(renderContext: {
|
|
586
|
+
enabledElement: Types.IEnabledElement;
|
|
587
|
+
targetId: string;
|
|
588
|
+
annotation: Annotation;
|
|
589
|
+
annotationStyle: Record<string, any>;
|
|
590
|
+
svgDrawingHelper: SVGDrawingHelper;
|
|
591
|
+
}): boolean {
|
|
592
|
+
const { enabledElement, targetId, svgDrawingHelper, annotationStyle } =
|
|
593
|
+
renderContext;
|
|
645
594
|
const { viewport } = enabledElement;
|
|
646
595
|
const { worldToCanvas } = viewport;
|
|
647
596
|
const { element } = viewport;
|
|
597
|
+
const annotation = renderContext.annotation as SplineROIAnnotation;
|
|
598
|
+
const { annotationUID, data, highlighted } = annotation;
|
|
599
|
+
const { handles } = data;
|
|
600
|
+
const { points: controlPoints, activeHandleIndex } = handles;
|
|
601
|
+
const newAnnotation = this.editData?.newAnnotation;
|
|
648
602
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
let annotations = getAnnotations(this.getToolName(), element);
|
|
603
|
+
const {
|
|
604
|
+
lineWidth,
|
|
605
|
+
lineDash,
|
|
606
|
+
color,
|
|
607
|
+
locked: annotationLocked,
|
|
608
|
+
} = annotationStyle;
|
|
656
609
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
610
|
+
const canvasCoordinates = controlPoints.map((p) =>
|
|
611
|
+
worldToCanvas(p)
|
|
612
|
+
) as Types.Point2[];
|
|
660
613
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
);
|
|
614
|
+
const { drawPreviewEnabled } = this.configuration.spline;
|
|
615
|
+
const splineType = annotation.data.spline.type;
|
|
616
|
+
const splineConfig = this._getSplineConfig(splineType);
|
|
617
|
+
const spline = this._updateSplineInstance(element, annotation);
|
|
618
|
+
const splinePolylineCanvas = spline.getPolylinePoints();
|
|
619
|
+
const splinePolylineWorld = [];
|
|
665
620
|
|
|
666
|
-
|
|
667
|
-
|
|
621
|
+
for (let i = 0, len = splinePolylineCanvas.length; i < len; i++) {
|
|
622
|
+
splinePolylineWorld.push(viewport.canvasToWorld(splinePolylineCanvas[i]));
|
|
668
623
|
}
|
|
669
624
|
|
|
670
|
-
|
|
671
|
-
const newAnnotation = this.editData?.newAnnotation;
|
|
672
|
-
const styleSpecifier: StyleSpecifier = {
|
|
673
|
-
toolGroupId: this.toolGroupId,
|
|
674
|
-
toolName: this.getToolName(),
|
|
675
|
-
viewportId: enabledElement.viewport.id,
|
|
676
|
-
};
|
|
625
|
+
data.contour.polyline = splinePolylineWorld;
|
|
677
626
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
const { annotationUID, data, highlighted } = annotation;
|
|
681
|
-
const { handles } = data;
|
|
682
|
-
const { points: controlPoints, activeHandleIndex } = handles;
|
|
683
|
-
|
|
684
|
-
styleSpecifier.annotationUID = annotationUID;
|
|
685
|
-
|
|
686
|
-
const lineWidth = this.getStyle(
|
|
687
|
-
'lineWidth',
|
|
688
|
-
styleSpecifier,
|
|
689
|
-
annotation
|
|
690
|
-
) as number;
|
|
691
|
-
const lineDash = this.getStyle(
|
|
692
|
-
'lineDash',
|
|
693
|
-
styleSpecifier,
|
|
694
|
-
annotation
|
|
695
|
-
) as string;
|
|
696
|
-
const color = this.getStyle(
|
|
697
|
-
'color',
|
|
698
|
-
styleSpecifier,
|
|
699
|
-
annotation
|
|
700
|
-
) as string;
|
|
701
|
-
|
|
702
|
-
const canvasCoordinates = controlPoints.map((p) =>
|
|
703
|
-
worldToCanvas(p)
|
|
704
|
-
) as Types.Point2[];
|
|
705
|
-
|
|
706
|
-
const { drawPreviewEnabled } = this.configuration.spline;
|
|
707
|
-
const splineType = annotation.data.spline.type;
|
|
708
|
-
const splineConfig = this._getSplineConfig(splineType);
|
|
709
|
-
const spline = this._updateSplineInstance(element, annotation);
|
|
710
|
-
const splinePolylineCanvas = spline.getPolylinePoints();
|
|
711
|
-
const splinePolylineWorld = [];
|
|
712
|
-
|
|
713
|
-
for (let i = 0, len = splinePolylineCanvas.length; i < len; i++) {
|
|
714
|
-
splinePolylineWorld.push(
|
|
715
|
-
viewport.canvasToWorld(splinePolylineCanvas[i])
|
|
716
|
-
);
|
|
717
|
-
}
|
|
627
|
+
// Let the base class render the contour
|
|
628
|
+
super.renderAnnotationInstance(renderContext);
|
|
718
629
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
areaUnit: null,
|
|
731
|
-
};
|
|
732
|
-
|
|
733
|
-
this._calculateCachedStats(annotation, element);
|
|
734
|
-
} else if (annotation.invalidated) {
|
|
735
|
-
this._throttledCalculateCachedStats(annotation, element);
|
|
736
|
-
}
|
|
630
|
+
// If cachedStats does not exist, or the areaUnit is missing (as part of
|
|
631
|
+
// import/hydration etc.), force to recalculate the stats from the points
|
|
632
|
+
if (
|
|
633
|
+
!data.cachedStats[targetId] ||
|
|
634
|
+
data.cachedStats[targetId].areaUnit == null
|
|
635
|
+
) {
|
|
636
|
+
data.cachedStats[targetId] = {
|
|
637
|
+
Modality: null,
|
|
638
|
+
area: null,
|
|
639
|
+
areaUnit: null,
|
|
640
|
+
};
|
|
737
641
|
|
|
738
|
-
|
|
642
|
+
this._calculateCachedStats(annotation, element);
|
|
643
|
+
} else if (annotation.invalidated) {
|
|
644
|
+
this._throttledCalculateCachedStats(annotation, element);
|
|
645
|
+
}
|
|
739
646
|
|
|
740
|
-
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
647
|
+
let activeHandleCanvasCoords;
|
|
743
648
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
) {
|
|
749
|
-
// Not locked or creating and hovering over handle, so render handle.
|
|
750
|
-
activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
|
|
751
|
-
}
|
|
649
|
+
if (!annotationLocked && !this.editData && activeHandleIndex !== null) {
|
|
650
|
+
// Not locked or creating and hovering over handle, so render handle.
|
|
651
|
+
activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
|
|
652
|
+
}
|
|
752
653
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
drawHandlesSvg(
|
|
756
|
-
svgDrawingHelper,
|
|
757
|
-
annotationUID,
|
|
758
|
-
handleGroupUID,
|
|
759
|
-
canvasCoordinates,
|
|
760
|
-
{
|
|
761
|
-
color,
|
|
762
|
-
lineDash,
|
|
763
|
-
lineWidth,
|
|
764
|
-
handleRadius: '3',
|
|
765
|
-
}
|
|
766
|
-
);
|
|
767
|
-
}
|
|
654
|
+
if (activeHandleCanvasCoords || newAnnotation || highlighted) {
|
|
655
|
+
const handleGroupUID = '0';
|
|
768
656
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
svgDrawingHelper,
|
|
783
|
-
annotationUID,
|
|
784
|
-
'previewSplineChange',
|
|
785
|
-
previewPolylinePoints,
|
|
786
|
-
{
|
|
787
|
-
color: '#9EA0CA',
|
|
788
|
-
lineDash,
|
|
789
|
-
lineWidth,
|
|
790
|
-
}
|
|
791
|
-
);
|
|
792
|
-
}
|
|
657
|
+
// Move this call to the base class (contour seg) in the near future
|
|
658
|
+
drawHandlesSvg(
|
|
659
|
+
svgDrawingHelper,
|
|
660
|
+
annotationUID,
|
|
661
|
+
handleGroupUID,
|
|
662
|
+
canvasCoordinates,
|
|
663
|
+
{
|
|
664
|
+
color,
|
|
665
|
+
lineWidth: Math.max(1, lineWidth),
|
|
666
|
+
handleRadius: '3',
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
}
|
|
793
670
|
|
|
794
|
-
|
|
795
|
-
|
|
671
|
+
if (
|
|
672
|
+
drawPreviewEnabled &&
|
|
673
|
+
spline.numControlPoints > 1 &&
|
|
674
|
+
this.editData?.lastCanvasPoint &&
|
|
675
|
+
!spline.closed
|
|
676
|
+
) {
|
|
677
|
+
const { lastCanvasPoint } = this.editData;
|
|
678
|
+
const previewPolylinePoints = spline.getPreviewPolylinePoints(
|
|
679
|
+
lastCanvasPoint,
|
|
680
|
+
SPLINE_CLICK_CLOSE_CURVE_DIST
|
|
681
|
+
);
|
|
796
682
|
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
683
|
+
drawPolylineSvg(
|
|
684
|
+
svgDrawingHelper,
|
|
685
|
+
annotationUID,
|
|
686
|
+
'previewSplineChange',
|
|
687
|
+
previewPolylinePoints,
|
|
688
|
+
{
|
|
689
|
+
color: '#9EA0CA',
|
|
690
|
+
lineDash,
|
|
691
|
+
lineWidth: 1,
|
|
800
692
|
}
|
|
693
|
+
);
|
|
694
|
+
}
|
|
801
695
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
color: 'rgba(255, 255, 255, 0.5)',
|
|
809
|
-
lineDash,
|
|
810
|
-
lineWidth,
|
|
811
|
-
}
|
|
812
|
-
);
|
|
696
|
+
if (splineConfig.showControlPointsConnectors) {
|
|
697
|
+
const controlPointsConnectors = [...canvasCoordinates];
|
|
698
|
+
|
|
699
|
+
// Connect the last point to the first one when the spline is closed
|
|
700
|
+
if (spline.closed) {
|
|
701
|
+
controlPointsConnectors.push(canvasCoordinates[0]);
|
|
813
702
|
}
|
|
814
703
|
|
|
815
704
|
drawPolylineSvg(
|
|
816
705
|
svgDrawingHelper,
|
|
817
706
|
annotationUID,
|
|
818
|
-
'
|
|
819
|
-
|
|
707
|
+
'controlPointsConnectors',
|
|
708
|
+
controlPointsConnectors,
|
|
820
709
|
{
|
|
821
|
-
color,
|
|
822
|
-
|
|
823
|
-
lineWidth,
|
|
710
|
+
color: 'rgba(255, 255, 255, 0.5)',
|
|
711
|
+
lineWidth: 1,
|
|
824
712
|
}
|
|
825
713
|
);
|
|
714
|
+
}
|
|
826
715
|
|
|
827
|
-
|
|
716
|
+
this._renderStats(
|
|
717
|
+
annotation,
|
|
718
|
+
viewport,
|
|
719
|
+
svgDrawingHelper,
|
|
720
|
+
annotationStyle.textbox
|
|
721
|
+
);
|
|
828
722
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
723
|
+
annotation.invalidated = false;
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
832
726
|
|
|
833
|
-
|
|
834
|
-
|
|
727
|
+
protected createAnnotation(evt: EventTypes.InteractionEventType): Annotation {
|
|
728
|
+
const contourAnnotation = super.createAnnotation(evt);
|
|
729
|
+
const { world: worldPos } = evt.detail.currentPoints;
|
|
730
|
+
const { type: splineType } = this.configuration.spline;
|
|
731
|
+
const splineConfig = this._getSplineConfig(splineType);
|
|
732
|
+
const spline = new splineConfig.Class();
|
|
733
|
+
|
|
734
|
+
return <SplineROIAnnotation>utilities.deepMerge(contourAnnotation, {
|
|
735
|
+
data: {
|
|
736
|
+
handles: {
|
|
737
|
+
points: [[...worldPos]],
|
|
738
|
+
},
|
|
739
|
+
spline: {
|
|
740
|
+
type: splineConfig.type,
|
|
741
|
+
instance: spline,
|
|
742
|
+
resolution: splineConfig.resolution,
|
|
743
|
+
},
|
|
744
|
+
cachedStats: {},
|
|
745
|
+
},
|
|
746
|
+
});
|
|
747
|
+
}
|
|
835
748
|
|
|
836
|
-
_renderStats = (
|
|
749
|
+
private _renderStats = (
|
|
750
|
+
annotation,
|
|
751
|
+
viewport,
|
|
752
|
+
svgDrawingHelper,
|
|
753
|
+
textboxStyle
|
|
754
|
+
) => {
|
|
837
755
|
const data = annotation.data;
|
|
838
756
|
const targetId = this.getTargetId(viewport);
|
|
839
757
|
|
|
840
|
-
if (!data.spline.closed) {
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
const styleSpecifier: StyleSpecifier = {
|
|
845
|
-
toolGroupId: this.toolGroupId,
|
|
846
|
-
toolName: this.getToolName(),
|
|
847
|
-
viewportId: enabledElement.viewport.id,
|
|
848
|
-
};
|
|
849
|
-
|
|
850
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
851
|
-
if (!options.visibility) {
|
|
758
|
+
if (!data.spline.closed || !textboxStyle.visibility) {
|
|
852
759
|
return;
|
|
853
760
|
}
|
|
854
761
|
|
|
@@ -880,7 +787,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
880
787
|
textBoxPosition,
|
|
881
788
|
canvasCoordinates,
|
|
882
789
|
{},
|
|
883
|
-
|
|
790
|
+
textboxStyle
|
|
884
791
|
);
|
|
885
792
|
|
|
886
793
|
const { x: left, y: top, width, height } = boundingBox;
|
|
@@ -1007,23 +914,6 @@ class SplineROITool extends AnnotationTool {
|
|
|
1007
914
|
return Object.assign({ type }, DEFAULT_SPLINE_CONFIG, splineConfigs[type]);
|
|
1008
915
|
}
|
|
1009
916
|
|
|
1010
|
-
private _updateSplineScale(spline: ISpline, annotation: SplineROIAnnotation) {
|
|
1011
|
-
const splineType = annotation.data.spline.type;
|
|
1012
|
-
const splineConfig = this._getSplineConfig(splineType);
|
|
1013
|
-
|
|
1014
|
-
if (
|
|
1015
|
-
!(spline instanceof CardinalSpline) ||
|
|
1016
|
-
spline.fixedScale ||
|
|
1017
|
-
splineConfig.scale === undefined ||
|
|
1018
|
-
spline.scale === splineConfig.scale
|
|
1019
|
-
) {
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
spline.scale = splineConfig.scale;
|
|
1024
|
-
annotation.invalidated = true;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
917
|
private _updateSplineInstance(
|
|
1028
918
|
element: HTMLDivElement,
|
|
1029
919
|
annotation: SplineROIAnnotation
|
|
@@ -1038,7 +928,7 @@ class SplineROITool extends AnnotationTool {
|
|
|
1038
928
|
const canvasPoints = worldPoints.map(worldToCanvas);
|
|
1039
929
|
|
|
1040
930
|
spline.setControlPoints(canvasPoints);
|
|
1041
|
-
spline.closed = !!data.
|
|
931
|
+
spline.closed = !!data.contour.closed;
|
|
1042
932
|
|
|
1043
933
|
// Update spline resolution in case it has changed
|
|
1044
934
|
if (spline.resolution !== splineConfig.resolution) {
|
|
@@ -1069,14 +959,14 @@ class SplineROITool extends AnnotationTool {
|
|
|
1069
959
|
}
|
|
1070
960
|
const data = annotation.data;
|
|
1071
961
|
|
|
1072
|
-
if (!data.
|
|
962
|
+
if (!data.contour.closed) {
|
|
1073
963
|
return;
|
|
1074
964
|
}
|
|
1075
965
|
|
|
1076
966
|
const enabledElement = getEnabledElement(element);
|
|
1077
967
|
const { viewport, renderingEngine } = enabledElement;
|
|
1078
968
|
const { cachedStats } = data;
|
|
1079
|
-
const { polyline: points } = data.
|
|
969
|
+
const { polyline: points } = data.contour;
|
|
1080
970
|
const targetIds = Object.keys(cachedStats);
|
|
1081
971
|
|
|
1082
972
|
for (let i = 0; i < targetIds.length; i++) {
|
|
@@ -38,7 +38,9 @@ function activateClosedContourEdit(
|
|
|
38
38
|
const enabledElement = getEnabledElement(element);
|
|
39
39
|
const { viewport } = enabledElement;
|
|
40
40
|
|
|
41
|
-
const prevCanvasPoints = annotation.data.polyline.map(
|
|
41
|
+
const prevCanvasPoints = annotation.data.contour.polyline.map(
|
|
42
|
+
viewport.worldToCanvas
|
|
43
|
+
);
|
|
42
44
|
|
|
43
45
|
const { spacing, xDir, yDir } = getSubPixelSpacingAndXYDirections(
|
|
44
46
|
viewport,
|
|
@@ -223,8 +225,8 @@ function finishEditAndStartNewEdit(evt: EventTypes.InteractionEventType): void {
|
|
|
223
225
|
viewport.canvasToWorld(canvasPoint)
|
|
224
226
|
);
|
|
225
227
|
|
|
226
|
-
annotation.data.polyline = worldPoints;
|
|
227
|
-
annotation.data.
|
|
228
|
+
annotation.data.contour.polyline = worldPoints;
|
|
229
|
+
annotation.data.contour.closed = true;
|
|
228
230
|
|
|
229
231
|
this.triggerAnnotationModified(annotation, enabledElement);
|
|
230
232
|
|
|
@@ -441,8 +443,8 @@ function completeClosedContourEdit(element: HTMLDivElement) {
|
|
|
441
443
|
const worldPoints = updatedPoints.map((canvasPoint) =>
|
|
442
444
|
viewport.canvasToWorld(canvasPoint)
|
|
443
445
|
);
|
|
444
|
-
annotation.data.polyline = worldPoints;
|
|
445
|
-
annotation.data.
|
|
446
|
+
annotation.data.contour.polyline = worldPoints;
|
|
447
|
+
annotation.data.contour.closed = true;
|
|
446
448
|
|
|
447
449
|
annotation.invalidated = true;
|
|
448
450
|
|
|
@@ -227,8 +227,8 @@ function completeDrawClosedContour(element: HTMLDivElement): boolean {
|
|
|
227
227
|
viewport.canvasToWorld(canvasPoint)
|
|
228
228
|
);
|
|
229
229
|
|
|
230
|
-
annotation.data.polyline = worldPoints;
|
|
231
|
-
annotation.data.
|
|
230
|
+
annotation.data.contour.polyline = worldPoints;
|
|
231
|
+
annotation.data.contour.closed = true;
|
|
232
232
|
const { textBox } = annotation.data.handles;
|
|
233
233
|
|
|
234
234
|
if (!textBox.hasMoved) {
|
|
@@ -297,8 +297,8 @@ function completeDrawOpenContour(element: HTMLDivElement): boolean {
|
|
|
297
297
|
viewport.canvasToWorld(canvasPoint)
|
|
298
298
|
);
|
|
299
299
|
|
|
300
|
-
annotation.data.polyline = worldPoints;
|
|
301
|
-
annotation.data.
|
|
300
|
+
annotation.data.contour.polyline = worldPoints;
|
|
301
|
+
annotation.data.contour.closed = false;
|
|
302
302
|
const { textBox } = annotation.data.handles;
|
|
303
303
|
|
|
304
304
|
// Add the first and last points to the list of handles. These means they
|