@cornerstonejs/tools 1.15.1 → 1.16.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/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js +5 -6
- package/dist/cjs/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
- package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.d.ts +2 -2
- package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.js +4 -4
- package/dist/cjs/utilities/segmentation/brushSizeForToolGroup.js.map +1 -1
- package/dist/cjs/utilities/segmentation/utilities.d.ts +1 -2
- package/dist/cjs/utilities/segmentation/utilities.js +4 -1
- package/dist/cjs/utilities/segmentation/utilities.js.map +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js.map +1 -1
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js +5 -6
- package/dist/esm/tools/displayTools/SegmentationDisplayTool.js.map +1 -1
- package/dist/esm/utilities/segmentation/brushSizeForToolGroup.d.ts +2 -2
- package/dist/esm/utilities/segmentation/brushSizeForToolGroup.js +4 -4
- package/dist/esm/utilities/segmentation/brushSizeForToolGroup.js.map +1 -1
- package/dist/esm/utilities/segmentation/utilities.d.ts +1 -2
- package/dist/esm/utilities/segmentation/utilities.js +4 -1
- package/dist/esm/utilities/segmentation/utilities.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +3 -0
- package/src/tools/displayTools/SegmentationDisplayTool.ts +12 -18
- package/src/utilities/segmentation/brushSizeForToolGroup.ts +22 -4
- package/src/utilities/segmentation/utilities.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cornerstonejs/core": "^1.
|
|
32
|
+
"@cornerstonejs/core": "^1.16.0",
|
|
33
33
|
"lodash.clonedeep": "4.5.0",
|
|
34
34
|
"lodash.get": "^4.4.2"
|
|
35
35
|
},
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"type": "individual",
|
|
53
53
|
"url": "https://ohif.org/donate"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e36741ef4ad046104fc63c1169073b48cbef8856"
|
|
56
56
|
}
|
|
@@ -276,6 +276,9 @@ function _setLabelmapColorAndOpacity(
|
|
|
276
276
|
isActiveLabelmap
|
|
277
277
|
);
|
|
278
278
|
|
|
279
|
+
// Todo: the below loop probably can be optimized so that we don't hit it
|
|
280
|
+
// unless a config has changed. Right now we get into the following loop
|
|
281
|
+
// even for brush drawing which does not makes sense
|
|
279
282
|
for (let i = 0; i < numColors; i++) {
|
|
280
283
|
const segmentIndex = i;
|
|
281
284
|
const segmentColor = colorLUT[segmentIndex];
|
|
@@ -143,26 +143,20 @@ class SegmentationDisplayTool extends BaseTool {
|
|
|
143
143
|
const config = this._getMergedRepresentationsConfig(toolGroupId);
|
|
144
144
|
|
|
145
145
|
const viewportsRenderList = [];
|
|
146
|
+
const display =
|
|
147
|
+
representation.type === Representations.Labelmap
|
|
148
|
+
? labelmapDisplay
|
|
149
|
+
: contourDisplay;
|
|
150
|
+
|
|
146
151
|
for (const viewport of toolGroupViewports) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
config
|
|
153
|
-
)
|
|
154
|
-
);
|
|
155
|
-
} else if (representation.type == Representations.Contour) {
|
|
156
|
-
viewportsRenderList.push(
|
|
157
|
-
contourDisplay.render(
|
|
158
|
-
viewport as Types.IVolumeViewport,
|
|
159
|
-
representation,
|
|
160
|
-
config
|
|
161
|
-
)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
152
|
+
const renderedViewport = display.render(
|
|
153
|
+
viewport as Types.IVolumeViewport,
|
|
154
|
+
representation,
|
|
155
|
+
config
|
|
156
|
+
);
|
|
165
157
|
|
|
158
|
+
viewportsRenderList.push(renderedViewport);
|
|
159
|
+
}
|
|
166
160
|
return viewportsRenderList;
|
|
167
161
|
}
|
|
168
162
|
);
|
|
@@ -4,9 +4,17 @@ import triggerAnnotationRenderForViewportIds from '../triggerAnnotationRenderFor
|
|
|
4
4
|
import { getRenderingEngine } from '@cornerstonejs/core';
|
|
5
5
|
import getBrushToolInstances from './utilities';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Sets the brush size for all brush-based tools in a given tool group.
|
|
9
|
+
* @param toolGroupId - The ID of the tool group to set the brush size for.
|
|
10
|
+
* @param brushSize - The new brush size to set.
|
|
11
|
+
* @param toolName - The name of the specific tool to set the brush size for (optional)
|
|
12
|
+
* If not provided, all brush-based tools in the tool group will be affected.
|
|
13
|
+
*/
|
|
7
14
|
export function setBrushSizeForToolGroup(
|
|
8
15
|
toolGroupId: string,
|
|
9
|
-
brushSize: number
|
|
16
|
+
brushSize: number,
|
|
17
|
+
toolName?: string
|
|
10
18
|
): void {
|
|
11
19
|
const toolGroup = getToolGroup(toolGroupId);
|
|
12
20
|
|
|
@@ -14,7 +22,7 @@ export function setBrushSizeForToolGroup(
|
|
|
14
22
|
return;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
const brushBasedToolInstances = getBrushToolInstances(toolGroupId);
|
|
25
|
+
const brushBasedToolInstances = getBrushToolInstances(toolGroupId, toolName);
|
|
18
26
|
|
|
19
27
|
brushBasedToolInstances.forEach((tool: BrushTool) => {
|
|
20
28
|
tool.configuration.brushSize = brushSize;
|
|
@@ -45,7 +53,17 @@ export function setBrushSizeForToolGroup(
|
|
|
45
53
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIds);
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Gets the brush size for the first brush-based tool instance in a given tool group.
|
|
58
|
+
* @param toolGroupId - The ID of the tool group to get the brush size for.
|
|
59
|
+
* @param toolName - The name of the specific tool to get the brush size for (Optional)
|
|
60
|
+
* If not provided, the first brush-based tool instance in the tool group will be used.
|
|
61
|
+
* @returns The brush size of the selected tool instance, or undefined if no brush-based tool instance is found.
|
|
62
|
+
*/
|
|
63
|
+
export function getBrushSizeForToolGroup(
|
|
64
|
+
toolGroupId: string,
|
|
65
|
+
toolName?: string
|
|
66
|
+
): void {
|
|
49
67
|
const toolGroup = getToolGroup(toolGroupId);
|
|
50
68
|
|
|
51
69
|
if (toolGroup === undefined) {
|
|
@@ -58,7 +76,7 @@ export function getBrushSizeForToolGroup(toolGroupId: string): void {
|
|
|
58
76
|
return;
|
|
59
77
|
}
|
|
60
78
|
|
|
61
|
-
const brushBasedToolInstances = getBrushToolInstances(toolGroupId);
|
|
79
|
+
const brushBasedToolInstances = getBrushToolInstances(toolGroupId, toolName);
|
|
62
80
|
|
|
63
81
|
// one is enough as they share the same brush size
|
|
64
82
|
const brushToolInstance = brushBasedToolInstances[0];
|
|
@@ -10,7 +10,10 @@ export type ThresholdInformation = {
|
|
|
10
10
|
upper: number;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export default function getBrushToolInstances(
|
|
13
|
+
export default function getBrushToolInstances(
|
|
14
|
+
toolGroupId: string,
|
|
15
|
+
toolName?: string
|
|
16
|
+
) {
|
|
14
17
|
const toolGroup = getToolGroup(toolGroupId);
|
|
15
18
|
|
|
16
19
|
if (toolGroup === undefined) {
|
|
@@ -23,6 +26,10 @@ export default function getBrushToolInstances(toolGroupId) {
|
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
if (toolName && toolInstances[toolName]) {
|
|
30
|
+
return [toolInstances[toolName]];
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
// For each tool that has BrushTool as base class, set the brush size.
|
|
27
34
|
const brushBasedToolInstances = Object.values(toolInstances).filter(
|
|
28
35
|
(toolInstance) => toolInstance instanceof BrushTool
|