dwv 0.33.1 → 0.34.0-beta.10

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/dwv.d.ts CHANGED
@@ -12,6 +12,264 @@ export declare function addTagsToDictionary(group: string, tags: {
12
12
  [x: string]: string[];
13
13
  }): void;
14
14
 
15
+ /**
16
+ * Image annotation.
17
+ */
18
+ export declare class Annotation {
19
+ /**
20
+ * The ID.
21
+ *
22
+ * @type {string}
23
+ */
24
+ id: string;
25
+ /**
26
+ * The reference image SOP UID.
27
+ *
28
+ * @type {string}
29
+ */
30
+ referenceSopUID: string;
31
+ /**
32
+ * The mathematical shape.
33
+ *
34
+ * @type {object}
35
+ */
36
+ mathShape: object;
37
+ /**
38
+ * Additional points used to define the annotation.
39
+ *
40
+ * @type {Point2D[]|undefined}
41
+ */
42
+ referencePoints: Point2D[] | undefined;
43
+ /**
44
+ * The color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
45
+ *
46
+ * @type {string|undefined}
47
+ */
48
+ colour: string | undefined;
49
+ /**
50
+ * Annotation quantification.
51
+ *
52
+ * @type {object|undefined}
53
+ */
54
+ quantification: object | undefined;
55
+ /**
56
+ * Text expression. Can contain variables surrounded with '{}' that will
57
+ * be extracted from the quantification object.
58
+ *
59
+ * @type {string|undefined}
60
+ */
61
+ textExpr: string | undefined;
62
+ /**
63
+ * Label position. If undefined, the default shape
64
+ * label position will be used.
65
+ *
66
+ * @type {Point2D|undefined}
67
+ */
68
+ labelPosition: Point2D | undefined;
69
+ /**
70
+ * Set the associated view controller.
71
+ *
72
+ * @param {ViewController} viewController The associated view controller.
73
+ */
74
+ setViewController(viewController: ViewController): void;
75
+ /**
76
+ * Get the image origin for a image UID.
77
+ *
78
+ * @returns {Index|undefined} The origin index.
79
+ */
80
+ getOriginIndex(): Index | undefined;
81
+ /**
82
+ * Set the annotation text expression.
83
+ *
84
+ * @param {Object.<string, string>} labelText The list of label
85
+ * texts indexed by modality.
86
+ */
87
+ setTextExpr(labelText: {
88
+ [x: string]: string;
89
+ }): void;
90
+ /**
91
+ * Get the annotation label text by applying the
92
+ * text expression on the current quantification.
93
+ *
94
+ * @returns {string} The resulting text.
95
+ */
96
+ getText(): string;
97
+ /**
98
+ * Update the annotation quantification.
99
+ */
100
+ updateQuantification(): void;
101
+ /**
102
+ * Get the math shape associated draw factory.
103
+ *
104
+ * @returns {object} The factory.
105
+ */
106
+ getFactory(): object;
107
+ /**
108
+ * Get the string type of this annotation.
109
+ *
110
+ * @returns {string} The type.
111
+ */
112
+ getType(): string;
113
+ #private;
114
+ }
115
+
116
+ /**
117
+ * Annotation group.
118
+ */
119
+ export declare class AnnotationGroup {
120
+ /**
121
+ * @param {Annotation[]} [list] Optional list, will
122
+ * create new if not provided.
123
+ */
124
+ constructor(list?: Annotation[]);
125
+ /**
126
+ * Get the annotation group as an array.
127
+ *
128
+ * @returns {Annotation[]} The array.
129
+ */
130
+ getList(): Annotation[];
131
+ /**
132
+ * Get the number of annotations of this list.
133
+ *
134
+ * @returns {number} The number of annotations.
135
+ */
136
+ getLength(): number;
137
+ /**
138
+ * Check if the annotation group is editable.
139
+ *
140
+ * @returns {boolean} True if editable.
141
+ */
142
+ isEditable(): boolean;
143
+ /**
144
+ * Set the annotation group editability.
145
+ *
146
+ * @param {boolean} flag True to make the annotation group editable.
147
+ */
148
+ setEditable(flag: boolean): void;
149
+ /**
150
+ * Add a new annotation.
151
+ *
152
+ * @param {Annotation} annotation The annotation to add.
153
+ */
154
+ add(annotation: Annotation): void;
155
+ /**
156
+ * Update an existing annotation.
157
+ *
158
+ * @param {Annotation} annotation The annotation to update.
159
+ * @param {string[]} [propKeys] Optional properties that got updated.
160
+ */
161
+ update(annotation: Annotation, propKeys?: string[]): void;
162
+ /**
163
+ * Remove an annotation.
164
+ *
165
+ * @param {string} id The id of the annotation to remove.
166
+ */
167
+ remove(id: string): void;
168
+ /**
169
+ * Set the associated view controller.
170
+ *
171
+ * @param {ViewController} viewController The associated view controller.
172
+ */
173
+ setViewController(viewController: ViewController): void;
174
+ /**
175
+ * Find an annotation.
176
+ *
177
+ * @param {string} id The id of the annotation to find.
178
+ * @returns {Annotation|undefined} The found annotation.
179
+ */
180
+ find(id: string): Annotation | undefined;
181
+ /**
182
+ * Get the meta data.
183
+ *
184
+ * @returns {Object<string, any>} The meta data.
185
+ */
186
+ getMeta(): {
187
+ [x: string]: any;
188
+ };
189
+ /**
190
+ * Check if this list contains a meta data value.
191
+ *
192
+ * @param {string} key The key to check.
193
+ * @returns {boolean} True if the meta data is present.
194
+ */
195
+ hasMeta(key: string): boolean;
196
+ /**
197
+ * Get a meta data value.
198
+ *
199
+ * @param {string} key The meta data key.
200
+ * @returns {string|object} The meta data value.
201
+ */
202
+ getMetaValue(key: string): string | object;
203
+ /**
204
+ * Set a meta data.
205
+ *
206
+ * @param {string} key The meta data key.
207
+ * @param {string|object} value The value of the meta data.
208
+ */
209
+ setMetaValue(key: string, value: string | object): void;
210
+ /**
211
+ * Add an event listener to this class.
212
+ *
213
+ * @param {string} type The event type.
214
+ * @param {Function} callback The function associated with the provided
215
+ * event type, will be called with the fired event.
216
+ */
217
+ addEventListener(type: string, callback: Function): void;
218
+ /**
219
+ * Remove an event listener from this class.
220
+ *
221
+ * @param {string} type The event type.
222
+ * @param {Function} callback The function associated with the provided
223
+ * event type.
224
+ */
225
+ removeEventListener(type: string, callback: Function): void;
226
+ #private;
227
+ }
228
+
229
+ /**
230
+ * {@link AnnotationGroup} factory.
231
+ */
232
+ export declare class AnnotationGroupFactory {
233
+ /**
234
+ * Get a warning string if elements are not as expected.
235
+ * Created by checkElements.
236
+ *
237
+ * @returns {string|undefined} The warning.
238
+ */
239
+ getWarning(): string | undefined;
240
+ /**
241
+ * Check dicom elements. Throws an error if not suitable.
242
+ *
243
+ * @param {Object<string, DataElement>} dataElements The DICOM data elements.
244
+ * @returns {string|undefined} A possible warning.
245
+ */
246
+ checkElements(dataElements: {
247
+ [x: string]: DataElement;
248
+ }): string | undefined;
249
+ /**
250
+ * Get an {@link Annotation} object from the read DICOM file.
251
+ *
252
+ * @param {Object<string, DataElement>} dataElements The DICOM tags.
253
+ * @returns {AnnotationGroup} A new annotation group.
254
+ */
255
+ create(dataElements: {
256
+ [x: string]: DataElement;
257
+ }): AnnotationGroup;
258
+ /**
259
+ * Convert an annotation group into a DICOM SR object.
260
+ *
261
+ * @param {AnnotationGroup} annotationGroup The annotation group.
262
+ * @param {Object<string, any>} [extraTags] Optional list of extra tags.
263
+ * @returns {Object<string, DataElement>} A list of dicom elements.
264
+ */
265
+ toDicom(annotationGroup: AnnotationGroup, extraTags?: {
266
+ [x: string]: any;
267
+ }): {
268
+ [x: string]: DataElement;
269
+ };
270
+ #private;
271
+ }
272
+
15
273
  /**
16
274
  * List of ViewConfigs indexed by dataIds.
17
275
  *
@@ -35,12 +293,12 @@ export declare function addTagsToDictionary(group: string, tags: {
35
293
  */
