@cornerstonejs/tools 4.9.0 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +9 -3
- package/dist/esm/stateManagement/segmentation/index.d.ts +2 -1
- package/dist/esm/stateManagement/segmentation/index.js +2 -1
- package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +10 -1
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +2 -0
- package/dist/esm/stateManagement/segmentation/segmentationEventManager.d.ts +7 -0
- package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +66 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.d.ts +2 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +5 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +2 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +5 -1
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.d.ts +3 -1
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +7 -2
- package/dist/esm/utilities/contours/interpolation/interpolate.js +2 -1
- package/dist/esm/utilities/segmentation/computeAndAddRepresentation.d.ts +1 -1
- package/dist/esm/utilities/segmentation/computeAndAddRepresentation.js +1 -34
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { triggerEvent, eventTarget, Enums, getRenderingEngines, getEnabledElementByViewportId, } from '@cornerstonejs/core';
|
|
2
2
|
import { SegmentationRepresentations, Events as csToolsEvents, } from '../../enums';
|
|
3
3
|
import Representations from '../../enums/SegmentationRepresentations';
|
|
4
|
+
import { getSegmentation } from './getSegmentation';
|
|
4
5
|
import { getSegmentationRepresentations } from './getSegmentationRepresentation';
|
|
5
6
|
import surfaceDisplay from '../../tools/displayTools/Surface/surfaceDisplay';
|
|
6
7
|
import contourDisplay from '../../tools/displayTools/Contour/contourDisplay';
|
|
@@ -9,6 +10,7 @@ import { addTool } from '../../store/addTool';
|
|
|
9
10
|
import { state } from '../../store/state';
|
|
10
11
|
import PlanarFreehandContourSegmentationTool from '../../tools/annotation/PlanarFreehandContourSegmentationTool';
|
|
11
12
|
import { getToolGroupForViewport } from '../../store/ToolGroupManager';
|
|
13
|
+
import { addDefaultSegmentationListener } from './segmentationEventManager';
|
|
12
14
|
const renderers = {
|
|
13
15
|
[Representations.Labelmap]: labelmapDisplay,
|
|
14
16
|
[Representations.Contour]: contourDisplay,
|
|
@@ -102,15 +104,19 @@ class SegmentationRenderingEngine {
|
|
|
102
104
|
if (!viewport) {
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
|
-
const viewportRenderList = [];
|
|
106
107
|
const segmentationRenderList = segmentationRepresentations.map((representation) => {
|
|
107
108
|
if (representation.type === SegmentationRepresentations.Contour) {
|
|
108
109
|
this._addPlanarFreeHandToolIfAbsent(viewport);
|
|
109
110
|
}
|
|
110
111
|
const display = renderers[representation.type];
|
|
112
|
+
const segmentation = getSegmentation(representation.segmentationId);
|
|
113
|
+
const existingRepresentation = segmentation.representationData[representation.type] !== undefined;
|
|
111
114
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
display.render(viewport, representation).then(() => {
|
|
116
|
+
if (!existingRepresentation) {
|
|
117
|
+
addDefaultSegmentationListener(viewport, representation.segmentationId, representation.type);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
114
120
|
}
|
|
115
121
|
catch (error) {
|
|
116
122
|
console.error(error);
|
|
@@ -22,10 +22,11 @@ import { segmentationStyle } from './SegmentationStyle';
|
|
|
22
22
|
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
23
23
|
import { getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId } from './getCurrentLabelmapImageIdForViewport';
|
|
24
24
|
import { getActiveSegmentation } from './getActiveSegmentation';
|
|
25
|
+
import { addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners } from './segmentationEventManager';
|
|
25
26
|
declare const helpers: {
|
|
26
27
|
clearSegmentValue: typeof clearSegmentValue;
|
|
27
28
|
convertStackToVolumeLabelmap: typeof convertStackToVolumeLabelmap;
|
|
28
29
|
computeVolumeLabelmapFromStack: typeof computeVolumeLabelmapFromStack;
|
|
29
30
|
convertVolumeToStackLabelmap: typeof convertVolumeToStackLabelmap;
|
|
30
31
|
};
|
|
31
|
-
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
|
|
32
|
+
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
|
|
@@ -22,10 +22,11 @@ import { segmentationStyle } from './SegmentationStyle';
|
|
|
22
22
|
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
23
23
|
import { getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, } from './getCurrentLabelmapImageIdForViewport';
|
|
24
24
|
import { getActiveSegmentation } from './getActiveSegmentation';
|
|
25
|
+
import { addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, } from './segmentationEventManager';
|
|
25
26
|
const helpers = {
|
|
26
27
|
clearSegmentValue,
|
|
27
28
|
convertStackToVolumeLabelmap,
|
|
28
29
|
computeVolumeLabelmapFromStack,
|
|
29
30
|
convertVolumeToStackLabelmap,
|
|
30
31
|
};
|
|
31
|
-
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
|
|
32
|
+
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, addSegmentationListener, addDefaultSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, utilities, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, getCurrentLabelmapImageIdsForViewport, getLabelmapImageIdsForImageId, getActiveSegmentation, };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
1
2
|
import CORNERSTONE_COLOR_LUT from '../../constants/COLOR_LUT';
|
|
2
3
|
import { triggerAnnotationRenderForViewportIds } from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
3
4
|
import { SegmentationRepresentations } from '../../enums';
|
|
4
|
-
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
5
|
+
import { triggerSegmentationModified, triggerSegmentationDataModified, } from './triggerSegmentationEvents';
|
|
5
6
|
import { addColorLUT } from './addColorLUT';
|
|
6
7
|
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
8
|
+
import { addDefaultSegmentationListener } from './segmentationEventManager';
|
|
7
9
|
import { getActiveSegmentIndex, setActiveSegmentIndex } from './segmentIndex';
|
|
8
10
|
function internalAddSegmentationRepresentation(viewportId, representationInput) {
|
|
9
11
|
const { segmentationId, config } = representationInput;
|
|
@@ -12,6 +14,10 @@ function internalAddSegmentationRepresentation(viewportId, representationInput)
|
|
|
12
14
|
...config,
|
|
13
15
|
};
|
|
14
16
|
defaultSegmentationStateManager.addSegmentationRepresentation(viewportId, segmentationId, representationInput.type, renderingConfig);
|
|
17
|
+
const { viewport } = getEnabledElementByViewportId(viewportId) || {};
|
|
18
|
+
if (viewport) {
|
|
19
|
+
addDefaultSegmentationListener(viewport, segmentationId, representationInput.type);
|
|
20
|
+
}
|
|
15
21
|
if (!getActiveSegmentIndex(segmentationId)) {
|
|
16
22
|
let firstSegmentIndex = 1;
|
|
17
23
|
const segmentation = defaultSegmentationStateManager.getSegmentation(segmentationId);
|
|
@@ -26,6 +32,9 @@ function internalAddSegmentationRepresentation(viewportId, representationInput)
|
|
|
26
32
|
if (representationInput.type === SegmentationRepresentations.Contour) {
|
|
27
33
|
triggerAnnotationRenderForViewportIds([viewportId]);
|
|
28
34
|
}
|
|
35
|
+
if (representationInput.type === SegmentationRepresentations.Surface) {
|
|
36
|
+
triggerSegmentationDataModified(segmentationId);
|
|
37
|
+
}
|
|
29
38
|
triggerSegmentationModified(segmentationId);
|
|
30
39
|
}
|
|
31
40
|
function getColorLUTIndex(config) {
|
|
@@ -5,6 +5,7 @@ import { getSegmentationRepresentations } from './getSegmentationRepresentation'
|
|
|
5
5
|
import { getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
6
6
|
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
7
7
|
import { surfaceDisplay } from '../../tools/displayTools/Surface';
|
|
8
|
+
import { removeSegmentationListener } from './segmentationEventManager';
|
|
8
9
|
function removeSegmentationRepresentation(viewportId, specifier, immediate) {
|
|
9
10
|
return _removeSegmentationRepresentations(viewportId, specifier, immediate);
|
|
10
11
|
}
|
|
@@ -64,6 +65,7 @@ function _removeRepresentationObject(viewportId, segmentationId, type, immediate
|
|
|
64
65
|
else if (representation.type === SegmentationRepresentations.Surface) {
|
|
65
66
|
surfaceDisplay.removeRepresentation(viewportId, representation.segmentationId, immediate);
|
|
66
67
|
}
|
|
68
|
+
removeSegmentationListener(representation.segmentationId, representation.type);
|
|
67
69
|
});
|
|
68
70
|
const { viewport } = getEnabledElementByViewportId(viewportId) || {};
|
|
69
71
|
if (viewport) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Types } from '@cornerstonejs/core';
|
|
2
|
+
import { SegmentationRepresentations } from '../../enums';
|
|
3
|
+
export declare function addDefaultSegmentationListener(viewport: Types.IVolumeViewport | Types.IStackViewport, segmentationId: string, representationType: SegmentationRepresentations): void;
|
|
4
|
+
declare function addSegmentationListener(segmentationId: string, representationType: string, updateFunction: (segmentationId: string) => Promise<void>): void;
|
|
5
|
+
declare function removeSegmentationListener(segmentationId: string, representationType: string): void;
|
|
6
|
+
declare function removeAllSegmentationListeners(segmentationId: string): void;
|
|
7
|
+
export { addSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { eventTarget } from '@cornerstonejs/core';
|
|
2
|
+
import { Events, SegmentationRepresentations } from '../../enums';
|
|
3
|
+
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
4
|
+
import debounce from '../../utilities/debounce';
|
|
5
|
+
import surfaceDisplay from '../../tools/displayTools/Surface/surfaceDisplay';
|
|
6
|
+
import contourDisplay from '../../tools/displayTools/Contour/contourDisplay';
|
|
7
|
+
import labelmapDisplay from '../../tools/displayTools/Labelmap/labelmapDisplay';
|
|
8
|
+
const renderers = {
|
|
9
|
+
[SegmentationRepresentations.Labelmap]: labelmapDisplay,
|
|
10
|
+
[SegmentationRepresentations.Contour]: contourDisplay,
|
|
11
|
+
[SegmentationRepresentations.Surface]: surfaceDisplay,
|
|
12
|
+
};
|
|
13
|
+
const segmentationListeners = new Map();
|
|
14
|
+
export function addDefaultSegmentationListener(viewport, segmentationId, representationType) {
|
|
15
|
+
const updateFunction = renderers[representationType].getUpdateFunction(viewport);
|
|
16
|
+
if (updateFunction) {
|
|
17
|
+
addSegmentationListener(segmentationId, representationType, updateFunction);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function addSegmentationListener(segmentationId, representationType, updateFunction) {
|
|
21
|
+
if (!segmentationListeners.has(segmentationId)) {
|
|
22
|
+
segmentationListeners.set(segmentationId, new Map());
|
|
23
|
+
}
|
|
24
|
+
const listenerMap = segmentationListeners.get(segmentationId);
|
|
25
|
+
if (listenerMap.has(representationType)) {
|
|
26
|
+
removeSegmentationListener(segmentationId, representationType);
|
|
27
|
+
}
|
|
28
|
+
const listener = createDebouncedSegmentationListener(segmentationId, updateFunction);
|
|
29
|
+
eventTarget.addEventListener(Events.SEGMENTATION_DATA_MODIFIED, listener);
|
|
30
|
+
listenerMap.set(representationType, listener);
|
|
31
|
+
}
|
|
32
|
+
function removeSegmentationListener(segmentationId, representationType) {
|
|
33
|
+
const listenerMap = segmentationListeners.get(segmentationId);
|
|
34
|
+
if (!listenerMap) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const listener = listenerMap.get(representationType);
|
|
38
|
+
if (!listener) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
eventTarget.removeEventListener(Events.SEGMENTATION_DATA_MODIFIED, listener);
|
|
42
|
+
listenerMap.delete(representationType);
|
|
43
|
+
}
|
|
44
|
+
function removeAllSegmentationListeners(segmentationId) {
|
|
45
|
+
const listenerMap = segmentationListeners.get(segmentationId);
|
|
46
|
+
if (!listenerMap) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
for (const listener of listenerMap.values()) {
|
|
50
|
+
eventTarget.removeEventListener(Events.SEGMENTATION_DATA_MODIFIED, listener);
|
|
51
|
+
}
|
|
52
|
+
segmentationListeners.delete(segmentationId);
|
|
53
|
+
}
|
|
54
|
+
function createDebouncedSegmentationListener(segmentationId, updateFunction) {
|
|
55
|
+
const debouncedHandler = debounce((event) => {
|
|
56
|
+
const eventSegmentationId = event.detail?.segmentationId;
|
|
57
|
+
if (eventSegmentationId === segmentationId) {
|
|
58
|
+
updateFunction(segmentationId);
|
|
59
|
+
triggerSegmentationModified(segmentationId);
|
|
60
|
+
}
|
|
61
|
+
}, 300);
|
|
62
|
+
return ((event) => {
|
|
63
|
+
debouncedHandler(event);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export { addSegmentationListener, removeSegmentationListener, removeAllSegmentationListeners, };
|
|
@@ -2,7 +2,9 @@ import type { StackViewport, Types } from '@cornerstonejs/core';
|
|
|
2
2
|
import type { ContourRepresentation } from '../../../types/SegmentationStateTypes';
|
|
3
3
|
declare function removeRepresentation(viewportId: string, segmentationId: string, renderImmediate?: boolean): void;
|
|
4
4
|
declare function render(viewport: StackViewport | Types.IVolumeViewport, contourRepresentation: ContourRepresentation): Promise<void>;
|
|
5
|
+
declare function getUpdateFunction(viewport: Types.IVolumeViewport | Types.IStackViewport): (segmentationId: string) => Promise<void>;
|
|
5
6
|
declare const _default: {
|
|
7
|
+
getUpdateFunction: typeof getUpdateFunction;
|
|
6
8
|
render: typeof render;
|
|
7
9
|
removeRepresentation: typeof removeRepresentation;
|
|
8
10
|
};
|
|
@@ -33,7 +33,7 @@ async function render(viewport, contourRepresentation) {
|
|
|
33
33
|
getPolySeg()?.canComputeRequestedRepresentation(segmentationId, Representations.Contour) &&
|
|
34
34
|
!polySegConversionInProgressForViewportId.get(viewport.id)) {
|
|
35
35
|
polySegConversionInProgressForViewportId.set(viewport.id, true);
|
|
36
|
-
contourData = await computeAndAddRepresentation(segmentationId, Representations.Contour, () => polySeg.computeContourData(segmentationId, { viewport })
|
|
36
|
+
contourData = await computeAndAddRepresentation(segmentationId, Representations.Contour, () => polySeg.computeContourData(segmentationId, { viewport }));
|
|
37
37
|
polySegConversionInProgressForViewportId.set(viewport.id, false);
|
|
38
38
|
}
|
|
39
39
|
else if (!contourData && !getPolySeg()) {
|
|
@@ -140,7 +140,11 @@ function _checkContourNormalsMatchViewport(annotationUIDsMap, viewportNormal) {
|
|
|
140
140
|
}
|
|
141
141
|
return true;
|
|
142
142
|
}
|
|
143
|
+
function getUpdateFunction(viewport) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
143
146
|
export default {
|
|
147
|
+
getUpdateFunction,
|
|
144
148
|
render,
|
|
145
149
|
removeRepresentation,
|
|
146
150
|
};
|
|
@@ -3,7 +3,9 @@ import type { LabelmapRepresentation } from '../../../types/SegmentationStateTyp
|
|
|
3
3
|
export declare const MAX_NUMBER_COLORS = 255;
|
|
4
4
|
declare function removeRepresentation(viewportId: string, segmentationId: string, renderImmediate?: boolean): void;
|
|
5
5
|
declare function render(viewport: Types.IStackViewport | Types.IVolumeViewport, representation: LabelmapRepresentation): Promise<void>;
|
|
6
|
+
declare function getUpdateFunction(viewport: Types.IVolumeViewport | Types.IStackViewport): (segmentationId: string) => Promise<void> | null;
|
|
6
7
|
declare const _default: {
|
|
8
|
+
getUpdateFunction: typeof getUpdateFunction;
|
|
7
9
|
render: typeof render;
|
|
8
10
|
removeRepresentation: typeof removeRepresentation;
|
|
9
11
|
};
|
|
@@ -48,7 +48,7 @@ async function render(viewport, representation) {
|
|
|
48
48
|
!polySegConversionInProgress) {
|
|
49
49
|
polySegConversionInProgress = true;
|
|
50
50
|
const polySeg = getPolySeg();
|
|
51
|
-
labelmapData = await computeAndAddRepresentation(segmentationId, SegmentationRepresentations.Labelmap, () => polySeg.computeLabelmapData(segmentationId, { viewport }), () =>
|
|
51
|
+
labelmapData = await computeAndAddRepresentation(segmentationId, SegmentationRepresentations.Labelmap, () => polySeg.computeLabelmapData(segmentationId, { viewport }), () => {
|
|
52
52
|
defaultSegmentationStateManager.processLabelmapRepresentationAddition(viewport.id, segmentationId);
|
|
53
53
|
setTimeout(() => {
|
|
54
54
|
triggerSegmentationDataModified(segmentationId);
|
|
@@ -265,7 +265,11 @@ async function _addLabelmapToViewport(viewport, labelmapData, segmentationId, co
|
|
|
265
265
|
const result = await addLabelmapToElement(viewport.element, labelmapData, segmentationId, config);
|
|
266
266
|
return result || undefined;
|
|
267
267
|
}
|
|
268
|
+
function getUpdateFunction(viewport) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
268
271
|
export default {
|
|
272
|
+
getUpdateFunction,
|
|
269
273
|
render,
|
|
270
274
|
removeRepresentation,
|
|
271
275
|
};
|
|
@@ -2,9 +2,11 @@ import type { Types } from '@cornerstonejs/core';
|
|
|
2
2
|
import type { SegmentationRepresentation } from '../../../types/SegmentationStateTypes';
|
|
3
3
|
declare function removeRepresentation(viewportId: string, segmentationId: string, renderImmediate?: boolean): void;
|
|
4
4
|
declare function render(viewport: Types.IVolumeViewport | Types.IStackViewport, representation: SegmentationRepresentation): Promise<void>;
|
|
5
|
+
declare function getUpdateFunction(viewport: Types.IVolumeViewport | Types.IStackViewport): (segmentationId: string) => Promise<void>;
|
|
5
6
|
declare const _default: {
|
|
7
|
+
getUpdateFunction: typeof getUpdateFunction;
|
|
6
8
|
render: typeof render;
|
|
7
9
|
removeRepresentation: typeof removeRepresentation;
|
|
8
10
|
};
|
|
9
11
|
export default _default;
|
|
10
|
-
export { render, removeRepresentation };
|
|
12
|
+
export { getUpdateFunction, render, removeRepresentation };
|
|
@@ -29,7 +29,7 @@ async function render(viewport, representation) {
|
|
|
29
29
|
if (!SurfaceData &&
|
|
30
30
|
getPolySeg()?.canComputeRequestedRepresentation(segmentationId, Representations.Surface)) {
|
|
31
31
|
const polySeg = getPolySeg();
|
|
32
|
-
SurfaceData = await computeAndAddRepresentation(segmentationId, Representations.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport })
|
|
32
|
+
SurfaceData = await computeAndAddRepresentation(segmentationId, Representations.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport }));
|
|
33
33
|
if (!SurfaceData) {
|
|
34
34
|
throw new Error(`No Surface data found for segmentationId ${segmentationId} even we tried to compute it`);
|
|
35
35
|
}
|
|
@@ -69,8 +69,13 @@ async function render(viewport, representation) {
|
|
|
69
69
|
});
|
|
70
70
|
viewport.render();
|
|
71
71
|
}
|
|
72
|
+
function getUpdateFunction(viewport) {
|
|
73
|
+
const polySeg = getPolySeg();
|
|
74
|
+
return (segmentationId) => polySeg.updateSurfaceData(segmentationId, { viewport });
|
|
75
|
+
}
|
|
72
76
|
export default {
|
|
77
|
+
getUpdateFunction,
|
|
73
78
|
render,
|
|
74
79
|
removeRepresentation,
|
|
75
80
|
};
|
|
76
|
-
export { render, removeRepresentation };
|
|
81
|
+
export { getUpdateFunction, render, removeRepresentation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { triggerEvent, utilities } from '@cornerstonejs/core';
|
|
1
|
+
import { eventTarget, triggerEvent, utilities } from '@cornerstonejs/core';
|
|
2
2
|
import { vec3 } from 'gl-matrix';
|
|
3
3
|
import createPolylineToolData from './createPolylineToolData';
|
|
4
4
|
import findAnnotationsForInterpolation from './findAnnotationForInterpolation';
|
|
@@ -55,6 +55,7 @@ function startInterpolation(viewportData) {
|
|
|
55
55
|
};
|
|
56
56
|
if (interpolationList.length) {
|
|
57
57
|
triggerEvent(viewportData.viewport.element, EventTypes.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED, eventDetails);
|
|
58
|
+
triggerEvent(eventTarget, EventTypes.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED, eventDetails);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
function _linearlyInterpolateBetween(indices, annotationPair, interpolationData, eventData) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SegmentationRepresentations } from '../../enums';
|
|
2
|
-
declare function computeAndAddRepresentation<T>(segmentationId: string, type: SegmentationRepresentations, computeFunction: () => Promise<T>,
|
|
2
|
+
declare function computeAndAddRepresentation<T>(segmentationId: string, type: SegmentationRepresentations, computeFunction: () => Promise<T>, onComputationComplete?: () => void): Promise<T>;
|
|
3
3
|
export { computeAndAddRepresentation };
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { eventTarget } from '@cornerstonejs/core';
|
|
2
|
-
import { Events } from '../../enums';
|
|
3
1
|
import addRepresentationData from '../../stateManagement/segmentation/internalAddRepresentationData';
|
|
4
|
-
|
|
5
|
-
import debounce from '../debounce';
|
|
6
|
-
const computedRepresentations = new Map();
|
|
7
|
-
async function computeAndAddRepresentation(segmentationId, type, computeFunction, updateFunction, onComputationComplete) {
|
|
2
|
+
async function computeAndAddRepresentation(segmentationId, type, computeFunction, onComputationComplete) {
|
|
8
3
|
const data = await computeFunction();
|
|
9
4
|
addRepresentationData({
|
|
10
5
|
segmentationId,
|
|
@@ -12,34 +7,6 @@ async function computeAndAddRepresentation(segmentationId, type, computeFunction
|
|
|
12
7
|
data,
|
|
13
8
|
});
|
|
14
9
|
onComputationComplete?.();
|
|
15
|
-
if (!computedRepresentations.has(segmentationId)) {
|
|
16
|
-
computedRepresentations.set(segmentationId, []);
|
|
17
|
-
}
|
|
18
|
-
const representations = computedRepresentations.get(segmentationId);
|
|
19
|
-
if (!representations.includes(type)) {
|
|
20
|
-
representations.push(type);
|
|
21
|
-
}
|
|
22
|
-
subscribeToSegmentationChanges(updateFunction);
|
|
23
|
-
triggerSegmentationModified(segmentationId);
|
|
24
10
|
return data;
|
|
25
11
|
}
|
|
26
|
-
function subscribeToSegmentationChanges(updateFunction) {
|
|
27
|
-
const debouncedUpdateFunction = (event) => {
|
|
28
|
-
_debouncedSegmentationModified(event, updateFunction);
|
|
29
|
-
};
|
|
30
|
-
updateFunction._debouncedUpdateFunction = debouncedUpdateFunction;
|
|
31
|
-
eventTarget.removeEventListener(Events.SEGMENTATION_DATA_MODIFIED, updateFunction._debouncedUpdateFunction);
|
|
32
|
-
eventTarget.addEventListener(Events.SEGMENTATION_DATA_MODIFIED, updateFunction._debouncedUpdateFunction);
|
|
33
|
-
}
|
|
34
|
-
const _debouncedSegmentationModified = debounce((event, updateFunction) => {
|
|
35
|
-
const segmentationId = event.detail.segmentationId;
|
|
36
|
-
const representations = computedRepresentations.get(segmentationId);
|
|
37
|
-
if (!representations || !representations.length) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
updateFunction(segmentationId);
|
|
41
|
-
if (representations.length) {
|
|
42
|
-
triggerSegmentationModified(segmentationId);
|
|
43
|
-
}
|
|
44
|
-
}, 300);
|
|
45
12
|
export { computeAndAddRepresentation };
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.9.
|
|
1
|
+
export declare const version = "4.9.2";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.9.
|
|
1
|
+
export const version = '4.9.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"canvas": "3.2.0"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
|
-
"@cornerstonejs/core": "4.9.
|
|
111
|
+
"@cornerstonejs/core": "4.9.2",
|
|
112
112
|
"@kitware/vtk.js": "32.12.1",
|
|
113
113
|
"@types/d3-array": "3.2.1",
|
|
114
114
|
"@types/d3-interpolate": "3.0.4",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"type": "individual",
|
|
128
128
|
"url": "https://ohif.org/donate"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "d128e0856504bc33713d061f6642122b27ae82e3"
|
|
131
131
|
}
|