@cornerstonejs/tools 1.80.0 → 1.80.2
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/types/CINETypes.d.ts +1 -0
- package/dist/cjs/utilities/cine/playClip.js +52 -5
- package/dist/cjs/utilities/cine/playClip.js.map +1 -1
- package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js +13 -2
- package/dist/cjs/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -1
- package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js +0 -1
- package/dist/cjs/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -1
- package/dist/cjs/utilities/viewport/jumpToSlice.js +4 -6
- package/dist/cjs/utilities/viewport/jumpToSlice.js.map +1 -1
- package/dist/esm/utilities/cine/playClip.js +52 -5
- package/dist/esm/utilities/cine/playClip.js.map +1 -1
- package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +11 -2
- package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js.map +1 -1
- package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js +1 -2
- package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js.map +1 -1
- package/dist/esm/utilities/viewport/jumpToSlice.js +5 -7
- package/dist/esm/utilities/viewport/jumpToSlice.js.map +1 -1
- package/dist/types/types/CINETypes.d.ts +1 -0
- package/dist/types/types/CINETypes.d.ts.map +1 -1
- package/dist/types/utilities/cine/playClip.d.ts.map +1 -1
- package/dist/types/utilities/stackPrefetch/stackContextPrefetch.d.ts.map +1 -1
- package/dist/types/utilities/stackPrefetch/stackPrefetchUtils.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/types/CINETypes.ts +3 -0
- package/src/utilities/cine/playClip.ts +67 -8
- package/src/utilities/stackPrefetch/stackContextPrefetch.ts +12 -2
- package/src/utilities/stackPrefetch/stackPrefetchUtils.ts +7 -5
- package/src/utilities/viewport/jumpToSlice.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.80.
|
|
3
|
+
"version": "1.80.2",
|
|
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.80.
|
|
32
|
+
"@cornerstonejs/core": "^1.80.2",
|
|
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": "ec105a93611d3cbcdba011bb4681ae3dd501f0f0"
|
|
63
63
|
}
|
package/src/types/CINETypes.ts
CHANGED
|
@@ -33,6 +33,9 @@ type CinePlayContext = {
|
|
|
33
33
|
// the next image.
|
|
34
34
|
waitForRenderedCount?: number;
|
|
35
35
|
scroll(delta: number): void;
|
|
36
|
+
// An alternate implementation for video viewports or others that have
|
|
37
|
+
// native play functionality
|
|
38
|
+
play?(fps?: number): number;
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
export type { PlayClipOptions, ToolData, CinePlayContext };
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
utilities as csUtils,
|
|
4
4
|
getEnabledElement,
|
|
5
5
|
StackViewport,
|
|
6
|
+
VideoViewport,
|
|
6
7
|
VolumeViewport,
|
|
7
8
|
cache,
|
|
8
9
|
BaseVolumeViewport,
|
|
@@ -152,7 +153,14 @@ function playClip(
|
|
|
152
153
|
const delta = newStepIndex - currentStepIndex;
|
|
153
154
|
|
|
154
155
|
if (delta) {
|
|
155
|
-
|
|
156
|
+
try {
|
|
157
|
+
playClipContext.scroll(delta);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.warn('Play clip not scrolling', e);
|
|
160
|
+
_stopClipWithData(playClipData);
|
|
161
|
+
triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, eventDetail);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
156
164
|
}
|
|
157
165
|
};
|
|
158
166
|
|
|
@@ -160,9 +168,14 @@ function playClip(
|
|
|
160
168
|
dynamicVolumesPlayingMap.set(volume.volumeId, element);
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
if (playClipContext.play) {
|
|
172
|
+
playClipData.framesPerSecond = playClipContext.play(
|
|
173
|
+
playClipOptions.framesPerSecond
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// If playClipTimeouts array is available, not empty and its elements are NOT uniform ...
|
|
177
|
+
// ... (at least one timeout is different from the others), use alternate setTimeout implementation
|
|
178
|
+
} else if (
|
|
166
179
|
playClipTimeouts &&
|
|
167
180
|
playClipTimeouts.length > 0 &&
|
|
168
181
|
playClipIsTimeVarying
|
|
@@ -213,6 +226,7 @@ function _stopClip(
|
|
|
213
226
|
const enabledElement = getEnabledElement(element);
|
|
214
227
|
|
|
215
228
|
let toolState;
|
|
229
|
+
const viewport = enabledElement?.viewport;
|
|
216
230
|
if (!enabledElement) {
|
|
217
231
|
if (viewportId) {
|
|
218
232
|
toolState = getToolStateByViewportId(viewportId);
|
|
@@ -228,10 +242,9 @@ function _stopClip(
|
|
|
228
242
|
_stopClipWithData(toolState);
|
|
229
243
|
}
|
|
230
244
|
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
) {
|
|
245
|
+
if (viewport instanceof VideoViewport) {
|
|
246
|
+
viewport.pause();
|
|
247
|
+
} else if (stopDynamicCine && viewport instanceof BaseVolumeViewport) {
|
|
235
248
|
_stopDynamicVolumeCine(element);
|
|
236
249
|
}
|
|
237
250
|
}
|
|
@@ -374,6 +387,45 @@ function _createStackViewportCinePlayContext(
|
|
|
374
387
|
};
|
|
375
388
|
}
|
|
376
389
|
|
|
390
|
+
function _createVideoViewportCinePlayContext(
|
|
391
|
+
viewport: VideoViewport,
|
|
392
|
+
waitForRendered: number
|
|
393
|
+
): CINETypes.CinePlayContext {
|
|
394
|
+
return {
|
|
395
|
+
get numScrollSteps(): number {
|
|
396
|
+
return viewport.getNumberOfSlices();
|
|
397
|
+
},
|
|
398
|
+
get currentStepIndex(): number {
|
|
399
|
+
return viewport.getSliceIndex();
|
|
400
|
+
},
|
|
401
|
+
get frameTimeVectorEnabled(): boolean {
|
|
402
|
+
// It is always in acquired orientation
|
|
403
|
+
return true;
|
|
404
|
+
},
|
|
405
|
+
waitForRenderedCount: 0,
|
|
406
|
+
scroll(delta: number): void {
|
|
407
|
+
if (
|
|
408
|
+
this.waitForRenderedCount <= waitForRendered &&
|
|
409
|
+
viewport.viewportStatus !== ViewportStatus.RENDERED
|
|
410
|
+
) {
|
|
411
|
+
this.waitForRenderedCount++;
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
this.waitForRenderedCount = 0;
|
|
415
|
+
scroll(viewport, { delta, debounceLoading: debounced });
|
|
416
|
+
},
|
|
417
|
+
play(fps?: number): number {
|
|
418
|
+
if (fps) {
|
|
419
|
+
// This is a bit of a kludge to correspond to playback rates
|
|
420
|
+
// for other viewports
|
|
421
|
+
viewport.setPlaybackRate(fps / 24);
|
|
422
|
+
}
|
|
423
|
+
viewport.play();
|
|
424
|
+
return viewport.getFrameRate();
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
377
429
|
function _createVolumeViewportCinePlayContext(
|
|
378
430
|
viewport: VolumeViewport,
|
|
379
431
|
volume: Types.IImageVolume
|
|
@@ -475,6 +527,13 @@ function _createCinePlayContext(
|
|
|
475
527
|
return _createVolumeViewportCinePlayContext(viewport, volume);
|
|
476
528
|
}
|
|
477
529
|
|
|
530
|
+
if (viewport instanceof VideoViewport) {
|
|
531
|
+
return _createVideoViewportCinePlayContext(
|
|
532
|
+
viewport,
|
|
533
|
+
playClipOptions.waitForRendered ?? 30
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
|
|
478
537
|
throw new Error('Unknown viewport type');
|
|
479
538
|
}
|
|
480
539
|
|
|
@@ -64,7 +64,10 @@ const resetPrefetchDelay = 5;
|
|
|
64
64
|
const enable = (element): void => {
|
|
65
65
|
const stack = getStackData(element);
|
|
66
66
|
|
|
67
|
-
if (!stack
|
|
67
|
+
if (!stack) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (!stack.imageIds?.length) {
|
|
68
71
|
console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
|
|
69
72
|
return;
|
|
70
73
|
}
|
|
@@ -90,6 +93,9 @@ const enable = (element): void => {
|
|
|
90
93
|
|
|
91
94
|
function prefetch(element) {
|
|
92
95
|
const stack = getStackData(element);
|
|
96
|
+
if (!stack) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
93
99
|
if (!stack?.imageIds?.length) {
|
|
94
100
|
console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
|
|
95
101
|
return;
|
|
@@ -273,7 +279,11 @@ const signum = (x) => (x < 0 ? -1 : 1);
|
|
|
273
279
|
|
|
274
280
|
const updateToolState = (element, usage?: number) => {
|
|
275
281
|
const stack = getStackData(element);
|
|
276
|
-
if (!stack
|
|
282
|
+
if (!stack) {
|
|
283
|
+
// Other viewport type - no message
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (!stack.imageIds?.length) {
|
|
277
287
|
console.warn('CornerstoneTools.stackPrefetch: No images in stack.');
|
|
278
288
|
return;
|
|
279
289
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getEnabledElement,
|
|
3
|
+
StackViewport,
|
|
4
|
+
Enums,
|
|
5
|
+
VideoViewport,
|
|
6
|
+
WSIViewport,
|
|
7
|
+
} from '@cornerstonejs/core';
|
|
2
8
|
import { getToolState } from './state';
|
|
3
9
|
|
|
4
10
|
export const requestType = Enums.RequestType.Prefetch;
|
|
@@ -54,10 +60,6 @@ export function getStackData(element) {
|
|
|
54
60
|
if (!(viewport instanceof StackViewport)) {
|
|
55
61
|
// we shouldn't throw error here, since the viewport might have
|
|
56
62
|
// changed from stack to volume during prefetch
|
|
57
|
-
console.warn(
|
|
58
|
-
'stackPrefetch: element must be a StackViewport, VolumeViewport stackPrefetch not yet implemented'
|
|
59
|
-
);
|
|
60
|
-
|
|
61
63
|
return null;
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -54,11 +54,11 @@ function _getImageSliceData(
|
|
|
54
54
|
? viewport.getTargetImageIdIndex()
|
|
55
55
|
: viewport.getCurrentImageIdIndex(),
|
|
56
56
|
};
|
|
57
|
-
} else if (viewport instanceof VolumeViewport) {
|
|
58
|
-
return csUtils.getImageSliceDataForVolumeViewport(viewport);
|
|
59
|
-
} else {
|
|
60
|
-
throw new Error('Unsupported viewport type');
|
|
61
57
|
}
|
|
58
|
+
return {
|
|
59
|
+
numberOfSlices: viewport.getNumberOfSlices(),
|
|
60
|
+
imageIndex: viewport.getSliceIndex(),
|
|
61
|
+
};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function _getImageIndexToJump(
|