36
294
  export declare class App {
37
295
  /**
38
- * Get the image.
296
+ * Get a DicomData.
39
297
  *
40
298
  * @param {string} dataId The data id.
41
- * @returns {Image|undefined} The associated image.
299
+ * @returns {DicomData|undefined} The data.
42
300
  */
43
- getImage(dataId: string): Image_2 | undefined;
301
+ getData(dataId: string): DicomData | undefined;
44
302
  /**
45
303
  * Set the image at the given id.
46
304
  *
@@ -49,15 +307,12 @@ export declare class App {
49
307
  */
50
308
  setImage(dataId: string, img: Image_2): void;
51
309
  /**
52
- * Add a new image.
310
+ * Add a new DicomData.
53
311
  *
54
- * @param {Image} image The new image.
55
- * @param {object} meta The image meta.
56
- * @param {string} source The source of the new image,
57
- * will be passed with load events.
58
- * @returns {string} The new image data id.
312
+ * @param {DicomData} data The new data.
313
+ * @returns {string} The data id.
59
314
  */
60
- addNewImage(image: Image_2, meta: object, source: string): string;
315
+ addData(data: DicomData): string;
61
316
  /**
62
317
  * Get the meta data.
63
318
  *
@@ -176,6 +431,15 @@ export declare class App {
176
431
  * @function
177
432
  */
178
433
  addToUndoStack: (cmd: object) => void;
434
+ /**
435
+ * Remove a command from the undo stack.
436
+ *
437
+ * @param {string} name The name of the command to remove.
438
+ * @returns {boolean} True if the command was found and removed.
439
+ * @fires UndoStack#undoremove
440
+ * @function
441
+ */
442
+ removeFromUndoStack: (name: string) => boolean;
179
443
  /**
180
444
  * Initialise the application.
181
445
  *
@@ -412,19 +676,22 @@ export declare class App {
412
676
  /**
413
677
  * Set the drawings of the active layer group.
414
678
  *
415
- * @param {Array} drawings An array of drawings.
416
- * @param {Array} drawingsDetails An array of drawings details.
679
+ * @deprecated
680
+ * @param {Array} _drawings An array of drawings.
681
+ * @param {Array} _drawingsDetails An array of drawings details.
417
682
  */
418
- setDrawings(drawings: any[], drawingsDetails: any[]): void;
683
+ setDrawings(_drawings: any[], _drawingsDetails: any[]): void;
419
684
  /**
420
685
  * Get the JSON state of the app.
421
686
  *
687
+ * @deprecated
422
688
  * @returns {string} The state of the app as a JSON string.
423
689
  */
424
690
  getJsonState(): string;
425
691
  /**
426
692
  * Apply a JSON state to this app.
427
693
  *
694
+ * @deprecated
428
695
  * @param {string} jsonState The state of the app as a JSON string.
429
696
  */
430
697
  applyJsonState(jsonState: string): void;
@@ -532,6 +799,29 @@ export declare class App {
532
799
  * @param {string} dataId The data id.
533
800
  */
534
801
  toggleOverlayListeners(dataId: string): void;
802
+ /**
803
+ * Create new annotation data based on the data of
804
+ * the active view layer.
805
+ *
806
+ * @param {LayerGroup} layerGroup The layerGroup with the data to associate
807
+ * to the annotation.
808
+ * @returns {DicomData} The new data.
809
+ */
810
+ createAnnotationData(layerGroup: LayerGroup): DicomData;
811
+ /**
812
+ * Add new data and render it with a simple new data view config.
813
+ *
814
+ * @param {DicomData} data The data to add.
815
+ * @param {string} divId The div where to draw.
816
+ */
817
+ addAndRenderAnnotationData(data: DicomData, divId: string): void;
818
+ /**
819
+ * Add a draw layer.
820
+ *
821
+ * @param {string} dataId The data id.
822
+ * @param {ViewConfig} viewConfig The data view config.
823
+ */
824
+ addDrawLayer(dataId: string, viewConfig: ViewConfig): void;
535
825
  #private;
536
826
  }
537
827
 
@@ -734,10 +1024,10 @@ export declare namespace customUI {
734
1024
  /**
735
1025
  * Open a dialogue to edit roi data. Defaults to window.prompt.
736
1026
  *
737
- * @param {object} data The roi data.
1027
+ * @param {Annotation} annotation The roi data.
738
1028
  * @param {Function} callback The callback to launch on dialogue exit.
739
1029
  */
740
- export function openRoiDialog(data: any, callback: Function): void;
1030
+ export function openRoiDialog(annotation: Annotation, callback: Function): void;
741
1031
  }
742
1032
 
743
1033
  /**
@@ -887,35 +1177,69 @@ export declare class DicomCode {
887
1177
  */
888
1178
  constructor(meaning: string);
889
1179
  /**
890
- * Code meaning (0008,0104).
1180
+ * Code meaning.
891
1181
  *
892
1182
  * @type {string}
893
1183
  */
894
1184
  meaning: string;
895
1185
  /**
896
- * Code value (0008,0100).
1186
+ * Code value.
897
1187
  *
898
1188
  * @type {string|undefined}
899
1189
  */
900
1190
  value: string | undefined;
901
1191
  /**
902
- * Long code value (0008,0119).
1192
+ * Long code value.
903
1193
  *
904
1194
  * @type {string|undefined}
905
1195
  */
906
1196
  longValue: string | undefined;
907
1197
  /**
908
- * URN code value (0008,0120).
1198
+ * URN code value.
909
1199
  *
910
1200
  * @type {string|undefined}
911
1201
  */
912
1202
  urnValue: string | undefined;
913
1203
  /**
914
- * Coding scheme designator (0008,0102).
1204
+ * Coding scheme designator.
915
1205
  *
916
1206
  * @type {string|undefined}
917
1207
  */
918
1208
  schemeDesignator: string | undefined;
1209
+ /**
1210
+ * Get a string representation of this object.
1211
+ *
1212
+ * @returns {string} The code as string.
1213
+ */
1214
+ toString(): string;
1215
+ }
1216
+
1217
+ /**
1218
+ * DICOM data: meta and possible image.
1219
+ */
1220
+ export declare class DicomData {
1221
+ /**
1222
+ * @param {object} meta The DICOM meta data.
1223
+ */
1224
+ constructor(meta: object);
1225
+ /**
1226
+ * DICOM meta data.
1227
+ *
1228
+ * @type {object}
1229
+ */
1230
+ meta: object;
1231
+ /**
1232
+ * Image extracted from meta data.
1233
+ *
1234
+ * @type {Image|undefined}
1235
+ */
1236
+ image: Image_2 | undefined;
1237
+ /**
1238
+ * Annotattion group extracted from meta data.
1239
+ *
1240
+ * @type {AnnotationGroup|undefined}
1241
+ */
1242
+ annotationGroup: AnnotationGroup | undefined;
919
1243
  }
