dwv 0.33.0-beta.1 → 0.33.0-beta.11

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
@@ -1,3 +1,5 @@
1
+ import Konva from 'konva';
2
+
1
3
  /**
2
4
  * Add tags to the dictionary.
3
5
  *
@@ -6,6 +8,11 @@
6
8
  */
7
9
  export declare function addTagsToDictionary(group: string, tags: object): void;
8
10
 
11
+ /**
12
+ * List of ViewConfigs indexed by dataIds.
13
+ *
14
+ * @typedef {Object<string, ViewConfig[]>} DataViewConfigs
15
+ */
9
16
  /**
10
17
  * Main application class.
11
18
  *
@@ -13,9 +20,10 @@ export declare function addTagsToDictionary(group: string, tags: object): void;
13
20
  * // create the dwv app
14
21
  * const app = new dwv.App();
15
22
  * // initialise
16
- * app.init({
17
- * dataViewConfigs: {'*': [{divId: 'layerGroup0'}]}
18
- * });
23
+ * const viewConfig0 = new dwv.ViewConfig('layerGroup0');
24
+ * const viewConfigs = {'*': [viewConfig0]};
25
+ * const options = new dwv.AppOptions(viewConfigs);
26
+ * app.init(options);
19
27
  * // load dicom data
20
28
  * app.loadURLs([
21
29
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
@@ -25,10 +33,10 @@ export declare class App {
25
33
  /**
26
34
  * Get the image.
27
35
  *
28
- * @param {number} index The data index.
36
+ * @param {string} dataId The data id.
29
37
  * @returns {Image} The associated image.
30
38
  */
31
- getImage(index: number): Image_2;
39
+ getImage(dataId: string): Image_2;
32
40
  /**
33
41
  * Get the last loaded image.
34
42
  *
@@ -36,12 +44,12 @@ export declare class App {
36
44
  */
37
45
  getLastImage(): Image_2;
38
46
  /**
39
- * Set the image at the given index.
47
+ * Set the image at the given id.
40
48
  *
41
- * @param {number} index The data index.
49
+ * @param {string} dataId The data id.
42
50
  * @param {Image} img The associated image.
43
51
  */
44
- setImage(index: number, img: Image_2): void;
52
+ setImage(dataId: string, img: Image_2): void;
45
53
  /**
46
54
  * Set the last image.
47
55
  *
@@ -53,22 +61,22 @@ export declare class App {
53
61
  *
54
62
  * @param {Image} image The new image.
55
63
  * @param {object} meta The image meta.
56
- * @returns {number} The new image id.
64
+ * @returns {string} The new image data id.
57
65
  */
58
- addNewImage(image: Image_2, meta: object): number;
66
+ addNewImage(image: Image_2, meta: object): string;
59
67
  /**
60
68
  * Get the meta data.
61
69
  *
62
- * @param {number} index The data index.
70
+ * @param {string} dataId The data id.
63
71
  * @returns {object} The list of meta data.
64
72
  */
65
- getMetaData(index: number): object;
73
+ getMetaData(dataId: string): object;
66
74
  /**
67
- * Get the number of loaded data.
75
+ * Get the list of ids in the data storage.
68
76
  *
69
- * @returns {number} The number.
77
+ * @returns {Array} The list of data ids.
70
78
  */
71
- getNumberOfLoadedData(): number;
79
+ getDataIds(): any[];
72
80
  /**
73
81
  * Can the data be scrolled?
74
82
  *
@@ -102,9 +110,9 @@ export declare class App {
102
110
  /**
103
111
  * Get the toolbox controller.
104
112
  *
105
- * @returns {object} The controller.
113
+ * @returns {ToolboxController} The controller.
106
114
  */
107
- getToolboxController(): object;
115
+ getToolboxController(): ToolboxController;
108
116
  /**
109
117
  * Get the active layer group.
110
118
  * The layer is available after the first loaded item.
@@ -113,21 +121,21 @@ export declare class App {
113
121
  */
114
122
  getActiveLayerGroup(): LayerGroup;
115
123
  /**
116
- * Get the view layers associated to a data index.
124
+ * Get the view layers associated to a data id.
117
125
  * The layer are available after the first loaded item.
118
126
  *
119
- * @param {number} index The data index.
120
- * @returns {Array} The layers.
127
+ * @param {string} dataId The data id.
128
+ * @returns {ViewLayer[]} The layers.
121
129
  */
122
- getViewLayersByDataIndex(index: number): any[];
130
+ getViewLayersByDataId(dataId: string): ViewLayer[];
123
131
  /**
124
- * Get the draw layers associated to a data index.
132
+ * Get the draw layers associated to a data id.
125
133
  * The layer are available after the first loaded item.
126
134
  *
127
- * @param {number} index The data index.
128
- * @returns {Array} The layers.
135
+ * @param {string} dataId The data id.
136
+ * @returns {DrawLayer[]} The layers.
129
137
  */
130
- getDrawLayersByDataIndex(index: number): any[];
138
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
131
139
  /**
132
140
  * Get a layer group by div id.
133
141
  * The layer is available after the first loaded item.
@@ -153,34 +161,22 @@ export declare class App {
153
161
  *
154
162
  * @param {object} cmd The command to add.
155
163
  * @fires UndoStack#undoadd
164
+ * @function
156
165
  */
157
166
  addToUndoStack: (cmd: object) => void;
158
167
  /**
159
168
  * Initialise the application.
160
169
  *
161
- * @param {object} opt The application option with:
162
- * - `dataViewConfigs`: data indexed object containing the data view
163
- * configurations in the form of a list of objects containing:
164
- * - divId: the HTML div id
165
- * - orientation: optional 'axial', 'coronal' or 'sagittal' orientation
166
- * string (default undefined keeps the original slice order)
167
- * - `binders`: array of layerGroup binders
168
- * - `tools`: tool name indexed object containing individual tool
169
- * configurations in the form of a list of objects containing:
170
- * - options: array of tool options
171
- * - `viewOnFirstLoadItem`: boolean flag to trigger the first data render
172
- * after the first loaded data or not
173
- * - `defaultCharacterSet`: the default chraracter set string used for DICOM
174
- * parsing
175
- * - `overlayConfig`: list of tags / properties used as overlay information.
170
+ * @param {AppOptions} opt The application options
176
171
  * @example
177
172
  * // create the dwv app
178
173
  * const app = new dwv.App();
179
174
  * // initialise
180
- * app.init({
181
- * dataViewConfigs: {'*': [{divId: 'layerGroup0'}]},
182
- * viewOnFirstLoadItem: false
183
- * });
175
+ * const viewConfig0 = new dwv.ViewConfig('layerGroup0');
176
+ * const viewConfigs = {'*': [viewConfig0]};
177
+ * const options = new dwv.AppOptions(viewConfigs);
178
+ * options.viewOnFirstLoadItem = false;
179
+ * app.init(options);
184
180
  * // render button
185
181
  * const button = document.createElement('button');
186
182
  * button.id = 'render';
@@ -200,7 +196,7 @@ export declare class App {
200
196
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
201
197
  * ]);
202
198
  */
203
- init(opt: object): void;
199
+ init(opt: AppOptions): void;
204
200
  /**
205
201
  * Reset the application.
206
202
  */
