@cornerstonejs/tools 1.68.3 → 1.70.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/eventListeners/keyboard/keyDownListener.js +1 -1
- package/dist/cjs/eventListeners/keyboard/keyDownListener.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/addSegmentations.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/store/state.js +2 -2
- package/dist/cjs/store/state.js.map +1 -1
- package/dist/cjs/synchronizers/callbacks/presentationViewSyncCallback.d.ts +2 -0
- package/dist/cjs/synchronizers/callbacks/presentationViewSyncCallback.js +16 -0
- package/dist/cjs/synchronizers/callbacks/presentationViewSyncCallback.js.map +1 -0
- package/dist/cjs/synchronizers/index.d.ts +2 -1
- package/dist/cjs/synchronizers/index.js +3 -1
- package/dist/cjs/synchronizers/index.js.map +1 -1
- package/dist/cjs/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts +3 -0
- package/dist/cjs/synchronizers/synchronizers/createPresentationViewSynchronizer.js +15 -0
- package/dist/cjs/synchronizers/synchronizers/createPresentationViewSynchronizer.js.map +1 -0
- package/dist/cjs/synchronizers/synchronizers/index.d.ts +2 -1
- package/dist/cjs/synchronizers/synchronizers/index.js +3 -1
- package/dist/cjs/synchronizers/synchronizers/index.js.map +1 -1
- package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +1 -1
- package/dist/cjs/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
- package/dist/cjs/tools/segmentation/BrushTool.d.ts +16 -1
- package/dist/cjs/tools/segmentation/BrushTool.js +6 -3
- package/dist/cjs/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/cjs/utilities/segmentation/createLabelmapVolumeForViewport.d.ts +8 -8
- package/dist/cjs/utilities/segmentation/createLabelmapVolumeForViewport.js +5 -2
- package/dist/cjs/utilities/segmentation/createLabelmapVolumeForViewport.js.map +1 -1
- package/dist/cjs/utilities/triggerAnnotationRender.js +0 -1
- package/dist/cjs/utilities/triggerAnnotationRender.js.map +1 -1
- package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
- package/dist/esm/eventListeners/keyboard/keyDownListener.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/addSegmentations.js +2 -2
- package/dist/esm/stateManagement/segmentation/addSegmentations.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/store/state.js +10 -2
- package/dist/esm/store/state.js.map +1 -1
- package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +13 -0
- package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js.map +1 -0
- package/dist/esm/synchronizers/index.js +2 -1
- package/dist/esm/synchronizers/index.js.map +1 -1
- package/dist/esm/synchronizers/synchronizers/createPresentationViewSynchronizer.js +9 -0
- package/dist/esm/synchronizers/synchronizers/createPresentationViewSynchronizer.js.map +1 -0
- package/dist/esm/synchronizers/synchronizers/index.js +2 -1
- package/dist/esm/synchronizers/synchronizers/index.js.map +1 -1
- package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js +1 -1
- package/dist/esm/tools/displayTools/Surface/addOrUpdateSurfaceToElement.js.map +1 -1
- package/dist/esm/tools/segmentation/BrushTool.js +6 -3
- package/dist/esm/tools/segmentation/BrushTool.js.map +1 -1
- package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +2 -2
- package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js.map +1 -1
- package/dist/esm/utilities/triggerAnnotationRender.js +0 -1
- package/dist/esm/utilities/triggerAnnotationRender.js.map +1 -1
- package/dist/types/store/state.d.ts.map +1 -1
- package/dist/types/synchronizers/callbacks/presentationViewSyncCallback.d.ts +3 -0
- package/dist/types/synchronizers/callbacks/presentationViewSyncCallback.d.ts.map +1 -0
- package/dist/types/synchronizers/index.d.ts +2 -1
- package/dist/types/synchronizers/index.d.ts.map +1 -1
- package/dist/types/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts +4 -0
- package/dist/types/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts.map +1 -0
- package/dist/types/synchronizers/synchronizers/index.d.ts +2 -1
- package/dist/types/synchronizers/synchronizers/index.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Surface/addOrUpdateSurfaceToElement.d.ts.map +1 -1
- package/dist/types/tools/segmentation/BrushTool.d.ts +16 -1
- package/dist/types/tools/segmentation/BrushTool.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/createLabelmapVolumeForViewport.d.ts +8 -8
- package/dist/types/utilities/segmentation/createLabelmapVolumeForViewport.d.ts.map +1 -1
- package/dist/types/utilities/triggerAnnotationRender.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +4 -4
- package/src/eventListeners/keyboard/keyDownListener.ts +2 -2
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +1 -1
- package/src/stateManagement/segmentation/addSegmentations.ts +2 -2
- package/src/store/ToolGroupManager/ToolGroup.ts +1 -1
- package/src/store/state.ts +10 -3
- package/src/synchronizers/callbacks/presentationViewSyncCallback.ts +36 -0
- package/src/synchronizers/callbacks/voiSyncCallback.ts +1 -1
- package/src/synchronizers/index.ts +2 -0
- package/src/synchronizers/synchronizers/createPresentationViewSynchronizer.ts +29 -0
- package/src/synchronizers/synchronizers/index.ts +2 -0
- package/src/tools/displayTools/Surface/addOrUpdateSurfaceToElement.ts +2 -1
- package/src/tools/segmentation/BrushTool.ts +19 -5
- package/src/utilities/segmentation/createLabelmapVolumeForViewport.ts +10 -10
- package/src/utilities/triggerAnnotationRender.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/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.70.0",
|
|
33
33
|
"@icr/polyseg-wasm": "0.4.0",
|
|
34
34
|
"@types/offscreencanvas": "2019.7.3",
|
|
35
35
|
"comlink": "^4.4.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@icr/polyseg-wasm": "0.4.0",
|
|
44
|
-
"@kitware/vtk.js": "
|
|
44
|
+
"@kitware/vtk.js": "30.3.1",
|
|
45
45
|
"@types/d3-array": "^3.0.4",
|
|
46
46
|
"@types/d3-interpolate": "^3.0.1",
|
|
47
47
|
"d3-array": "^3.2.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"type": "individual",
|
|
60
60
|
"url": "https://ohif.org/donate"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "00e347188b0b57854ddbefdfae220db42c4bf02f"
|
|
63
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
2
1
|
import { getEnabledElement, triggerEvent } from '@cornerstonejs/core';
|
|
2
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
3
3
|
import Events from '../../enums/Events';
|
|
4
4
|
import { KeyDownEventDetail, KeyUpEventDetail } from '../../types/EventTypes';
|
|
5
5
|
|
|
@@ -97,7 +97,7 @@ function _onKeyUp(evt: KeyboardEvent): void {
|
|
|
97
97
|
state.element.addEventListener('keydown', keyListener);
|
|
98
98
|
|
|
99
99
|
// Restore `state` to `defaultState`
|
|
100
|
-
state =
|
|
100
|
+
state = cloneDeep(defaultState);
|
|
101
101
|
triggerEvent(eventDetail.element, Events.KEY_UP, eventDetail);
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -450,7 +450,7 @@ export default class SegmentationStateManager {
|
|
|
450
450
|
console.warn('Color LUT table already exists, overwriting');
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
-
this.state.colorLUT[lutIndex] =
|
|
453
|
+
this.state.colorLUT[lutIndex] = cloneDeep(colorLUT);
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
2
2
|
import { SegmentationPublicInput } from '../../types/SegmentationStateTypes';
|
|
3
3
|
import { validateSegmentationInput } from './helpers';
|
|
4
4
|
import { addSegmentation as addSegmentationToState } from './segmentationState';
|
|
@@ -18,7 +18,7 @@ function addSegmentations(
|
|
|
18
18
|
validateSegmentationInput(segmentationInputArray);
|
|
19
19
|
|
|
20
20
|
segmentationInputArray.map((segInput) => {
|
|
21
|
-
const segmentationInput =
|
|
21
|
+
const segmentationInput = cloneDeep(segInput);
|
|
22
22
|
|
|
23
23
|
addSegmentationToState(segmentationInput);
|
|
24
24
|
});
|
package/src/store/state.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _cloneDeep from 'lodash.clonedeep';
|
|
2
|
-
|
|
3
1
|
import { IToolGroup, IToolClassReference } from '../types';
|
|
4
2
|
import Synchronizer from './SynchronizerManager/Synchronizer';
|
|
5
3
|
import svgNodeCache, { resetSvgNodeCache } from './svgNodeCache';
|
|
4
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
6
5
|
|
|
7
6
|
interface ICornerstoneTools3dState {
|
|
8
7
|
isInteractingWithTool: boolean;
|
|
@@ -46,7 +45,15 @@ let state: ICornerstoneTools3dState = {
|
|
|
46
45
|
|
|
47
46
|
function resetCornerstoneToolsState(): void {
|
|
48
47
|
resetSvgNodeCache();
|
|
49
|
-
state =
|
|
48
|
+
state = {
|
|
49
|
+
...cloneDeep({
|
|
50
|
+
...defaultState,
|
|
51
|
+
svgNodeCache: {},
|
|
52
|
+
}),
|
|
53
|
+
svgNodeCache: {
|
|
54
|
+
...defaultState.svgNodeCache,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
export {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getRenderingEngine, Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Synchronizer callback to synchronize the camera. Synchronization
|
|
5
|
+
*
|
|
6
|
+
* targetViewport.options.syncZoom set to false to not sync the zoom
|
|
7
|
+
* targetViewport.options.syncPan set to false to not sync the pan
|
|
8
|
+
|
|
9
|
+
* @param synchronizerInstance - The Instance of the Synchronizer
|
|
10
|
+
* @param sourceViewport - The list of IDs defining the source viewport.
|
|
11
|
+
* @param targetViewport - The list of IDs defining the target viewport, different
|
|
12
|
+
* from sourceViewport
|
|
13
|
+
*/
|
|
14
|
+
export default function presentationViewSyncCallback(
|
|
15
|
+
_synchronizerInstance,
|
|
16
|
+
sourceViewport: Types.IViewportId,
|
|
17
|
+
targetViewport: Types.IViewportId,
|
|
18
|
+
_sourceEvent,
|
|
19
|
+
options?: Types.ViewPresentationSelector
|
|
20
|
+
): void {
|
|
21
|
+
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
22
|
+
if (!renderingEngine) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`No RenderingEngine for Id: ${targetViewport.renderingEngineId}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
29
|
+
const sViewport = renderingEngine.getViewport(sourceViewport.viewportId);
|
|
30
|
+
|
|
31
|
+
const presentationView = sViewport.getViewPresentation(options);
|
|
32
|
+
|
|
33
|
+
tViewport.setView(null, presentationView);
|
|
34
|
+
|
|
35
|
+
tViewport.render();
|
|
36
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import createCameraPositionSynchronizer from './synchronizers/createCameraPositionSynchronizer';
|
|
2
|
+
import createPresentationViewSynchronizer from './synchronizers/createPresentationViewSynchronizer';
|
|
2
3
|
import createVOISynchronizer from './synchronizers/createVOISynchronizer';
|
|
3
4
|
import createZoomPanSynchronizer from './synchronizers/createZoomPanSynchronizer';
|
|
4
5
|
import createImageSliceSynchronizer from './synchronizers/createImageSliceSynchronizer';
|
|
@@ -9,6 +10,7 @@ const createStackImageSynchronizer = createImageSliceSynchronizer;
|
|
|
9
10
|
|
|
10
11
|
export {
|
|
11
12
|
createCameraPositionSynchronizer,
|
|
13
|
+
createPresentationViewSynchronizer,
|
|
12
14
|
createVOISynchronizer,
|
|
13
15
|
createZoomPanSynchronizer,
|
|
14
16
|
createImageSliceSynchronizer,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Enums } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import { createSynchronizer } from '../../store/SynchronizerManager';
|
|
4
|
+
import presentationViewSyncCallback from '../callbacks/presentationViewSyncCallback';
|
|
5
|
+
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
6
|
+
|
|
7
|
+
const { CAMERA_MODIFIED } = Enums.Events;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A helper that creates a new `Synchronizer` which listens to the `CAMERA_MODIFIED`
|
|
11
|
+
* rendering event and calls the `cameraSyncCallback` based on presentation view
|
|
12
|
+
* values and not based on absolute camera positions.
|
|
13
|
+
*
|
|
14
|
+
* @param synchronizerName - The name of the synchronizer.
|
|
15
|
+
* @returns A new `Synchronizer` instance.
|
|
16
|
+
*/
|
|
17
|
+
export default function createPresentationViewSynchronizer(
|
|
18
|
+
synchronizerName: string,
|
|
19
|
+
options?: Types.ViewPresentation
|
|
20
|
+
): Synchronizer {
|
|
21
|
+
const presentationView = createSynchronizer(
|
|
22
|
+
synchronizerName,
|
|
23
|
+
CAMERA_MODIFIED,
|
|
24
|
+
presentationViewSyncCallback,
|
|
25
|
+
options
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return presentationView;
|
|
29
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import createCameraPositionSynchronizer from './createCameraPositionSynchronizer';
|
|
2
|
+
import createPresentationViewSynchronizer from './createPresentationViewSynchronizer';
|
|
2
3
|
import createVOISynchronizer from './createVOISynchronizer';
|
|
3
4
|
import createZoomPanSynchronizer from './createZoomPanSynchronizer';
|
|
4
5
|
import createImageSliceSynchronizer from './createImageSliceSynchronizer';
|
|
@@ -7,6 +8,7 @@ import createImageSliceSynchronizer from './createImageSliceSynchronizer';
|
|
|
7
8
|
const createStackImageSynchronizer = createImageSliceSynchronizer;
|
|
8
9
|
export {
|
|
9
10
|
createCameraPositionSynchronizer,
|
|
11
|
+
createPresentationViewSynchronizer,
|
|
10
12
|
createVOISynchronizer,
|
|
11
13
|
createZoomPanSynchronizer,
|
|
12
14
|
createImageSliceSynchronizer,
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
utilities as csUtils,
|
|
3
|
+
cache,
|
|
4
|
+
getEnabledElement,
|
|
5
|
+
} from '@cornerstonejs/core';
|
|
2
6
|
import { vec3, vec2 } from 'gl-matrix';
|
|
3
7
|
|
|
4
8
|
import type { Types } from '@cornerstonejs/core';
|
|
@@ -113,6 +117,7 @@ class BrushTool extends BaseTool {
|
|
|
113
117
|
},
|
|
114
118
|
defaultStrategy: 'FILL_INSIDE_CIRCLE',
|
|
115
119
|
activeStrategy: 'FILL_INSIDE_CIRCLE',
|
|
120
|
+
thresholdVolumeId: null,
|
|
116
121
|
brushSize: 25,
|
|
117
122
|
preview: {
|
|
118
123
|
// Have to enable the preview to use this
|
|
@@ -203,14 +208,23 @@ class BrushTool extends BaseTool {
|
|
|
203
208
|
] as LabelmapSegmentationDataVolume;
|
|
204
209
|
const actors = viewport.getActors();
|
|
205
210
|
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
const
|
|
211
|
+
// we used to take the first actor here but we should take the one that is
|
|
212
|
+
// probably the same size as the segmentation volume
|
|
213
|
+
const volumes = actors.map((actorEntry) =>
|
|
214
|
+
cache.getVolume(actorEntry.referenceId)
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const segmentationVolume = cache.getVolume(volumeId);
|
|
218
|
+
|
|
219
|
+
const referencedVolumeIdToThreshold =
|
|
220
|
+
volumes.find((volume) =>
|
|
221
|
+
csUtils.isEqual(volume.dimensions, segmentationVolume.dimensions)
|
|
222
|
+
)?.volumeId || volumes[0]?.volumeId;
|
|
209
223
|
|
|
210
224
|
return {
|
|
211
225
|
volumeId,
|
|
212
226
|
referencedVolumeId:
|
|
213
|
-
|
|
227
|
+
this.configuration.thresholdVolumeId ?? referencedVolumeIdToThreshold,
|
|
214
228
|
segmentsLocked,
|
|
215
229
|
segmentationRepresentationUID,
|
|
216
230
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
2
2
|
import {
|
|
3
3
|
getEnabledElementByIds,
|
|
4
4
|
volumeLoader,
|
|
@@ -23,16 +23,16 @@ export default async function createLabelmapVolumeForViewport(input: {
|
|
|
23
23
|
renderingEngineId: string;
|
|
24
24
|
segmentationId?: string;
|
|
25
25
|
options?: {
|
|
26
|
-
volumeId
|
|
27
|
-
scalarData
|
|
28
|
-
targetBuffer
|
|
26
|
+
volumeId: string;
|
|
27
|
+
scalarData: Float32Array | Uint8Array | Uint16Array | Int16Array;
|
|
28
|
+
targetBuffer: {
|
|
29
29
|
type: 'Float32Array' | 'Uint8Array' | 'Uint16Array' | 'Int8Array';
|
|
30
30
|
};
|
|
31
|
-
metadata
|
|
32
|
-
dimensions
|
|
33
|
-
spacing
|
|
34
|
-
origin
|
|
35
|
-
direction
|
|
31
|
+
metadata: Types.Metadata;
|
|
32
|
+
dimensions: Types.Point3;
|
|
33
|
+
spacing: Types.Point3;
|
|
34
|
+
origin: Types.Point3;
|
|
35
|
+
direction: Types.Mat3;
|
|
36
36
|
};
|
|
37
37
|
}): Promise<string> {
|
|
38
38
|
const { viewportId, renderingEngineId, options } = input;
|
|
@@ -60,7 +60,7 @@ export default async function createLabelmapVolumeForViewport(input: {
|
|
|
60
60
|
if (options) {
|
|
61
61
|
// create a new labelmap with its own properties
|
|
62
62
|
// This allows creation of a higher resolution labelmap vs reference volume
|
|
63
|
-
const properties =
|
|
63
|
+
const properties = cloneDeep(options);
|
|
64
64
|
await volumeLoader.createLocalVolume(properties, segmentationId);
|
|
65
65
|
} else {
|
|
66
66
|
// create a labelmap from a reference volume
|
|
@@ -159,7 +159,9 @@ class AnnotationRenderingEngine {
|
|
|
159
159
|
const enabledElement = getEnabledElement(element);
|
|
160
160
|
|
|
161
161
|
if (!enabledElement) {
|
|
162
|
-
|
|
162
|
+
// Happens during testing, and isn't an issue as it just means there
|
|
163
|
+
// is overlap between shutdown and re-render
|
|
164
|
+
// console.warn('Element has been disabled');
|
|
163
165
|
return;
|
|
164
166
|
}
|
|
165
167
|
|