@cornerstonejs/tools 1.66.3 → 1.66.4
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/store/ToolGroupManager/ToolGroup.d.ts +1 -0
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +10 -3
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/tools/CrosshairsTool.d.ts +1 -0
- package/dist/cjs/tools/CrosshairsTool.js +14 -0
- package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
- package/dist/cjs/tools/ReferenceLinesTool.d.ts +3 -2
- package/dist/cjs/tools/ReferenceLinesTool.js +8 -3
- package/dist/cjs/tools/ReferenceLinesTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js +2 -2
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/cjs/utilities/cine/playClip.d.ts +1 -1
- package/dist/cjs/utilities/cine/playClip.js +30 -11
- package/dist/cjs/utilities/cine/playClip.js.map +1 -1
- package/dist/cjs/utilities/cine/state.d.ts +2 -1
- package/dist/cjs/utilities/cine/state.js +5 -1
- package/dist/cjs/utilities/cine/state.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +10 -3
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/tools/CrosshairsTool.js +14 -0
- package/dist/esm/tools/CrosshairsTool.js.map +1 -1
- package/dist/esm/tools/ReferenceLinesTool.js +8 -3
- package/dist/esm/tools/ReferenceLinesTool.js.map +1 -1
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +2 -2
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/esm/utilities/cine/playClip.js +31 -12
- package/dist/esm/utilities/cine/playClip.js.map +1 -1
- package/dist/esm/utilities/cine/state.js +4 -1
- package/dist/esm/utilities/cine/state.js.map +1 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts +1 -0
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
- package/dist/types/tools/CrosshairsTool.d.ts +1 -0
- package/dist/types/tools/CrosshairsTool.d.ts.map +1 -1
- package/dist/types/tools/ReferenceLinesTool.d.ts +3 -2
- package/dist/types/tools/ReferenceLinesTool.d.ts.map +1 -1
- package/dist/types/utilities/cine/playClip.d.ts +1 -1
- package/dist/types/utilities/cine/playClip.d.ts.map +1 -1
- package/dist/types/utilities/cine/state.d.ts +2 -1
- package/dist/types/utilities/cine/state.d.ts.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/store/ToolGroupManager/ToolGroup.ts +17 -6
- package/src/tools/CrosshairsTool.ts +22 -0
- package/src/tools/ReferenceLinesTool.ts +14 -6
- package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +2 -2
- package/src/utilities/cine/playClip.ts +35 -12
- package/src/utilities/cine/state.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.66.
|
|
3
|
+
"version": "1.66.4",
|
|
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.66.
|
|
32
|
+
"@cornerstonejs/core": "^1.66.4",
|
|
33
33
|
"@icr/polyseg-wasm": "0.4.0",
|
|
34
34
|
"@types/offscreencanvas": "2019.7.3",
|
|
35
35
|
"comlink": "^4.4.1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"type": "individual",
|
|
60
60
|
"url": "https://ohif.org/donate"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4d12d9d2ecf38805e7c9ca7e93bf36372bfe85ff"
|
|
63
63
|
}
|
|
@@ -90,6 +90,15 @@ export default class ToolGroup implements IToolGroup {
|
|
|
90
90
|
return toolInstance;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves the tool instances associated with this tool group.
|
|
95
|
+
*
|
|
96
|
+
* @returns A record containing the tool instances, where the keys are the tool names and the values are the tool instances.
|
|
97
|
+
*/
|
|
98
|
+
public getToolInstances(): Record<string, any> {
|
|
99
|
+
return this._toolInstances;
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
/**
|
|
94
103
|
* Check if a tool is already added to the tool group
|
|
95
104
|
* @param toolName - Tool name
|
|
@@ -658,7 +667,8 @@ export default class ToolGroup implements IToolGroup {
|
|
|
658
667
|
configuration: ToolConfiguration,
|
|
659
668
|
overwrite?: boolean
|
|
660
669
|
): boolean {
|
|
661
|
-
|
|
670
|
+
const toolInstance = this._toolInstances[toolName];
|
|
671
|
+
if (toolInstance === undefined) {
|
|
662
672
|
console.warn(
|
|
663
673
|
`Tool ${toolName} not present, can't set tool configuration.`
|
|
664
674
|
);
|
|
@@ -673,13 +683,14 @@ export default class ToolGroup implements IToolGroup {
|
|
|
673
683
|
// We should not deep copy here, it is the job of the application to
|
|
674
684
|
// deep copy the configuration before passing it to the toolGroup, otherwise
|
|
675
685
|
// some strange appending behaviour happens for the arrays
|
|
676
|
-
_configuration = Object.assign(
|
|
677
|
-
this._toolInstances[toolName].configuration,
|
|
678
|
-
configuration
|
|
679
|
-
);
|
|
686
|
+
_configuration = Object.assign(toolInstance.configuration, configuration);
|
|
680
687
|
}
|
|
681
688
|
|
|
682
|
-
|
|
689
|
+
toolInstance.configuration = _configuration;
|
|
690
|
+
|
|
691
|
+
if (typeof toolInstance.onSetToolConfiguration === 'function') {
|
|
692
|
+
toolInstance.onSetToolConfiguration();
|
|
693
|
+
}
|
|
683
694
|
|
|
684
695
|
this._renderViewports();
|
|
685
696
|
|
|
@@ -311,6 +311,28 @@ class CrosshairsTool extends AnnotationTool {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
resetCrosshairs = () => {
|
|
315
|
+
const viewportsInfo = this._getViewportsInfo();
|
|
316
|
+
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
317
|
+
const enabledElement = getEnabledElementByIds(
|
|
318
|
+
viewportId,
|
|
319
|
+
renderingEngineId
|
|
320
|
+
);
|
|
321
|
+
const { viewport } = enabledElement;
|
|
322
|
+
const { element } = viewport;
|
|
323
|
+
let annotations = this._getAnnotations(enabledElement);
|
|
324
|
+
annotations = this.filterInteractableAnnotationsForElement(
|
|
325
|
+
element,
|
|
326
|
+
annotations
|
|
327
|
+
);
|
|
328
|
+
if (annotations.length) {
|
|
329
|
+
removeAnnotation(annotations[0].annotationUID);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
this.computeToolCenter(viewportsInfo);
|
|
334
|
+
};
|
|
335
|
+
|
|
314
336
|
/**
|
|
315
337
|
* When activated, it initializes the crosshairs. It begins by computing
|
|
316
338
|
* the intersection of viewports associated with the crosshairs instance.
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CONSTANTS,
|
|
5
5
|
utilities as csUtils,
|
|
6
6
|
} from '@cornerstonejs/core';
|
|
7
|
-
import type
|
|
7
|
+
import { type Types, getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
8
8
|
|
|
9
9
|
import { addAnnotation } from '../stateManagement/annotation/annotationState';
|
|
10
10
|
|
|
@@ -21,7 +21,6 @@ const { EPSILON } = CONSTANTS;
|
|
|
21
21
|
/**
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
24
|
class ReferenceLines extends AnnotationDisplayTool {
|
|
26
25
|
static toolName;
|
|
27
26
|
|
|
@@ -30,7 +29,7 @@ class ReferenceLines extends AnnotationDisplayTool {
|
|
|
30
29
|
_throttledCalculateCachedStats: any;
|
|
31
30
|
editData: {
|
|
32
31
|
renderingEngine: any;
|
|
33
|
-
|
|
32
|
+
sourceViewportId: string;
|
|
34
33
|
annotation: ReferenceLineAnnotation;
|
|
35
34
|
} | null = {} as any;
|
|
36
35
|
isDrawing: boolean;
|
|
@@ -71,7 +70,7 @@ class ReferenceLines extends AnnotationDisplayTool {
|
|
|
71
70
|
this.configuration.sourceViewportId
|
|
72
71
|
) as Types.IVolumeViewport;
|
|
73
72
|
|
|
74
|
-
if (!sourceViewport
|
|
73
|
+
if (!sourceViewport?.getImageData()) {
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -110,7 +109,7 @@ class ReferenceLines extends AnnotationDisplayTool {
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
this.editData = {
|
|
113
|
-
sourceViewport,
|
|
112
|
+
sourceViewportId: sourceViewport.id,
|
|
114
113
|
renderingEngine,
|
|
115
114
|
annotation,
|
|
116
115
|
};
|
|
@@ -127,6 +126,10 @@ class ReferenceLines extends AnnotationDisplayTool {
|
|
|
127
126
|
this._init();
|
|
128
127
|
};
|
|
129
128
|
|
|
129
|
+
onSetToolConfiguration = (): void => {
|
|
130
|
+
this._init();
|
|
131
|
+
};
|
|
132
|
+
|
|
130
133
|
onCameraModified = (evt: Types.EventTypes.CameraModifiedEvent): void => {
|
|
131
134
|
// If the camera is modified, we need to update the reference lines
|
|
132
135
|
// we really don't care which viewport triggered the
|
|
@@ -148,10 +151,15 @@ class ReferenceLines extends AnnotationDisplayTool {
|
|
|
148
151
|
svgDrawingHelper: SVGDrawingHelper
|
|
149
152
|
): boolean => {
|
|
150
153
|
const { viewport: targetViewport } = enabledElement;
|
|
151
|
-
const { annotation,
|
|
154
|
+
const { annotation, sourceViewportId } = this.editData;
|
|
152
155
|
|
|
153
156
|
let renderStatus = false;
|
|
154
157
|
|
|
158
|
+
// we need to grab the viewport again since there might have been
|
|
159
|
+
// a change in the viewport state since the last time we cached it
|
|
160
|
+
const { viewport: sourceViewport } =
|
|
161
|
+
getEnabledElementByViewportId(sourceViewportId) || {};
|
|
162
|
+
|
|
155
163
|
if (!sourceViewport) {
|
|
156
164
|
return renderStatus;
|
|
157
165
|
}
|
|
@@ -395,7 +395,7 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
|
|
|
395
395
|
|
|
396
396
|
_calculateCachedStatsTool(annotation, enabledElement) {
|
|
397
397
|
const data = annotation.data;
|
|
398
|
-
const {
|
|
398
|
+
const { viewport } = enabledElement;
|
|
399
399
|
|
|
400
400
|
const { cachedStats } = data;
|
|
401
401
|
const targetId = this.getTargetId(viewport);
|
|
@@ -409,7 +409,7 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
|
|
|
409
409
|
annotation.invalidated = false;
|
|
410
410
|
|
|
411
411
|
// Dispatching annotation modified
|
|
412
|
-
triggerAnnotationModified(annotation, element);
|
|
412
|
+
triggerAnnotationModified(annotation, viewport.element);
|
|
413
413
|
|
|
414
414
|
return cachedStats;
|
|
415
415
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { Types } from '@cornerstonejs/core';
|
|
13
13
|
import CINE_EVENTS from './events';
|
|
14
|
-
import { addToolState, getToolState } from './state';
|
|
14
|
+
import { addToolState, getToolState, getToolStateByViewportId } from './state';
|
|
15
15
|
import { CINETypes } from '../../types';
|
|
16
16
|
import scroll from '../scroll';
|
|
17
17
|
|
|
@@ -83,7 +83,10 @@ function playClip(
|
|
|
83
83
|
// Make sure the specified clip is not running before any property update.
|
|
84
84
|
// If a 3D CINE was playing it passes isDynamicCinePlaying as FALSE to
|
|
85
85
|
// prevent stopping a 4D CINE in case it is playing on another viewport.
|
|
86
|
-
_stopClip(element,
|
|
86
|
+
_stopClip(element, {
|
|
87
|
+
stopDynamicCine: !isDynamicCinePlaying,
|
|
88
|
+
viewportId: viewport.id,
|
|
89
|
+
});
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
playClipData.dynamicCineEnabled = playClipOptions.dynamicCineEnabled;
|
|
@@ -125,7 +128,10 @@ function playClip(
|
|
|
125
128
|
if (!loop && newStepIndexOutOfRange) {
|
|
126
129
|
// If a 3D CINE was playing it passes isDynamicCinePlaying as FALSE to
|
|
127
130
|
// prevent stopping a 4D CINE in case it is playing on another viewport.
|
|
128
|
-
_stopClip(element,
|
|
131
|
+
_stopClip(element, {
|
|
132
|
+
stopDynamicCine: !isDynamicCinePlaying,
|
|
133
|
+
viewportId: viewport.id,
|
|
134
|
+
});
|
|
129
135
|
|
|
130
136
|
const eventDetail = { element };
|
|
131
137
|
|
|
@@ -189,23 +195,40 @@ function playClip(
|
|
|
189
195
|
* Stops an already playing clip.
|
|
190
196
|
* @param element - HTML Element
|
|
191
197
|
*/
|
|
192
|
-
function stopClip(element: HTMLDivElement): void {
|
|
193
|
-
_stopClip(element,
|
|
198
|
+
function stopClip(element: HTMLDivElement, viewportId?: string): void {
|
|
199
|
+
_stopClip(element, {
|
|
200
|
+
stopDynamicCine: true,
|
|
201
|
+
viewportId,
|
|
202
|
+
});
|
|
194
203
|
}
|
|
195
204
|
|
|
196
|
-
function _stopClip(
|
|
205
|
+
function _stopClip(
|
|
206
|
+
element: HTMLDivElement,
|
|
207
|
+
options = { stopDynamicCine: true, viewportId: undefined }
|
|
208
|
+
) {
|
|
209
|
+
const { stopDynamicCine, viewportId } = options;
|
|
197
210
|
const enabledElement = getEnabledElement(element);
|
|
211
|
+
|
|
212
|
+
let toolState;
|
|
198
213
|
if (!enabledElement) {
|
|
199
|
-
|
|
214
|
+
if (viewportId) {
|
|
215
|
+
toolState = getToolStateByViewportId(viewportId);
|
|
216
|
+
} else {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
const { viewport } = enabledElement;
|
|
221
|
+
toolState = getToolState(viewport.element);
|
|
200
222
|
}
|
|
201
|
-
const { viewport } = enabledElement;
|
|
202
|
-
const cineToolData = getToolState(viewport.element);
|
|
203
223
|
|
|
204
|
-
if (
|
|
205
|
-
_stopClipWithData(
|
|
224
|
+
if (toolState) {
|
|
225
|
+
_stopClipWithData(toolState);
|
|
206
226
|
}
|
|
207
227
|
|
|
208
|
-
if (
|
|
228
|
+
if (
|
|
229
|
+
stopDynamicCine &&
|
|
230
|
+
enabledElement?.viewport instanceof BaseVolumeViewport
|
|
231
|
+
) {
|
|
209
232
|
_stopDynamicVolumeCine(element);
|
|
210
233
|
}
|
|
211
234
|
}
|
|
@@ -15,4 +15,10 @@ function getToolState(element: HTMLDivElement): CINETypes.ToolData | undefined {
|
|
|
15
15
|
return state[viewportId];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function getToolStateByViewportId(
|
|
19
|
+
viewportId: string
|
|
20
|
+
): CINETypes.ToolData | undefined {
|
|
21
|
+
return state[viewportId];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { addToolState, getToolState, getToolStateByViewportId };
|