@cornerstonejs/tools 5.4.1 → 5.4.3
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.
|
@@ -11,14 +11,14 @@ export default function drawLine(svgDrawingHelper, annotationUID, lineUID, start
|
|
|
11
11
|
const svgNodeHash = _getHash(annotationUID, 'line', lineUID);
|
|
12
12
|
const existingLine = svgDrawingHelper.getSvgNode(svgNodeHash);
|
|
13
13
|
const layerId = svgDrawingHelper.svgLayerElement.id;
|
|
14
|
-
const dropShadowStyle = shadow ? `
|
|
14
|
+
const dropShadowStyle = shadow ? `url(#shadow-${layerId});` : '';
|
|
15
15
|
const attributes = {
|
|
16
16
|
x1: `${start[0]}`,
|
|
17
17
|
y1: `${start[1]}`,
|
|
18
18
|
x2: `${end[0]}`,
|
|
19
19
|
y2: `${end[1]}`,
|
|
20
20
|
stroke: textBoxLinkLineColor || color,
|
|
21
|
-
|
|
21
|
+
filter: dropShadowStyle,
|
|
22
22
|
'stroke-width': strokeWidth,
|
|
23
23
|
'stroke-dasharray': lineDash,
|
|
24
24
|
'marker-start': markerStartId ? `url(#${markerStartId})` : '',
|
|
@@ -11,6 +11,7 @@ import { getSegmentBinding } from '../../../stateManagement/segmentation/helpers
|
|
|
11
11
|
import { segmentationStyle } from '../../../stateManagement/segmentation/SegmentationStyle.js';
|
|
12
12
|
import { getLabelmapForActorReference } from './volumeLabelmapImageMapper.js';
|
|
13
13
|
const actorTransferFunctions = new WeakMap();
|
|
14
|
+
const lastAppliedLabelmapStyle = new WeakMap();
|
|
14
15
|
const MAX_NUMBER_COLORS = 255;
|
|
15
16
|
function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentationRepresentation) {
|
|
16
17
|
const { segmentationId } = segmentationRepresentation;
|
|
@@ -49,9 +50,6 @@ function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentation
|
|
|
49
50
|
type: SegmentationRepresentations.Labelmap,
|
|
50
51
|
});
|
|
51
52
|
const labelmapActor = labelmapActorEntry.actor;
|
|
52
|
-
const { cfun, ofun } = getOrCreateTransferFunctions(labelmapActor);
|
|
53
|
-
cfun.removeAllPoints();
|
|
54
|
-
ofun.removeAllPoints();
|
|
55
53
|
const colorNodes = [
|
|
56
54
|
{ x: 0, r: 0, g: 0, b: 0, midpoint: 0.5, sharpness: 1.0 },
|
|
57
55
|
];
|
|
@@ -96,6 +94,41 @@ function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentation
|
|
|
96
94
|
});
|
|
97
95
|
}
|
|
98
96
|
});
|
|
97
|
+
const activeSegmentIndex = getActiveSegmentIndex(segmentationRepresentation.segmentationId);
|
|
98
|
+
const outlineWidths = new Array(numColors - 1).fill(0);
|
|
99
|
+
if (renderOutline) {
|
|
100
|
+
labelValueEntries.forEach(({ labelValue, segmentIndex }) => {
|
|
101
|
+
if (segmentsHidden.has(segmentIndex)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
outlineWidths[labelValue - 1] =
|
|
105
|
+
segmentIndex === activeSegmentIndex
|
|
106
|
+
? outlineWidth + activeSegmentOutlineWidthDelta
|
|
107
|
+
: outlineWidth;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const visible = isActiveLabelmap || renderInactiveSegmentations;
|
|
111
|
+
const useImageSliceProperties = labelmapActorEntry.actorMapper?.renderMode === ActorRenderMode.VTK_IMAGE ||
|
|
112
|
+
labelmapActorEntry.actorMapper?.renderMode ===
|
|
113
|
+
ActorRenderMode.VTK_VOLUME_SLICE;
|
|
114
|
+
const { preLoad } = labelmapActor.get?.('preLoad') || { preLoad: null };
|
|
115
|
+
const styleSignature = JSON.stringify({
|
|
116
|
+
colorNodes,
|
|
117
|
+
opacityNodes,
|
|
118
|
+
renderOutline,
|
|
119
|
+
outlineOpacity,
|
|
120
|
+
outlineWidths,
|
|
121
|
+
visible,
|
|
122
|
+
useImageSliceProperties,
|
|
123
|
+
});
|
|
124
|
+
const canUseStyleCache = !preLoad;
|
|
125
|
+
if (canUseStyleCache &&
|
|
126
|
+
lastAppliedLabelmapStyle.get(labelmapActor) === styleSignature) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { cfun, ofun } = getOrCreateTransferFunctions(labelmapActor);
|
|
130
|
+
cfun.removeAllPoints();
|
|
131
|
+
ofun.removeAllPoints();
|
|
99
132
|
cfun.setNodes(colorNodes);
|
|
100
133
|
ofun.setNodes(opacityNodes);
|
|
101
134
|
ofun.setClamping(false);
|
|
@@ -103,7 +136,6 @@ function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentation
|
|
|
103
136
|
const labelmapMapper = actorMapper?.mapper
|
|
104
137
|
? actorMapper.mapper
|
|
105
138
|
: labelmapActor.getMapper();
|
|
106
|
-
const { preLoad } = labelmapActor.get?.('preLoad') || { preLoad: null };
|
|
107
139
|
if (preLoad) {
|
|
108
140
|
preLoad({ cfun, ofun, actor: labelmapActor });
|
|
109
141
|
}
|
|
@@ -112,9 +144,7 @@ function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentation
|
|
|
112
144
|
labelmapActor.getProperty().setScalarOpacity(0, ofun);
|
|
113
145
|
labelmapActor.getProperty().setInterpolationTypeToNearest();
|
|
114
146
|
}
|
|
115
|
-
if (
|
|
116
|
-
labelmapActorEntry.actorMapper?.renderMode ===
|
|
117
|
-
ActorRenderMode.VTK_VOLUME_SLICE) {
|
|
147
|
+
if (useImageSliceProperties) {
|
|
118
148
|
const imageSlice = labelmapActor;
|
|
119
149
|
imageSlice.setForceTranslucent(true);
|
|
120
150
|
imageSlice.setForceOpaque(false);
|
|
@@ -123,33 +153,24 @@ function setLabelmapColorAndOpacity(viewportId, labelmapActorEntry, segmentation
|
|
|
123
153
|
if (renderOutline) {
|
|
124
154
|
labelmapActor.getProperty().setUseLabelOutline(renderOutline);
|
|
125
155
|
labelmapActor.getProperty().setLabelOutlineOpacity(outlineOpacity);
|
|
126
|
-
const activeSegmentIndex = getActiveSegmentIndex(segmentationRepresentation.segmentationId);
|
|
127
|
-
const outlineWidths = new Array(numColors - 1).fill(0);
|
|
128
|
-
labelValueEntries.forEach(({ labelValue, segmentIndex }) => {
|
|
129
|
-
const isHidden = segmentsHidden.has(segmentIndex);
|
|
130
|
-
if (isHidden) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
outlineWidths[labelValue - 1] =
|
|
134
|
-
segmentIndex === activeSegmentIndex
|
|
135
|
-
? outlineWidth + activeSegmentOutlineWidthDelta
|
|
136
|
-
: outlineWidth;
|
|
137
|
-
});
|
|
138
156
|
labelmapActor.getProperty().setLabelOutlineThickness(outlineWidths);
|
|
139
157
|
labelmapActor.modified();
|
|
140
158
|
labelmapActor.getProperty().modified();
|
|
141
159
|
labelmapMapper?.modified?.();
|
|
142
160
|
}
|
|
143
161
|
else {
|
|
144
|
-
labelmapActor
|
|
145
|
-
.getProperty()
|
|
146
|
-
.setLabelOutlineThickness(new Array(numColors - 1).fill(0));
|
|
162
|
+
labelmapActor.getProperty().setLabelOutlineThickness(outlineWidths);
|
|
147
163
|
}
|
|
148
|
-
const visible = isActiveLabelmap || renderInactiveSegmentations;
|
|
149
164
|
labelmapActor.setVisibility(visible);
|
|
150
165
|
labelmapActor.modified();
|
|
151
166
|
labelmapActor.getProperty().modified();
|
|
152
167
|
labelmapMapper?.modified?.();
|
|
168
|
+
if (canUseStyleCache) {
|
|
169
|
+
lastAppliedLabelmapStyle.set(labelmapActor, styleSignature);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
lastAppliedLabelmapStyle.delete(labelmapActor);
|
|
173
|
+
}
|
|
153
174
|
}
|
|
154
175
|
function getOrCreateTransferFunctions(actor) {
|
|
155
176
|
const existing = actorTransferFunctions.get(actor);
|
|
@@ -141,14 +141,18 @@ class ColorbarCanvas {
|
|
|
141
141
|
const range = this._showFullImageRange ? this._imageRange : { ...voiRange };
|
|
142
142
|
let previousColorPoint = undefined;
|
|
143
143
|
let currentColorPoint = getColorPoint(0);
|
|
144
|
+
const minPosition = rgbPoints[0];
|
|
145
|
+
const maxPosition = rgbPoints[rgbPoints.length - 4];
|
|
146
|
+
const colormapRange = maxPosition - minPosition;
|
|
144
147
|
const incRawPixelValue = (range.upper - range.lower) / (maxValue - 1);
|
|
145
148
|
let rawPixelValue = range.lower;
|
|
146
149
|
for (let i = 0; i < maxValue; i++) {
|
|
147
150
|
const tVoiRange = (rawPixelValue - voiRange.lower) /
|
|
148
151
|
Math.abs(voiRange.upper - voiRange.lower);
|
|
152
|
+
const tColormapPosition = minPosition + tVoiRange * colormapRange;
|
|
149
153
|
if (currentColorPoint) {
|
|
150
154
|
for (let i = currentColorPoint.index; i < colorsCount; i++) {
|
|
151
|
-
if (
|
|
155
|
+
if (tColormapPosition <= currentColorPoint.position) {
|
|
152
156
|
break;
|
|
153
157
|
}
|
|
154
158
|
previousColorPoint = currentColorPoint;
|
|
@@ -163,7 +167,7 @@ class ColorbarCanvas {
|
|
|
163
167
|
normColor = [...previousColorPoint.color];
|
|
164
168
|
}
|
|
165
169
|
else {
|
|
166
|
-
const tColorRange = (
|
|
170
|
+
const tColorRange = (tColormapPosition - previousColorPoint.position) /
|
|
167
171
|
(currentColorPoint.position - previousColorPoint.position);
|
|
168
172
|
normColor = interpolateVec3(previousColorPoint.color, currentColorPoint.color, tColorRange);
|
|
169
173
|
}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.4.
|
|
1
|
+
export declare const version = "5.4.3";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.4.
|
|
1
|
+
export const version = '5.4.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.3",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -126,11 +126,11 @@
|
|
|
126
126
|
"lodash.get": "4.4.2"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@cornerstonejs/core": "5.4.
|
|
129
|
+
"@cornerstonejs/core": "5.4.3",
|
|
130
130
|
"canvas": "3.2.0"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|
|
133
|
-
"@cornerstonejs/core": "5.4.
|
|
133
|
+
"@cornerstonejs/core": "5.4.3",
|
|
134
134
|
"@kitware/vtk.js": "35.5.3",
|
|
135
135
|
"@types/d3-array": "3.2.1",
|
|
136
136
|
"@types/d3-interpolate": "3.0.4",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"type": "individual",
|
|
150
150
|
"url": "https://ohif.org/donate"
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "a2d8c6ebe29611f43742052902fec74f5664bc65"
|
|
153
153
|
}
|