dwv 0.34.0-beta.2 → 0.34.0-beta.21

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
@@ -19,8 +19,6 @@ export declare class Annotation {
19
19
  /**
20
20
  * The ID.
21
21
  *
22
- * 'Tracking Unique Identifier', 112040, DCM.
23
- *
24
22
  * @type {string}
25
23
  */
26
24
  id: string;
@@ -30,12 +28,6 @@ export declare class Annotation {
30
28
  * @type {string}
31
29
  */
32
30
  referenceSopUID: string;
33
- /**
34
- * The position: an Index converted to string.
35
- *
36
- * @type {string}
37
- */
38
- position: string;
39
31
  /**
40
32
  * The mathematical shape.
41
33
  *
@@ -43,40 +35,81 @@ export declare class Annotation {
43
35
  */
44
36
  mathShape: object;
45
37
  /**
46
- * The color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
38
+ * Additional points used to define the annotation.
47
39
  *
48
- * 'RGB R Component', 110834, DCM...
40
+ * @type {Point2D[]|undefined}
41
+ */
42
+ referencePoints: Point2D[] | undefined;
43
+ /**
44
+ * The color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
49
45
  *
50
- * @type {string}
46
+ * @type {string|undefined}
51
47
  */
52
- colour: string;
48
+ colour: string | undefined;
53
49
  /**
54
50
  * Annotation quantification.
55
51
  *
56
- * @type {object}
52
+ * @type {object|undefined}
57
53
  */
58
- quantification: object;
54
+ quantification: object | undefined;
59
55
  /**
60
56
  * Text expression. Can contain variables surrounded with '{}' that will
61
57
  * be extracted from the quantification object.
62
58
  *
63
- * 'Short label', 125309, DCM.
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
+ * The plane origin, the 3D position of index [0, 0, k].
64
71
  *
65
- * @type {string}
72
+ * @type {Point3D|undefined}
66
73
  */
67
- textExpr: string;
74
+ planeOrigin: Point3D | undefined;
68
75
  /**
69
- * Set the associated view controller.
76
+ * A couple of points that help define the annotation plane.
77
+ *
78
+ * @type {Point3D[]|undefined}
79
+ */
80
+ planePoints: Point3D[] | undefined;
81
+ /**
82
+ * Get the orientation name for this annotation.
83
+ *
84
+ * @returns {string|undefined} The orientation name,
85
+ * undefined if same as reference data.
86
+ */
87
+ getOrientationName(): string | undefined;
88
+ /**
89
+ * Initialise the annotation.
70
90
  *
71
91
  * @param {ViewController} viewController The associated view controller.
72
92
  */
93
+ init(viewController: ViewController): void;
94
+ /**
95
+ * Check if an input view is compatible with the annotation.
96
+ *
97
+ * @param {PlaneHelper} planeHelper The input view to check.
98
+ * @returns {boolean} True if compatible view.
99
+ */
100
+ isCompatibleView(planeHelper: PlaneHelper): boolean;
101
+ /**
102
+ * Set the associated view controller if it is compatible.
103
+ *
104
+ * @param {ViewController} viewController The view controller.
105
+ */
73
106
  setViewController(viewController: ViewController): void;
74
107
  /**
75
- * Get the image origin for a image UID.
108
+ * Get the centroid of the math shape.
76
109
  *
77
- * @returns {Index|undefined} The origin index.
110
+ * @returns {Point|undefined} The 3D centroid point.
78
111
  */
79
- getOriginIndex(): Index | undefined;
112
+ getCentroid(): Point | undefined;
80
113
  /**
81
114
  * Set the annotation text expression.
82
115
  *
@@ -98,7 +131,7 @@ export declare class Annotation {
98
131
  */
99
132
  updateQuantification(): void;
100
133
  /**
101
- * Get the math shape associated factory.
134
+ * Get the math shape associated draw factory.
102
135
  *
103
136
  * @returns {object} The factory.
104
137
  */
@@ -106,50 +139,6 @@ export declare class Annotation {
106
139
  #private;
107
140
  }
108
141
 
109
- /**
110
- * {@link Annotation} factory.
111
- */
112
- export declare class AnnotationFactory {
113
- /**
114
- * Get a warning string if elements are not as expected.
115
- * Created by checkElements.
116
- *
117
- * @returns {string|undefined} The warning.
118
- */
119
- getWarning(): string | undefined;
120
- /**
121
- * Check dicom elements. Throws an error if not suitable.
122
- *
123
- * @param {Object<string, DataElement>} dataElements The DICOM data elements.
124
- * @returns {string|undefined} A possible warning.
125
- */
126
- checkElements(dataElements: {
127
- [x: string]: DataElement;
128
- }): string | undefined;
129
- /**
130
- * Get an {@link Annotation} object from the read DICOM file.
131
- *
132
- * @param {Object<string, DataElement>} dataElements The DICOM tags.
133
- * @returns {AnnotationGroup} A new annotation group.
134
- */
135
- create(dataElements: {
136
- [x: string]: DataElement;
137
- }): AnnotationGroup;
138
- /**
139
- * Convert an annotation group into a DICOM SR object.
140
- *
141
- * @param {AnnotationGroup} annotationGroup The annotation group.
142
- * @param {Object<string, any>} [extraTags] Optional list of extra tags.
143
- * @returns {Object<string, DataElement>} A list of dicom elements.
144
- */
145
- toDicom(annotationGroup: AnnotationGroup, extraTags?: {
146
- [x: string]: any;
147
- }): {
148
- [x: string]: DataElement;
149
- };
150
- #private;
151
- }
152
-
153
142
  /**
154
143
  * Annotation group.
155
144
  */
@@ -171,6 +160,30 @@ export declare class AnnotationGroup {
171
160
  * @returns {number} The number of annotations.
172
161
  */
173
162
  getLength(): number;
163
+ /**
164
+ * Check if the annotation group is editable.
165
+ *
166
+ * @returns {boolean} True if editable.
167
+ */
168
+ isEditable(): boolean;
169
+ /**
170
+ * Set the annotation group editability.
171
+ *
172
+ * @param {boolean} flag True to make the annotation group editable.
173
+ */
174
+ setEditable(flag: boolean): void;
175
+ /**
176
+ * Get the group colour.
177
+ *
178
+ * @returns {string} The colour as hex string.
179
+ */
180
+ getColour(): string;
181
+ /**
182
+ * Set the group colour.
183
+ *
184
+ * @param {string} colour The colour as hex string.
185
+ */
186
+ setColour(colour: string): void;
174
187
  /**
175
188
  * Add a new annotation.
176
189
  *
@@ -181,8 +194,9 @@ export declare class AnnotationGroup {
181
194
  * Update an existing annotation.
182
195
  *
183
196
  * @param {Annotation} annotation The annotation to update.
197
+ * @param {string[]} [propKeys] Optional properties that got updated.
184
198
  */
185
- update(annotation: Annotation): void;
199
+ update(annotation: Annotation, propKeys?: string[]): void;
186
200
  /**
187
201
  * Remove an annotation.
188
202
  *
@@ -202,6 +216,14 @@ export declare class AnnotationGroup {
202
216
  * @returns {Annotation|undefined} The found annotation.
203
217
  */
204
218
  find(id: string): Annotation | undefined;
219
+ /**
220
+ * Get the meta data.
221
+ *
222
+ * @returns {Object<string, any>} The meta data.
223
+ */
224
+ getMeta(): {
225
+ [x: string]: any;
226
+ };
205
227
  /**
206
228
  * Check if this list contains a meta data value.
207
229
  *
@@ -213,16 +235,16 @@ export declare class AnnotationGroup {
213
235
  * Get a meta data value.
214
236
  *
215
237
  * @param {string} key The meta data key.
216
- * @returns {string} The meta data value.
238
+ * @returns {string|object} The meta data value.
217
239
  */
218
- getMeta(key: string): string;
240
+ getMetaValue(key: string): string | object;
219
241
  /**
220
242
  * Set a meta data.
221
243
  *
222
244
  * @param {string} key The meta data key.
223
- * @param {string} value The value of the meta data.
245
+ * @param {string|object} value The value of the meta data.
224
246
  */
225
- setMeta(key: string, value: string): void;
247
+ setMetaValue(key: string, value: string | object): void;
226
248
  /**
227
249
  * Add an event listener to this class.
228
250
  *
@@ -242,6 +264,50 @@ export declare class AnnotationGroup {
242
264
  #private;
243
265
  }
244
266
 
267
+ /**
268
+ * {@link AnnotationGroup} factory.
269
+ */
270
+ export declare class AnnotationGroupFactory {
271
+ /**
272
+ * Get a warning string if elements are not as expected.
273
+ * Created by checkElements.
274
+ *
275
+ * @returns {string|undefined} The warning.
276
+ */
277
+ getWarning(): string | undefined;
278
+ /**
279
+ * Check dicom elements. Throws an error if not suitable.
280
+ *
281
+ * @param {Object<string, DataElement>} dataElements The DICOM data elements.
282
+ * @returns {string|undefined} A possible warning.
283
+ */
284
+ checkElements(dataElements: {
285
+ [x: string]: DataElement;
286
+ }): string | undefined;
287
+ /**
288
+ * Get an {@link Annotation} object from the read DICOM file.
289
+ *
290
+ * @param {Object<string, DataElement>} dataElements The DICOM tags.
291
+ * @returns {AnnotationGroup} A new annotation group.
292
+ */
293
+ create(dataElements: {
294
+ [x: string]: DataElement;
295
+ }): AnnotationGroup;
296
+ /**
297
+ * Convert an annotation group into a DICOM SR object.
298
+ *
299
+ * @param {AnnotationGroup} annotationGroup The annotation group.
300
+ * @param {Object<string, any>} [extraTags] Optional list of extra tags.
301
+ * @returns {Object<string, DataElement>} A list of dicom elements.
302
+ */
303
+ toDicom(annotationGroup: AnnotationGroup, extraTags?: {
304
+ [x: string]: any;
305
+ }): {
306
+ [x: string]: DataElement;
307
+ };
308
+ #private;
309
+ }
310
+
245
311
  /**
246
312
  * List of ViewConfigs indexed by dataIds.
247
313
  *
@@ -367,6 +433,16 @@ export declare class App {
367
433
  * @returns {ViewLayer[]} The layers.
368
434
  */
369
435
  getViewLayersByDataId(dataId: string): ViewLayer[];
436
+ /**
437
+ * Get a list of view layers according to an input callback function.
438
+ *
439
+ * @param {Function} [callbackFn] A function that takes
440
+ * a ViewLayer as input and returns a boolean. If undefined,
441
+ * returns all view layers.
442
+ * @returns {ViewLayer[]} The layers that
443
+ * satisfy the callbackFn.
444
+ */
445
+ getViewLayers(callbackFn?: Function): ViewLayer[];
370
446
  /**
371
447
  * Get the draw layers associated to a data id.
372
448
  * The layer are available after the first loaded item.
@@ -375,6 +451,16 @@ export declare class App {
375
451
  * @returns {DrawLayer[]} The layers.
376
452
  */
377
453
  getDrawLayersByDataId(dataId: string): DrawLayer[];
454
+ /**
455
+ * Get a list of draw layers according to an input callback function.
456
+ *
457
+ * @param {Function} [callbackFn] A function that takes
458
+ * a DrawLayer as input and returns a boolean. If undefined,
459
+ * returns all draw layers.
460
+ * @returns {DrawLayer[]} The layers that
461
+ * satisfy the callbackFn.
462
+ */
463
+ getDrawLayers(callbackFn?: Function): DrawLayer[];
378
464
  /**
379
465
  * Get a layer group by div id.
380
466
  * The layer is available after the first loaded item.
@@ -403,6 +489,15 @@ export declare class App {
403
489
  * @function
404
490
  */
405
491
  addToUndoStack: (cmd: object) => void;
492
+ /**
493
+ * Remove a command from the undo stack.
494
+ *
495
+ * @param {string} name The name of the command to remove.
496
+ * @returns {boolean} True if the command was found and removed.
497
+ * @fires UndoStack#undoremove
498
+ * @function
499
+ */
500
+ removeFromUndoStack: (name: string) => boolean;
406
501
  /**
407
502
  * Initialise the application.
408
503
  *
@@ -639,25 +734,20 @@ export declare class App {
639
734
  /**
640
735
  * Set the drawings of the active layer group.
641
736
  *
642
- * @deprecated
643
- * @param {Array} _drawings An array of drawings.
644
- * @param {Array} _drawingsDetails An array of drawings details.
645
- */
646
- setDrawings(_drawings: any[], _drawingsDetails: any[]): void;
647
- /**
648
- * Get the JSON state of the app.
649
- *
650
- * @deprecated
651
- * @returns {string} The state of the app as a JSON string.
737
+ * @deprecated Please switch to DICOM SR annotations.
738
+ * @param {Array} drawings An array of drawings.
739
+ * @param {Array} drawingsDetails An array of drawings details.
740
+ * @param {string} dataId The converted data id.
652
741
  */
653
- getJsonState(): string;
742
+ setDrawings(drawings: any[], drawingsDetails: any[], dataId: string): void;
654
743
  /**
655
744
  * Apply a JSON state to this app.
656
745
  *
657
746
  * @deprecated
658
747
  * @param {string} jsonState The state of the app as a JSON string.
748
+ * @param {string} dataId The state data id.
659
749
  */
660
- applyJsonState(jsonState: string): void;
750
+ applyJsonState(jsonState: string, dataId: string): void;
661
751
  /**
662
752
  * Handle resize: fit the display to the window.
663
753
  * To be called once the image is loaded.
@@ -762,6 +852,22 @@ export declare class App {
762
852
  * @param {string} dataId The data id.
763
853
  */
764
854
  toggleOverlayListeners(dataId: string): void;
855
+ /**
856
+ * Create new annotation data based on the data of
857
+ * the active view layer.
858
+ *
859
+ * @param {string} refDataId The reference data id.
860
+ * @returns {DicomData} The new data.
861
+ */
862
+ createAnnotationData(refDataId: string): DicomData;
863
+ /**
864
+ * Add new data and render it with a simple new data view config.
865
+ *
866
+ * @param {DicomData} data The data to add.
867
+ * @param {string} divId The div where to draw.
868
+ * @param {string} refDataId The reference data id.
869
+ */
870
+ addAndRenderAnnotationData(data: DicomData, divId: string, refDataId: string): void;
765
871
  /**
766
872
  * Add a draw layer.
767
873
  *
@@ -905,6 +1011,79 @@ export declare class ChangeSegmentColourCommand {
905
1011
  #private;
906
1012
  }
907
1013
 
1014
+ /**
1015
+ * Circle shape.
1016
+ */
1017
+ export declare class Circle {
1018
+ /**
1019
+ * @param {Point2D} centre A Point2D representing the centre
1020
+ * of the circle.
1021
+ * @param {number} radius The radius of the circle.
1022
+ */
1023
+ constructor(centre: Point2D, radius: number);
1024
+ /**
1025
+ * Get the centre (point) of the circle.
1026
+ *
1027
+ * @returns {Point2D} The center (point) of the circle.
1028
+ */
1029
+ getCenter(): Point2D;
1030
+ /**
1031
+ * Get the centroid of the circle.
1032
+ *
1033
+ * @returns {Point2D} The centroid point.
1034
+ */
1035
+ getCentroid(): Point2D;
1036
+ /**
1037
+ * Get the radius of the circle.
1038
+ *
1039
+ * @returns {number} The radius of the circle.
1040
+ */
1041
+ getRadius(): number;
1042
+ /**
1043
+ * Check for equality.
1044
+ *
1045
+ * @param {Circle} rhs The object to compare to.
1046
+ * @returns {boolean} True if both objects are equal.
1047
+ */
1048
+ equals(rhs: Circle): boolean;
1049
+ /**
1050
+ * Get the surface of the circle.
1051
+ *
1052
+ * @returns {number} The surface of the circle.
1053
+ */
1054
+ getSurface(): number;
1055
+ /**
1056
+ * Get the surface of the circle according to a spacing.
1057
+ *
1058
+ * @param {Scalar2D} spacing2D The 2D spacing.
1059
+ * @returns {number} The surface of the circle multiplied by the given
1060
+ * spacing or null for null spacings.
1061
+ */
1062
+ getWorldSurface(spacing2D: Scalar2D): number;
1063
+ /**
1064
+ * Get the rounded limits of the circle.
1065
+ *
1066
+ * See: {@link https://en.wikipedia.org/wiki/Circle#Equations}.
1067
+ *
1068
+ * Circle formula: `x*x + y*y = r*r`.
1069
+ *
1070
+ * Implies: `y = (+-) sqrt(r*r - x*x)`.
1071
+ *
1072
+ * @returns {number[][][]} The rounded limits:
1073
+ * list of [x, y] pairs (min, max).
1074
+ */
1075
+ getRound(): number[][][];
1076
+ /**
1077
+ * Quantify an circle according to view information.
1078
+ *
1079
+ * @param {ViewController} viewController The associated view controller.
1080
+ * @param {string[]} flags A list of stat values to calculate.
1081
+ * @returns {object} A quantification object.
1082
+ */
1083
+ quantify(viewController: ViewController, flags: string[]): object;
1084
+ #private;
1085
+ }
1086
+
908
1087
  /**
909
1088
  * Colour map: red, green and blue components
910
1089
  * to associate with intensity values.
@@ -1117,7 +1296,6 @@ export declare class DeleteSegmentCommand {
1117
1296
  * DICOM code: item of a basic code sequence.
1118
1297
  *
1119
1298
  * Ref: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part03/sect_8.8.html}.
1120
- * List: {@link https://dicom.nema.org/medical/dicom/2022a/output/chtml/part16/chapter_d.html}.
1121
1299
  */
1122
1300
  export declare class DicomCode {
1123
1301
  /**
@@ -1407,6 +1585,18 @@ export declare class DrawController {
1407
1585
  * @returns {AnnotationGroup} The list.
1408
1586
  */
1409
1587
  getAnnotationGroup(): AnnotationGroup;
1588
+ /**
1589
+ * Check if the annotation group is editable.
1590
+ *
1591
+ * @returns {boolean} True if editable.
1592
+ */
1593
+ isAnnotationGroupEditable(): boolean;
1594
+ /**
1595
+ * Set the annotation group editability.
1596
+ *
1597
+ * @param {boolean} flag True to make the annotation group editable.
1598
+ */
1599
+ setAnnotationGroupEditable(flag: boolean): void;
1410
1600
  /**
1411
1601
  * Add an annotation.
1412
1602
  *
@@ -1417,14 +1607,39 @@ export declare class DrawController {
1417
1607
  * Update an anotation from the list.
1418
1608
  *
1419
1609
  * @param {Annotation} annotation The annotation to update.
1610
+ * @param {string[]} [propKeys] Optional properties that got updated.
1420
1611
  */
1421
- updateAnnotation(annotation: Annotation): void;
1612
+ updateAnnotation(annotation: Annotation, propKeys?: string[]): void;
1422
1613
  /**
1423
1614
  * Remove an anotation for the list.
1424
1615
  *
1425
1616
  * @param {string} id The id of the annotation to remove.
1426
1617
  */
1427
1618
  removeAnnotation(id: string): void;
1619
+ /**
1620
+ * Remove an annotation via a remove command (triggers draw actions).
1621
+ *
1622
+ * @param {string} id The annotation id.
1623
+ * @param {Function} exeCallback The undo stack callback.
1624
+ */
1625
+ removeAnnotationWithCommand(id: string, exeCallback: Function): void;
1626
+ /**
1627
+ * Update an annotation via an update command (triggers draw actions).
1628
+ *
1629
+ * @param {string} id The annotation id.
1630
+ * @param {object} originalProps The original annotation properties
1631
+ * that will be updated.
1632
+ * @param {object} newProps The new annotation properties
1633
+ * that will replace the original ones.
1634
+ * @param {Function} exeCallback The undo stack callback.
1635
+ */
1636
+ updateAnnotationWithCommand(id: string, originalProps: object, newProps: object, exeCallback: Function): void;
1637
+ /**
1638
+ * Remove all annotations via remove commands (triggers draw actions).
1639
+ *
1640
+ * @param {Function} exeCallback The undo stack callback.
1641
+ */
1642
+ removeAllAnnotationsWithCommand(exeCallback: Function): void;
1428
1643
  /**
1429
1644
  * Check if the annotation group contains a meta data value.
1430
1645
  *
@@ -1439,12 +1654,6 @@ export declare class DrawController {
1439
1654
  * @param {string} value The value of the meta data.
1440
1655
  */
1441
1656
  setAnnotationMeta(key: string, value: string): void;
1442
- /**
1443
- * Get draw store details.
1444
- *
1445
- * @deprecated
1446
- */
1447
- getDrawStoreDetails(): void;
1448
1657
  #private;
1449
1658
  }
1450
1659
 
@@ -1464,12 +1673,24 @@ export declare class DrawLayer {
1464
1673
  * as this layer id.
1465
1674
  */
1466
1675
  constructor(containerDiv: HTMLDivElement);
1676
+ /**
1677
+ * Set the draw shape handler.
1678
+ *
1679
+ * @param {DrawShapeHandler|undefined} handler The shape handler.
1680
+ */
1681
+ setShapeHandler(handler: DrawShapeHandler | undefined): void;
1467
1682
  /**
1468
1683
  * Get the associated data id.
1469
1684
  *
1470
1685
  * @returns {string} The id.
1471
1686
  */
1472
1687
  getDataId(): string;
1688
+ /**
1689
+ * Get the reference data id.
1690
+ *
1691
+ * @returns {string} The id.
1692
+ */
1693
+ getReferenceLayerId(): string;
1473
1694
  /**
1474
1695
  * Get the Konva stage.
1475
1696
  *
@@ -1549,6 +1770,14 @@ export declare class DrawLayer {
1549
1770
  * @param {Point3D} [center] The scale center.
1550
1771
  */
1551
1772
  setScale(newScale: Scalar3D, center?: Point3D): void;
1773
+ /**
1774
+ * Initialise the layer scale.
1775
+ *
1776
+ * @param {Scalar3D} newScale The scale as {x,y,z}.
1777
+ * @param {Scalar2D} absoluteZoomOffset The zoom offset as {x,y}
1778
+ * without the fit scale (as provided by getAbsoluteZoomOffset).
1779
+ */
1780
+ initScale(newScale: Scalar3D, absoluteZoomOffset: Scalar2D): void;
1552
1781
  /**
1553
1782
  * Set the layer offset.
1554
1783
  *
@@ -1585,17 +1814,23 @@ export declare class DrawLayer {
1585
1814
  *
1586
1815
  * @param {Scalar2D} size The image size as {x,y}.
1587
1816
  * @param {Scalar2D} spacing The image spacing as {x,y}.
1817
+ * @param {string} refLayerId The reference image dataId.
1588
1818
  */
1589
- initialise(size: Scalar2D, spacing: Scalar2D): void;
1819
+ initialise(size: Scalar2D, spacing: Scalar2D, refLayerId: string): void;
1590
1820
  /**
1591
1821
  * Set the annotation group.
1592
1822
  *
1593
- * @param {AnnotationGroup} group The annotation group.
1823
+ * @param {AnnotationGroup} annotationGroup The annotation group.
1594
1824
  * @param {string} dataId The associated data id.
1595
- * @param {object} cmdCallback The command callback.
1596
- * @param {object} exeCallback The exe callback.
1825
+ * @param {object} exeCallback The undo stack callback.
1597
1826
  */
1598
- setAnnotationGroup(group: AnnotationGroup, dataId: string, cmdCallback: object, exeCallback: object): void;
1827
+ setAnnotationGroup(annotationGroup: AnnotationGroup, dataId: string, exeCallback: object): void;
1828
+ /**
1829
+ * Activate shapes at current position.
1830
+ *
1831
+ * @param {boolean} flag The flag to activate or not.
1832
+ */
1833
+ activateCurrentPositionShapes(flag: boolean): void;
1599
1834
  /**
1600
1835
  * Fit the layer to its parent container.
1601
1836
  *
@@ -1605,34 +1840,52 @@ export declare class DrawLayer {
1605
1840
  */
1606
1841
  fitToContainer(containerSize: Scalar2D, divToWorldSizeRatio: number, fitOffset: Scalar2D): void;
1607
1842
  /**
1608
- * Check the visibility of a given group.
1843
+ * Check the visibility of an annotation.
1844
+ *
1845
+ * @param {string} id The id of the annotation.
1846
+ * @returns {boolean} True if the annotation is visible.
1847
+ */
1848
+ isAnnotationVisible(id: string): boolean;
1849
+ /**
1850
+ * Set the visibility of an annotation.
1609
1851
  *
1610
- * @param {string} id The id of the group.
1611
- * @returns {boolean} True if the group is visible.
1852
+ * @param {string} id The id of the annotation.
1853
+ * @param {boolean} [visible] True to set to visible,
1854
+ * will toggle visibility if not defined.
1855
+ * @returns {boolean} False if the annotation shape cannot be found.
1612
1856
  */
1613
- isGroupVisible(id: string): boolean;
1857
+ setAnnotationVisibility(id: string, visible?: boolean): boolean;
1614
1858
  /**
1615
- * Toggle the visibility of a given group.
1859
+ * Set the visibility of all labels.
1616
1860
  *
1617
- * @param {string} id The id of the group.
1618
- * @returns {boolean} False if the group cannot be found.
1861
+ * @param {boolean} [visible] True to set to visible,
1862
+ * will toggle visibility if not defined.
1619
1863
  */
1620
- toggleGroupVisibility(id: string): boolean;
1864
+ setLabelsVisibility(visible?: boolean): void;
1865
+ /**
1866
+ * Set a shape group label visibility according to
1867
+ * this layer setting.
1868
+ *
1869
+ * @param {Konva.Group} shapeGroup The shape group.
1870
+ */
1871
+ setLabelVisibility(shapeGroup: Konva.Group): void;
1621
1872
  /**
1622
1873
  * Delete a Draw from the stage.
1623
1874
  *
1624
- * @param {string} id The id of the group to delete.
1625
- * @param {Function} exeCallback The callback to call once the
1875
+ * @deprecated
1876
+ * @param {string} _id The id of the group to delete.
1877
+ * @param {Function} _exeCallback The callback to call once the
1626
1878
  * DeleteCommand has been executed.
1627
1879
  */
1628
- deleteDraw(id: string, exeCallback: Function): void;
1880
+ deleteDraw(_id: string, _exeCallback: Function): void;
1629
1881
  /**
1630
1882
  * Delete all Draws from the stage.
1631
1883
  *
1632
- * @param {Function} exeCallback The callback to call once the
1884
+ * @deprecated
1885
+ * @param {Function} _exeCallback The callback to call once the
1633
1886
  * DeleteCommand has been executed.
1634
1887
  */
1635
- deleteDraws(exeCallback: Function): void;
1888
+ deleteDraws(_exeCallback: Function): void;
1636
1889
  /**
1637
1890
  * Get the total number of draws of this layer
1638
1891
  * (at all positions).
@@ -1652,52 +1905,182 @@ export declare class DrawLayer {
1652
1905
  * Set the current position.
1653
1906
  *
1654
1907
  * @param {Point} position The new position.
1655
- * @param {Index} index The new index.
1908
+ * @param {Index} [index] Optional coresponding index.
1656
1909
  * @returns {boolean} True if the position was updated.
1657
1910
  */
1658
- setCurrentPosition(position: Point, index: Index): boolean;
1911
+ setCurrentPosition(position: Point, index?: Index): boolean;
1912
+ /**
1913
+ * Get the current position group.
1914
+ *
1915
+ * @returns {Konva.Group|undefined} The Konva.Group.
1916
+ */
1917
+ getCurrentPosGroup(): Konva.Group | undefined;
1918
+ /**
1919
+ * Get a Konva group using its id.
1920
+ *
1921
+ * @param {string} id The group id.
1922
+ * @returns {object|undefined} The Konva group.
1923
+ */
1924
+ getGroup(id: string): object | undefined;
1925
+ /**
1926
+ * Add an event listener to this class.
1927
+ *
1928
+ * @param {string} type The event type.
1929
+ * @param {Function} callback The function associated with the provided
1930
+ * event type, will be called with the fired event.
1931
+ */
1932
+ addEventListener(type: string, callback: Function): void;
1933
+ /**
1934
+ * Remove an event listener from this class.
1935
+ *
1936
+ * @param {string} type The event type.
1937
+ * @param {Function} callback The function associated with the provided
1938
+ * event type.
1939
+ */
1940
+ removeEventListener(type: string, callback: Function): void;
1941
+ #private;
1942
+ }
1943
+
1944
+ /**
1945
+ * Draw shape handler: handle action on existing shapes.
1946
+ */
1947
+ export declare class DrawShapeHandler {
1948
+ /**
1949
+ * @callback eventFn@callback eventFn
1950
+ * @param {object} event The event.
1951
+ */
1952
+ /**
1953
+ * @param {App} app The associated application.
1954
+ * @param {Function} eventCallback Event callback.
1955
+ */
1956
+ constructor(app: App, eventCallback: Function);
1957
+ /**
1958
+ * Set the draw editor shape.
1959
+ *
1960
+ * @param {Konva.Shape} shape The shape to edit.
1961
+ * @param {DrawLayer} drawLayer The layer the shape belongs to.
1962
+ */
1963
+ setEditorShape(shape: Konva.Shape, drawLayer: DrawLayer): void;
1964
+ /**
1965
+ * Get the currently edited shape group.
1966
+ *
1967
+ * @returns {Konva.Group|undefined} The edited group.
1968
+ */
1969
+ getEditorShapeGroup(): Konva.Group | undefined;
1970
+ /**
1971
+ * Get the currently edited annotation.
1972
+ *
1973
+ * @returns {Annotation|undefined} The edited annotation.
1974
+ */
1975
+ getEditorAnnotation(): Annotation | undefined;
1976
+ /**
1977
+ * Disable and reset the shape editor.
1978
+ */
1979
+ disableAndResetEditor(): void;
1980
+ /**
1981
+ * Store specific mouse over cursor.
1982
+ *
1983
+ * @param {string} cursor The cursor name.
1984
+ */
1985
+ storeMouseOverCursor(cursor: string): void;
1986
+ /**
1987
+ * Handle shape group mouseout.
1988
+ */
1989
+ onMouseOutShapeGroup(): void;
1990
+ /**
1991
+ * Add shape group listeners.
1992
+ *
1993
+ * @param {Konva.Group} shapeGroup The shape group to set on.
1994
+ * @param {Annotation} annotation The associated annotation.
1995
+ * @param {DrawLayer} drawLayer The origin draw layer.
1996
+ */
1997
+ addShapeGroupListeners(shapeGroup: Konva.Group, annotation: Annotation, drawLayer: DrawLayer): void;
1998
+ /**
1999
+ * Remove shape group listeners.
2000
+ *
2001
+ * @param {Konva.Group} shapeGroup The shape group to set off.
2002
+ */
2003
+ removeShapeListeners(shapeGroup: Konva.Group): void;
2004
+ #private;
2005
+ }
2006
+
2007
+ /**
2008
+ * Ellipse shape.
2009
+ */
2010
+ export declare class Ellipse {
2011
+ /**
2012
+ * @param {Point2D} centre A Point2D representing the centre
2013
+ * of the ellipse.
2014
+ * @param {number} a The radius of the ellipse on the horizontal axe.
2015
+ * @param {number} b The radius of the ellipse on the vertical axe.
2016
+ */
2017
+ constructor(centre: Point2D, a: number, b: number);
2018
+ /**
2019
+ * Get the centre (point) of the ellipse.
2020
+ *
2021
+ * @returns {Point2D} The center (point) of the ellipse.
2022
+ */
2023
+ getCenter(): Point2D;
2024
+ /**
2025
+ * Get the centroid of the ellipse.
2026
+ *
2027
+ * @returns {Point2D} The centroid point.
2028
+ */
2029
+ getCentroid(): Point2D;
2030
+ /**
2031
+ * Get the radius of the ellipse on the horizontal axe.
2032
+ *
2033
+ * @returns {number} The radius of the ellipse on the horizontal axe.
2034
+ */
2035
+ getA(): number;
1659
2036
  /**
1660
- * Activate the current draw layer.
2037
+ * Get the radius of the ellipse on the vertical axe.
1661
2038
  *
1662
- * @param {Index} index The current position.
1663
- * @param {number} scrollIndex The scroll index.
2039
+ * @returns {number} The radius of the ellipse on the vertical axe.
1664
2040
  */
1665
- activateDrawLayer(index: Index, scrollIndex: number): void;
2041
+ getB(): number;
1666
2042
  /**
1667
- * Get the current position group.
2043
+ * Check for equality.
1668
2044
  *
1669
- * @returns {Konva.Group|undefined} The Konva.Group.
2045
+ * @param {Ellipse} rhs The object to compare to.
2046
+ * @returns {boolean} True if both objects are equal.
1670
2047
  */
1671
- getCurrentPosGroup(): Konva.Group | undefined;
2048
+ equals(rhs: Ellipse): boolean;
1672
2049
  /**
1673
- * Get the non current position groups. Used to stop listeners.
2050
+ * Get the surface of the ellipse.
1674
2051
  *
1675
- * @returns {object[]} The groups that do not have the current position id.
2052
+ * @returns {number} The surface of the ellipse.
1676
2053
  */
1677
- getNonCurrentPosGroup(): object[];
2054
+ getSurface(): number;
1678
2055
  /**
1679
- * Get a Konva group using its id.
2056
+ * Get the surface of the ellipse according to a spacing.
1680
2057
  *
1681
- * @param {string} id The group id.
1682
- * @returns {object|undefined} The Konva group.
2058
+ * @param {Scalar2D} spacing2D The 2D spacing.
2059
+ * @returns {number} The surface of the ellipse multiplied by the given
2060
+ * spacing or null for null spacings.
1683
2061
  */
1684
- getGroup(id: string): object | undefined;
2062
+ getWorldSurface(spacing2D: Scalar2D): number;
1685
2063
  /**
1686
- * Add an event listener to this class.
2064
+ * Get the rounded limits of the ellipse.
1687
2065
  *
1688
- * @param {string} type The event type.
1689
- * @param {Function} callback The function associated with the provided
1690
- * event type, will be called with the fired event.
2066
+ * See: {@link https://en.wikipedia.org/wiki/Ellipse#Standard_equation}.
2067
+ *
2068
+ * Ellipse formula: `x*x / a*a + y*y / b*b = 1`.
2069
+ *
2070
+ * Implies: `y = (+-)(b/a) * sqrt(a*a - x*x)`.
2071
+ *
2072
+ * @returns {number[][][]} The rounded limits:
2073
+ * list of [x, y] pairs (min, max).
1691
2074
  */
1692
- addEventListener(type: string, callback: Function): void;
2075
+ getRound(): number[][][];
1693
2076
  /**
1694
- * Remove an event listener from this class.
2077
+ * Quantify an ellipse according to view information.
1695
2078
  *
1696
- * @param {string} type The event type.
1697
- * @param {Function} callback The function associated with the provided
1698
- * event type.
2079
+ * @param {ViewController} viewController The associated view controller.
2080
+ * @param {string[]} flags A list of stat values to calculate.
2081
+ * @returns {object} A quantification object.
1699
2082
  */
1700
- removeEventListener(type: string, callback: Function): void;
2083
+ quantify(viewController: ViewController, flags: string[]): object;
1701
2084
  #private;
1702
2085
  }
1703
2086
 
@@ -1945,7 +2328,7 @@ export declare function getEllipseIndices(center: Index, radius: number[], dir:
1945
2328
  * @param {object} event The event to get the layer div id from. Expecting
1946
2329
  * an event origininating from a canvas inside a layer HTML div
1947
2330
  * with the 'layer' class and id generated with `getLayerDivId`.
1948
- * @returns {object} The layer details as {groupDivId, layerId}.
2331
+ * @returns {object} The layer details as {groupDivId, layerIndex, layerId}.
1949
2332
  */
1950
2333
  export declare function getLayerDetailsFromEvent(event: object): object;
1951
2334
 
@@ -1960,11 +2343,12 @@ export declare function getMousePoint(event: object): Point2D;
1960
2343
  /**
1961
2344
  * Get the name of an image orientation patient.
1962
2345
  *
1963
- * @param {number[]} orientation The image orientation patient.
2346
+ * @param {number[]} cosines The image orientation
2347
+ * patient cosines (6 values).
1964
2348
  * @returns {string|undefined} The orientation
1965
2349
  * name: axial, coronal or sagittal.
1966
2350
  */
1967
- export declare function getOrientationName(orientation: number[]): string | undefined;
2351
+ export declare function getOrientationName(cosines: number[]): string | undefined;
1968
2352
 
1969
2353
  /**
1970
2354
  * Get the PixelData Tag.
@@ -2115,6 +2499,13 @@ declare class Image_2 {
2115
2499
  * @returns {Point3D|undefined} The origin.
2116
2500
  */
2117
2501
  getOriginForImageUid(uid: string): Point3D | undefined;
2502
+ /**
2503
+ * Check if the image includes an UID.
2504
+ *
2505
+ * @param {string} uid The UID.
2506
+ * @returns {boolean} True if present.
2507
+ */
2508
+ includesImageUid(uid: string): boolean;
2118
2509
  /**
2119
2510
  * Check if this image includes the input uids.
2120
2511
  *
@@ -2535,13 +2926,6 @@ export declare class Index {
2535
2926
  * @returns {Index} The new index.
2536
2927
  */
2537
2928
  getWithNew2D(i: number, j: number): Index;
2538
- /**
2539
- * Get a string id from the index values in the form of: '#0-1_#1-2'.
2540
- *
2541
- * @param {number[]} [dims] Optional list of dimensions to use.
2542
- * @returns {string} The string id.
2543
- */
2544
- toStringId(dims?: number[]): string;
2545
2929
  #private;
2546
2930
  }
2547
2931
 
@@ -2646,6 +3030,35 @@ export declare class LayerGroup {
2646
3030
  * a layer with the input id.
2647
3031
  */
2648
3032
  includes(id: string): boolean;
3033
+ /**
3034
+ * Get a list of view layers according to an input callback function.
3035
+ *
3036
+ * @param {Function} [callbackFn] A function that takes
3037
+ * a ViewLayer as input and returns a boolean. If undefined,
3038
+ * returns all view layers.
3039
+ * @returns {ViewLayer[]} The layers that
3040
+ * satisfy the callbackFn.
3041
+ */
3042
+ getViewLayers(callbackFn?: Function): ViewLayer[];
3043
+ /**
3044
+ * Test if one of the view layers satisfies an input callbackFn.
3045
+ *
3046
+ * @param {Function} callbackFn A function that takes
3047
+ * a ViewLayer as input and returns a boolean.
3048
+ * @returns {boolean} True if one of the ViewLayers
3049
+ * satisfies the callbackFn.
3050
+ */
3051
+ someViewLayer(callbackFn: Function): boolean;
3052
+ /**
3053
+ * Get a list of draw layers according to an input callback function.
3054
+ *
3055
+ * @param {Function} [callbackFn] A function that takes
3056
+ * a DrawLayer as input and returns a boolean. If undefined,
3057
+ * returns all draw layers.
3058
+ * @returns {DrawLayer[]} The layers that
3059
+ * satisfy the callbackFn.
3060
+ */
3061
+ getDrawLayers(callbackFn?: Function): DrawLayer[];
2649
3062
  /**
2650
3063
  * Get the number of view layers handled by this class.
2651
3064
  *
@@ -2712,9 +3125,10 @@ export declare class LayerGroup {
2712
3125
  /**
2713
3126
  * Set the active draw layer.
2714
3127
  *
2715
- * @param {number} index The index of the layer to set as active.
3128
+ * @param {number|undefined} index The index of the layer to set as active
3129
+ * or undefined to not set any.
2716
3130
  */
2717
- setActiveDrawLayer(index: number): void;
3131
+ setActiveDrawLayer(index: number | undefined): void;
2718
3132
  /**
2719
3133
  * Set the active draw layer with a data id.
2720
3134
  *
@@ -2767,14 +3181,6 @@ export declare class LayerGroup {
2767
3181
  * Remove the tooltip html div.
2768
3182
  */
2769
3183
  removeTooltipDiv(): void;
2770
- /**
2771
- * Test if one of the view layers satisfies an input callbackFn.
2772
- *
2773
- * @param {Function} callbackFn A function that takes a ViewLayer as input
2774
- * and returns a boolean.
2775
- * @returns {boolean} True if one of the ViewLayers satisfies the callbackFn.
2776
- */
2777
- someViewLayer(callbackFn: Function): boolean;
2778
3184
  /**
2779
3185
  * Can the input position be set on one of the view layers.
2780
3186
  *
@@ -3054,6 +3460,12 @@ export declare class MaskSegmentHelper {
3054
3460
  * @returns {boolean} True if the segment is included.
3055
3461
  */
3056
3462
  hasSegment(segmentNumber: number): boolean;
3463
+ /**
3464
+ * Get the number of segments of the segmentation.
3465
+ *
3466
+ * @returns {number} The number of segments.
3467
+ */
3468
+ getNumberOfSegments(): number;
3057
3469
  /**
3058
3470
  * Check if a segment is present in a mask image.
3059
3471
  *
@@ -3319,11 +3731,22 @@ export declare class OverlayData {
3319
3731
  */
3320
3732
  export declare class PlaneHelper {
3321
3733
  /**
3322
- * @param {Spacing} spacing The spacing.
3323
- * @param {Matrix33} imageOrientation The image oientation.
3734
+ * @param {Geometry} imageGeometry The image geometry.
3324
3735
  * @param {Matrix33} viewOrientation The view orientation.
3325
3736
  */
3326
- constructor(spacing: Spacing, imageOrientation: Matrix33, viewOrientation: Matrix33);
3737
+ constructor(imageGeometry: Geometry, viewOrientation: Matrix33);
3738
+ /**
3739
+ * Get the view orientation.
3740
+ *
3741
+ * @returns {Matrix33} The orientation matrix.
3742
+ */
3743
+ getViewOrientation(): Matrix33;
3744
+ /**
3745
+ * Get the target orientation.
3746
+ *
3747
+ * @returns {Matrix33} The orientation matrix.
3748
+ */
3749
+ getTargetOrientation(): Matrix33;
3327
3750
  /**
3328
3751
  * Get a 3D offset from a plane one.
3329
3752
  *
@@ -3387,6 +3810,34 @@ export declare class PlaneHelper {
3387
3810
  * @returns {Point3D} The de-orienteded point.
3388
3811
  */
3389
3812
  getImageDeOrientedPoint3D(point: Point3D): Point3D;
3813
+ /**
3814
+ * Get a world position from a 2D plane position.
3815
+ *
3816
+ * @param {Point2D} point2D The input point.
3817
+ * @param {number} k The slice index.
3818
+ * @returns {Point3D} The associated position.
3819
+ */
3820
+ getPositionFromPlanePoint(point2D: Point2D, k: number): Point3D;
3821
+ /**
3822
+ * Get a list of points that define the plane at position k.
3823
+ *
3824
+ * @param {number} k The slice index value.
3825
+ * @returns {Point3D[]} An origin and 2 cosines vectors.
3826
+ */
3827
+ getPlanePoints(k: number): Point3D[];
3828
+ /**
3829
+ * Image world to index.
3830
+ *
3831
+ * @param {Point} point The input point.
3832
+ * @returns {Index} The corresponding index.
3833
+ */
3834
+ worldToIndex(point: Point): Index;
3835
+ /**
3836
+ * Is this view in the same orientation as the image aquisition.
3837
+ *
3838
+ * @returns {boolean} True if in aquisition plane.
3839
+ */
3840
+ isAquisitionOrientation(): boolean;
3390
3841
  /**
3391
3842
  * Reorder values to follow target orientation.
3392
3843
  *
@@ -3412,7 +3863,7 @@ export declare class PlaneHelper {
3412
3863
  /**
3413
3864
  * Immutable point.
3414
3865
  * Warning: the input array is NOT cloned, modifying it will
3415
- * modify the index values.
3866
+ * modify the point values.
3416
3867
  */
3417
3868
  export declare class Point {
3418
3869
  /**
@@ -3420,26 +3871,26 @@ export declare class Point {
3420
3871
  */
3421
3872
  constructor(values: number[]);
3422
3873
  /**
3423
- * Get the index value at the given array index.
3874
+ * Get the point value at the given array index.
3424
3875
  *
3425
3876
  * @param {number} i The index to get.
3426
3877
  * @returns {number} The value.
3427
3878
  */
3428
3879
  get(i: number): number;
3429
3880
  /**
3430
- * Get the length of the index.
3881
+ * Get the length of the point.
3431
3882
  *
3432
3883
  * @returns {number} The length.
3433
3884
  */
3434
3885
  length(): number;
3435
3886
  /**
3436
- * Get a string representation of the Index.
3887
+ * Get a string representation of the point.
3437
3888
  *
3438
- * @returns {string} The Index as a string.
3889
+ * @returns {string} The point as a string.
3439
3890
  */
3440
3891
  toString(): string;
3441
3892
  /**
3442
- * Get the values of this index.
3893
+ * Get the values of this point.
3443
3894
  *
3444
3895
  * @returns {number[]} The array of values.
3445
3896
  */
@@ -3509,6 +3960,18 @@ export declare class Point2D {
3509
3960
  * @returns {number} The Y position of the point.
3510
3961
  */
3511
3962
  getY(): number;
3963
+ /**
3964
+ * Get the values of this point.
3965
+ *
3966
+ * @returns {number[]} The array of values.
3967
+ */
3968
+ getValues(): number[];
3969
+ /**
3970
+ * Get the centroid of the point, ie itself.
3971
+ *
3972
+ * @returns {Point2D} The centroid point.
3973
+ */
3974
+ getCentroid(): Point2D;
3512
3975
  /**
3513
3976
  * Check for Point2D equality.
3514
3977
  *
@@ -3560,6 +4023,12 @@ export declare class Point3D {
3560
4023
  * @returns {number} The Z position of the point.
3561
4024
  */
3562
4025
  getZ(): number;
4026
+ /**
4027
+ * Get the values of this point.
4028
+ *
4029
+ * @returns {number[]} The array of values.
4030
+ */
4031
+ getValues(): number[];
3563
4032
  /**
3564
4033
  * Check for Point3D equality.
3565
4034
  *
@@ -3621,6 +4090,137 @@ export declare class Point3D {
3621
4090
  */
3622
4091
  export declare function precisionRound(number: number, precision: number): number;
3623
4092
 
4093
+ /**
4094
+ * Protractor shape: 3 points from which to calculate an angle.
4095
+ */
4096
+ export declare class Protractor {
4097
+ /**
4098
+ * @param {Point2D[]} points The list of Point2D that make
4099
+ * the protractor.
4100
+ */
4101
+ constructor(points: Point2D[]);
4102
+ /**
4103
+ * Get a point of the list.
4104
+ *
4105
+ * @param {number} index The index of the point
4106
+ * to get (beware, no size check).
4107
+ * @returns {Point2D|undefined} The Point2D at the given index.
4108
+ */
4109
+ getPoint(index: number): Point2D | undefined;
4110
+ /**
4111
+ * Get the length of the path (should be 3).
4112
+ *
4113
+ * @returns {number} The length of the path.
4114
+ */
4115
+ getLength(): number;
4116
+ /**
4117
+ * Get the centroid of the protractor.
4118
+ *
4119
+ * @returns {Point2D} THe centroid point.
4120
+ */
4121
+ getCentroid(): Point2D;
4122
+ /**
4123
+ * Quantify a path according to view information.
4124
+ *
4125
+ * @param {ViewController} _viewController The associated view controller.
4126
+ * @param {string[]} _flags A list of stat values to calculate.
4127
+ * @returns {object} A quantification object.
4128
+ */
4129
+ quantify(_viewController: ViewController, _flags: string[]): object;
4130
+ #private;
4131
+ }
4132
+
4133
+ /**
4134
+ * Rectangle shape.
4135
+ */
4136
+ export declare class Rectangle {
4137
+ /**
4138
+ * @param {Point2D} begin A Point2D representing the beginning
4139
+ * of the rectangle.
4140
+ * @param {Point2D} end A Point2D representing the end
4141
+ * of the rectangle.
4142
+ */
4143
+ constructor(begin: Point2D, end: Point2D);
4144
+ /**
4145
+ * Get the begin point of the rectangle.
4146
+ *
4147
+ * @returns {Point2D} The begin point of the rectangle.
4148
+ */
4149
+ getBegin(): Point2D;
4150
+ /**
4151
+ * Get the end point of the rectangle.
4152
+ *
4153
+ * @returns {Point2D} The end point of the rectangle.
4154
+ */
4155
+ getEnd(): Point2D;
4156
+ /**
4157
+ * Check for equality.
4158
+ *
4159
+ * @param {Rectangle} rhs The object to compare to.
4160
+ * @returns {boolean} True if both objects are equal.
4161
+ */
4162
+ equals(rhs: Rectangle): boolean;
4163
+ /**
4164
+ * Get the surface of the rectangle.
4165
+ *
4166
+ * @returns {number} The surface of the rectangle.
4167
+ */
4168
+ getSurface(): number;
4169
+ /**
4170
+ * Get the surface of the rectangle according to a spacing.
4171
+ *
4172
+ * @param {Scalar2D} spacing2D The 2D spacing.
4173
+ * @returns {number} The surface of the rectangle multiplied by the given
4174
+ * spacing or null for null spacings.
4175
+ */
4176
+ getWorldSurface(spacing2D: Scalar2D): number;
4177
+ /**
4178
+ * Get the real width of the rectangle.
4179
+ *
4180
+ * @returns {number} The real width of the rectangle.
4181
+ */
4182
+ getRealWidth(): number;
4183
+ /**
4184
+ * Get the real height of the rectangle.
4185
+ *
4186
+ * @returns {number} The real height of the rectangle.
4187
+ */
4188
+ getRealHeight(): number;
4189
+ /**
4190
+ * Get the width of the rectangle.
4191
+ *
4192
+ * @returns {number} The width of the rectangle.
4193
+ */
4194
+ getWidth(): number;
4195
+ /**
4196
+ * Get the height of the rectangle.
4197
+ *
4198
+ * @returns {number} The height of the rectangle.
4199
+ */
4200
+ getHeight(): number;
4201
+ /**
4202
+ * Get the rounded limits of the rectangle.
4203
+ *
4204
+ * @returns {object} The rounded limits as {min, max} (Point2D).
4205
+ */
4206
+ getRound(): object;
4207
+ /**
4208
+ * Get the centroid of the rectangle.
4209
+ *
4210
+ * @returns {Point2D} The centroid point.
4211
+ */
4212
+ getCentroid(): Point2D;
4213
+ /**
4214
+ * Quantify a rectangle according to view information.
4215
+ *
4216
+ * @param {ViewController} viewController The associated view controller.
4217
+ * @param {string[]} flags A list of stat values to calculate.
4218
+ * @returns {object} A quantification object.
4219
+ */
4220
+ quantify(viewController: ViewController, flags: string[]): object;
4221
+ #private;
4222
+ }
4223
+
3624
4224
  /**
3625
4225
  * Rescale Slope and Intercept.
3626
4226
  */
@@ -3695,6 +4295,58 @@ export declare class RGB {
3695
4295
  b: number;
3696
4296
  }
3697
4297
 
4298
+ /**
4299
+ * Region Of Interest shape.
4300
+ * Note: should be a closed path.
4301
+ */
4302
+ export declare class ROI {
4303
+ /**
4304
+ * @param {Point2D[]} [points] Optional initial point list.
4305
+ */
4306
+ constructor(points?: Point2D[]);
4307
+ /**
4308
+ * Get a point of the list at a given index.
4309
+ *
4310
+ * @param {number} index The index of the point to get
4311
+ * (beware, no size check).
4312
+ * @returns {Point2D|undefined} The Point2D at the given index.
4313
+ */
4314
+ getPoint(index: number): Point2D | undefined;
4315
+ /**
4316
+ * Get the point list.
4317
+ *
4318
+ * @returns {Point2D[]} The list.
4319
+ */
4320
+ getPoints(): Point2D[];
4321
+ /**
4322
+ * Get the length of the point list.
4323
+ *
4324
+ * @returns {number} The length of the point list.
4325
+ */
4326
+ getLength(): number;
4327
+ /**
4328
+ * Add a point to the ROI.
4329
+ *
4330
+ * @param {Point2D} point The Point2D to add.
4331
+ */
4332
+ addPoint(point: Point2D): void;
4333
+ /**
4334
+ * Add points to the ROI.
4335
+ *
4336
+ * @param {Point2D[]} rhs The array of POints2D to add.
4337
+ */
4338
+ addPoints(rhs: Point2D[]): void;
4339
+ /**
4340
+ * Get the centroid of the roi. Only valid for
4341
+ * a non-self-intersecting closed polygon.
4342
+ * Ref: {@link https://en.wikipedia.org/wiki/Centroid#Of_a_polygon}.
4343
+ *
4344
+ * @returns {Point2D} The centroid point.
4345
+ */
4346
+ getCentroid(): Point2D;
4347
+ #private;
4348
+ }
4349
+
3698
4350
  /**
3699
4351
  * Mutable 2D scalar ({x,y}).
3700
4352
  */
@@ -4110,12 +4762,109 @@ export declare class ToolConfig {
4110
4762
  * List of client provided tools to be added to
4111
4763
  * the default ones.
4112
4764
  *
4765
+ * @example
4766
+ * // custom tool
4767
+ * class AlertTool {
4768
+ * mousedown() {alert('AlertTool mousedown');}
4769
+ * init() {}
4770
+ * activate() {}
4771
+ * }
4772
+ * // pass it to dwv tool list
4773
+ * dwv.toolList['Alert'] = AlertTool;
4774
+ * // create the dwv app
4775
+ * const app = new dwv.App();
4776
+ * // initialise
4777
+ * const viewConfig0 = new dwv.ViewConfig('layerGroup0');
4778
+ * const viewConfigs = {'*': [viewConfig0]};
4779
+ * const options = new dwv.AppOptions(viewConfigs);
4780
+ * options.tools = {Alert: {}};
4781
+ * app.init(options);
4782
+ * // activate tool
4783
+ * app.addEventListener('load', function () {
4784
+ * app.setTool('Alert');
4785
+ * });
4786
+ * // load dicom data
4787
+ * app.loadURLs([
4788
+ * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
4789
+ * ]);
4790
+ *
4113
4791
  * @type {Object<string, any>}
4114
4792
  */
4115
4793
  export declare const toolList: {
4116
4794
  [x: string]: any;
4117
4795
  };
4118
4796
 
4797
+ /**
4798
+ * List of client provided tool options to be added to
4799
+ * the default ones.
4800
+ *
4801
+ * @example
4802
+ * // custom factory
4803
+ * class LoveFactory {
4804
+ * getName() {return 'love';}
4805
+ * static supports(mathShape) {return mathShape instanceof ROI;}
4806
+ * getNPoints() {return 1;}
4807
+ * getTimeout() {return 0;}
4808
+ * setAnnotationMathShape(annotation, points) {
4809
+ * const px = points[0].getX();
4810
+ * const py = points[0].getY();
4811
+ * annotation.mathShape = new dwv.ROI([
4812
+ * new dwv.Point2D(px+15,py), new dwv.Point2D(px+10,py-10),
4813
+ * new dwv.Point2D(px,py), new dwv.Point2D(px-10,py-10),
4814
+ * new dwv.Point2D(px-15,py), new dwv.Point2D(px,py+20)
4815
+ * ]);
4816
+ * annotation.getFactory = function () {return new LoveFactory();}
4817
+ * }
4818
+ * createShapeGroup(annotation, style) {
4819
+ * const roi = annotation.mathShape;
4820
+ * // konva line
4821
+ * const arr = [];
4822
+ * for (let i = 0; i < roi.getLength(); ++i) {
4823
+ * arr.push(roi.getPoint(i).getX());
4824
+ * arr.push(roi.getPoint(i).getY());
4825
+ * }
4826
+ * const shape = new Konva.Line({
4827
+ * name: 'shape', points: arr,
4828
+ * stroke: 'red', strokeWidth: 2,
4829
+ * closed: true
4830
+ * });
4831
+ * // konva group
4832
+ * const group = new Konva.Group();
4833
+ * group.name('love-group');
4834
+ * group.visible(true);
4835
+ * group.id(annotation.id);
4836
+ * group.add(shape);
4837
+ * return group;
4838
+ * }
4839
+ * }
4840
+ * // pass it to dwv option list
4841
+ * dwv.toolOptions['draw'] = {LoveFactory};
4842
+ * // create the dwv app
4843
+ * const app = new dwv.App();
4844
+ * // initialise
4845
+ * const viewConfig0 = new dwv.ViewConfig('layerGroup0');
4846
+ * const viewConfigs = {'*': [viewConfig0]};
4847
+ * const options = new dwv.AppOptions(viewConfigs);
4848
+ * options.tools = {Draw: {options: ['Love']}};
4849
+ * app.init(options);
4850
+ * // activate tool
4851
+ * app.addEventListener('load', function () {
4852
+ * app.setTool('Draw');
4853
+ * app.setToolFeatures({shapeName: 'Love'});
4854
+ * });
4855
+ * // load dicom data
4856
+ * app.loadURLs([
4857
+ * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
4858
+ * ]);
4859
+ *
4860
+ * @type {Object<string, Object<string, any>>}
4861
+ */
4862
+ export declare const toolOptions: {
4863
+ [x: string]: {
4864
+ [x: string]: any;
4865
+ };
4866
+ };
4867
+
4119
4868
  /**
4120
4869
  * Immutable 3D vector.
4121
4870
  */
@@ -4358,9 +5107,16 @@ export declare class View {
4358
5107
  * Get the image origin for a image UID.
4359
5108
  *
4360
5109
  * @param {string} uid The UID.
4361
- * @returns {Index|undefined} The origin index.
5110
+ * @returns {Point3D|undefined} The origin.
5111
+ */
5112
+ getOriginForImageUid(uid: string): Point3D | undefined;
5113
+ /**
5114
+ * Check if the image includes an UID.
5115
+ *
5116
+ * @param {string} uid The UID.
5117
+ * @returns {boolean} True if present.
4362
5118
  */
4363
- getOriginIndexForImageUid(uid: string): Index | undefined;
5119
+ includesImageUid(uid: string): boolean;
4364
5120
  /**
4365
5121
  * Check if the current position (default) or
4366
5122
  * the provided position is in bounds.
@@ -4380,11 +5136,11 @@ export declare class View {
4380
5136
  * Set the current position.
4381
5137
  *
4382
5138
  * @param {Point} position The new position.
4383
- * @param {boolean} silent Flag to fire event or not.
5139
+ * @param {boolean} [silent] Flag to fire event or not.
4384
5140
  * @returns {boolean} False if not in bounds.
4385
5141
  * @fires View#positionchange
4386
5142
  */
4387
- setCurrentPosition(position: Point, silent: boolean): boolean;
5143
+ setCurrentPosition(position: Point, silent?: boolean): boolean;
4388
5144
  /**
4389
5145
  * Set the current index.
4390
5146
  *
@@ -4466,6 +5222,12 @@ export declare class View {
4466
5222
  * @returns {number} The index.
4467
5223
  */
4468
5224
  getScrollIndex(): number;
5225
+ /**
5226
+ * Is this view in the same orientation as the image aquisition.
5227
+ *
5228
+ * @returns {boolean} True if in aquisition plane.
5229
+ */
5230
+ isAquisitionOrientation(): boolean;
4469
5231
  #private;
4470
5232
  }
4471
5233
 
@@ -4605,12 +5367,19 @@ export declare class ViewController {
4605
5367
  */
4606
5368
  getCurrentImageUid(): string;
4607
5369
  /**
4608
- * Get the image origin index for a image UID.
5370
+ * Get the image origin for a image UID.
5371
+ *
5372
+ * @param {string} uid The UID.
5373
+ * @returns {Point3D|undefined} The origin.
5374
+ */
5375
+ getOriginForImageUid(uid: string): Point3D | undefined;
5376
+ /**
5377
+ * Check if the image includes an UID.
4609
5378
  *
4610
5379
  * @param {string} uid The UID.
4611
- * @returns {Index|undefined} The origin index.
5380
+ * @returns {boolean} True if present.
4612
5381
  */
4613
- getOriginIndexForImageUid(uid: string): Index | undefined;
5382
+ includesImageUid(uid: string): boolean;
4614
5383
  /**
4615
5384
  * Get the current oriented index.
4616
5385
  *
@@ -4632,10 +5401,23 @@ export declare class ViewController {
4632
5401
  /**
4633
5402
  * Get the first origin or at a given position.
4634
5403
  *
4635
- * @param {Point} [position] Opitonal position.
5404
+ * @param {Point} [position] Optional position.
4636
5405
  * @returns {Point3D} The origin.
4637
5406
  */
4638
5407
  getOrigin(position?: Point): Point3D;
5408
+ /**
5409
+ * Is this view in the same orientation as the image aquisition.
5410
+ *
5411
+ * @returns {boolean} True if in aquisition plane.
5412
+ */
5413
+ isAquisitionOrientation(): boolean;
5414
+ /**
5415
+ * Get a list of points that define the plane at position k.
5416
+ *
5417
+ * @param {number} k The slice index value.
5418
+ * @returns {Point3D[]} A couple of 3D points.
5419
+ */
5420
+ getPlanePoints(k: number): Point3D[];
4639
5421
  /**
4640
5422
  * Get the current scroll position value.
4641
5423
  *
@@ -4676,12 +5458,6 @@ export declare class ViewController {
4676
5458
  * @returns {string} The unit.
4677
5459
  */
4678
5460
  getPixelUnit(): string;
4679
- /**
4680
- * Get the image study instance UID.
4681
- *
4682
- * @returns {string} The UID.
4683
- */
4684
- getStudyInstanceUID(): string;
4685
5461
  /**
4686
5462
  * Get some values from the associated image in a region.
4687
5463
  *
@@ -4777,9 +5553,11 @@ export declare class ViewController {
4777
5553
  * Get a world position from a 2D plane position.
4778
5554
  *
4779
5555
  * @param {Point2D} point2D The input point.
5556
+ * @param {number} [k] Optional slice index,
5557
+ * if undefined, uses the current one.
4780
5558
  * @returns {Point} The associated position.
4781
5559
  */
4782
- getPositionFromPlanePoint(point2D: Point2D): Point;
5560
+ getPositionFromPlanePoint(point2D: Point2D, k?: number): Point;
4783
5561
  /**
4784
5562
  * Get a 2D plane position from a world position.
4785
5563
  *
@@ -4787,6 +5565,13 @@ export declare class ViewController {
4787
5565
  * @returns {Point2D} The 2D position.
4788
5566
  */
4789
5567
  getPlanePositionFromPosition(point: Point): Point2D;
5568
+ /**
5569
+ * Get the index of a world position.
5570
+ *
5571
+ * @param {Point} point The 3D position.
5572
+ * @returns {Index} The index.
5573
+ */
5574
+ getIndexFromPosition(point: Point): Index;
4790
5575
  /**
4791
5576
  * Set the current index.
4792
5577
  *