@@ -213,34 +209,35 @@ export declare class App {
213
209
  * Add an event listener to this class.
214
210
  *
215
211
  * @param {string} type The event type.
216
- * @param {object} callback The method associated with the provided
212
+ * @param {Function} callback The function associated with the provided
217
213
  * event type, will be called with the fired event.
218
214
  */
219
- addEventListener(type: string, callback: object): void;
215
+ addEventListener(type: string, callback: Function): void;
220
216
  /**
221
217
  * Remove an event listener from this class.
222
218
  *
223
219
  * @param {string} type The event type.
224
- * @param {object} callback The method associated with the provided
220
+ * @param {Function} callback The function associated with the provided
225
221
  * event type.
226
222
  */
227
- removeEventListener(type: string, callback: object): void;
223
+ removeEventListener(type: string, callback: Function): void;
228
224
  /**
229
225
  * Load a list of files. Can be image files or a state file.
230
226
  *
231
- * @param {FileList} files The list of files to load.
227
+ * @param {File[]} files The list of files to load.
232
228
  * @fires App#loadstart
233
229
  * @fires App#loadprogress
234
230
  * @fires App#loaditem
235
231
  * @fires App#loadend
236
- * @fires App#loaderror
237
- * @fires App#loadabort
232
+ * @fires App#error
233
+ * @fires App#abort
234
+ * @function
238
235
  */
239
- loadFiles: (files: FileList) => void;
236
+ loadFiles: (files: File[]) => void;
240
237
  /**
241
238
  * Load a list of URLs. Can be image files or a state file.
242
239
  *
243
- * @param {Array} urls The list of urls to load.
240
+ * @param {string[]} urls The list of urls to load.
244
241
  * @param {object} [options] The options object, can contain:
245
242
  * - requestHeaders: an array of {name, value} to use as request headers
246
243
  * - withCredentials: boolean xhr.withCredentials flag to pass to the request
@@ -249,15 +246,17 @@ export declare class App {
249
246
  * @fires App#loadprogress
250
247
  * @fires App#loaditem
251
248
  * @fires App#loadend
252
- * @fires App#loaderror
253
- * @fires App#loadabort
249
+ * @fires App#error
250
+ * @fires App#abort
251
+ * @function
254
252
  */
255
- loadURLs: (urls: any[], options?: object) => void;
253
+ loadURLs: (urls: string[], options?: object) => void;
256
254
  /**
257
255
  * Load from an input uri.
258
256
  *
259
257
  * @param {string} uri The input uri, for example: 'window.location.href'.
260
258
  * @param {object} [options] Optional url request options.
259
+ * @function
261
260
  */
262
261
  loadFromUri: (uri: string, options?: object) => void;
263
262
  /**
@@ -269,8 +268,9 @@ export declare class App {
269
268
  * @fires App#loadprogress
270
269
  * @fires App#loaditem
271
270
  * @fires App#loadend
272
- * @fires App#loaderror
273
- * @fires App#loadabort
271
+ * @fires App#error
272
+ * @fires App#abort
273
+ * @function
274
274
  */
275
275
  loadImageObject: (data: any[]) => void;
276
276
  /**
@@ -286,33 +286,73 @@ export declare class App {
286
286
  * Init the Window/Level display
287
287
  */
288
288
  initWLDisplay(): void;
289
+ /**
290
+ * Set the imageSmoothing flag value. Default is false.
291
+ *
292
+ * @param {boolean} flag True to enable smoothing.
293
+ */
294
+ setImageSmoothing(flag: boolean): void;
295
+ /**
296
+ * Get the layer group configuration from a data id.
297
+ *
298
+ * @param {string} dataId The data id.
299
+ * @param {boolean} [excludeStarConfig] Exclude the star config
300
+ * (default to false).
301
+ * @returns {ViewConfig[]} The list of associated configs.
302
+ */
303
+ getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
304
+ /**
305
+ * Get the layer group configuration for a data id and group
306
+ * div id.
307
+ *
308
+ * @param {string} dataId The data id.
309
+ * @param {string} groupDivId The layer group div id.
310
+ * @param {boolean} [excludeStarConfig] Exclude the star config
311
+ * (default to false).
312
+ * @returns {ViewConfig|undefined} The associated config.
313
+ */
314
+ getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
289
315
  /**
290
316
  * Get the data view config.
291
317
  * Carefull, returns a reference, do not modify without resetting.
292
318
  *
293
- * @returns {object} The configuration list.
319
+ * @returns {Object<string, ViewConfig[]>} The configuration list.
294
320
  */
295
- getDataViewConfig(): object;
321
+ getDataViewConfigs(): {
322
+ [x: string]: ViewConfig[];
323
+ };
296
324
  /**
297
- * Set the data view configuration (see the init options for details).
325
+ * Set the data view configuration.
326
+ * Resets the stage and recreates all the views.
298
327
  *
299
- * @param {object} configs The configuration list.
328
+ * @param {Object<string, ViewConfig[]>} configs The configuration list.
300
329
  */
301
- setDataViewConfig(configs: object): void;
330
+ setDataViewConfigs(configs: {
331
+ [x: string]: ViewConfig[];
332
+ }): void;
302
333
  /**
303
334
  * Add a data view config.
304
335
  *
305
- * @param {number} dataId The data id.
306
- * @param {object} config The view configuration.
336
+ * @param {string} dataId The data id.
337
+ * @param {ViewConfig} config The view configuration.
307
338
  */
308
- addDataViewConfig(dataId: number, config: object): void;
339
+ addDataViewConfig(dataId: string, config: ViewConfig): void;
309
340
  /**
310
341
  * Remove a data view config.
311
342
  *
312
- * @param {number} dataId The data id.
313
- * @param {object} config The view configuration.
343
+ * @param {string} dataId The data id.
344
+ * @param {ViewConfig} config The view configuration.
314
345
  */
315
- removeDataViewConfig(dataId: number, config: object): void;
346
+ removeDataViewConfig(dataId: string, config: ViewConfig): void;
347
+ /**
348
+ * Update an existing data view config.
349
+ * Removes and re-creates the layer if found.
350
+ *
351
+ * @param {string} dataId The data id.
352
+ * @param {string} divId The div id.
353
+ * @param {ViewConfig} config The view configuration.
354
+ */
355
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
316
356
  /**
317
357
  * Set the layer groups binders.
318
358
  *
@@ -322,9 +362,10 @@ export declare class App {
322
362
  /**
323
363
  * Render the current data.
324
364
  *
325
- * @param {number} dataIndex The data index to render.
365
+ * @param {string} dataId The data id to render.
366
+ * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
326
367
  */
327
- render(dataIndex: number): void;
368
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
328
369
  /**
329
370
  * Zoom to the layers.
330
371
  *
@@ -369,6 +410,8 @@ export declare class App {
369
410
  * Handle resize: fit the display to the window.
370
411
  * To be called once the image is loaded.
371
412
  * Can be connected to a window 'resize' event.
413
+ *
414
+ * @function
372
415
  */
373
416
  onResize: () => void;
374
417
  /**
@@ -376,6 +419,7 @@ export declare class App {
376
419
  *
377
420
  * @param {KeyboardEvent} event The key down event.
378
421
  * @fires App#keydown
422
+ * @function
379
423
  */
380
424
  onKeydown: (event: KeyboardEvent) => void;
381
425
  /**
@@ -390,6 +434,7 @@ export declare class App {
390
434
  * @param {KeyboardEvent} event The key down event.
391
435
  * @fires UndoStack#undo
392
436
  * @fires UndoStack#redo
437
+ * @function
393
438
  */
394
439
  defaultOnKeydown: (event: KeyboardEvent) => void;
395
440
  /**
@@ -403,9 +448,9 @@ export declare class App {
403
448
  /**
404
449
  * Set the colour map.
405
450
  *
406
- * @param {string} colourMap The colour map name.
451
+ * @param {string} name The colour map name.
407
452
  */
408
- setColourMap(colourMap: string): void;
453
+ setColourMap(name: string): void;
409
454
  /**
410
455
  * Set the window/level preset.
411
456
  *
@@ -449,21 +494,77 @@ export declare class App {
449
494
  */
450
495
  getCurrentStackIndex(): number;
451
496
  /**
452
- * Get the overlay data for a data index.
497
+ * Get the overlay data for a data id.
453
498
  *
454
- * @param {number} dataIndex The data index.
455
- * @returns {OverlayData} The overlay data.
499
+ * @param {string} dataId The data id.
500
+ * @returns {OverlayData|undefined} The overlay data.
456
501
  */
457
- getOverlayData(dataIndex: number): OverlayData;
502
+ getOverlayData(dataId: string): OverlayData | undefined;
458
503
  /**
459
504
  * Toggle overlay listeners.
460
505
  *
461
- * @param {number} dataIndex The data index.
506
+ * @param {string} dataId The data id.
462
507
  */
463
- toggleOverlayListeners(dataIndex: number): void;
508
+ toggleOverlayListeners(dataId: string): void;
464
509
  #private;
465
510
  }
466
511
 
512
+ /**
513
+ * Application options.
514
+ */
515
+ export declare class AppOptions {
516
+ /**
517
+ * @param {Object<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
518
+ * indexed object containing the data view configurations.
519
+ */
520
+ constructor(dataViewConfigs?: {
521
+ [x: string]: ViewConfig[];
522
+ });
523
+ /**
524
+ * DataId indexed object containing the data view configurations.
525
+ *
526
+ * @type {Object<string, ViewConfig[]>|undefined}
527
+ */
528
+ dataViewConfigs: {
529
+ [x: string]: ViewConfig[];
530
+ } | undefined;
531
+ /**
532
+ * Tool name indexed object containing individual tool configurations.
533
+ *
534
+ * @type {Object<string, ToolConfig>|undefined}
535
+ */
536
+ tools: {
537
+ [x: string]: ToolConfig;
538
+ } | undefined;
539
+ /**
540
+ * Optional array of layerGroup binder names.
541
+ *
542
+ * @type {string[]|undefined}
543
+ */
544
+ binders: string[] | undefined;
545
+ /**
546
+ * Optional boolean flag to trigger the first data render
547
+ * after the first loaded data or not. Defaults to true;
548
+ *
549
+ * @type {boolean|undefined}
550
+ */
551
+ viewOnFirstLoadItem: boolean | undefined;
552
+ /**
553
+ * Optional default chraracter set string used for DICOM parsing if
554
+ * not passed in DICOM file.
555
+ * Valid values: https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
556
+ *
557
+ * @type {string|undefined}
558
+ */
559
+ defaultCharacterSet: string | undefined;
560
+ /**
561
+ * Optional overlay config.
562
+ *
563
+ * @type {object|undefined}
564
+ */
565
+ overlayConfig: object | undefined;
566
+ }
567
+
467
568
  /**
468
569
  * Build a multipart message.
469
570
  * See: https://en.wikipedia.org/wiki/MIME#Multipart_messages
@@ -476,6 +577,37 @@ export declare class App {
476
577
  */
477
578
  export declare function buildMultipart(parts: any[], boundary: string): Uint8Array;
478
579
 