920
1244
 
921
1245
  /**
@@ -981,6 +1305,55 @@ export declare class DicomParser {
981
1305
  #private;
982
1306
  }
983
1307
 
1308
+ /**
1309
+ * DICOM SR content: item of a SR content sequence.
1310
+ *
1311
+ * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_C.17.3.html}.
1312
+ */
1313
+ export declare class DicomSRContent {
1314
+ /**
1315
+ * @param {string} valueType The content item value type.
1316
+ */
1317
+ constructor(valueType: string);
1318
+ /**
1319
+ * Value type.
1320
+ *
1321
+ * @type {string}
1322
+ */
1323
+ valueType: string;
1324
+ /**
1325
+ * Concept name code.
1326
+ *
1327
+ * @type {DicomCode|undefined}
1328
+ */
1329
+ conceptNameCode: DicomCode | undefined;
1330
+ /**
1331
+ * Relationship Type.
1332
+ *
1333
+ * @type {string}
1334
+ */
1335
+ relationshipType: string;
1336
+ /**
1337
+ * Content sequence (0040,A730).
1338
+ *
1339
+ * @type {DicomSRContent[]|undefined}
1340
+ */
1341
+ contentSequence: DicomSRContent[] | undefined;
1342
+ /**
1343
+ * Value.
1344
+ *
1345
+ * @type {object}
1346
+ */
1347
+ value: object;
1348
+ /**
1349
+ * Get a string representation of this object.
1350
+ *
1351
+ * @param {string} [prefix] An optional prefix for recursive content.
1352
+ * @returns {string} The object as string.
1353
+ */
1354
+ toString(prefix?: string): string;
1355
+ }
1356
+
984
1357
  /**
985
1358
  * DICOM writer.
986
1359
  *
@@ -1070,135 +1443,107 @@ export declare class DicomWriter {
1070
1443
  */
