@cornerstonejs/tools 2.0.0-beta.28 → 2.0.0-beta.29
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/constants/COLOR_LUT.d.ts +2 -1
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +1 -1
- package/dist/esm/eventListeners/segmentation/segmentationModifiedEventListener.js +0 -1
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedListener.d.ts +3 -0
- package/dist/esm/eventListeners/segmentation/segmentationRepresentationModifiedListener.js +6 -0
- package/dist/esm/init.js +4 -0
- package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +22 -12
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -0
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +63 -25
- package/dist/esm/stateManagement/segmentation/SegmentationStyle.d.ts +22 -25
- package/dist/esm/stateManagement/segmentation/SegmentationStyle.js +138 -77
- package/dist/esm/stateManagement/segmentation/activeSegmentation.js +0 -4
- package/dist/esm/stateManagement/segmentation/config/segmentationColor.js +5 -5
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +12 -8
- package/dist/esm/stateManagement/segmentation/config/styleHelpers.d.ts +17 -31
- package/dist/esm/stateManagement/segmentation/config/styleHelpers.js +14 -37
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationModified.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationModified.js +4 -14
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationModified.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationModified.js +10 -0
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationRemoved.d.ts +2 -0
- package/dist/esm/stateManagement/segmentation/events/triggerSegmentationRepresentationRemoved.js +10 -0
- package/dist/esm/stateManagement/segmentation/getActiveSegmentIndex.js +3 -1
- package/dist/esm/stateManagement/segmentation/getGlobalStyle.js +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +0 -1
- package/dist/esm/stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices.js +14 -0
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -6
- package/dist/esm/stateManagement/segmentation/index.d.ts +3 -1
- package/dist/esm/stateManagement/segmentation/index.js +3 -1
- package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +9 -8
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +1 -1
- package/dist/esm/stateManagement/segmentation/polySeg/computeAndAddRepresentation.js +0 -1
- package/dist/esm/stateManagement/segmentation/removeSegment.d.ts +3 -0
- package/dist/esm/stateManagement/segmentation/removeSegment.js +50 -0
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +10 -12
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +18 -2
- package/dist/esm/stateManagement/segmentation/segmentLocking.js +7 -11
- package/dist/esm/stateManagement/segmentation/setGlobalStyle.js +3 -3
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.d.ts +3 -1
- package/dist/esm/stateManagement/segmentation/triggerSegmentationEvents.js +3 -1
- package/dist/esm/stateManagement/segmentation/updateSegmentations.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/updateSegmentations.js +11 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +11 -10
- package/dist/esm/tools/displayTools/Contour/contourConfig.js +2 -2
- package/dist/esm/tools/displayTools/Contour/contourHandler/handleContourSegmentation.js +1 -5
- package/dist/esm/tools/displayTools/Labelmap/labelmapConfig.js +3 -3
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +38 -29
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +2 -2
- package/dist/esm/tools/segmentation/BrushTool.js +4 -1
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +1 -1
- package/dist/esm/types/ContourTypes.d.ts +15 -8
- package/dist/esm/types/EventTypes.d.ts +6 -0
- package/dist/esm/types/LabelmapTypes.d.ts +9 -6
- package/dist/esm/types/SegmentationStateTypes.d.ts +31 -21
- package/dist/esm/types/SurfaceTypes.d.ts +1 -0
- package/dist/esm/types/index.d.ts +6 -4
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.d.ts +8 -2
- package/dist/esm/utilities/dynamicVolume/generateImageFromTimeData.js +51 -24
- package/dist/esm/utilities/dynamicVolume/index.d.ts +2 -2
- package/dist/esm/utilities/dynamicVolume/index.js +2 -2
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { triggerSegmentationRender } from './SegmentationRenderingEngine';
|
|
1
2
|
import { segmentationStyle } from './SegmentationStyle';
|
|
2
|
-
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
3
3
|
export function setGlobalStyle(type, styles, suppressEvents) {
|
|
4
|
-
segmentationStyle.
|
|
4
|
+
segmentationStyle.setStyle({ type }, styles);
|
|
5
5
|
if (!suppressEvents) {
|
|
6
|
-
|
|
6
|
+
triggerSegmentationRender();
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { triggerSegmentationDataModified } from './events/triggerSegmentationDataModified';
|
|
2
2
|
import { triggerSegmentationModified } from './events/triggerSegmentationModified';
|
|
3
3
|
import { triggerSegmentationRemoved } from './events/triggerSegmentationRemoved';
|
|
4
|
-
|
|
4
|
+
import { triggerSegmentationRepresentationModified } from './events/triggerSegmentationRepresentationModified';
|
|
5
|
+
import { triggerSegmentationRepresentationRemoved } from './events/triggerSegmentationRepresentationRemoved';
|
|
6
|
+
export { triggerSegmentationDataModified, triggerSegmentationModified, triggerSegmentationRemoved, triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { triggerSegmentationDataModified } from './events/triggerSegmentationDataModified';
|
|
2
2
|
import { triggerSegmentationModified } from './events/triggerSegmentationModified';
|
|
3
3
|
import { triggerSegmentationRemoved } from './events/triggerSegmentationRemoved';
|
|
4
|
-
|
|
4
|
+
import { triggerSegmentationRepresentationModified } from './events/triggerSegmentationRepresentationModified';
|
|
5
|
+
import { triggerSegmentationRepresentationRemoved } from './events/triggerSegmentationRepresentationRemoved';
|
|
6
|
+
export { triggerSegmentationDataModified, triggerSegmentationModified, triggerSegmentationRemoved, triggerSegmentationRepresentationModified, triggerSegmentationRepresentationRemoved, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
2
|
+
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
3
|
+
export function updateSegmentations(segmentationUpdateArray, suppressEvents) {
|
|
4
|
+
const segmentationStateManager = defaultSegmentationStateManager;
|
|
5
|
+
segmentationUpdateArray.forEach((segmentationUpdate) => {
|
|
6
|
+
segmentationStateManager.updateSegmentation(segmentationUpdate.segmentationId, segmentationUpdate.payload);
|
|
7
|
+
if (!suppressEvents) {
|
|
8
|
+
triggerSegmentationModified(segmentationUpdate.segmentationId);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -14,8 +14,8 @@ import { getSegmentationRepresentationVisibility } from '../../stateManagement/s
|
|
|
14
14
|
import { getViewportIdsWithSegmentation } from '../../stateManagement/segmentation/getViewportIdsWithSegmentation';
|
|
15
15
|
import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
16
16
|
import { getLockedSegmentIndices } from '../../stateManagement/segmentation/segmentLocking';
|
|
17
|
-
import { getSegmentIndexVisibility } from '../../stateManagement/segmentation/config/segmentationVisibility';
|
|
18
17
|
import { segmentationStyle } from '../../stateManagement/segmentation/SegmentationStyle';
|
|
18
|
+
import { internalGetHiddenSegmentIndices } from '../../stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices';
|
|
19
19
|
class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
20
20
|
constructor(toolProps, defaultToolProps) {
|
|
21
21
|
super(toolProps, defaultToolProps);
|
|
@@ -121,7 +121,7 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
121
121
|
});
|
|
122
122
|
const activeSegmentation = getActiveSegmentation(viewportId);
|
|
123
123
|
const isActive = activeSegmentation?.segmentationId === segmentationId;
|
|
124
|
-
const
|
|
124
|
+
const style = segmentationStyle.getStyle({
|
|
125
125
|
viewportId,
|
|
126
126
|
segmentationId,
|
|
127
127
|
type: SegmentationRepresentations.Contour,
|
|
@@ -139,8 +139,8 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
139
139
|
fillOpacity = mergedConfig.fillAlphaAutoGenerated ?? fillOpacity;
|
|
140
140
|
}
|
|
141
141
|
else if (isActive) {
|
|
142
|
-
lineWidth = mergedConfig.
|
|
143
|
-
lineDash = mergedConfig.
|
|
142
|
+
lineWidth = mergedConfig.outlineWidth ?? lineWidth;
|
|
143
|
+
lineDash = mergedConfig.outlineDash ?? lineDash;
|
|
144
144
|
lineOpacity = mergedConfig.outlineOpacity ?? lineOpacity;
|
|
145
145
|
fillOpacity = mergedConfig.fillAlpha ?? fillOpacity;
|
|
146
146
|
}
|
|
@@ -150,13 +150,18 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
150
150
|
lineOpacity = mergedConfig.outlineOpacityInactive ?? lineOpacity;
|
|
151
151
|
fillOpacity = mergedConfig.fillAlphaInactive ?? fillOpacity;
|
|
152
152
|
}
|
|
153
|
-
if (
|
|
153
|
+
if (getActiveSegmentIndex(segmentationId) === segmentIndex) {
|
|
154
154
|
lineWidth += mergedConfig.activeSegmentOutlineWidthDelta;
|
|
155
155
|
}
|
|
156
156
|
lineWidth = mergedConfig.renderOutline ? lineWidth : 0;
|
|
157
157
|
fillOpacity = mergedConfig.renderFill ? fillOpacity : 0;
|
|
158
158
|
const color = `rgba(${segmentColor[0]}, ${segmentColor[1]}, ${segmentColor[2]}, ${lineOpacity})`;
|
|
159
159
|
const fillColor = `rgb(${segmentColor[0]}, ${segmentColor[1]}, ${segmentColor[2]})`;
|
|
160
|
+
const hiddenSegments = internalGetHiddenSegmentIndices(viewportId, {
|
|
161
|
+
segmentationId,
|
|
162
|
+
type: SegmentationRepresentations.Contour,
|
|
163
|
+
});
|
|
164
|
+
const isVisible = !hiddenSegments.has(segmentIndex);
|
|
160
165
|
return {
|
|
161
166
|
color,
|
|
162
167
|
fillColor,
|
|
@@ -166,11 +171,7 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
166
171
|
textbox: {
|
|
167
172
|
color,
|
|
168
173
|
},
|
|
169
|
-
visibility: segmentationVisible &&
|
|
170
|
-
getSegmentIndexVisibility(viewportId, {
|
|
171
|
-
segmentationId,
|
|
172
|
-
type: SegmentationRepresentations.Contour,
|
|
173
|
-
}, segmentIndex),
|
|
174
|
+
visibility: segmentationVisible && isVisible,
|
|
174
175
|
locked: annotationLocked,
|
|
175
176
|
};
|
|
176
177
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const defaultContourConfig = {
|
|
2
2
|
renderOutline: true,
|
|
3
3
|
outlineWidthAutoGenerated: 3,
|
|
4
|
-
|
|
4
|
+
outlineWidth: 1,
|
|
5
5
|
outlineWidthInactive: 1,
|
|
6
6
|
outlineOpacity: 1,
|
|
7
7
|
outlineOpacityInactive: 0.85,
|
|
8
|
-
|
|
8
|
+
outlineDash: undefined,
|
|
9
9
|
outlineDashInactive: undefined,
|
|
10
10
|
outlineDashAutoGenerated: '5,3',
|
|
11
11
|
activeSegmentOutlineWidthDelta: 0,
|
|
@@ -3,9 +3,9 @@ import { cache, utilities } from '@cornerstonejs/core';
|
|
|
3
3
|
import { getClosestImageIdForStackViewport } from '../../../../utilities/annotationHydration';
|
|
4
4
|
import { addContourSegmentationAnnotation } from '../../../../utilities/contourSegmentation';
|
|
5
5
|
import { validateGeometry } from './utils';
|
|
6
|
-
import { getHiddenSegmentIndices } from '../../../../stateManagement/segmentation/config/segmentationVisibility';
|
|
7
6
|
import { SegmentationRepresentations } from '../../../../enums';
|
|
8
7
|
import { segmentationStyle } from '../../../../stateManagement/segmentation/SegmentationStyle';
|
|
8
|
+
import { internalGetHiddenSegmentIndices } from '../../../../stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices';
|
|
9
9
|
function handleContourSegmentation(viewport, geometryIds, annotationUIDsMap, contourRepresentation) {
|
|
10
10
|
if (annotationUIDsMap.size) {
|
|
11
11
|
updateContourSets(viewport, geometryIds, contourRepresentation);
|
|
@@ -87,10 +87,6 @@ function addContourSetsToElement(viewport, geometryIds, contourRepresentation) {
|
|
|
87
87
|
segmentSpecificMap.set(segmentIndex, segmentSpecificConfig);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
const segmentsHidden = getHiddenSegmentIndices(viewport.id, {
|
|
91
|
-
segmentationId,
|
|
92
|
-
type: SegmentationRepresentations.Contour,
|
|
93
|
-
});
|
|
94
90
|
viewport.resetCamera();
|
|
95
91
|
viewport.render();
|
|
96
92
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const defaultLabelmapConfig = {
|
|
2
2
|
renderOutline: true,
|
|
3
3
|
renderOutlineInactive: true,
|
|
4
|
-
|
|
4
|
+
outlineWidth: 3,
|
|
5
5
|
outlineWidthInactive: 2,
|
|
6
6
|
activeSegmentOutlineWidthDelta: 0,
|
|
7
7
|
renderFill: true,
|
|
8
8
|
renderFillInactive: true,
|
|
9
|
-
fillAlpha: 0.
|
|
10
|
-
fillAlphaInactive: 0.
|
|
9
|
+
fillAlpha: 0.5,
|
|
10
|
+
fillAlphaInactive: 0.4,
|
|
11
11
|
outlineOpacity: 1,
|
|
12
12
|
outlineOpacityInactive: 0.85,
|
|
13
13
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import Representations from '../../../enums/SegmentationRepresentations';
|
|
1
|
+
import { getEnabledElementByViewportId, VolumeViewport, } from '@cornerstonejs/core';
|
|
3
2
|
import addLabelmapToElement from './addLabelmapToElement';
|
|
4
3
|
import removeLabelmapFromElement from './removeLabelmapFromElement';
|
|
5
|
-
import {
|
|
6
|
-
import { getActiveSegmentation } from '../../../stateManagement/segmentation/getActiveSegmentation';
|
|
4
|
+
import { getActiveSegmentation } from '../../../stateManagement/segmentation/activeSegmentation';
|
|
7
5
|
import { getColorLUT } from '../../../stateManagement/segmentation/getColorLUT';
|
|
8
6
|
import { getCurrentLabelmapImageIdForViewport } from '../../../stateManagement/segmentation/getCurrentLabelmapImageIdForViewport';
|
|
9
7
|
import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation';
|
|
@@ -12,6 +10,8 @@ import { computeAndAddLabelmapRepresentation } from '../../../stateManagement/se
|
|
|
12
10
|
import { getSegmentationActor } from '../../../stateManagement/segmentation/helpers';
|
|
13
11
|
import { segmentationStyle } from '../../../stateManagement/segmentation/SegmentationStyle';
|
|
14
12
|
import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
|
|
13
|
+
import { internalGetHiddenSegmentIndices } from '../../../stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices';
|
|
14
|
+
import { getActiveSegmentIndex } from '../../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
15
15
|
const MAX_NUMBER_COLORS = 255;
|
|
16
16
|
const labelMapConfigCache = new Map();
|
|
17
17
|
let polySegConversionInProgress = false;
|
|
@@ -35,13 +35,13 @@ async function render(viewport, representation) {
|
|
|
35
35
|
console.warn('No segmentation found for segmentationId: ', segmentationId);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
let labelmapData = segmentation.representationData[
|
|
38
|
+
let labelmapData = segmentation.representationData[SegmentationRepresentations.Labelmap];
|
|
39
39
|
let labelmapActor = getSegmentationActor(viewport.id, {
|
|
40
40
|
segmentationId,
|
|
41
41
|
type: SegmentationRepresentations.Labelmap,
|
|
42
42
|
});
|
|
43
43
|
if (!labelmapData &&
|
|
44
|
-
canComputeRequestedRepresentation(segmentationId,
|
|
44
|
+
canComputeRequestedRepresentation(segmentationId, SegmentationRepresentations.Labelmap) &&
|
|
45
45
|
!polySegConversionInProgress) {
|
|
46
46
|
polySegConversionInProgress = true;
|
|
47
47
|
labelmapData = await computeAndAddLabelmapRepresentation(segmentationId, {
|
|
@@ -84,27 +84,29 @@ async function render(viewport, representation) {
|
|
|
84
84
|
}
|
|
85
85
|
function _setLabelmapColorAndOpacity(viewportId, labelmapActor, segmentationRepresentation) {
|
|
86
86
|
const { segmentationId } = segmentationRepresentation;
|
|
87
|
-
const { cfun, ofun
|
|
87
|
+
const { cfun, ofun } = segmentationRepresentation.config;
|
|
88
|
+
const { colorLUTIndex } = segmentationRepresentation;
|
|
88
89
|
const activeSegmentation = getActiveSegmentation(viewportId);
|
|
89
90
|
const isActiveLabelmap = activeSegmentation?.segmentationId === segmentationId;
|
|
90
|
-
const
|
|
91
|
+
const labelmapStyle = segmentationStyle.getStyle({
|
|
91
92
|
viewportId,
|
|
92
|
-
type:
|
|
93
|
+
type: SegmentationRepresentations.Labelmap,
|
|
93
94
|
segmentationId,
|
|
94
95
|
});
|
|
96
|
+
const renderInactiveSegmentations = segmentationStyle.getRenderInactiveSegmentations(viewportId);
|
|
95
97
|
const colorLUT = getColorLUT(colorLUTIndex);
|
|
96
98
|
const numColors = Math.min(256, colorLUT.length);
|
|
97
99
|
const { outlineWidth, renderOutline, outlineOpacity, activeSegmentOutlineWidthDelta, } = _getLabelmapConfig(labelmapStyle, isActiveLabelmap);
|
|
98
|
-
const segmentsHidden =
|
|
100
|
+
const segmentsHidden = internalGetHiddenSegmentIndices(viewportId, {
|
|
99
101
|
segmentationId,
|
|
100
|
-
type:
|
|
102
|
+
type: SegmentationRepresentations.Labelmap,
|
|
101
103
|
});
|
|
102
104
|
for (let i = 0; i < numColors; i++) {
|
|
103
105
|
const segmentIndex = i;
|
|
104
106
|
const segmentColor = colorLUT[segmentIndex];
|
|
105
|
-
const
|
|
107
|
+
const perSegmentStyle = segmentationStyle.getStyle({
|
|
106
108
|
viewportId,
|
|
107
|
-
type:
|
|
109
|
+
type: SegmentationRepresentations.Labelmap,
|
|
108
110
|
segmentationId,
|
|
109
111
|
segmentIndex,
|
|
110
112
|
});
|
|
@@ -116,7 +118,7 @@ function _setLabelmapColorAndOpacity(viewportId, labelmapActor, segmentationRepr
|
|
|
116
118
|
renderOutline,
|
|
117
119
|
segmentColor,
|
|
118
120
|
outlineWidth,
|
|
119
|
-
segmentsHidden,
|
|
121
|
+
segmentsHidden: segmentsHidden,
|
|
120
122
|
cfun,
|
|
121
123
|
ofun,
|
|
122
124
|
});
|
|
@@ -140,22 +142,29 @@ function _setLabelmapColorAndOpacity(viewportId, labelmapActor, segmentationRepr
|
|
|
140
142
|
ofun.setClamping(false);
|
|
141
143
|
labelmapActor.getProperty().setScalarOpacity(0, ofun);
|
|
142
144
|
labelmapActor.getProperty().setInterpolationTypeToNearest();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
if (renderOutline) {
|
|
146
|
+
labelmapActor.getProperty().setUseLabelOutline(renderOutline);
|
|
147
|
+
labelmapActor.getProperty().setLabelOutlineOpacity(outlineOpacity);
|
|
148
|
+
const activeSegmentIndex = getActiveSegmentIndex(segmentationRepresentation.segmentationId);
|
|
149
|
+
const outlineWidths = new Array(numColors - 1);
|
|
150
|
+
for (let i = 1; i < numColors; i++) {
|
|
151
|
+
const isHidden = segmentsHidden.has(i);
|
|
152
|
+
if (isHidden) {
|
|
153
|
+
outlineWidths[i - 1] = 0;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
outlineWidths[i - 1] =
|
|
157
|
+
i === activeSegmentIndex
|
|
158
|
+
? outlineWidth + activeSegmentOutlineWidthDelta
|
|
159
|
+
: outlineWidth;
|
|
152
160
|
}
|
|
153
|
-
outlineWidths
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
labelmapActor.getProperty().setLabelOutlineThickness(outlineWidths);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
labelmapActor
|
|
165
|
+
.getProperty()
|
|
166
|
+
.setLabelOutlineThickness(new Array(numColors - 1).fill(0));
|
|
157
167
|
}
|
|
158
|
-
labelmapActor.getProperty().setLabelOutlineThickness(outlineWidths);
|
|
159
168
|
const visible = isActiveLabelmap || renderInactiveSegmentations;
|
|
160
169
|
labelmapActor.setVisibility(visible);
|
|
161
170
|
}
|
|
@@ -169,7 +178,7 @@ function _getLabelmapConfig(labelmapConfig, isActiveLabelmap, segmentsLabelmapCo
|
|
|
169
178
|
? configToUse.fillAlpha
|
|
170
179
|
: configToUse.fillAlphaInactive;
|
|
171
180
|
const outlineWidth = isActiveLabelmap
|
|
172
|
-
? configToUse.
|
|
181
|
+
? configToUse.outlineWidth
|
|
173
182
|
: configToUse.outlineWidthInactive;
|
|
174
183
|
const renderFill = isActiveLabelmap
|
|
175
184
|
? configToUse.renderFill
|
|
@@ -5,7 +5,7 @@ import addOrUpdateSurfaceToElement from './addOrUpdateSurfaceToElement';
|
|
|
5
5
|
import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation';
|
|
6
6
|
import { getColorLUT } from '../../../stateManagement/segmentation/getColorLUT';
|
|
7
7
|
import { canComputeRequestedRepresentation } from '../../../stateManagement/segmentation/polySeg/canComputeRequestedRepresentation';
|
|
8
|
-
import { computeAndAddSurfaceRepresentation } from '../../../stateManagement/segmentation/polySeg';
|
|
8
|
+
import { computeAndAddSurfaceRepresentation } from '../../../stateManagement/segmentation/polySeg/Surface/computeAndAddSurfaceRepresentation';
|
|
9
9
|
function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
|
|
10
10
|
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
11
11
|
if (!enabledElement) {
|
|
@@ -41,7 +41,7 @@ async function render(viewport, representation) {
|
|
|
41
41
|
if (!geometryIds?.size) {
|
|
42
42
|
console.warn(`No Surfaces found for segmentationId ${segmentationId}. Skipping render.`);
|
|
43
43
|
}
|
|
44
|
-
const colorLUTIndex = representation
|
|
44
|
+
const { colorLUTIndex } = representation;
|
|
45
45
|
const colorLUT = getColorLUT(colorLUTIndex);
|
|
46
46
|
const surfaces = [];
|
|
47
47
|
geometryIds.forEach((geometryId, segmentIndex) => {
|
|
@@ -132,10 +132,10 @@ class BrushTool extends BaseTool {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
this.previewCallback = () => {
|
|
135
|
+
this._previewData.timer = null;
|
|
135
136
|
if (this._previewData.preview) {
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
|
-
this._previewData.timer = null;
|
|
139
139
|
this._previewData.preview = this.applyActiveStrategyCallback(getEnabledElement(this._previewData.element), this.getOperationData(this._previewData.element), StrategyCallbacks.Preview);
|
|
140
140
|
};
|
|
141
141
|
this._dragCallback = (evt) => {
|
|
@@ -317,6 +317,9 @@ class BrushTool extends BaseTool {
|
|
|
317
317
|
}
|
|
318
318
|
const { segmentationId } = activeRepresentation;
|
|
319
319
|
const segmentIndex = getActiveSegmentIndex(segmentationId);
|
|
320
|
+
if (!segmentIndex) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
320
323
|
const segmentColor = getSegmentIndexColor(viewportId, segmentationId, segmentIndex);
|
|
321
324
|
return {
|
|
322
325
|
segmentIndex,
|
|
@@ -38,8 +38,8 @@ export default class BrushStrategy {
|
|
|
38
38
|
this._fill.forEach((func) => func(initializedData));
|
|
39
39
|
const { segmentationVoxelManager, previewVoxelManager, previewSegmentIndex, } = initializedData;
|
|
40
40
|
triggerSegmentationDataModified(initializedData.segmentationId, segmentationVoxelManager.getArrayOfModifiedSlices());
|
|
41
|
-
segmentationVoxelManager.resetModifiedSlices();
|
|
42
41
|
if (!previewSegmentIndex || !previewVoxelManager.modifiedSlices.size) {
|
|
42
|
+
segmentationVoxelManager.resetModifiedSlices();
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
return initializedData.preview || initializedData;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
outlineWidthActive?: number;
|
|
4
|
-
outlineWidthInactive?: number;
|
|
1
|
+
export type BaseContourStyle = {
|
|
2
|
+
outlineWidth?: number;
|
|
5
3
|
outlineOpacity?: number;
|
|
6
|
-
|
|
7
|
-
outlineDashActive?: string;
|
|
8
|
-
outlineDashInactive?: string;
|
|
4
|
+
outlineDash?: string;
|
|
9
5
|
activeSegmentOutlineWidthDelta?: number;
|
|
10
|
-
outlineDashAutoGenerated?: string;
|
|
11
6
|
renderOutline?: boolean;
|
|
12
7
|
renderFill?: boolean;
|
|
13
8
|
fillAlpha?: number;
|
|
9
|
+
};
|
|
10
|
+
export type InactiveContourStyle = {
|
|
11
|
+
outlineWidthInactive?: number;
|
|
12
|
+
outlineOpacityInactive?: number;
|
|
13
|
+
outlineDashInactive?: string;
|
|
14
14
|
fillAlphaInactive?: number;
|
|
15
|
+
renderOutlineInactive?: boolean;
|
|
16
|
+
renderFillInactive?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type AutoGeneratedContourStyle = {
|
|
19
|
+
outlineWidthAutoGenerated?: number;
|
|
20
|
+
outlineDashAutoGenerated?: string;
|
|
15
21
|
fillAlphaAutoGenerated?: number;
|
|
16
22
|
};
|
|
23
|
+
export type ContourStyle = BaseContourStyle & InactiveContourStyle & AutoGeneratedContourStyle;
|
|
17
24
|
export type ContourSegmentationData = {
|
|
18
25
|
geometryIds?: string[];
|
|
19
26
|
annotationUIDsMap?: Map<number, Set<string>>;
|
|
@@ -111,15 +111,21 @@ type SegmentationDataModifiedEventDetail = {
|
|
|
111
111
|
};
|
|
112
112
|
type SegmentationRenderedEventDetail = {
|
|
113
113
|
viewportId: string;
|
|
114
|
+
segmentationId: string;
|
|
115
|
+
type: string;
|
|
114
116
|
};
|
|
115
117
|
type SegmentationRepresentationModifiedEventDetail = {
|
|
116
118
|
segmentationId: string;
|
|
119
|
+
type: string;
|
|
120
|
+
viewportId: string;
|
|
117
121
|
};
|
|
118
122
|
type SegmentationRemovedEventDetail = {
|
|
119
123
|
segmentationId: string;
|
|
120
124
|
};
|
|
121
125
|
type SegmentationRepresentationRemovedEventDetail = {
|
|
122
126
|
segmentationId: string;
|
|
127
|
+
type: string;
|
|
128
|
+
viewportId: string;
|
|
123
129
|
};
|
|
124
130
|
type SegmentationModifiedEventDetail = {
|
|
125
131
|
segmentationId: string;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type BaseLabelmapStyle = {
|
|
2
2
|
renderOutline?: boolean;
|
|
3
|
-
|
|
4
|
-
outlineWidthActive?: number;
|
|
5
|
-
outlineWidthInactive?: number;
|
|
3
|
+
outlineWidth?: number;
|
|
6
4
|
activeSegmentOutlineWidthDelta?: number;
|
|
7
5
|
renderFill?: boolean;
|
|
8
|
-
renderFillInactive?: boolean;
|
|
9
6
|
fillAlpha?: number;
|
|
10
|
-
fillAlphaInactive?: number;
|
|
11
7
|
outlineOpacity?: number;
|
|
8
|
+
};
|
|
9
|
+
export type InactiveLabelmapStyle = {
|
|
10
|
+
renderOutlineInactive?: boolean;
|
|
11
|
+
outlineWidthInactive?: number;
|
|
12
|
+
renderFillInactive?: boolean;
|
|
13
|
+
fillAlphaInactive?: number;
|
|
12
14
|
outlineOpacityInactive?: number;
|
|
13
15
|
};
|
|
16
|
+
export type LabelmapStyle = BaseLabelmapStyle & InactiveLabelmapStyle;
|
|
14
17
|
export type LabelmapSegmentationDataVolume = {
|
|
15
18
|
volumeId: string;
|
|
16
19
|
referencedVolumeId?: string;
|
|
@@ -11,48 +11,52 @@ export type RepresentationsData = {
|
|
|
11
11
|
[Enums.SegmentationRepresentations.Surface]?: SurfaceSegmentationData;
|
|
12
12
|
};
|
|
13
13
|
export type RepresentationData = LabelmapSegmentationData | ContourSegmentationData | SurfaceSegmentationData;
|
|
14
|
-
export type
|
|
15
|
-
|
|
14
|
+
export type Segment = {
|
|
15
|
+
segmentIndex: number;
|
|
16
16
|
label: string;
|
|
17
|
-
|
|
18
|
-
segmentsLocked: Set<number>;
|
|
17
|
+
locked: boolean;
|
|
19
18
|
cachedStats: {
|
|
20
|
-
[key: string]:
|
|
19
|
+
[key: string]: unknown;
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
active: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type Segmentation = {
|
|
24
|
+
segmentationId: string;
|
|
25
|
+
label: string;
|
|
26
|
+
segments: {
|
|
27
|
+
[segmentIndex: number]: Segment;
|
|
24
28
|
};
|
|
25
29
|
representationData: RepresentationsData;
|
|
26
30
|
};
|
|
27
|
-
type
|
|
28
|
-
colorLUTIndex: number;
|
|
29
|
-
};
|
|
30
|
-
export type LabelmapRenderingConfig = BaseRenderingConfig & {
|
|
31
|
+
export type LabelmapRenderingConfig = {
|
|
31
32
|
cfun: vtkColorTransferFunction;
|
|
32
33
|
ofun: vtkPiecewiseFunction;
|
|
33
34
|
};
|
|
34
|
-
export type ContourRenderingConfig =
|
|
35
|
-
export type SurfaceRenderingConfig =
|
|
35
|
+
export type ContourRenderingConfig = {};
|
|
36
|
+
export type SurfaceRenderingConfig = {};
|
|
36
37
|
export type RenderingConfig = LabelmapRenderingConfig | ContourRenderingConfig | SurfaceRenderingConfig;
|
|
37
38
|
type BaseSegmentationRepresentation = {
|
|
39
|
+
colorLUTIndex: number;
|
|
38
40
|
segmentationId: string;
|
|
39
41
|
type: Enums.SegmentationRepresentations;
|
|
40
42
|
visible: boolean;
|
|
41
43
|
active: boolean;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
segments: {
|
|
45
|
+
[segmentIndex: number]: {
|
|
46
|
+
visible: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
46
49
|
};
|
|
47
|
-
export type LabelmapRepresentation =
|
|
50
|
+
export type LabelmapRepresentation = BaseSegmentationRepresentation & {
|
|
48
51
|
config: LabelmapRenderingConfig;
|
|
49
52
|
};
|
|
50
|
-
export type ContourRepresentation =
|
|
53
|
+
export type ContourRepresentation = BaseSegmentationRepresentation & {
|
|
51
54
|
config: ContourRenderingConfig;
|
|
52
55
|
};
|
|
53
|
-
export type SurfaceRepresentation =
|
|
56
|
+
export type SurfaceRepresentation = BaseSegmentationRepresentation & {
|
|
54
57
|
config: SurfaceRenderingConfig;
|
|
55
58
|
};
|
|
59
|
+
export type SegmentationRepresentation = LabelmapRepresentation | ContourRepresentation | SurfaceRepresentation;
|
|
56
60
|
export type SegmentationState = {
|
|
57
61
|
colorLUT: Types.ColorLUT[];
|
|
58
62
|
segmentations: Segmentation[];
|
|
@@ -66,12 +70,18 @@ export type SegmentationPublicInput = {
|
|
|
66
70
|
type: Enums.SegmentationRepresentations;
|
|
67
71
|
data?: RepresentationData;
|
|
68
72
|
};
|
|
73
|
+
config?: {
|
|
74
|
+
segments?: {
|
|
75
|
+
[segmentIndex: number]: Partial<Segment>;
|
|
76
|
+
};
|
|
77
|
+
label?: string;
|
|
78
|
+
};
|
|
69
79
|
};
|
|
70
80
|
export type RepresentationPublicInput = {
|
|
71
81
|
segmentationId: string;
|
|
72
82
|
type?: Enums.SegmentationRepresentations;
|
|
73
83
|
config?: {
|
|
74
|
-
|
|
84
|
+
colorLUTOrIndex?: Types.ColorLUT[] | number;
|
|
75
85
|
};
|
|
76
86
|
};
|
|
77
87
|
export {};
|
|
@@ -2,7 +2,6 @@ import type { Annotation, Annotations, AnnotationState, GroupSpecificAnnotations
|
|
|
2
2
|
import type { ContourAnnotationData, ContourAnnotation } from './ContourAnnotation';
|
|
3
3
|
import type { ContourSegmentationAnnotationData, ContourSegmentationAnnotation } from './ContourSegmentationAnnotation';
|
|
4
4
|
import type * as EventTypes from './EventTypes';
|
|
5
|
-
import type * as LabelmapTypes from './LabelmapTypes';
|
|
6
5
|
import type IPoints from './IPoints';
|
|
7
6
|
import type ITouchPoints from './ITouchPoints';
|
|
8
7
|
import type IDistance from './IDistance';
|
|
@@ -22,12 +21,12 @@ import type ScrollOptions from './ScrollOptions';
|
|
|
22
21
|
import type BoundsIJK from './BoundsIJK';
|
|
23
22
|
import type SVGDrawingHelper from './SVGDrawingHelper';
|
|
24
23
|
import type * as CINETypes from './CINETypes';
|
|
25
|
-
import type { RepresentationData, RepresentationsData, Segmentation, SegmentationState } from './SegmentationStateTypes';
|
|
24
|
+
import type { RepresentationData, RepresentationsData, Segmentation, Segment, SegmentationPublicInput, SegmentationRepresentation, SegmentationState } from './SegmentationStateTypes';
|
|
26
25
|
import type { ISculptToolShape } from './ISculptToolShape';
|
|
27
26
|
import type ISynchronizerEventHandler from './ISynchronizerEventHandler';
|
|
28
27
|
import type { FloodFillGetter, FloodFillOptions, FloodFillResult } from './FloodFillTypes';
|
|
29
28
|
import type IToolClassReference from './IToolClassReference';
|
|
30
|
-
import type { ContourSegmentationData } from './ContourTypes';
|
|
29
|
+
import type { ContourSegmentationData, ContourStyle } from './ContourTypes';
|
|
31
30
|
import type IAnnotationManager from './IAnnotationManager';
|
|
32
31
|
import type AnnotationGroupSelector from './AnnotationGroupSelector';
|
|
33
32
|
import type AnnotationRenderContext from './AnnotationRenderContext';
|
|
@@ -47,4 +46,7 @@ import type { SplineProps } from './SplineProps';
|
|
|
47
46
|
import type { BidirectionalData } from '../utilities/segmentation/createBidirectionalToolData';
|
|
48
47
|
import type { PolySegConversionOptions } from './PolySeg';
|
|
49
48
|
import type { IBaseTool } from './IBaseTool';
|
|
50
|
-
|
|
49
|
+
import type { RepresentationStyle } from './../stateManagement/segmentation/SegmentationStyle';
|
|
50
|
+
import type { LabelmapStyle } from './LabelmapTypes';
|
|
51
|
+
import type { SurfaceStyle } from './SurfaceTypes';
|
|
52
|
+
export type { Annotation, Annotations, ContourAnnotationData, ContourAnnotation, ContourSegmentationAnnotationData, ContourSegmentationAnnotation, BidirectionalData, CanvasCoordinates, IAnnotationManager, InterpolationViewportData, ImageInterpolationData, GroupSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, AnnotationGroupSelector, AnnotationRenderContext, PlanarBoundingBox, ToolProps, PublicToolProps, ToolConfiguration, EventTypes, IPoints, ITouchPoints, IDistance, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, ToolAction, IToolGroup, IToolClassReference, ISynchronizerEventHandler, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationRepresentation, SegmentationState, RepresentationData, RepresentationsData, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, BoundsIJK, SVGDrawingHelper, FloodFillResult, FloodFillGetter, FloodFillOptions, ContourSegmentationData, ISculptToolShape, Statistics, NamedStatistics, LabelmapToolOperationData, LabelmapToolOperationDataStack, LabelmapToolOperationDataVolume, CardinalSplineProps, ClosestControlPoint, ClosestPoint, ClosestSplinePoint, ControlPointInfo, ISpline, SplineCurveSegment, SplineLineSegment, SplineProps, PolySegConversionOptions, IBaseTool, RepresentationStyle, Segment, SegmentationPublicInput, LabelmapStyle, ContourStyle, SurfaceStyle, };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
2
|
import { Enums } from '@cornerstonejs/core';
|
|
3
|
-
declare function generateImageFromTimeData(dynamicVolume: Types.IDynamicImageVolume, operation: Enums.GenerateImageType,
|
|
4
|
-
|
|
3
|
+
declare function generateImageFromTimeData(dynamicVolume: Types.IDynamicImageVolume, operation: Enums.GenerateImageType, options: {
|
|
4
|
+
frameNumbers?: number[];
|
|
5
|
+
}): Float32Array;
|
|
6
|
+
declare function updateVolumeFromTimeData(dynamicVolume: Types.IDynamicImageVolume, operation: Enums.GenerateImageType, options: {
|
|
7
|
+
frameNumbers?: number[];
|
|
8
|
+
targetVolume: Types.IImageVolume;
|
|
9
|
+
}): void;
|
|
10
|
+
export { generateImageFromTimeData, updateVolumeFromTimeData };
|