@cornerstonejs/tools 1.9.3 → 1.10.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/enums/Events.d.ts +1 -0
- package/dist/cjs/enums/Events.js +1 -0
- package/dist/cjs/enums/Events.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +8 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/types/EventTypes.d.ts +8 -1
- package/dist/esm/enums/Events.d.ts +1 -0
- package/dist/esm/enums/Events.js +1 -0
- package/dist/esm/enums/Events.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +9 -2
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/types/EventTypes.d.ts +8 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/enums/Events.ts +13 -0
- package/src/store/ToolGroupManager/ToolGroup.ts +13 -1
- package/src/types/EventTypes.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.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.10.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": "898c6a5a3c38fadaa181a74205de6fc29b50e62a"
|
|
56
56
|
}
|
package/src/enums/Events.ts
CHANGED
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
enum Events {
|
|
8
|
+
///////////////////////////////////////
|
|
9
|
+
// Tools
|
|
10
|
+
///////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Triggers on the eventTarget when a new tools is activated.
|
|
14
|
+
*
|
|
15
|
+
* Make use of {@link EventTypes.ToolActivatedEventType | Tool Activated Event Type }
|
|
16
|
+
* for typing your event listeners for this tool activated event, and see what event
|
|
17
|
+
* detail is included in {@link EventTypes.ToolActivatedEventDetail | Tool Activated Event Detail}.
|
|
18
|
+
*/
|
|
19
|
+
TOOL_ACTIVATED = 'CORNERSTONE_TOOLS_TOOL_ACTIVATED',
|
|
20
|
+
|
|
8
21
|
///////////////////////////////////////
|
|
9
22
|
// Annotations
|
|
10
23
|
///////////////////////////////////////
|
|
@@ -2,6 +2,8 @@ import { MouseBindings, ToolModes } from '../../enums';
|
|
|
2
2
|
import cloneDeep from 'lodash.clonedeep';
|
|
3
3
|
import get from 'lodash.get';
|
|
4
4
|
import {
|
|
5
|
+
triggerEvent,
|
|
6
|
+
eventTarget,
|
|
5
7
|
getRenderingEngine,
|
|
6
8
|
getRenderingEngines,
|
|
7
9
|
getEnabledElementByIds,
|
|
@@ -9,6 +11,8 @@ import {
|
|
|
9
11
|
utilities as csUtils,
|
|
10
12
|
} from '@cornerstonejs/core';
|
|
11
13
|
import type { Types } from '@cornerstonejs/core';
|
|
14
|
+
import { Events } from '../../enums';
|
|
15
|
+
import { ToolActivatedEventDetail } from '../../types/EventTypes';
|
|
12
16
|
import { state } from '../index';
|
|
13
17
|
import {
|
|
14
18
|
IToolBinding,
|
|
@@ -69,7 +73,7 @@ export default class ToolGroup implements IToolGroup {
|
|
|
69
73
|
const toolInstance = this._toolInstances[toolInstanceName];
|
|
70
74
|
if (!toolInstance) {
|
|
71
75
|
console.warn(
|
|
72
|
-
`'${toolInstanceName}' is not registered with this toolGroup.`
|
|
76
|
+
`'${toolInstanceName}' is not registered with this toolGroup (${this.id}).`
|
|
73
77
|
);
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
@@ -372,6 +376,14 @@ export default class ToolGroup implements IToolGroup {
|
|
|
372
376
|
toolInstance.onSetToolActive();
|
|
373
377
|
}
|
|
374
378
|
this._renderViewports();
|
|
379
|
+
|
|
380
|
+
const eventDetail: ToolActivatedEventDetail = {
|
|
381
|
+
toolGroupId: this.id,
|
|
382
|
+
toolName,
|
|
383
|
+
toolBindingsOptions,
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
triggerEvent(eventTarget, Events.TOOL_ACTIVATED, eventDetail);
|
|
375
387
|
}
|
|
376
388
|
|
|
377
389
|
/**
|
package/src/types/EventTypes.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Annotation } from './AnnotationTypes';
|
|
|
3
3
|
import IPoints from './IPoints';
|
|
4
4
|
import ITouchPoints from './ITouchPoints';
|
|
5
5
|
import IDistance from './IDistance';
|
|
6
|
+
import { SetToolBindingsType } from './ISetToolModeOptions';
|
|
6
7
|
import { Swipe } from '../enums/Touch';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -70,6 +71,18 @@ type InteractionStartEventDetail = InteractionEventDetail;
|
|
|
70
71
|
|
|
71
72
|
type InteractionEndEventDetail = InteractionEventDetail;
|
|
72
73
|
|
|
74
|
+
/**
|
|
75
|
+
* The data that is passed to the event handler when a tool is activated.
|
|
76
|
+
*/
|
|
77
|
+
type ToolActivatedEventDetail = {
|
|
78
|
+
/** unique id of the toolGroup */
|
|
79
|
+
toolGroupId: string;
|
|
80
|
+
/** Tool name */
|
|
81
|
+
toolName: string;
|
|
82
|
+
/** Tool binding options */
|
|
83
|
+
toolBindingsOptions: SetToolBindingsType;
|
|
84
|
+
};
|
|
85
|
+
|
|
73
86
|
/**
|
|
74
87
|
* The data that is passed to the event handler when a new annotation is added
|
|
75
88
|
* to the annotations.
|
|
@@ -411,6 +424,11 @@ type NormalizedMouseEventType = Types.CustomEventType<MouseCustomEventDetail>;
|
|
|
411
424
|
*/
|
|
412
425
|
type NormalizedTouchEventType = Types.CustomEventType<TouchCustomEventDetail>;
|
|
413
426
|
|
|
427
|
+
/**
|
|
428
|
+
* The ToolActivated event type
|
|
429
|
+
*/
|
|
430
|
+
type ToolActivatedEventType = Types.CustomEventType<ToolActivatedEventDetail>;
|
|
431
|
+
|
|
414
432
|
/**
|
|
415
433
|
* The AnnotationAdded event type
|
|
416
434
|
*/
|
|
@@ -611,6 +629,8 @@ export {
|
|
|
611
629
|
NormalizedInteractionEventDetail,
|
|
612
630
|
NormalizedMouseEventType,
|
|
613
631
|
NormalizedTouchEventType,
|
|
632
|
+
ToolActivatedEventDetail,
|
|
633
|
+
ToolActivatedEventType,
|
|
614
634
|
AnnotationAddedEventDetail,
|
|
615
635
|
AnnotationAddedEventType,
|
|
616
636
|
AnnotationCompletedEventDetail,
|