1071
1444
  export declare class DrawController {
1072
1445
  /**
1073
- * @param {DrawLayer} drawLayer The draw layer.
1446
+ * @param {AnnotationGroup} [group] Optional annotation group.
1074
1447
  */
1075
- constructor(drawLayer: DrawLayer);
1448
+ constructor(group?: AnnotationGroup);
1076
1449
  /**
1077
- * Get the current position group.
1450
+ * Get an annotation.
1078
1451
  *
1079
- * @returns {Konva.Group|undefined} The Konva.Group.
1080
- */
1081
- getCurrentPosGroup(): Konva.Group | undefined;
1082
- /**
1083
- * Reset: clear the layers array.
1452
+ * @param {string} id The annotation id.
1453
+ * @returns {Annotation|undefined} The annotation.
1084
1454
  */
1085
- reset(): void;
1455
+ getAnnotation(id: string): Annotation | undefined;
1086
1456
  /**
1087
- * Get a Konva group using its id.
1457
+ * Get the annotation group.
1088
1458
  *
1089
- * @param {string} id The group id.
1090
- * @returns {object|undefined} The Konva group.
1459
+ * @returns {AnnotationGroup} The list.
1091
1460
  */
1092
- getGroup(id: string): object | undefined;
1461
+ getAnnotationGroup(): AnnotationGroup;
1093
1462
  /**
1094
- * Activate the current draw layer.
1463
+ * Check if the annotation group is editable.
1095
1464
  *
1096
- * @param {Index} index The current position.
1097
- * @param {number} scrollIndex The scroll index.
1098
- */
1099
- activateDrawLayer(index: Index, scrollIndex: number): void;
1100
- /**
1101
- * Get a list of drawing display details.
1102
- *
1103
- * @returns {DrawDetails[]} A list of draw details.
1465
+ * @returns {boolean} True if editable.
1104
1466
  */
1105
- getDrawDisplayDetails(): DrawDetails[];
1467
+ isAnnotationGroupEditable(): boolean;
1106
1468
  /**
1107
- * Get a list of drawing store details. Used in state.
1469
+ * Set the annotation group editability.
1108
1470
  *
1109
- * @returns {object} A list of draw details including id, text, quant...
1110
- * TODO Unify with getDrawDisplayDetails?
1471
+ * @param {boolean} flag True to make the annotation group editable.
1111
1472
  */
1112
- getDrawStoreDetails(): object;
1473
+ setAnnotationGroupEditable(flag: boolean): void;
1113
1474
  /**
1114
- * Set the drawings on the current stage.
1475
+ * Add an annotation.
1115
1476
  *
1116
- * @param {Array} drawings An array of drawings.
1117
- * @param {DrawDetails[]} drawingsDetails An array of drawings details.
1118
- * @param {object} cmdCallback The DrawCommand callback.
1119
- * @param {object} exeCallback The callback to call once the
1120
- * DrawCommand has been executed.
1477
+ * @param {Annotation} annotation The annotation to add.
1121
1478
  */
1122
- setDrawings(drawings: any[], drawingsDetails: DrawDetails[], cmdCallback: object, exeCallback: object): void;
1479
+ addAnnotation(annotation: Annotation): void;
1123
1480
  /**
1124
- * Update a drawing from its details.
1481
+ * Update an anotation from the list.
1125
1482
  *
1126
- * @param {DrawDetails} drawDetails Details of the drawing to update.
1483
+ * @param {Annotation} annotation The annotation to update.
1484
+ * @param {string[]} [propKeys] Optional properties that got updated.
1127
1485
  */
1128
- updateDraw(drawDetails: DrawDetails): void;
1486
+ updateAnnotation(annotation: Annotation, propKeys?: string[]): void;
1129
1487
  /**
1130
- * Delete a Draw from the stage.
1488
+ * Remove an anotation for the list.
1131
1489
  *
1132
- * @param {Konva.Group} group The group to delete.
1133
- * @param {object} cmdCallback The DeleteCommand callback.
1134
- * @param {object} exeCallback The callback to call once the
1135
- * DeleteCommand has been executed.
1490
+ * @param {string} id The id of the annotation to remove.
1136
1491
  */
1137
- deleteDrawGroup(group: Konva.Group, cmdCallback: object, exeCallback: object): void;
1492
+ removeAnnotation(id: string): void;
1138
1493
  /**
1139
- * Delete a Draw from the stage.
1494
+ * Remove an annotation via a remove command (triggers draw actions).
1140
1495
  *
1141
- * @param {string} id The id of the group to delete.
1142
- * @param {Function} cmdCallback The DeleteCommand callback.
1143
- * @param {Function} exeCallback The callback to call once the
1144
- * DeleteCommand has been executed.
1145
- * @returns {boolean} False if the group cannot be found.
1496
+ * @param {string} id The annotation id.
1497
+ * @param {Function} exeCallback The undo stack callback.
1146
1498
  */
1147
- deleteDraw(id: string, cmdCallback: Function, exeCallback: Function): boolean;
1148
- /**
1149
- * Delete all Draws from the stage.
1150
- *
1151
- * @param {Function} cmdCallback The DeleteCommand callback.
1152
- * @param {Function} exeCallback The callback to call once the
1153
- * DeleteCommand has been executed.
1154
- */
1155
- deleteDraws(cmdCallback: Function, exeCallback: Function): void;
1156
- /**
1157
- * Get the total number of draws
1158
- * (at all positions).
1159
- *
1160
- * @returns {number} The total number of draws.
1161
- */
1162
- getNumberOfDraws(): number;
1163
- #private;
1164
- }
1165
-
1166
- /**
1167
- * Draw details.
1168
- */
1169
- export declare class DrawDetails {
1499
+ removeAnnotationWithCommand(id: string, exeCallback: Function): void;
1170
1500
  /**
1171
- * The draw ID.
1501
+ * Update an annotation via an update command (triggers draw actions).
1172
1502
  *
1173
- * @type {number}
1503
+ * @param {string} id The annotation id.
1504
+ * @param {object} originalProps The original annotation properties
1505
+ * that will be updated.
1506
+ * @param {object} newProps The new annotation properties
1507
+ * that will replace the original ones.
1508
+ * @param {Function} exeCallback The undo stack callback.
1174
1509
  */
1175
- id: number;
1510
+ updateAnnotationWithCommand(id: string, originalProps: object, newProps: object, exeCallback: Function): void;
1176
1511
  /**
1177
- * The draw position: an Index converted to string.
1512
+ * Remove all annotations via remove commands (triggers draw actions).
1178
1513
  *
1179
- * @type {string}
1514
+ * @param {Function} exeCallback The undo stack callback.
1180
1515
  */
1181
- position: string;
1516
+ removeAllAnnotationsWithCommand(exeCallback: Function): void;
1182
1517
  /**
1183
- * The draw type.
1518
+ * Check if the annotation group contains a meta data value.
1184
1519
  *
1185
- * @type {string}
1520
+ * @param {string} key The key to check.
1521
+ * @returns {boolean} True if the meta data is present.
1186
1522
  */
1187
- type: string;
1523
+ hasAnnotationMeta(key: string): boolean;
1188
1524
  /**
1189
- * The draw color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
1525
+ * Set an annotation meta data.
1190
1526
  *
1191
- * @type {string}
1527
+ * @param {string} key The meta data to set.
1528
+ * @param {string} value The value of the meta data.
1192
1529
  */
1193
- color: string;
1530
+ setAnnotationMeta(key: string, value: string): void;
1194
1531
  /**
1195
- * The draw meta.
1532
+ * Get draw store details.
1196
1533
  *
1197
- * @type {DrawMeta}
1534
+ * @deprecated
1198
1535
  */
1199
- meta: DrawMeta;
1536
+ getDrawStoreDetails(): void;
1537
+ #private;
1200
1538
  }