580
+ /**
581
+ * Colour map: red, green and blue components
582
+ * to associate with intensity values.
583
+ */
584
+ export declare class ColourMap {
585
+ /**
586
+ * @param {number[]} red Red component.
587
+ * @param {number[]} green Green component.
588
+ * @param {number[]} blue Blue component.
589
+ */
590
+ constructor(red: number[], green: number[], blue: number[]);
591
+ /**
592
+ * Red component: 256 values in the [0, 255] range.
593
+ *
594
+ * @type {number[]}
595
+ */
596
+ red: number[];
597
+ /**
598
+ * Green component: 256 values in the [0, 255] range.
599
+ *
600
+ * @type {number[]}
601
+ */
602
+ green: number[];
603
+ /**
604
+ * Blue component: 256 values in the [0, 255] range.
605
+ *
606
+ * @type {number[]}
607
+ */
608
+ blue: number[];
609
+ }
610
+
479
611
  /**
480
612
  * Create an Image from DICOM elements.
481
613
  *
@@ -511,6 +643,68 @@ export declare namespace customUI {
511
643
  export function openRoiDialog(data: any, callback: Function): void;
512
644
  }
513
645
 
646
+ /**
647
+ * DICOM data element.
648
+ */
649
+ export declare class DataElement {
650
+ /**
651
+ * @param {string} vr The element VR (Value Representation).
652
+ */
653
+ constructor(vr: string);
654
+ /**
655
+ * The element Value Representation.
656
+ *
657
+ * @type {string}
658
+ */
659
+ vr: string;
660
+ /**
661
+ * The element value.
662
+ *
663
+ * @type {Array}
664
+ */
665
+ value: any[];
666
+ /**
667
+ * The element dicom tag.
668
+ *
669
+ * @type {Tag}
670
+ */
671
+ tag: Tag;
672
+ /**
673
+ * The element Value Length.
674
+ *
675
+ * @type {number}
676
+ */
677
+ vl: number;
678
+ /**
679
+ * Flag to know if defined or undefined sequence length.
680
+ *
681
+ * @type {boolean}
682
+ */
683
+ undefinedLength: boolean;
684
+ /**
685
+ * The element start offset.
686
+ *
687
+ * @type {number}
688
+ */
689
+ startOffset: number;
690
+ /**
691
+ * The element end offset.
692
+ *
693
+ * @type {number}
694
+ */
695
+ endOffset: number;
696
+ /**
697
+ * The sequence items.
698
+ *
699
+ * @type {Array}
700
+ */
701
+ items: any[];
702
+ }
703
+
704
+ declare type DataElements = {
705
+ [x: string]: DataElement;
706
+ };
707
+
514
708
  /**
515
709
  * Decoder scripts to be passed to web workers for image decoding.
516
710
  */
