@cornerstonejs/tools 0.14.1 → 0.15.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/types/CINETypes.d.ts +19 -0
- package/dist/cjs/types/CINETypes.js +3 -0
- package/dist/cjs/types/CINETypes.js.map +1 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/cine/events.d.ts +5 -0
- package/dist/cjs/utilities/cine/events.js +9 -0
- package/dist/cjs/utilities/cine/events.js.map +1 -0
- package/dist/cjs/utilities/cine/index.d.ts +4 -0
- package/dist/cjs/utilities/cine/index.js +15 -0
- package/dist/cjs/utilities/cine/index.js.map +1 -0
- package/dist/cjs/utilities/cine/playClip.d.ts +4 -0
- package/dist/cjs/utilities/cine/playClip.js +165 -0
- package/dist/cjs/utilities/cine/playClip.js.map +1 -0
- package/dist/cjs/utilities/cine/state.d.ts +4 -0
- package/dist/cjs/utilities/cine/state.js +18 -0
- package/dist/cjs/utilities/cine/state.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/esm/types/CINETypes.d.ts +19 -0
- package/dist/esm/types/CINETypes.js +2 -0
- package/dist/esm/types/CINETypes.js.map +1 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utilities/cine/events.d.ts +5 -0
- package/dist/esm/utilities/cine/events.js +7 -0
- package/dist/esm/utilities/cine/events.js.map +1 -0
- package/dist/esm/utilities/cine/index.d.ts +4 -0
- package/dist/esm/utilities/cine/index.js +5 -0
- package/dist/esm/utilities/cine/index.js.map +1 -0
- package/dist/esm/utilities/cine/playClip.d.ts +4 -0
- package/dist/esm/utilities/cine/playClip.js +157 -0
- package/dist/esm/utilities/cine/playClip.js.map +1 -0
- package/dist/esm/utilities/cine/state.d.ts +4 -0
- package/dist/esm/utilities/cine/state.js +14 -0
- package/dist/esm/utilities/cine/state.js.map +1 -0
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare type PlayClipOptions = {
|
|
2
|
+
framesPerSecond?: number;
|
|
3
|
+
frameTimeVector?: number[];
|
|
4
|
+
reverse?: boolean;
|
|
5
|
+
loop?: boolean;
|
|
6
|
+
frameTimeVectorSpeedMultiplier?: number;
|
|
7
|
+
};
|
|
8
|
+
interface ToolData {
|
|
9
|
+
intervalId: number | undefined;
|
|
10
|
+
framesPerSecond: number;
|
|
11
|
+
lastFrameTimeStamp: number | undefined;
|
|
12
|
+
frameTimeVector: number[] | undefined;
|
|
13
|
+
ignoreFrameTimeVector: boolean;
|
|
14
|
+
usingFrameTimeVector: boolean;
|
|
15
|
+
speed: number;
|
|
16
|
+
reverse: boolean;
|
|
17
|
+
loop: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type { PlayClipOptions, ToolData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CINETypes.js","sourceRoot":"","sources":["../../../src/types/CINETypes.ts"],"names":[],"mappings":""}
|
|
@@ -14,5 +14,6 @@ import type { ToolProps, PublicToolProps } from './ToolProps';
|
|
|
14
14
|
import type { SVGCursorDescriptor, SVGPoint } from './CursorTypes';
|
|
15
15
|
import type JumpToSliceOptions from './JumpToSliceOptions';
|
|
16
16
|
import type ScrollOptions from './ScrollOptions';
|
|
17
|
+
import type * as CINETypes from './CINETypes';
|
|
17
18
|
import type { Color, ColorLUT, RepresentationConfig, SegmentationRepresentationConfig, SegmentationRepresentationData, Segmentation, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
|
|
18
|
-
export type { Annotation, Annotations, FrameOfReferenceSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, PlanarBoundingBox, ToolProps, PublicToolProps, EventTypes, IPoints, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, IToolGroup, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, RepresentationPublicInput, Color, ColorLUT, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, };
|
|
19
|
+
export type { Annotation, Annotations, FrameOfReferenceSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, PlanarBoundingBox, ToolProps, PublicToolProps, EventTypes, IPoints, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, IToolGroup, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, RepresentationPublicInput, Color, ColorLUT, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Events;
|
|
4
|
+
(function (Events) {
|
|
5
|
+
Events["CLIP_STOPPED"] = "CORNERSTONE_CINE_TOOL_STOPPED";
|
|
6
|
+
Events["CLIP_STARTED"] = "CORNERSTONE_CINE_TOOL_STARTED";
|
|
7
|
+
})(Events || (Events = {}));
|
|
8
|
+
exports.default = Events;
|
|
9
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/utilities/cine/events.ts"],"names":[],"mappings":";;AAGA,IAAK,MAGJ;AAHD,WAAK,MAAM;IACT,wDAA8C,CAAA;IAC9C,wDAA8C,CAAA;AAChD,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.addToolState = exports.getToolState = exports.Events = exports.stopClip = exports.playClip = void 0;
|
|
7
|
+
const playClip_1 = require("./playClip");
|
|
8
|
+
Object.defineProperty(exports, "playClip", { enumerable: true, get: function () { return playClip_1.playClip; } });
|
|
9
|
+
Object.defineProperty(exports, "stopClip", { enumerable: true, get: function () { return playClip_1.stopClip; } });
|
|
10
|
+
const events_1 = __importDefault(require("./events"));
|
|
11
|
+
exports.Events = events_1.default;
|
|
12
|
+
const state_1 = require("./state");
|
|
13
|
+
Object.defineProperty(exports, "getToolState", { enumerable: true, get: function () { return state_1.getToolState; } });
|
|
14
|
+
Object.defineProperty(exports, "addToolState", { enumerable: true, get: function () { return state_1.addToolState; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/cine/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAgD;AAIvC,yFAJA,mBAAQ,OAIA;AAAE,yFAJA,mBAAQ,OAIA;AAH3B,sDAA8B;AAGD,iBAHtB,gBAAM,CAGsB;AAFnC,mCAAqD;AAEhB,6FAF5B,oBAAY,OAE4B;AAAE,6FAF5B,oBAAY,OAE4B"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stopClip = exports.playClip = void 0;
|
|
7
|
+
const core_1 = require("@cornerstonejs/core");
|
|
8
|
+
const events_1 = __importDefault(require("./events"));
|
|
9
|
+
const state_1 = require("./state");
|
|
10
|
+
const { triggerEvent } = core_1.utilities;
|
|
11
|
+
function playClip(element, playClipOptions) {
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
|
+
let playClipTimeouts;
|
|
14
|
+
let playClipIsTimeVarying;
|
|
15
|
+
if (element === undefined) {
|
|
16
|
+
throw new Error('playClip: element must not be undefined');
|
|
17
|
+
}
|
|
18
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
19
|
+
if (!enabledElement) {
|
|
20
|
+
throw new Error('playClip: element must be a valid Cornerstone enabled element');
|
|
21
|
+
}
|
|
22
|
+
const { viewport } = enabledElement;
|
|
23
|
+
if (!(viewport instanceof core_1.StackViewport)) {
|
|
24
|
+
throw new Error('playClip: element must be a stack viewport, volume viewport playClip not yet implemented');
|
|
25
|
+
}
|
|
26
|
+
const stackData = {
|
|
27
|
+
currentImageIdIndex: viewport.getCurrentImageIdIndex(),
|
|
28
|
+
imageIds: viewport.getImageIds(),
|
|
29
|
+
};
|
|
30
|
+
let playClipData = (0, state_1.getToolState)(element);
|
|
31
|
+
if (!playClipData) {
|
|
32
|
+
playClipData = {
|
|
33
|
+
intervalId: undefined,
|
|
34
|
+
framesPerSecond: 30,
|
|
35
|
+
lastFrameTimeStamp: undefined,
|
|
36
|
+
ignoreFrameTimeVector: false,
|
|
37
|
+
usingFrameTimeVector: false,
|
|
38
|
+
frameTimeVector: (_a = playClipOptions.frameTimeVector) !== null && _a !== void 0 ? _a : undefined,
|
|
39
|
+
speed: (_b = playClipOptions.frameTimeVectorSpeedMultiplier) !== null && _b !== void 0 ? _b : 1,
|
|
40
|
+
reverse: (_c = playClipOptions.reverse) !== null && _c !== void 0 ? _c : false,
|
|
41
|
+
loop: (_d = playClipOptions.loop) !== null && _d !== void 0 ? _d : true,
|
|
42
|
+
};
|
|
43
|
+
(0, state_1.addToolState)(element, playClipData);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
_stopClipWithData(playClipData);
|
|
47
|
+
}
|
|
48
|
+
if (playClipOptions.framesPerSecond < 0 ||
|
|
49
|
+
playClipOptions.framesPerSecond > 0) {
|
|
50
|
+
playClipData.framesPerSecond = Number(playClipOptions.framesPerSecond);
|
|
51
|
+
playClipData.reverse = playClipData.framesPerSecond < 0;
|
|
52
|
+
playClipData.ignoreFrameTimeVector = true;
|
|
53
|
+
}
|
|
54
|
+
if (playClipData.ignoreFrameTimeVector !== true &&
|
|
55
|
+
playClipData.frameTimeVector &&
|
|
56
|
+
playClipData.frameTimeVector.length === stackData.imageIds.length) {
|
|
57
|
+
const { timeouts, isTimeVarying } = _getPlayClipTimeouts(playClipData.frameTimeVector, playClipData.speed);
|
|
58
|
+
playClipTimeouts = timeouts;
|
|
59
|
+
playClipIsTimeVarying = isTimeVarying;
|
|
60
|
+
}
|
|
61
|
+
const playClipAction = () => {
|
|
62
|
+
let newImageIdIndex = stackData.currentImageIdIndex;
|
|
63
|
+
const imageCount = stackData.imageIds.length;
|
|
64
|
+
if (playClipData.reverse) {
|
|
65
|
+
newImageIdIndex--;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
newImageIdIndex++;
|
|
69
|
+
}
|
|
70
|
+
if (!playClipData.loop &&
|
|
71
|
+
(newImageIdIndex < 0 || newImageIdIndex >= imageCount)) {
|
|
72
|
+
_stopClipWithData(playClipData);
|
|
73
|
+
const eventDetail = {
|
|
74
|
+
element,
|
|
75
|
+
};
|
|
76
|
+
triggerEvent(element, events_1.default.CLIP_STOPPED, eventDetail);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (newImageIdIndex >= imageCount) {
|
|
80
|
+
newImageIdIndex = 0;
|
|
81
|
+
}
|
|
82
|
+
if (newImageIdIndex < 0) {
|
|
83
|
+
newImageIdIndex = imageCount - 1;
|
|
84
|
+
}
|
|
85
|
+
if (newImageIdIndex !== stackData.currentImageIdIndex) {
|
|
86
|
+
viewport.setImageIdIndex(newImageIdIndex).then(() => {
|
|
87
|
+
stackData.currentImageIdIndex = newImageIdIndex;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (playClipTimeouts &&
|
|
92
|
+
playClipTimeouts.length > 0 &&
|
|
93
|
+
playClipIsTimeVarying) {
|
|
94
|
+
playClipData.usingFrameTimeVector = true;
|
|
95
|
+
playClipData.intervalId = window.setTimeout(function playClipTimeoutHandler() {
|
|
96
|
+
playClipData.intervalId = window.setTimeout(playClipTimeoutHandler, playClipTimeouts[stackData.currentImageIdIndex]);
|
|
97
|
+
playClipAction();
|
|
98
|
+
}, 0);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
playClipData.usingFrameTimeVector = false;
|
|
102
|
+
playClipData.intervalId = window.setInterval(playClipAction, 1000 / Math.abs(playClipData.framesPerSecond));
|
|
103
|
+
}
|
|
104
|
+
const eventDetail = {
|
|
105
|
+
element,
|
|
106
|
+
};
|
|
107
|
+
triggerEvent(element, events_1.default.CLIP_STARTED, eventDetail);
|
|
108
|
+
}
|
|
109
|
+
exports.playClip = playClip;
|
|
110
|
+
function stopClip(element) {
|
|
111
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
112
|
+
const { viewport } = enabledElement;
|
|
113
|
+
const cineToolData = (0, state_1.getToolState)(viewport.element);
|
|
114
|
+
if (!cineToolData) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
_stopClipWithData(cineToolData);
|
|
118
|
+
}
|
|
119
|
+
exports.stopClip = stopClip;
|
|
120
|
+
function _getPlayClipTimeouts(vector, speed) {
|
|
121
|
+
let i;
|
|
122
|
+
let sample;
|
|
123
|
+
let delay;
|
|
124
|
+
let sum = 0;
|
|
125
|
+
const limit = vector.length;
|
|
126
|
+
const timeouts = [];
|
|
127
|
+
let isTimeVarying = false;
|
|
128
|
+
if (typeof speed !== 'number' || speed <= 0) {
|
|
129
|
+
speed = 1;
|
|
130
|
+
}
|
|
131
|
+
for (i = 1; i < limit; i++) {
|
|
132
|
+
delay = (Number(vector[i]) / speed) | 0;
|
|
133
|
+
timeouts.push(delay);
|
|
134
|
+
if (i === 1) {
|
|
135
|
+
sample = delay;
|
|
136
|
+
}
|
|
137
|
+
else if (delay !== sample) {
|
|
138
|
+
isTimeVarying = true;
|
|
139
|
+
}
|
|
140
|
+
sum += delay;
|
|
141
|
+
}
|
|
142
|
+
if (timeouts.length > 0) {
|
|
143
|
+
if (isTimeVarying) {
|
|
144
|
+
delay = (sum / timeouts.length) | 0;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
delay = timeouts[0];
|
|
148
|
+
}
|
|
149
|
+
timeouts.push(delay);
|
|
150
|
+
}
|
|
151
|
+
return { timeouts, isTimeVarying };
|
|
152
|
+
}
|
|
153
|
+
function _stopClipWithData(playClipData) {
|
|
154
|
+
const id = playClipData.intervalId;
|
|
155
|
+
if (typeof id !== 'undefined') {
|
|
156
|
+
playClipData.intervalId = undefined;
|
|
157
|
+
if (playClipData.usingFrameTimeVector) {
|
|
158
|
+
clearTimeout(id);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
clearInterval(id);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=playClip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playClip.js","sourceRoot":"","sources":["../../../../src/utilities/cine/playClip.ts"],"names":[],"mappings":";;;;;;AAAA,8CAI6B;AAC7B,sDAAmC;AACnC,mCAAqD;AAGrD,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAS,CAAC;AASnC,SAAS,QAAQ,CACf,OAAuB,EACvB,eAA0C;;IAE1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AAC,UAAU,CAAC;IAEnC,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE;QAC7B,YAAY,CAAC,UAAU,GAAG,SAAS,CAAC;QACpC,IAAI,YAAY,CAAC,oBAAoB,EAAE;YACrC,YAAY,CAAC,EAAE,CAAC,CAAC;SAClB;aAAM;YACL,aAAa,CAAC,EAAE,CAAC,CAAC;SACnB;KACF;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getToolState = exports.addToolState = void 0;
|
|
4
|
+
const core_1 = require("@cornerstonejs/core");
|
|
5
|
+
const state = {};
|
|
6
|
+
function addToolState(element, data) {
|
|
7
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
8
|
+
const { viewportId } = enabledElement;
|
|
9
|
+
state[viewportId] = data;
|
|
10
|
+
}
|
|
11
|
+
exports.addToolState = addToolState;
|
|
12
|
+
function getToolState(element) {
|
|
13
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
14
|
+
const { viewportId } = enabledElement;
|
|
15
|
+
return state[viewportId];
|
|
16
|
+
}
|
|
17
|
+
exports.getToolState = getToolState;
|
|
18
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../src/utilities/cine/state.ts"],"names":[],"mappings":";;;AAAA,8CAAwD;AAGxD,MAAM,KAAK,GAAuC,EAAE,CAAC;AAErD,SAAS,YAAY,CAAC,OAAuB,EAAE,IAAwB;IACrE,MAAM,cAAc,GAAG,IAAA,wBAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IACtC,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AAC3B,CAAC;AAQQ,oCAAY;AANrB,SAAS,YAAY,CAAC,OAAuB;IAC3C,MAAM,cAAc,GAAG,IAAA,wBAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IACtC,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAEsB,oCAAY"}
|
|
@@ -15,5 +15,6 @@ import * as planar from './planar';
|
|
|
15
15
|
import * as stackScrollTool from './stackScrollTool';
|
|
16
16
|
import * as viewportFilters from './viewportFilters';
|
|
17
17
|
import * as orientation from './orientation';
|
|
18
|
+
import * as cine from './cine';
|
|
18
19
|
import { triggerEvent } from '@cornerstonejs/core';
|
|
19
|
-
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, };
|
|
20
|
+
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, cine, };
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRenderForViewportIds = exports.segmentation = exports.calibrateImageSpacing = exports.triggerEvent = exports.isObject = exports.orientation = exports.throttle = exports.deepMerge = exports.debounce = exports.drawing = exports.stackScrollTool = exports.viewportFilters = exports.planar = exports.math = void 0;
|
|
25
|
+
exports.cine = exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRenderForViewportIds = exports.segmentation = exports.calibrateImageSpacing = exports.triggerEvent = exports.isObject = exports.orientation = exports.throttle = exports.deepMerge = exports.debounce = exports.drawing = exports.stackScrollTool = exports.viewportFilters = exports.planar = exports.math = void 0;
|
|
26
26
|
const getAnnotationNearPoint_1 = require("./getAnnotationNearPoint");
|
|
27
27
|
Object.defineProperty(exports, "getAnnotationNearPoint", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPoint; } });
|
|
28
28
|
Object.defineProperty(exports, "getAnnotationNearPointOnEnabledElement", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPointOnEnabledElement; } });
|
|
@@ -58,6 +58,8 @@ const viewportFilters = __importStar(require("./viewportFilters"));
|
|
|
58
58
|
exports.viewportFilters = viewportFilters;
|
|
59
59
|
const orientation = __importStar(require("./orientation"));
|
|
60
60
|
exports.orientation = orientation;
|
|
61
|
+
const cine = __importStar(require("./cine"));
|
|
62
|
+
exports.cine = cine;
|
|
61
63
|
const core_1 = require("@cornerstonejs/core");
|
|
62
64
|
Object.defineProperty(exports, "triggerEvent", { enumerable: true, get: function () { return core_1.triggerEvent; } });
|
|
63
65
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAGkC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAGkC;AA4ChC,uGA9CA,+CAAsB,OA8CA;AACtB,uHA9CA,+DAAsC,OA8CA;AA1CxC,0DAAkC;AA8BhC,mBA9BK,kBAAQ,CA8BL;AA7BV,4DAAoC;AA8BlC,oBA9BK,mBAAS,CA8BL;AA7BX,0DAAkC;AA8BhC,mBA9BK,kBAAQ,CA8BL;AA7BV,0DAAkC;AA+BhC,mBA/BK,kBAAQ,CA+BL;AA9BV,oFAA4D;AAgC1D,gCAhCK,+BAAqB,CAgCL;AA/BvB,oHAA4F;AAiC1F,gDAjCK,+CAAqC,CAiCL;AAhCvC,yEAAiD;AAqC/C,sBArCK,qBAAW,CAqCL;AAnCb,kFAA0D;AA+BxD,+BA/BK,8BAAoB,CA+BL;AA9BtB,0GAAkF;AA+BhF,2CA/BK,0CAAgC,CA+BL;AA5BlC,6DAA+C;AAyB7C,oCAAY;AAxBd,mDAAqC;AAgBnC,0BAAO;AAfT,6CAA+B;AAW7B,oBAAI;AAVN,iDAAmC;AAWjC,wBAAM;AAVR,mEAAqD;AAYnD,0CAAe;AAXjB,mEAAqD;AAUnD,0CAAe;AATjB,2DAA6C;AAe3C,kCAAW;AAdb,6CAA+B;AAyB7B,oBAAI;AAtBN,8CAAmD;AAajD,6FAbO,mBAAY,OAaP"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare type PlayClipOptions = {
|
|
2
|
+
framesPerSecond?: number;
|
|
3
|
+
frameTimeVector?: number[];
|
|
4
|
+
reverse?: boolean;
|
|
5
|
+
loop?: boolean;
|
|
6
|
+
frameTimeVectorSpeedMultiplier?: number;
|
|
7
|
+
};
|
|
8
|
+
interface ToolData {
|
|
9
|
+
intervalId: number | undefined;
|
|
10
|
+
framesPerSecond: number;
|
|
11
|
+
lastFrameTimeStamp: number | undefined;
|
|
12
|
+
frameTimeVector: number[] | undefined;
|
|
13
|
+
ignoreFrameTimeVector: boolean;
|
|
14
|
+
usingFrameTimeVector: boolean;
|
|
15
|
+
speed: number;
|
|
16
|
+
reverse: boolean;
|
|
17
|
+
loop: boolean;
|
|
18
|
+
}
|
|
19
|
+
export type { PlayClipOptions, ToolData };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CINETypes.js","sourceRoot":"","sources":["../../../src/types/CINETypes.ts"],"names":[],"mappings":""}
|
|
@@ -14,5 +14,6 @@ import type { ToolProps, PublicToolProps } from './ToolProps';
|
|
|
14
14
|
import type { SVGCursorDescriptor, SVGPoint } from './CursorTypes';
|
|
15
15
|
import type JumpToSliceOptions from './JumpToSliceOptions';
|
|
16
16
|
import type ScrollOptions from './ScrollOptions';
|
|
17
|
+
import type * as CINETypes from './CINETypes';
|
|
17
18
|
import type { Color, ColorLUT, RepresentationConfig, SegmentationRepresentationConfig, SegmentationRepresentationData, Segmentation, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, SegmentationState, RepresentationPublicInput } from './SegmentationStateTypes';
|
|
18
|
-
export type { Annotation, Annotations, FrameOfReferenceSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, PlanarBoundingBox, ToolProps, PublicToolProps, EventTypes, IPoints, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, IToolGroup, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, RepresentationPublicInput, Color, ColorLUT, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, };
|
|
19
|
+
export type { Annotation, Annotations, FrameOfReferenceSpecificAnnotations, AnnotationState, AnnotationStyle, ToolSpecificAnnotationTypes, JumpToSliceOptions, PlanarBoundingBox, ToolProps, PublicToolProps, EventTypes, IPoints, IToolBinding, SetToolBindingsType, ToolOptionsType, InteractionTypes, IToolGroup, ToolHandle, AnnotationHandle, TextBoxHandle, Segmentation, SegmentationState, SegmentationRepresentationData, SegmentationRepresentationConfig, RepresentationConfig, ToolGroupSpecificRepresentationState, ToolGroupSpecificLabelmapRepresentation, ToolGroupSpecificRepresentation, RepresentationPublicInput, Color, ColorLUT, LabelmapTypes, SVGCursorDescriptor, SVGPoint, ScrollOptions, CINETypes, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/utilities/cine/events.ts"],"names":[],"mappings":"AAGA,IAAK,MAGJ;AAHD,WAAK,MAAM;IACT,wDAA8C,CAAA;IAC9C,wDAA8C,CAAA;AAChD,CAAC,EAHI,MAAM,KAAN,MAAM,QAGV;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/cine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { utilities, getEnabledElement, StackViewport, } from '@cornerstonejs/core';
|
|
2
|
+
import CINE_EVENTS from './events';
|
|
3
|
+
import { addToolState, getToolState } from './state';
|
|
4
|
+
const { triggerEvent } = utilities;
|
|
5
|
+
function playClip(element, playClipOptions) {
|
|
6
|
+
let playClipTimeouts;
|
|
7
|
+
let playClipIsTimeVarying;
|
|
8
|
+
if (element === undefined) {
|
|
9
|
+
throw new Error('playClip: element must not be undefined');
|
|
10
|
+
}
|
|
11
|
+
const enabledElement = getEnabledElement(element);
|
|
12
|
+
if (!enabledElement) {
|
|
13
|
+
throw new Error('playClip: element must be a valid Cornerstone enabled element');
|
|
14
|
+
}
|
|
15
|
+
const { viewport } = enabledElement;
|
|
16
|
+
if (!(viewport instanceof StackViewport)) {
|
|
17
|
+
throw new Error('playClip: element must be a stack viewport, volume viewport playClip not yet implemented');
|
|
18
|
+
}
|
|
19
|
+
const stackData = {
|
|
20
|
+
currentImageIdIndex: viewport.getCurrentImageIdIndex(),
|
|
21
|
+
imageIds: viewport.getImageIds(),
|
|
22
|
+
};
|
|
23
|
+
let playClipData = getToolState(element);
|
|
24
|
+
if (!playClipData) {
|
|
25
|
+
playClipData = {
|
|
26
|
+
intervalId: undefined,
|
|
27
|
+
framesPerSecond: 30,
|
|
28
|
+
lastFrameTimeStamp: undefined,
|
|
29
|
+
ignoreFrameTimeVector: false,
|
|
30
|
+
usingFrameTimeVector: false,
|
|
31
|
+
frameTimeVector: playClipOptions.frameTimeVector ?? undefined,
|
|
32
|
+
speed: playClipOptions.frameTimeVectorSpeedMultiplier ?? 1,
|
|
33
|
+
reverse: playClipOptions.reverse ?? false,
|
|
34
|
+
loop: playClipOptions.loop ?? true,
|
|
35
|
+
};
|
|
36
|
+
addToolState(element, playClipData);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
_stopClipWithData(playClipData);
|
|
40
|
+
}
|
|
41
|
+
if (playClipOptions.framesPerSecond < 0 ||
|
|
42
|
+
playClipOptions.framesPerSecond > 0) {
|
|
43
|
+
playClipData.framesPerSecond = Number(playClipOptions.framesPerSecond);
|
|
44
|
+
playClipData.reverse = playClipData.framesPerSecond < 0;
|
|
45
|
+
playClipData.ignoreFrameTimeVector = true;
|
|
46
|
+
}
|
|
47
|
+
if (playClipData.ignoreFrameTimeVector !== true &&
|
|
48
|
+
playClipData.frameTimeVector &&
|
|
49
|
+
playClipData.frameTimeVector.length === stackData.imageIds.length) {
|
|
50
|
+
const { timeouts, isTimeVarying } = _getPlayClipTimeouts(playClipData.frameTimeVector, playClipData.speed);
|
|
51
|
+
playClipTimeouts = timeouts;
|
|
52
|
+
playClipIsTimeVarying = isTimeVarying;
|
|
53
|
+
}
|
|
54
|
+
const playClipAction = () => {
|
|
55
|
+
let newImageIdIndex = stackData.currentImageIdIndex;
|
|
56
|
+
const imageCount = stackData.imageIds.length;
|
|
57
|
+
if (playClipData.reverse) {
|
|
58
|
+
newImageIdIndex--;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
newImageIdIndex++;
|
|
62
|
+
}
|
|
63
|
+
if (!playClipData.loop &&
|
|
64
|
+
(newImageIdIndex < 0 || newImageIdIndex >= imageCount)) {
|
|
65
|
+
_stopClipWithData(playClipData);
|
|
66
|
+
const eventDetail = {
|
|
67
|
+
element,
|
|
68
|
+
};
|
|
69
|
+
triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, eventDetail);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (newImageIdIndex >= imageCount) {
|
|
73
|
+
newImageIdIndex = 0;
|
|
74
|
+
}
|
|
75
|
+
if (newImageIdIndex < 0) {
|
|
76
|
+
newImageIdIndex = imageCount - 1;
|
|
77
|
+
}
|
|
78
|
+
if (newImageIdIndex !== stackData.currentImageIdIndex) {
|
|
79
|
+
viewport.setImageIdIndex(newImageIdIndex).then(() => {
|
|
80
|
+
stackData.currentImageIdIndex = newImageIdIndex;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (playClipTimeouts &&
|
|
85
|
+
playClipTimeouts.length > 0 &&
|
|
86
|
+
playClipIsTimeVarying) {
|
|
87
|
+
playClipData.usingFrameTimeVector = true;
|
|
88
|
+
playClipData.intervalId = window.setTimeout(function playClipTimeoutHandler() {
|
|
89
|
+
playClipData.intervalId = window.setTimeout(playClipTimeoutHandler, playClipTimeouts[stackData.currentImageIdIndex]);
|
|
90
|
+
playClipAction();
|
|
91
|
+
}, 0);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
playClipData.usingFrameTimeVector = false;
|
|
95
|
+
playClipData.intervalId = window.setInterval(playClipAction, 1000 / Math.abs(playClipData.framesPerSecond));
|
|
96
|
+
}
|
|
97
|
+
const eventDetail = {
|
|
98
|
+
element,
|
|
99
|
+
};
|
|
100
|
+
triggerEvent(element, CINE_EVENTS.CLIP_STARTED, eventDetail);
|
|
101
|
+
}
|
|
102
|
+
function stopClip(element) {
|
|
103
|
+
const enabledElement = getEnabledElement(element);
|
|
104
|
+
const { viewport } = enabledElement;
|
|
105
|
+
const cineToolData = getToolState(viewport.element);
|
|
106
|
+
if (!cineToolData) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
_stopClipWithData(cineToolData);
|
|
110
|
+
}
|
|
111
|
+
function _getPlayClipTimeouts(vector, speed) {
|
|
112
|
+
let i;
|
|
113
|
+
let sample;
|
|
114
|
+
let delay;
|
|
115
|
+
let sum = 0;
|
|
116
|
+
const limit = vector.length;
|
|
117
|
+
const timeouts = [];
|
|
118
|
+
let isTimeVarying = false;
|
|
119
|
+
if (typeof speed !== 'number' || speed <= 0) {
|
|
120
|
+
speed = 1;
|
|
121
|
+
}
|
|
122
|
+
for (i = 1; i < limit; i++) {
|
|
123
|
+
delay = (Number(vector[i]) / speed) | 0;
|
|
124
|
+
timeouts.push(delay);
|
|
125
|
+
if (i === 1) {
|
|
126
|
+
sample = delay;
|
|
127
|
+
}
|
|
128
|
+
else if (delay !== sample) {
|
|
129
|
+
isTimeVarying = true;
|
|
130
|
+
}
|
|
131
|
+
sum += delay;
|
|
132
|
+
}
|
|
133
|
+
if (timeouts.length > 0) {
|
|
134
|
+
if (isTimeVarying) {
|
|
135
|
+
delay = (sum / timeouts.length) | 0;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
delay = timeouts[0];
|
|
139
|
+
}
|
|
140
|
+
timeouts.push(delay);
|
|
141
|
+
}
|
|
142
|
+
return { timeouts, isTimeVarying };
|
|
143
|
+
}
|
|
144
|
+
function _stopClipWithData(playClipData) {
|
|
145
|
+
const id = playClipData.intervalId;
|
|
146
|
+
if (typeof id !== 'undefined') {
|
|
147
|
+
playClipData.intervalId = undefined;
|
|
148
|
+
if (playClipData.usingFrameTimeVector) {
|
|
149
|
+
clearTimeout(id);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
clearInterval(id);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export { playClip, stopClip };
|
|
157
|
+
//# sourceMappingURL=playClip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playClip.js","sourceRoot":"","sources":["../../../../src/utilities/cine/playClip.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,WAAW,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrD,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;AASnC,SAAS,QAAQ,CACf,OAAuB,EACvB,eAA0C;IAE1C,IAAI,gBAAgB,CAAC;IACrB,IAAI,qBAAqB,CAAC;IAE1B,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAElD,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;KACH;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;IAEpC,IAAI,CAAC,CAAC,QAAQ,YAAY,aAAa,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;KACH;IAED,MAAM,SAAS,GAAG;QAChB,mBAAmB,EAAE,QAAQ,CAAC,sBAAsB,EAAE;QACtD,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE;KACjC,CAAC;IAEF,IAAI,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG;YACb,UAAU,EAAE,SAAS;YACrB,eAAe,EAA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AAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,IAAI,aAAa,EAAE;YAGjB,KAAK,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACrC;aAAM;YACL,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;SACrB;QAED,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AACrC,CAAC;AAMD,SAAS,iBAAiB,CAAC,YAAY;IACrC,MAAM,EAAE,GAAG,YAAY,CAAC,UAAU,CAAC;IAEnC,IAAI,OAAO,EAAE,KAAK,WAAW,EAAE;QAC7B,YAAY,CAAC,UAAU,GAAG,SAAS,CAAC;QACpC,IAAI,YAAY,CAAC,oBAAoB,EAAE;YACrC,YAAY,CAAC,EAAE,CAAC,CAAC;SAClB;aAAM;YACL,aAAa,CAAC,EAAE,CAAC,CAAC;SACnB;KACF;AACH,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
2
|
+
const state = {};
|
|
3
|
+
function addToolState(element, data) {
|
|
4
|
+
const enabledElement = getEnabledElement(element);
|
|
5
|
+
const { viewportId } = enabledElement;
|
|
6
|
+
state[viewportId] = data;
|
|
7
|
+
}
|
|
8
|
+
function getToolState(element) {
|
|
9
|
+
const enabledElement = getEnabledElement(element);
|
|
10
|
+
const { viewportId } = enabledElement;
|
|
11
|
+
return state[viewportId];
|
|
12
|
+
}
|
|
13
|
+
export { addToolState, getToolState };
|
|
14
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../src/utilities/cine/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,KAAK,GAAuC,EAAE,CAAC;AAErD,SAAS,YAAY,CAAC,OAAuB,EAAE,IAAwB;IACrE,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IACtC,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AAC3B,CAAC;AAED,SAAS,YAAY,CAAC,OAAuB;IAC3C,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IACtC,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -15,5 +15,6 @@ import * as planar from './planar';
|
|
|
15
15
|
import * as stackScrollTool from './stackScrollTool';
|
|
16
16
|
import * as viewportFilters from './viewportFilters';
|
|
17
17
|
import * as orientation from './orientation';
|
|
18
|
+
import * as cine from './cine';
|
|
18
19
|
import { triggerEvent } from '@cornerstonejs/core';
|
|
19
|
-
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, };
|
|
20
|
+
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, cine, };
|
|
@@ -15,6 +15,7 @@ import * as planar from './planar';
|
|
|
15
15
|
import * as stackScrollTool from './stackScrollTool';
|
|
16
16
|
import * as viewportFilters from './viewportFilters';
|
|
17
17
|
import * as orientation from './orientation';
|
|
18
|
+
import * as cine from './cine';
|
|
18
19
|
import { triggerEvent } from '@cornerstonejs/core';
|
|
19
|
-
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, };
|
|
20
|
+
export { math, planar, viewportFilters, stackScrollTool, drawing, debounce, deepMerge, throttle, orientation, isObject, triggerEvent, calibrateImageSpacing, segmentation, triggerAnnotationRenderForViewportIds, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, cine, };
|
|
20
21
|
//# sourceMappingURL=index.js.map
|