1201
1539
 
1540
+ /**
1541
+ * Debug function to output the layer hierarchy as text.
1542
+ *
1543
+ * @param {object} layer The Konva layer.
1544
+ * @param {string} prefix A display prefix (used in recursion).
1545
+ * @returns {string} A text representation of the hierarchy.
1546
+ */
1202
1547
  /**
1203
1548
  * Draw layer.
1204
1549
  */
@@ -1208,6 +1553,12 @@ export declare class DrawLayer {
1208
1553
  * as this layer id.
1209
1554
  */
1210
1555
  constructor(containerDiv: HTMLDivElement);
1556
+ /**
1557
+ * Set the draw shape handler.
1558
+ *
1559
+ * @param {DrawShapeHandler|undefined} handler The shape handler.
1560
+ */
1561
+ setShapeHandler(handler: DrawShapeHandler | undefined): void;
1211
1562
  /**
1212
1563
  * Get the associated data id.
1213
1564
  *
@@ -1229,9 +1580,9 @@ export declare class DrawLayer {
1229
1580
  /**
1230
1581
  * Get the draw controller.
1231
1582
  *
1232
- * @returns {object} The controller.
1583
+ * @returns {DrawController} The controller.
1233
1584
  */
1234
- getDrawController(): object;
1585
+ getDrawController(): DrawController;
1235
1586
  /**
1236
1587
  * Set the plane helper.
1237
1588
  *
@@ -1329,9 +1680,16 @@ export declare class DrawLayer {
1329
1680
  *
1330
1681
  * @param {Scalar2D} size The image size as {x,y}.
1331
1682
  * @param {Scalar2D} spacing The image spacing as {x,y}.
1683
+ */
1684
+ initialise(size: Scalar2D, spacing: Scalar2D): void;
1685
+ /**
1686
+ * Set the annotation group.
1687
+ *
1688
+ * @param {AnnotationGroup} annotationGroup The annotation group.
1332
1689
  * @param {string} dataId The associated data id.
1690
+ * @param {object} exeCallback The undo stack callback.
1333
1691
  */
1334
- initialise(size: Scalar2D, spacing: Scalar2D, dataId: string): void;
1692
+ setAnnotationGroup(annotationGroup: AnnotationGroup, dataId: string, exeCallback: object): void;
1335
1693
  /**
1336
1694
  * Fit the layer to its parent container.
1337
1695
  *
@@ -1341,34 +1699,45 @@ export declare class DrawLayer {
1341
1699
  */
1342
1700
  fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void;
1343
1701
  /**
1344
- * Check the visibility of a given group.
1702
+ * Check the visibility of an annotation.
1703
+ *
1704
+ * @param {string} id The id of the annotation.
1705
+ * @returns {boolean} True if the annotation is visible.
1706
+ */
1707
+ isAnnotationVisible(id: string): boolean;
1708
+ /**
1709
+ * Set the visibility of an annotation.
1345
1710
  *
1346
- * @param {string} id The id of the group.
1347
- * @returns {boolean} True if the group is visible.
1711
+ * @param {string} id The id of the annotation.
1712
+ * @param {boolean} [visible] True to set to visible,
1713
+ * will toggle visibility if not defined.
1714
+ * @returns {boolean} False if the annotation shape cannot be found.
1348
1715
  */
1349
- isGroupVisible(id: string): boolean;
1716
+ setAnnotationVisibility(id: string, visible?: boolean): boolean;
1350
1717
  /**
1351
- * Toggle the visibility of a given group.
1718
+ * Set the visibility of all labels.
1352
1719
  *
1353
- * @param {string} id The id of the group.
1354
- * @returns {boolean} False if the group cannot be found.
1720
+ * @param {boolean} [visible] True to set to visible,
1721
+ * will toggle visibility if not defined.
1355
1722
  */
1356
- toggleGroupVisibility(id: string): boolean;
1723
+ setLabelsVisibility(visible?: boolean): void;
1357
1724
  /**
1358
1725
  * Delete a Draw from the stage.
1359
1726
  *
1360
- * @param {string} id The id of the group to delete.
1361
- * @param {object} exeCallback The callback to call once the
1727
+ * @deprecated
1728
+ * @param {string} _id The id of the group to delete.
1729
+ * @param {Function} _exeCallback The callback to call once the
1362
1730
  * DeleteCommand has been executed.
1363
1731
  */
1364
- deleteDraw(id: string, exeCallback: object): void;
1732
+ deleteDraw(_id: string, _exeCallback: Function): void;
1365
1733
  /**
1366
1734
  * Delete all Draws from the stage.
1367
1735
  *
1368
- * @param {object} exeCallback The callback to call once the
1736
+ * @deprecated
1737
+ * @param {Function} _exeCallback The callback to call once the
1369
1738
  * DeleteCommand has been executed.
1370
1739
  */
1371
- deleteDraws(exeCallback: object): void;
1740
+ deleteDraws(_exeCallback: Function): void;
1372
1741
  /**
1373
1742
  * Get the total number of draws of this layer
1374
1743
  * (at all positions).
@@ -1392,6 +1761,32 @@ export declare class DrawLayer {
1392
1761
  * @returns {boolean} True if the position was updated.
1393
1762
  */
1394
1763
  setCurrentPosition(position: Point, index: Index): boolean;
1764
+ /**
1765
+ * Activate the current draw layer.
1766
+ *
1767
+ * @param {Index} index The current position.
1768
+ * @param {number} scrollIndex The scroll index.
1769
+ */
1770
+ activateDrawLayer(index: Index, scrollIndex: number): void;
1771
+ /**
1772
+ * Get the current position group.
1773
+ *
1774
+ * @returns {Konva.Group|undefined} The Konva.Group.
1775
+ */
1776
+ getCurrentPosGroup(): Konva.Group | undefined;
1777
+ /**
1778
+ * Get the non current position groups. Used to stop listeners.
1779
+ *
1780
+ * @returns {object[]} The groups that do not have the current position id.
1781
+ */
1782
+ getNonCurrentPosGroup(): object[];
1783
+ /**
1784
+ * Get a Konva group using its id.
1785
+ *
1786
+ * @param {string} id The group id.
1787
+ * @returns {object|undefined} The Konva group.
1788
+ */
1789
+ getGroup(id: string): object | undefined;
1395
1790
  /**
1396
1791
  * Add an event listener to this class.
1397
1792
  *
@@ -1412,22 +1807,66 @@ export declare class DrawLayer {
1412
1807
  }
1413
1808
 
1414
1809
  /**
1415
- * Draw meta data.
1810
+ * Draw shape handler: handle action on existing shapes.
1416
1811
  */
1417
- export declare class DrawMeta {
1812
+ export declare class DrawShapeHandler {
1813
+ /**
1814
+ * @callback eventFn@callback eventFn
1815
+ * @param {object} event The event.
1816
+ */
1817
+ /**
1818
+ * @param {App} app The associated application.
1819
+ * @param {Function} eventCallback Event callback.
1820
+ */
1821
+ constructor(app: App, eventCallback: Function);
1418
1822
  /**
1419
- * Draw quantification.
1823
+ * Set the draw editor shape.
1420
1824
  *
1421
- * @type {object}
1825
+ * @param {Konva.Shape} shape The shape to edit.
1826
+ * @param {DrawLayer} drawLayer The layer the shape belongs to.
1422
1827
  */
1423
- quantification: object;
1828
+ setEditorShape(shape: Konva.Shape, drawLayer: DrawLayer): void;
1424
1829
  /**
1425
- * Draw text expression. Can contain variables surrounded with '{}' that will
1426
- * be extracted from the quantification object.
1830
+ * Get the currently edited shape group.
1427
1831
  *
1428
- * @type {string}
1832
+ * @returns {Konva.Group|undefined} The edited group.
1833
+ */
1834
+ getEditorShapeGroup(): Konva.Group | undefined;
1835
+ /**
1836
+ * Get the currently edited annotation.
1837
+ *
1838
+ * @returns {Annotation|undefined} The edited annotation.
1839
+ */
1840
+ getEditorAnnotation(): Annotation | undefined;
1841
+ /**
1842
+ * Disable and reset the shape editor.
1843
+ */
1844
+ disableAndResetEditor(): void;
1845
+ /**
1846
+ * Store specific mouse over cursor.
1847
+ *
1848
+ * @param {string} cursor The cursor name.
1849
+ */
1850
+ storeMouseOverCursor(cursor: string): void;
1851
+ /**
1852
+ * Handle shape group mouseout.
1429
1853
  */
1430
- textExpr: string;
1854
+ onMouseOutShapeGroup(): void;
1855
+ /**
1856
+ * Add shape group listeners.
1857
+ *
1858
+ * @param {DrawLayer} drawLayer The origin draw layer.
1859
+ * @param {Konva.Group} shapeGroup The shape group to set on.
1860
+ * @param {Annotation} annotation The associated annotation.
1861
+ */
1862
+ addShapeListeners(drawLayer: DrawLayer, shapeGroup: Konva.Group, annotation: Annotation): void;
1863
+ /**
1864
+ * Remove shape group listeners.
1865
+ *
1866
+ * @param {Konva.Group} shapeGroup The shape group to set off.
1867
+ */
1868
+ removeShapeListeners(shapeGroup: Konva.Group): void;
1869
+ #private;
1431
1870
  }
1432
1871
 
1433
1872
  /**
@@ -1619,6 +2058,16 @@ export declare class Geometry {
1619
2058
  */
1620
2059
  export declare function getDefaultDicomSegJson(): object;
1621
2060
 
2061
+ /**
2062
+ * Get a simple dicom element item from a content item object.
2063
+ *
2064
+ * @param {DicomSRContent} content The content item object.
2065
+ * @returns {Object<string, any>} The item as a list of (key, value) pairs.
2066
+ */
2067
+ export declare function getDicomSRContentItem(content: DicomSRContent): {
2068
+ [x: string]: any;
2069
+ };
2070
+
1622
2071
  /**
1623
2072
  * List of DICOM data elements indexed via a 8 character string formed from
1624
2073
  * the group and element numbers.
@@ -1700,6 +2149,16 @@ export declare function getPixelDataTag(): Tag;
1700
2149
  */
1701
2150
  export declare function getReverseOrientation(ori: string): string;
1702
2151
 
2152
+ /**
2153
+ * Get a content item object from a dicom element.
2154
+ *
2155
+ * @param {Object<string, DataElement>} dataElements The dicom element.
2156
+ * @returns {DicomSRContent} A content item object.
2157
+ */
2158
+ export declare function getSRContent(dataElements: {
2159
+ [x: string]: DataElement;
2160
+ }): DicomSRContent;
2161
+
1703
2162
  /**
1704
2163
  * Split a group-element key used to store DICOM elements.
1705
2164
  *
@@ -1817,6 +2276,13 @@ declare class Image_2 {
1817
2276
  * @returns {string} The UID.
1818
2277
  */
1819
2278
  getImageUid(index?: Index): string;
2279
+ /**
2280
+ * Get the image origin for a image UID.
2281
+ *
2282
+ * @param {string} uid The UID.
2283
+ * @returns {Point3D|undefined} The origin.
2284
+ */
2285
+ getOriginForImageUid(uid: string): Point3D | undefined;
1820
2286
  /**
1821
2287
  * Check if this image includes the input uids.
1822
2288
  *
@@ -3224,6 +3690,13 @@ export declare class Point2D {
3224
3690
  * @returns {string} The point as a string.
3225
3691
  */
3226
3692
  toString(): string;
3693
+ /**
3694
+ * Get the distance to another Point2D.
3695
+ *
3696
+ * @param {Point2D} point2D The input point.
3697
+ * @returns {number} Ths distance to the input point.
3698
+ */
3699
+ getDistance(point2D: Point2D): number;
3227
3700
  #private;
3228
3701
  }
3229
3702
 
@@ -4043,6 +4516,19 @@ export declare class View {
4043
4516
  * @returns {Index} The current index.
4044
4517
  */
4045
4518
  getCurrentIndex(): Index;
4519
+ /**
4520
+ * Get the SOP image UID of the current image.
4521
+ *
4522
+ * @returns {string} The UID.
4523
+ */
4524
+ getCurrentImageUid(): string;
4525
+ /**
4526
+ * Get the image origin for a image UID.
4527
+ *
4528
+ * @param {string} uid The UID.
4529
+ * @returns {Index|undefined} The origin index.
4530
+ */
4531
+ getOriginIndexForImageUid(uid: string): Index | undefined;
4046
4532
  /**
4047
4533
  * Check if the current position (default) or
4048
4534
  * the provided position is in bounds.
@@ -4213,9 +4699,8 @@ export declare class ViewConfig {
4213
4699
  export declare class ViewController {
4214
4700
  /**
4215
4701
  * @param {View} view The associated view.
4216
- * @param {string} dataId The associated data id.
4217
4702
  */
4218
- constructor(view: View, dataId: string);
4703
+ constructor(view: View);
4219
4704
  /**
4220
4705
  * Get the plane helper.
4221
4706
  *
@@ -4281,6 +4766,19 @@ export declare class ViewController {
4281
4766
  * @returns {Index} The current index.
4282
4767
  */
4283
4768
  getCurrentIndex(): Index;
4769
+ /**
4770
+ * Get the SOP image UID of the current image.
4771
+ *
4772
+ * @returns {string} The UID.
4773
+ */
4774
+ getCurrentImageUid(): string;
4775
+ /**
4776
+ * Get the image origin index for a image UID.
4777
+ *
4778
+ * @param {string} uid The UID.
4779
+ * @returns {Index|undefined} The origin index.
4780
+ */
4781
+ getOriginIndexForImageUid(uid: string): Index | undefined;
4284
4782
  /**
4285
4783
  * Get the current oriented index.
4286
4784
  *
@@ -4324,9 +4822,8 @@ export declare class ViewController {
4324
4822
  * Set the associated image.
4325
4823
  *
4326
4824
  * @param {Image} img The associated image.
4327
- * @param {string} dataId The data id of the image.
4328
4825
  */
4329
- setImage(img: Image_2, dataId: string): void;
4826
+ setImage(img: Image_2): void;
4330
4827
  /**
4331
4828
  * Get the current view (2D) spacing.
4332
4829
  *
@@ -4593,22 +5090,6 @@ export declare class ViewController {
4593
5090
  * @param {ViewLayer} viewLayer The layer to bind.
4594
5091
  */
4595
5092
  unbindImageAndLayer(viewLayer: ViewLayer): void;
4596
- /**
4597
- * Add an event listener to this class.
4598
- *
4599
- * @param {string} type The event type.
4600
- * @param {Function} callback The function associated with the provided
4601
- * event type, will be called with the fired event.
4602
- */
4603
- addEventListener(type: string, callback: Function): void;
4604
- /**
4605
- * Remove an event listener from this class.
4606
- *
4607
- * @param {string} type The event type.
4608
- * @param {Function} callback The function associated with the provided
4609
- * event type.
4610
- */
4611
- removeEventListener(type: string, callback: Function): void;
4612
5093
  #private;
4613
5094
  }
4614
5095