@@ -589,14 +783,16 @@ export declare class DicomParser {
589
783
  */
590
784
  setDecoderCharacterSet(characterSet: string): void;
591
785
  /**
592
- * Get the raw DICOM data elements.
786
+ * Get the DICOM data elements.
593
787
  *
594
- * @returns {object} The raw DICOM elements.
788
+ * @returns {Object<string, DataElement>} The data elements.
595
789
  */
596
- getDicomElements(): object;
790
+ getDicomElements(): {
791
+ [x: string]: DataElement;
792
+ };
597
793
  /**
598
794
  * Parse the complete DICOM file (given as input to the class).
599
- * Fills in the member object 'dicomElements'.
795
+ * Fills in the member object 'dataElements'.
600
796
  *
601
797
  * @param {ArrayBuffer} buffer The input array buffer.
602
798
  */
@@ -607,16 +803,33 @@ export declare class DicomParser {
607
803
  /**
608
804
  * DICOM writer.
609
805
  *
610
- * Example usage:
611
- * const parser = new DicomParser();
612
- * parser.parse(this.response);
613
- *
614
- * const writer = new DicomWriter(parser.getDicomElements());
615
- * const blob = new Blob([writer.getBuffer()], {type: 'application/dicom'});
616
- *
617
- * const element = document.getElementById("download");
618
- * element.href = URL.createObjectURL(blob);
619
- * element.download = "anonym.dcm";
806
+ * @example
807
+ * // add link to html
808
+ * const link = document.createElement("a");
809
+ * link.appendChild(document.createTextNode("download"));
810
+ * const div = document.getElementById("dwv");
811
+ * div.appendChild(link);
812
+ * // XMLHttpRequest onload callback
813
+ * const onload = function (event) {
814
+ * const parser = new dwv.DicomParser();
815
+ * parser.parse(event.target.response);
816
+ * // create writer
817
+ * const writer = new dwv.DicomWriter();
818
+ * // get buffer using default rules
819
+ * const dicomBuffer = writer.getBuffer(parser.getDicomElements());
820
+ * // create blob
821
+ * const blob = new Blob([dicomBuffer], {type: 'application/dicom'});
822
+ * // add blob to download link
823
+ * link.href = URL.createObjectURL(blob);
824
+ * link.download = "anonym.dcm";
825
+ * };
826
+ * // DICOM file request
827
+ * const request = new XMLHttpRequest();
828
+ * const url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';
829
+ * request.open('GET', url);
830
+ * request.responseType = 'arraybuffer';
831
+ * request.onload = onload;
832
+ * request.send();
620
833
  */
621
834
  export declare class DicomWriter {
622
835
  /**
@@ -627,10 +840,16 @@ export declare class DicomWriter {
627
840
  setUseUnVrForPrivateSq(flag: boolean): void;
628
841
  /**
629
842
  * Set the writing rules.
843
+ * List of writer rules indexed by either `default`, tagName or groupName.
844
+ * Each DICOM element will be checked to see if a rule is applicable.
845
+ * First checked by tagName and then by groupName,
846
+ * if nothing is found the default rule is applied.
630
847
  *
631
- * @param {object} rules The input rules.
848
+ * @param {Object<string, WriterRule>} rules The input rules.
632
849
  */
633
- setRules(rules: object): void;
850
+ setRules(rules: {
851
+ [x: string]: WriterRule;
852
+ }): void;
634
853
  /**
635
854
  * Use a TextEncoder instead of the default text decoder.
636
855
  */
@@ -639,16 +858,160 @@ export declare class DicomWriter {
639
858
  * Use default anonymisation rules.
640
859
  */
641
860
  useDefaultAnonymisationRules(): void;
861
+ /**
862
+ * Get the element to write according to the class rules.
863
+ * Priority order: tagName, groupName, default.
864
+ *
865
+ * @param {DataElement} element The element to check
866
+ * @returns {DataElement|null} The element to write, can be null.
867
+ */
868
+ getElementToWrite(element: DataElement): DataElement | null;
642
869
  /**
643
870
  * Get the ArrayBuffer corresponding to input DICOM elements.
644
871
  *
645
- * @param {Array} dicomElements The wrapped elements to write.
872
+ * @param {Object<string, DataElement>} dataElements The elements to write.
646
873
  * @returns {ArrayBuffer} The elements as a buffer.
647
874
  */
648
- getBuffer(dicomElements: any[]): ArrayBuffer;
875
+ getBuffer(dataElements: {
876
+ [x: string]: DataElement;
877
+ }): ArrayBuffer;
649
878
  #private;
650
879
  }
651
880
 
881
+ /**
882
+ * Draw controller.
883
+ */
884
+ export declare class DrawController {
885
+ /**
886
+ * @param {DrawLayer} drawLayer The draw layer.
887
+ */
888
+ constructor(drawLayer: DrawLayer);
889
+ /**
890
+ * Get the current position group.
891
+ *
892
+ * @returns {Konva.Group|undefined} The Konva.Group.
893
+ */
894
+ getCurrentPosGroup(): Konva.Group | undefined;
895
+ /**
896
+ * Reset: clear the layers array.
897
+ */
898
+ reset(): void;
899
+ /**
900
+ * Get a Konva group using its id.
901
+ *
902
+ * @param {string} id The group id.
903
+ * @returns {object|undefined} The Konva group.
904
+ */
905
+ getGroup(id: string): object | undefined;
906
+ /**
907
+ * Activate the current draw layer.
908
+ *
909
+ * @param {Index} index The current position.
910
+ * @param {number} scrollIndex The scroll index.
911
+ */
912
+ activateDrawLayer(index: Index, scrollIndex: number): void;
913
+ /**
914
+ * Get a list of drawing display details.
915
+ *
916
+ * @returns {DrawDetails[]} A list of draw details.
917
+ */
918
+ getDrawDisplayDetails(): DrawDetails[];
919
+ /**
920
+ * Get a list of drawing store details. Used in state.
921
+ *
922
+ * @returns {object} A list of draw details including id, text, quant...
923
+ * TODO Unify with getDrawDisplayDetails?
924
+ */
925
+ getDrawStoreDetails(): object;
926
+ /**
927
+ * Set the drawings on the current stage.
928
+ *
929
+ * @param {Array} drawings An array of drawings.
930
+ * @param {DrawDetails[]} drawingsDetails An array of drawings details.
931
+ * @param {object} cmdCallback The DrawCommand callback.
932
+ * @param {object} exeCallback The callback to call once the
933
+ * DrawCommand has been executed.
934
+ */
935
+ setDrawings(drawings: any[], drawingsDetails: DrawDetails[], cmdCallback: object, exeCallback: object): void;
936
+ /**
937
+ * Update a drawing from its details.
938
+ *
939
+ * @param {DrawDetails} drawDetails Details of the drawing to update.
940
+ */
941
+ updateDraw(drawDetails: DrawDetails): void;
942
+ /**
943
+ * Delete a Draw from the stage.
944
+ *
945
+ * @param {Konva.Group} group The group to delete.
946
+ * @param {object} cmdCallback The DeleteCommand callback.
947
+ * @param {object} exeCallback The callback to call once the
948
+ * DeleteCommand has been executed.
949
+ */
950
+ deleteDrawGroup(group: Konva.Group, cmdCallback: object, exeCallback: object): void;
951
+ /**
952
+ * Delete a Draw from the stage.
953
+ *
954
+ * @param {string} id The id of the group to delete.
955
+ * @param {Function} cmdCallback The DeleteCommand callback.
956
+ * @param {Function} exeCallback The callback to call once the
957
+ * DeleteCommand has been executed.
958
+ * @returns {boolean} False if the group cannot be found.
959
+ */
960
+ deleteDraw(id: string, cmdCallback: Function, exeCallback: Function): boolean;
961
+ /**
962
+ * Delete all Draws from the stage.
963
+ *
964
+ * @param {Function} cmdCallback The DeleteCommand callback.
965
+ * @param {Function} exeCallback The callback to call once the
966
+ * DeleteCommand has been executed.
967
+ */
968
+ deleteDraws(cmdCallback: Function, exeCallback: Function): void;
969
+ /**
970
+ * Get the total number of draws
971
+ * (at all positions).
972
+ *
973
+ * @returns {number} The total number of draws.
974
+ */
975
+ getNumberOfDraws(): number;
976
+ #private;
977
+ }
978
+
979
+ /**
980
+ * Draw details.
981
+ */
982
+ export declare class DrawDetails {
983
+ /**
984
+ * The draw ID.
985
+ *
986
+ * @type {number}
987
+ */
988
+ id: number;
989
+ /**
990
+ * The draw position: an Index converted to string.
991
+ *
992
+ * @type {string}
993
+ */
994
+ position: string;
995
+ /**
996
+ * The draw type.
997
+ *
998
+ * @type {string}
999
+ */
1000
+ type: string;
1001
+ /**
1002
+ * The draw color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
1003
+ *
1004
+ * @type {string}
1005
+ */
1006
+ color: string;
1007
+ /**
1008
+ * The draw meta.
1009
+ *
1010
+ * @type {DrawMeta}
1011
+ */
1012
+ meta: DrawMeta;
1013
+ }
1014
+
652
1015
  /**
653
1016
  * Draw layer.
654
1017
  */
@@ -659,23 +1022,23 @@ export declare class DrawLayer {
659
1022
  */
660
1023
  constructor(containerDiv: HTMLDivElement);
661
1024
  /**
662
- * Get the associated data index.
1025
+ * Get the associated data id.
663
1026
  *
664
- * @returns {number} The index.
1027
+ * @returns {string} The id.
665
1028
  */
666
- getDataIndex(): number;
1029
+ getDataId(): string;
667
1030
  /**
668
1031
  * Get the Konva stage.
669
1032
  *
670
- * @returns {object} The stage.
1033
+ * @returns {Konva.Stage} The stage.
671
1034
  */
672
- getKonvaStage(): object;
1035
+ getKonvaStage(): Konva.Stage;
673
1036
  /**
674
1037
  * Get the Konva layer.
675
1038
  *
676
- * @returns {object} The layer.
1039
+ * @returns {Konva.Layer} The layer.
677
1040
  */
678
- getKonvaLayer(): object;
1041
+ getKonvaLayer(): Konva.Layer;
679
1042
  /**
680
1043
  * Get the draw controller.
681
1044
  *
@@ -720,13 +1083,17 @@ export declare class DrawLayer {
720
1083
  * Add a flip offset along the layer Y axis.
721
1084
  */
722
1085
  addFlipOffsetY(): void;
1086
+ /**
1087
+ * Flip the scale along the layer Z axis.
1088
+ */
1089
+ flipScaleZ(): void;
723
1090
  /**
724
1091
  * Set the layer scale.
725
1092
  *
726
1093
  * @param {object} newScale The scale as {x,y}.
727
- * @param {Point3D} center The scale center.
1094
+ * @param {Point3D} [center] The scale center.
728
1095
  */
729
- setScale(newScale: object, center: Point3D): void;
1096
+ setScale(newScale: object, center?: Point3D): void;
730
1097
  /**
731
1098
  * Set the layer offset.
732
1099
  *
@@ -763,9 +1130,9 @@ export declare class DrawLayer {
763
1130
  *
764
1131
  * @param {object} size The image size as {x,y}.
765
1132
  * @param {object} spacing The image spacing as {x,y}.
766
- * @param {number} index The associated data index.
1133
+ * @param {string} dataId The associated data id.
767
1134
  */
768
- initialise(size: object, spacing: object, index: number): void;
1135
+ initialise(size: object, spacing: object, dataId: string): void;
769
1136
  /**
770
1137
  * Fit the layer to its parent container.
771
1138
  *
@@ -787,7 +1154,7 @@ export declare class DrawLayer {
787
1154
  * @param {string} id The id of the group.
788
1155
  * @returns {boolean} False if the group cannot be found.
789
1156
  */
790
- toogleGroupVisibility(id: string): boolean;
1157
+ toggleGroupVisibility(id: string): boolean;
791
1158
  /**
792
1159
  * Delete a Draw from the stage.
793
1160
  *
@@ -803,6 +1170,13 @@ export declare class DrawLayer {
803
1170
  * DeleteCommand has been executed.
804
1171
  */
805
1172
  deleteDraws(exeCallback: object): void;
1173
+ /**
1174
+ * Get the total number of draws of this layer
1175
+ * (at all positions).
1176
+ *
1177
+ * @returns {number|undefined} The total number of draws.
1178
+ */
1179
+ getNumberOfDraws(): number | undefined;
806
1180
  /**
807
1181
  * Enable and listen to container interaction events.
808
1182
  */
@@ -823,21 +1197,40 @@ export declare class DrawLayer {
823
1197
  * Add an event listener to this class.
824
1198
  *
825
1199
  * @param {string} type The event type.
826
- * @param {object} callback The method associated with the provided
1200
+ * @param {Function} callback The function associated with the provided
827
1201
  * event type, will be called with the fired event.
828
1202
  */
829
- addEventListener(type: string, callback: object): void;
1203
+ addEventListener(type: string, callback: Function): void;
830
1204
  /**
831
1205
  * Remove an event listener from this class.
832
1206
  *
833
1207
  * @param {string} type The event type.
834
- * @param {object} callback The method associated with the provided
1208
+ * @param {Function} callback The function associated with the provided
835
1209
  * event type.
836
1210
  */
837
- removeEventListener(type: string, callback: object): void;
1211
+ removeEventListener(type: string, callback: Function): void;
838
1212
  #private;
839
1213
  }
840
1214
 
1215
+ /**
1216
+ * Draw meta data.
1217
+ */
1218
+ export declare class DrawMeta {
1219
+ /**
1220
+ * Draw quantification.
1221
+ *
1222
+ * @type {object}
1223
+ */
1224
+ quantification: object;
1225
+ /**
1226
+ * Draw text expression. Can contain variables surrounded with '{}' that will
1227
+ * be extracted from the quantification object.
1228
+ *
1229
+ * @type {string}
1230
+ */
1231
+ textExpr: string;
1232
+ }
1233
+
841
1234
  /**
842
1235
  * 2D/3D Geometry class.
843
1236
  */
@@ -890,9 +1283,9 @@ export declare class Geometry {
890
1283
  /**
891
1284
  * Get the object origins.
892
1285
  *
893
- * @returns {Array} The object origins.
1286
+ * @returns {Point3D[]} The object origins.
894
1287
  */
895
- getOrigins(): any[];
1288
+ getOrigins(): Point3D[];
896
1289
  /**
897
1290
  * Check if a point is in the origin list.
898
1291
  *
@@ -985,10 +1378,10 @@ export declare class Geometry {
985
1378
  * Check that a index is within bounds.
986
1379
  *
987
1380
  * @param {Index} index The index to check.
988
- * @param {Array} [dirs] Optional list of directions to check.
1381
+ * @param {number[]} [dirs] Optional list of directions to check.
989
1382
  * @returns {boolean} True if the given coordinates are within bounds.
990
1383
  */
991
- isIndexInBounds(index: Index, dirs?: any[]): boolean;
1384
+ isIndexInBounds(index: Index, dirs?: number[]): boolean;
992
1385
  /**
993
1386
  * Convert an index into world coordinates.
994
1387
  *
@@ -1020,6 +1413,19 @@ export declare class Geometry {
1020
1413
  #private;
1021
1414
  }
1022
1415
 
1416
+ /**
1417
+ * Get the default DICOM seg tags as an object.
1418
+ *
1419
+ * @returns {object} The default tags.
1420
+ */
1421
+ export declare function getDefaultDicomSegJson(): object;
1422
+
1423
+ /**
1424
+ * List of DICOM data elements indexed via a 8 character string formed from
1425
+ * the group and element numbers.
1426
+ *
1427
+ * @typedef {Object<string, DataElement>} DataElements
1428
+ */
1023
1429
  /**
1024
1430
  * Get the version of the library.
1025
1431
  *
@@ -1028,15 +1434,40 @@ export declare class Geometry {
1028
1434
  export declare function getDwvVersion(): string;
1029
1435
 
1030
1436
  /**
1031
- * Get the DICOM elements from a DICOM json tags object.
1437
+ * Get the DICOM elements from a 'simple' DICOM json tags object.
1032
1438
  * The json is a simplified version of the oficial DICOM json with
1033
1439
  * tag names instead of keys and direct values (no value property) for
1034
- * simple tags.
1440
+ * simple tags. See synthetic test data (in tests/dicom) for examples.
1035
1441
  *
1036
- * @param {object} jsonTags The DICOM json tags object.
1037
- * @returns {object} The DICOM elements.
1442
+ * @param {Object<string, any>} jsonTags The DICOM
1443
+ * json tags object.
1444
+ * @returns {Object<string, DataElement>} The DICOM elements.
1038
1445
  */
1039
- export declare function getElementsFromJSONTags(jsonTags: object): object;
1446
+ export declare function getElementsFromJSONTags(jsonTags: {
1447
+ [x: string]: any;
1448
+ }): {
1449
+ [x: string]: DataElement;
1450
+ };
1451
+
1452
+ /**
1453
+ * Get the indices that form a ellpise.
1454
+ *
1455
+ * @param {Index} center The ellipse center.
1456
+ * @param {Array} radius The 2 ellipse radiuses.
1457
+ * @param {Array} dir The 2 ellipse directions.
1458
+ * @returns {Array} The indices of the ellipse.
1459
+ */
1460
+ export declare function getEllipseIndices(center: Index, radius: any[], dir: any[]): any[];
1461
+
1462
+ /**
1463
+ * Get the layer details from a mouse event.
1464
+ *
1465
+ * @param {object} event The event to get the layer div id from. Expecting
1466
+ * an event origininating from a canvas inside a layer HTML div
1467
+ * with the 'layer' class and id generated with `getLayerDivId`.
1468
+ * @returns {object} The layer details as {groupDivId, layerId}.
1469
+ */
1470
+ export declare function getLayerDetailsFromEvent(event: object): object;
1040
1471
 
1041
1472
  /**
1042
1473
  * Get the name of an image orientation patient.
@@ -1094,6 +1525,16 @@ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation
1094
1525
  */
1095
1526
  export declare function getUID(tagName: string): string;
1096
1527
 
1528
+ /**
1529
+ * Check that an input buffer includes the DICOM prefix 'DICM'
1530
+ * after the 128 bytes preamble.
1531
+ * Ref: [DICOM File Meta]{@link https://dicom.nema.org/dicom/2013/output/chtml/part10/chapter_7.html#sect_7.1}
1532
+ *
1533
+ * @param {ArrayBuffer} buffer The buffer to check.
1534
+ * @returns {boolean} True if the buffer includes the prefix.
1535
+ */
1536
+ export declare function hasDicomPrefix(buffer: ArrayBuffer): boolean;
1537
+
1097
1538
  export declare namespace i18n {
1098
1539
  /**
1099
1540
  * Get the translated text.
@@ -1338,18 +1779,18 @@ declare class Image_2 {
1338
1779
  * Add an event listener to this class.
1339
1780
  *
1340
1781
  * @param {string} type The event type.
1341
- * @param {object} callback The method associated with the provided
1782
+ * @param {Function} callback The function associated with the provided
1342
1783
  * event type, will be called with the fired event.
1343
1784
  */
1344
- addEventListener(type: string, callback: object): void;
1785
+ addEventListener(type: string, callback: Function): void;
1345
1786
  /**
1346
1787
  * Remove an event listener from this class.
1347
1788
  *
1348
1789
  * @param {string} type The event type.
1349
- * @param {object} callback The method associated with the provided
1790
+ * @param {Function} callback The function associated with the provided
1350
1791
  * event type.
1351
1792
  */
1352
- removeEventListener(type: string, callback: object): void;
1793
+ removeEventListener(type: string, callback: Function): void;
1353
1794
  /**
1354
1795
  * Set the inner buffer values at given offsets.
1355
1796
  *
@@ -1491,9 +1932,9 @@ export { Image_2 as Image }
1491
1932
  */
1492
1933
  export declare class Index {
1493
1934
  /**
1494
- * @param {Array} values The index values.
1935
+ * @param {number[]} values The index values.
1495
1936
  */
1496
- constructor(values: any[]);
1937
+ constructor(values: number[]);
1497
1938
  /**
1498
1939
  * Get the index value at the given array index.
1499
1940
  *
@@ -1516,9 +1957,9 @@ export declare class Index {
1516
1957
  /**
1517
1958
  * Get the values of this index.
1518
1959
  *
1519
- * @returns {Array} The array of values.
1960
+ * @returns {number[]} The array of values.
1520
1961
  */
1521
- getValues(): any[];
1962
+ getValues(): number[];
1522
1963
  /**
1523
1964
  * Check if the input index can be compared to this one.
1524
1965
  *
@@ -1537,9 +1978,9 @@ export declare class Index {
1537
1978
  * Compare indices and return different dimensions.
1538
1979
  *
1539
1980
  * @param {Index} rhs The index to compare to.
1540
- * @returns {Array} The list of different dimensions.
1981
+ * @returns {number[]} The list of different dimensions.
1541
1982
  */
1542
- compare(rhs: Index): any[];
1983
+ compare(rhs: Index): number[];
1543
1984
  /**
1544
1985
  * Add another index to this one.
1545
1986
  *
@@ -1558,13 +1999,22 @@ export declare class Index {
1558
1999
  /**
1559
2000
  * Get a string id from the index values in the form of: '#0-1_#1-2'.
1560
2001
  *
1561
- * @param {Array} [dims] Optional list of dimensions to use.
2002
+ * @param {number[]} [dims] Optional list of dimensions to use.
1562
2003
  * @returns {string} The string id.
1563
2004
  */
1564
- toStringId(dims?: any[]): string;
2005
+ toStringId(dims?: number[]): string;
1565
2006
  #private;
1566
2007
  }
1567
2008
 
2009
+ /**
2010
+ * CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to
2011
+ * unsigned int CIE LAB ([0, 65535]).
2012
+ *
2013
+ * @param {object} triplet CIE XYZ triplet as {x,y,z} with CIE LAB range.
2014
+ * @returns {object} CIE LAB triplet as {l,a,b} with unsigned range.
2015
+ */
2016
+ export declare function labToUintLab(triplet: object): object;
2017
+
1568
2018
  /**
1569
2019
  * Layer group.
1570
2020
  *
@@ -1586,18 +2036,6 @@ export declare class LayerGroup {
1586
2036
  * @param {HTMLElement} containerDiv The associated HTML div.
1587
2037
  */
1588
2038
  constructor(containerDiv: HTMLElement);
1589
- /**
1590
- * Get the target orientation.
1591
- *
1592
- * @returns {Matrix33} The orientation matrix.
1593
- */
1594
- getTargetOrientation(): Matrix33;
1595
- /**
1596
- * Set the target orientation.
1597
- *
1598
- * @param {Matrix33} orientation The orientation matrix.
1599
- */
1600
- setTargetOrientation(orientation: Matrix33): void;
1601
2039
  /**
1602
2040
  * Get the showCrosshair flag.
1603
2041
  *
@@ -1610,6 +2048,12 @@ export declare class LayerGroup {
1610
2048
  * @param {boolean} flag True to display the crosshair.
1611
2049
  */
1612
2050
  setShowCrosshair(flag: boolean): void;
2051
+ /**
2052
+ * Set the imageSmoothing flag value.
2053
+ *
2054
+ * @param {boolean} flag True to enable smoothing.
2055
+ */
2056
+ setImageSmoothing(flag: boolean): void;
1613
2057
  /**
1614
2058
  * Get the Id of the container div.
1615
2059
  *
@@ -1646,19 +2090,25 @@ export declare class LayerGroup {
1646
2090
  * @returns {number} The number of layers.
1647
2091
  */
1648
2092
  getNumberOfLayers(): number;
2093
+ /**
2094
+ * Get the number of view layers handled by this class.
2095
+ *
2096
+ * @returns {number} The number of layers.
2097
+ */
2098
+ getNumberOfViewLayers(): number;
1649
2099
  /**
1650
2100
  * Get the active image layer.
1651
2101
  *
1652
- * @returns {ViewLayer} The layer.
2102
+ * @returns {ViewLayer|undefined} The layer.
1653
2103
  */
1654
- getActiveViewLayer(): ViewLayer;
2104
+ getActiveViewLayer(): ViewLayer | undefined;
1655
2105
  /**
1656
- * Get the view layers associated to a data index.
2106
+ * Get the view layers associated to a data id.
1657
2107
  *
1658
- * @param {number} index The data index.
2108
+ * @param {string} dataId The data id.
1659
2109
  * @returns {ViewLayer[]} The layers.
1660
2110
  */
1661
- getViewLayersByDataIndex(index: number): ViewLayer[];
2111
+ getViewLayersByDataId(dataId: string): ViewLayer[];
1662
2112
  /**
1663
2113
  * Search view layers for equal imae meta data.
1664
2114
  *
@@ -1675,16 +2125,16 @@ export declare class LayerGroup {
1675
2125
  /**
1676
2126
  * Get the active draw layer.
1677
2127
  *
1678
- * @returns {DrawLayer} The layer.
2128
+ * @returns {DrawLayer|undefined} The layer.
1679
2129
  */
1680
- getActiveDrawLayer(): DrawLayer;
2130
+ getActiveDrawLayer(): DrawLayer | undefined;
1681
2131
  /**
1682
- * Get the draw layers associated to a data index.
2132
+ * Get the draw layers associated to a data id.
1683
2133
  *
1684
- * @param {number} index The data index.
2134
+ * @param {string} dataId The data id.
1685
2135
  * @returns {DrawLayer[]} The layers.
1686
2136
  */
1687
- getDrawLayersByDataIndex(index: number): DrawLayer[];
2137
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
1688
2138
  /**
1689
2139
  * Set the active view layer.
1690
2140
  *
@@ -1692,11 +2142,11 @@ export declare class LayerGroup {
1692
2142
  */
1693
2143
  setActiveViewLayer(index: number): void;
1694
2144
  /**
1695
- * Set the active view layer with a data index.
2145
+ * Set the active view layer with a data id.
1696
2146
  *
1697
- * @param {number} index The data index.
2147
+ * @param {string} dataId The data id.
1698
2148
  */
1699
- setActiveViewLayerByDataIndex(index: number): void;
2149
+ setActiveViewLayerByDataId(dataId: string): void;
1700
2150
  /**
1701
2151
  * Set the active draw layer.
1702
2152
  *
@@ -1704,11 +2154,11 @@ export declare class LayerGroup {
1704
2154
  */
1705
2155
  setActiveDrawLayer(index: number): void;
1706
2156
  /**
1707
- * Set the active draw layer with a data index.
2157
+ * Set the active draw layer with a data id.
1708
2158
  *
1709
- * @param {number} index The data index.
2159
+ * @param {string} dataId The data id.
1710
2160
  */
1711
- setActiveDrawLayerByDataIndex(index: number): void;
2161
+ setActiveDrawLayerByDataId(dataId: string): void;
1712
2162
  /**
1713
2163
  * Add a view layer.
1714
2164
  *
@@ -1727,6 +2177,9 @@ export declare class LayerGroup {
1727
2177
  empty(): void;
1728
2178
  /**
1729
2179
  * Remove a layer from this layer group.
2180
+ * Warning: if current active layer, the index will
2181
+ * be set to `undefined`. Call one of the setActive
2182
+ * methods to define the active index.
1730
2183
  *
1731
2184
  * @param {ViewLayer | DrawLayer} layer The layer to remove.
1732
2185
  */
@@ -1735,6 +2188,7 @@ export declare class LayerGroup {
1735
2188
  * Update layers (but not the active view layer) to a position change.
1736
2189
  *
1737
2190
  * @param {object} event The position change event.
2191
+ * @function
1738
2192
  */
1739
2193
  updateLayersToPositionChange: (event: object) => void;
1740
2194
  /**
@@ -1805,18 +2259,18 @@ export declare class LayerGroup {
1805
2259
  * Add an event listener to this class.
1806
2260
  *
1807
2261
  * @param {string} type The event type.
1808
- * @param {object} callback The method associated with the provided
2262
+ * @param {Function} callback The function associated with the provided
1809
2263
  * event type, will be called with the fired event.
1810
2264
  */
1811
- addEventListener(type: string, callback: object): void;
2265
+ addEventListener(type: string, callback: Function): void;
1812
2266
  /**
1813
2267
  * Remove an event listener from this class.
1814
2268
  *
1815
2269
  * @param {string} type The event type.
1816
- * @param {object} callback The method associated with the provided
2270
+ * @param {Function} callback The function associated with the provided
1817
2271
  * event type.
1818
2272
  */
1819
- removeEventListener(type: string, callback: object): void;
2273
+ removeEventListener(type: string, callback: Function): void;
1820
2274
  #private;
1821
2275
  }
1822
2276
 
@@ -1839,32 +2293,45 @@ export declare namespace logger {
1839
2293
  /**
1840
2294
  * List of available lookup tables (lut).
1841
2295
  *
1842
- * @type {Object<string, {red: number[], green: number[], blue: number[]}>}
2296
+ * @type {Object<string, ColourMap>}
1843
2297
  */
1844
- export declare const lut: {
1845
- [x: string]: {
1846
- red: number[];
1847
- green: number[];
1848
- blue: number[];
1849
- };
2298
+ export declare const luts: {
2299
+ [x: string]: ColourMap;
1850
2300
  };
1851
2301
 
2302
+ /**
2303
+ * Mask {@link Image} factory.
2304
+ */
2305
+ export declare class MaskFactory {
2306
+ checkElements(_dicomElements: any): void;
2307
+ /**
2308
+ * Get an {@link Image} object from the read DICOM file.
2309
+ *
2310
+ * @param {DataElements} dataElements The DICOM tags.
2311
+ * @param {Uint8Array | Int8Array |
2312
+ * Uint16Array | Int16Array |
2313
+ * Uint32Array | Int32Array} pixelBuffer The pixel buffer.
2314
+ * @returns {Image} A new Image.
2315
+ */
2316
+ create(dataElements: DataElements, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array): Image_2;
2317
+ }
2318
+
1852
2319
  /**
1853
2320
  * Immutable 3x3 Matrix.
1854
2321
  */
1855
2322
  export declare class Matrix33 {
1856
2323
  /**
1857
- * @param {Array} values row-major ordered 9 values.
2324
+ * @param {number[]} values row-major ordered 9 values.
1858
2325
  */
1859
- constructor(values: any[]);
2326
+ constructor(values: number[]);
1860
2327
  /**
1861
2328
  * Get a value of the matrix.
1862
2329
  *
1863
2330
  * @param {number} row The row at wich to get the value.
1864
2331
  * @param {number} col The column at wich to get the value.
1865
- * @returns {number} The value at the position.
2332
+ * @returns {number|undefined} The value at the position.
1866
2333
  */
1867
- get(row: number, col: number): number;
2334
+ get(row: number, col: number): number | undefined;
1868
2335
  /**
1869
2336
  * Get the inverse of this matrix.
1870
2337
  *
@@ -1903,10 +2370,10 @@ export declare class Matrix33 {
1903
2370
  /**
1904
2371
  * Multiply this matrix by a 3D array.
1905
2372
  *
1906
- * @param {Array} array3D The input 3D array.
1907
- * @returns {Array} The result 3D array.
2373
+ * @param {number[]} array3D The input 3D array.
2374
+ * @returns {number[]} The result 3D array.
1908
2375
  */
1909
- multiplyArray3D(array3D: any[]): any[];
2376
+ multiplyArray3D(array3D: number[]): number[];
1910
2377
  /**
1911
2378
  * Multiply this matrix by a 3D vector.
1912
2379
  *
@@ -1963,10 +2430,10 @@ export declare class Matrix33 {
1963
2430
  export declare class OverlayData {
1964
2431
  /**
1965
2432
  * @param {App} app The associated application.
1966
- * @param {number} dataId The associated data ID.
2433
+ * @param {string} dataId The associated data id.
1967
2434
  * @param {object} configs The overlay config.
1968
2435
  */
1969
- constructor(app: App, dataId: number, configs: object);
2436
+ constructor(app: App, dataId: string, configs: object);
1970
2437
  /**
1971
2438
  * Reset the data.
1972
2439
  */
@@ -2017,9 +2484,9 @@ export declare class OverlayData {
2017
2484
  */
2018
2485
  export declare class Point {
2019
2486
  /**
2020
- * @param {Array} values The point values.
2487
+ * @param {number[]} values The point values.
2021
2488
  */
2022
- constructor(values: any[]);
2489
+ constructor(values: number[]);
2023
2490
  /**
2024
2491
  * Get the index value at the given array index.
2025
2492
  *
@@ -2042,9 +2509,9 @@ export declare class Point {
2042
2509
  /**
2043
2510
  * Get the values of this index.
2044
2511
  *
2045
- * @returns {Array} The array of values.
2512
+ * @returns {number[]} The array of values.
2046
2513
  */
2047
- getValues(): any[];
2514
+ getValues(): number[];
2048
2515
  /**
2049
2516
  * Check if the input point can be compared to this one.
2050
2517
  *
@@ -2063,9 +2530,9 @@ export declare class Point {
2063
2530
  * Compare points and return different dimensions.
2064
2531
  *
2065
2532
  * @param {Point} rhs The point to compare to.
2066
- * @returns {Array} The list of different dimensions.
2533
+ * @returns {number[]} The list of different dimensions.
2067
2534
  */
2068
- compare(rhs: Point): any[];
2535
+ compare(rhs: Point): number[];
2069
2536
  /**
2070
2537
  * Get the 3D part of this point.
2071
2538
  *
@@ -2458,6 +2925,14 @@ export declare class Spacing {
2458
2925
  #private;
2459
2926
  }
2460
2927
 
2928
+ /**
2929
+ * Convert sRGB to CIE LAB (standard illuminant D65).
2930
+ *
2931
+ * @param {object} triplet sRGB triplet as {r,g,b}.
2932
+ * @returns {object} CIE LAB triplet as {l,a,b}.
2933
+ */
2934
+ export declare function srgbToCielab(triplet: object): object;
2935
+
2461
2936
  /**
2462
2937
  * Immutable tag.
2463
2938
  */
@@ -2550,12 +3025,103 @@ export declare class TagValueExtractor {
2550
3025
  /**
2551
3026
  * Get the time.
2552
3027
  *
2553
- * @param {object} _elements The DICOM elements.
3028
+ * @param {Object<string, DataElement>} _elements The DICOM elements.
2554
3029
  * @returns {number|undefined} The time value if available.
2555
3030
  */
2556
- getTime(_elements: object): number | undefined;
3031
+ getTime(_elements: {
3032
+ [x: string]: DataElement;
3033
+ }): number | undefined;
2557
3034
  }
2558
3035
 
3036
+ /**
3037
+ * Toolbox controller.
3038
+ */
3039
+ export declare class ToolboxController {
3040
+ /**
3041
+ * @param {object} toolList The list of tool objects.
3042
+ */
3043
+ constructor(toolList: object);
3044
+ /**
3045
+ * Initialise.
3046
+ */
3047
+ init(): void;
3048
+ /**
3049
+ * Get the tool list.
3050
+ *
3051
+ * @returns {Array} The list of tool objects.
3052
+ */
3053
+ getToolList(): any[];
3054
+ /**
3055
+ * Check if a tool is in the tool list.
3056
+ *
3057
+ * @param {string} name The name to check.
3058
+ * @returns {boolean} The tool list element for the given name.
3059
+ */
3060
+ hasTool(name: string): boolean;
3061
+ /**
3062
+ * Get the selected tool.
3063
+ *
3064
+ * @returns {object} The selected tool.
3065
+ */
3066
+ getSelectedTool(): object;
3067
+ /**
3068
+ * Get the selected tool event handler.
3069
+ *
3070
+ * @param {string} eventType The event type, for example
3071
+ * mousedown, touchstart...
3072
+ * @returns {Function} The event handler.
3073
+ */
3074
+ getSelectedToolEventHandler(eventType: string): Function;
3075
+ /**
3076
+ * Set the selected tool.
3077
+ *
3078
+ * @param {string} name The name of the tool.
3079
+ */
3080
+ setSelectedTool(name: string): void;
3081
+ /**
3082
+ * Set the selected tool live features.
3083
+ *
3084
+ * @param {object} list The list of features.
3085
+ */
3086
+ setToolFeatures(list: object): void;
3087
+ /**
3088
+ * Listen to layer interaction events.
3089
+ *
3090
+ * @param {LayerGroup} layerGroup The associated layer group.
3091
+ * @param {ViewLayer|DrawLayer} layer The layer to listen to.
3092
+ */
3093
+ bindLayerGroup(layerGroup: LayerGroup, layer: ViewLayer | DrawLayer): void;
3094
+ #private;
3095
+ }
3096
+
3097
+ /**
3098
+ * Tool configuration.
3099
+ */
3100
+ export declare class ToolConfig {
3101
+ /**
3102
+ * @param {string[]} [options] Optional tool options.
3103
+ */
3104
+ constructor(options?: string[]);
3105
+ /**
3106
+ * Optional tool options.
3107
+ * For Draw: list of shape names.
3108
+ * For Filter: list of filter names.
3109
+ *
3110
+ * @type {string[]|undefined}
3111
+ */
3112
+ options: string[] | undefined;
3113
+ }
3114
+
3115
+ /**
3116
+ * List of client provided tools to be added to
3117
+ * the default ones.
3118
+ *
3119
+ * @type {Object<string, any>}
3120
+ */
3121
+ export declare const toolList: {
3122
+ [x: string]: any;
3123
+ };
3124
+
2559
3125
  /**
2560
3126
  * Immutable 3D vector.
2561
3127
  */
@@ -2587,10 +3153,10 @@ export declare class Vector3D {
2587
3153
  /**
2588
3154
  * Check for Vector3D equality.
2589
3155
  *
2590
- * @param {object} rhs The other vector to compare to.
3156
+ * @param {Vector3D} rhs The other vector to compare to.
2591
3157
  * @returns {boolean} True if both vectors are equal.
2592
3158
  */
2593
- equals(rhs: object): boolean;
3159
+ equals(rhs: Vector3D): boolean;
2594
3160
  /**
2595
3161
  * Get a string representation of the Vector3D.
2596
3162
  *
@@ -2637,9 +3203,9 @@ export declare class Vector3D {
2637
3203
  * const dicomParser = new dwv.DicomParser();
2638
3204
  * dicomParser.parse(event.target.response);
2639
3205
  * // create the image object
2640
- * const image = createImage(dicomParser.getDicomElements());
3206
+ * const image = dwv.createImage(dicomParser.getDicomElements());
2641
3207
  * // create the view
2642
- * const view = createView(dicomParser.getDicomElements(), image);
3208
+ * const view = dwv.createView(dicomParser.getDicomElements(), image);
2643
3209
  * // setup canvas
2644
3210
  * const canvas = document.createElement('canvas');
2645
3211
  * canvas.width = 256;
@@ -2750,12 +3316,6 @@ export declare class View {
2750
3316
  * @param {object} presets The window presets.
2751
3317
  */
2752
3318
  setWindowPresets(presets: object): void;
2753
- /**
2754
- * Set the default colour map.
2755
- *
2756
- * @param {object} map The colour map.
2757
- */
2758
- setDefaultColourMap(map: object): void;
2759
3319
  /**
2760
3320
  * Add window presets to the existing ones.
2761
3321
  *
@@ -2771,16 +3331,16 @@ export declare class View {
2771
3331
  /**
2772
3332
  * Get the colour map of the image.
2773
3333
  *
2774
- * @returns {object} The colour map of the image.
3334
+ * @returns {string} The colour map name.
2775
3335
  */
2776
- getColourMap(): object;
3336
+ getColourMap(): string;
2777
3337
  /**
2778
3338
  * Set the colour map of the image.
2779
3339
  *
2780
- * @param {object} map The colour map of the image.
2781
- * @fires View#colourchange
3340
+ * @param {string} name The colour map name.
3341
+ * @fires View#colourmapchange
2782
3342
  */
2783
- setColourMap(map: object): void;
3343
+ setColourMap(name: string): void;
2784
3344
  /**
2785
3345
  * Get the current position.
2786
3346
  *
@@ -2801,12 +3361,12 @@ export declare class View {
2801
3361
  */
2802
3362
  canSetPosition(position: Point): boolean;
2803
3363
  /**
2804
- * Get the origin at a given position.
3364
+ * Get the first origin or at a given position.
2805
3365
  *
2806
- * @param {Point} position The position.
2807
- * @returns {Point} The origin.
3366
+ * @param {Point} [position] Optional position.
3367
+ * @returns {Point3D} The origin.
2808
3368
  */
2809
- getOrigin(position: Point): Point;
3369
+ getOrigin(position?: Point): Point3D;
2810
3370
  /**
2811
3371
  * Set the current position.
2812
3372
  *
@@ -2854,18 +3414,18 @@ export declare class View {
2854
3414
  * Add an event listener to this class.
2855
3415
  *
2856
3416
  * @param {string} type The event type.
2857
- * @param {object} callback The method associated with the provided
3417
+ * @param {Function} callback The function associated with the provided
2858
3418
  * event type, will be called with the fired event.
2859
3419
  */
2860
- addEventListener(type: string, callback: object): void;
3420
+ addEventListener(type: string, callback: Function): void;
2861
3421
  /**
2862
3422
  * Remove an event listener from this class.
2863
3423
  *
2864
3424
  * @param {string} type The event type.
2865
- * @param {object} callback The method associated with the provided
3425
+ * @param {Function} callback The function associated with the provided
2866
3426
  * event type.
2867
3427
  */
2868
- removeEventListener(type: string, callback: object): void;
3428
+ removeEventListener(type: string, callback: Function): void;
2869
3429
  /**
2870
3430
  * Get the image window/level that covers the full data range.
2871
3431
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -2925,15 +3485,63 @@ export declare class View {
2925
3485
  #private;
2926
3486
  }
2927
3487
 
3488
+ /**
3489
+ * View configuration: mainly defines the ´divId´
3490
+ * of the associated HTML div.
3491
+ */
3492
+ export declare class ViewConfig {
3493
+ /**
3494
+ * @param {string} divId The associated HTML div id.
3495
+ */
3496
+ constructor(divId: string);
3497
+ /**
3498
+ * Associated HTML div id.
3499
+ *
3500
+ * @type {string}
3501
+ */
3502
+ divId: string;
3503
+ /**
3504
+ * Optional orientation of the data; 'axial', 'coronal' or 'sagittal'.
3505
+ * If undefined, will use the data aquisition plane.
3506
+ *
3507
+ * @type {string|undefined}
3508
+ */
3509
+ orientation: string | undefined;
3510
+ /**
3511
+ * Optional view colour map name.
3512
+ *
3513
+ * @type {string|undefined}
3514
+ */
3515
+ colourMap: string | undefined;
3516
+ /**
3517
+ * Optional layer opacity; in [0, 1] range.
3518
+ *
3519
+ * @type {number|undefined}
3520
+ */
3521
+ opacity: number | undefined;
3522
+ /**
3523
+ * Optional layer window center.
3524
+ *
3525
+ * @type {number|undefined}
3526
+ */
3527
+ windowCenter: number | undefined;
3528
+ /**
3529
+ * Optional layer window width.
3530
+ *
3531
+ * @type {number|undefined}
3532
+ */
3533
+ windowWidth: number | undefined;
3534
+ }
3535
+
2928
3536
  /**
2929
3537
  * View controller.
2930
3538
  */
2931
3539
  export declare class ViewController {
2932
3540
  /**
2933
3541
  * @param {View} view The associated view.
2934
- * @param {number} index The associated data index.
3542
+ * @param {string} dataId The associated data id.
2935
3543
  */
2936
- constructor(view: View, index: number);
3544
+ constructor(view: View, dataId: string);
2937
3545
  /**
2938
3546
  * Get the plane helper.
2939
3547
  *
@@ -3036,12 +3644,12 @@ export declare class ViewController {
3036
3644
  */
3037
3645
  getCurrentScrollIndexValue(): object;
3038
3646
  /**
3039
- * Get the origin at a given posittion.
3647
+ * Get the first origin or at a given position.
3040
3648
  *
3041
- * @param {Point} position The input position.
3042
- * @returns {Point} The origin.
3649
+ * @param {Point} [position] Opitonal position.
3650
+ * @returns {Point3D} The origin.
3043
3651
  */
3044
- getOrigin(position: Point): Point;
3652
+ getOrigin(position?: Point): Point3D;
3045
3653
  /**
3046
3654
  * Get the current scroll position value.
3047
3655
  *
@@ -3060,13 +3668,13 @@ export declare class ViewController {
3060
3668
  * Set the associated image.
3061
3669
  *
3062
3670
  * @param {Image} img The associated image.
3063
- * @param {number} index The data index of the image.
3671
+ * @param {string} dataId The data id of the image.
3064
3672
  */
3065
- setImage(img: Image_2, index: number): void;
3673
+ setImage(img: Image_2, dataId: string): void;
3066
3674
  /**
3067
- * Get the current spacing.
3675
+ * Get the current view (2D) spacing.
3068
3676
  *
3069
- * @returns {Array} The 2D spacing.
3677
+ * @returns {Array} The spacing as a 2D array.
3070
3678
  */
3071
3679
  get2DSpacing(): any[];
3072
3680
  /**
@@ -3256,15 +3864,15 @@ export declare class ViewController {
3256
3864
  /**
3257
3865
  * Get the colour map.
3258
3866
  *
3259
- * @returns {object} The colour map.
3867
+ * @returns {string} The colour map name.
3260
3868
  */
3261
- getColourMap(): object;
3869
+ getColourMap(): string;
3262
3870
  /**
3263
3871
  * Set the colour map.
3264
3872
  *
3265
- * @param {object} colourMap The colour map.
3873
+ * @param {string} name The colour map name.
3266
3874
  */
3267
- setColourMap(colourMap: object): void;
3875
+ setColourMap(name: string): void;
3268
3876
  /**
3269
3877
  * @callback alphaFn@callback alphaFn
3270
3878
  * @param {object} value The pixel value.
@@ -3277,28 +3885,22 @@ export declare class ViewController {
3277
3885
  * @param {alphaFn} func The function.
3278
3886
  */
3279
3887
  setViewAlphaFunction(func: (value: object, index: object) => number): void;
3280
- /**
3281
- * Set the colour map from a name.
3282
- *
3283
- * @param {string} name The name of the colour map to set.
3284
- */
3285
- setColourMapFromName(name: string): void;
3286
3888
  /**
3287
3889
  * Add an event listener to this class.
3288
3890
  *
3289
3891
  * @param {string} type The event type.
3290
- * @param {object} callback The method associated with the provided
3892
+ * @param {Function} callback The function associated with the provided
3291
3893
  * event type, will be called with the fired event.
3292
3894
  */
3293
- addEventListener(type: string, callback: object): void;
3895
+ addEventListener(type: string, callback: Function): void;
3294
3896
  /**
3295
3897
  * Remove an event listener from this class.
3296
3898
  *
3297
3899
  * @param {string} type The event type.
3298
- * @param {object} callback The method associated with the provided
3900
+ * @param {Function} callback The function associated with the provided
3299
3901
  * event type.
3300
3902
  */
3301
- removeEventListener(type: string, callback: object): void;
3903
+ removeEventListener(type: string, callback: Function): void;
3302
3904
  #private;
3303
3905
  }
3304
3906
 
@@ -3312,24 +3914,24 @@ export declare class ViewLayer {
3312
3914
  */
3313
3915
  constructor(containerDiv: HTMLElement);
3314
3916
  /**
3315
- * Get the associated data index.
3917
+ * Get the associated data id.
3316
3918
  *
3317
- * @returns {number} The index.
3919
+ * @returns {string} The data id.
3318
3920
  */
3319
- getDataIndex(): number;
3921
+ getDataId(): string;
3320
3922
  /**
3321
- * Set the imageSmoothingEnabled flag value.
3923
+ * Set the imageSmoothing flag value.
3322
3924
  *
3323
3925
  * @param {boolean} flag True to enable smoothing.
3324
3926
  */
3325
- enableImageSmoothing(flag: boolean): void;
3927
+ setImageSmoothing(flag: boolean): void;
3326
3928
  /**
3327
3929
  * Set the associated view.
3328
3930
  *
3329
3931
  * @param {object} view The view.
3330
- * @param {number} index The associated data index.
3932
+ * @param {string} dataId The associated data id.
3331
3933
  */
3332
- setView(view: object, index: number): void;
3934
+ setView(view: object, dataId: string): void;
3333
3935
  /**
3334
3936
  * Get the view controller.
3335
3937
  *
@@ -3346,12 +3948,14 @@ export declare class ViewLayer {
3346
3948
  * Handle an image set event.
3347
3949
  *
3348
3950
  * @param {object} event The event.
3951
+ * @function
3349
3952
  */
3350
3953
  onimageset: (event: object) => void;
3351
3954
  /**
3352
3955
  * Handle an image change event.
3353
3956
  *
3354
3957
  * @param {object} event The event.
3958
+ * @function
3355
3959
  */
3356
3960
  onimagechange: (event: object) => void;
3357
3961
  /**
@@ -3392,13 +3996,17 @@ export declare class ViewLayer {
3392
3996
  * Add a flip offset along the layer Y axis.
3393
3997
  */
3394
3998
  addFlipOffsetY(): void;
3999
+ /**
4000
+ * Flip the scale along the layer Z axis.
4001
+ */
4002
+ flipScaleZ(): void;
3395
4003
  /**
3396
4004
  * Set the layer scale.
3397
4005
  *
3398
4006
  * @param {object} newScale The scale as {x,y}.
3399
- * @param {Point3D} center The scale center.
4007
+ * @param {Point3D} [center] The scale center.
3400
4008
  */
3401
- setScale(newScale: object, center: Point3D): void;
4009
+ setScale(newScale: object, center?: Point3D): void;
3402
4010
  /**
3403
4011
  * Set the base layer offset. Updates the layer offset.
3404
4012
  *
@@ -3442,7 +4050,8 @@ export declare class ViewLayer {
3442
4050
  *
3443
4051
  * @param {number} x The X position.
3444
4052
  * @param {number} y The Y position.
3445
- * @returns {object} The display position as {x,y}.
4053
+ * @returns {object} The display position as {x,y}, can be individually
4054
+ * undefined if out of bounds.
3446
4055
  */
3447
4056
  planePosToDisplay(x: number, y: number): object;
3448
4057
  /**
@@ -3501,18 +4110,18 @@ export declare class ViewLayer {
3501
4110
  * Add an event listener to this class.
3502
4111
  *
3503
4112
  * @param {string} type The event type.
3504
- * @param {object} callback The method associated with the provided
4113
+ * @param {Function} callback The function associated with the provided
3505
4114
  * event type, will be called with the fired event.
3506
4115
  */
3507
- addEventListener(type: string, callback: object): void;
4116
+ addEventListener(type: string, callback: Function): void;
3508
4117
  /**
3509
4118
  * Remove an event listener from this class.
3510
4119
  *
3511
4120
  * @param {string} type The event type.
3512
- * @param {object} callback The method associated with the provided
4121
+ * @param {Function} callback The function associated with the provided
3513
4122
  * event type.
3514
4123
  */
3515
- removeEventListener(type: string, callback: object): void;
4124
+ removeEventListener(type: string, callback: Function): void;
3516
4125
  /**
3517
4126
  * Set the current position.
3518
4127
  *
@@ -3626,4 +4235,26 @@ export declare class WindowLut {
3626
4235
  #private;
3627
4236
  }
3628
4237
 
4238
+ /**
4239
+ * Writer rule.
4240
+ */
4241
+ export declare class WriterRule {
4242
+ /**
4243
+ * @param {string} action The rule action.
4244
+ */
4245
+ constructor(action: string);
4246
+ /**
4247
+ * Rule action: `copy`, `remove`, `clear` or `replace`.
4248
+ *
4249
+ * @type {string}
4250
+ */
4251
+ action: string;
4252
+ /**
4253
+ * Optional value to use for replace action.
4254
+ *
4255
+ * @type {any|undefined}
4256
+ */
4257
+ value: any | undefined;
4258
+ }
4259
+
3629
4260
  export { }