dwv 0.33.0-beta.0 → 0.33.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dwv.d.ts CHANGED
@@ -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
232
  * @fires App#loaderror
237
233
  * @fires App#loadabort
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
@@ -251,13 +248,15 @@ export declare class App {
251
248
  * @fires App#loadend
252
249
  * @fires App#loaderror
253
250
  * @fires App#loadabort
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
  /**
@@ -271,6 +270,7 @@ export declare class App {
271
270
  * @fires App#loadend
272
271
  * @fires App#loaderror
273
272
  * @fires App#loadabort
273
+ * @function
274
274
  */
275
275
  loadImageObject: (data: any[]) => void;
276
276
  /**
@@ -286,19 +286,53 @@ 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;
289
295
  /**
290
296
  * Get the data view config.
291
297
  * Carefull, returns a reference, do not modify without resetting.
292
298
  *
293
- * @returns {object} The configuration list.
299
+ * @returns {Object<string, ViewConfig[]>} The configuration list.
300
+ */
301
+ getDataViewConfigs(): {
302
+ [x: string]: ViewConfig[];
303
+ };
304
+ /**
305
+ * Set the data view configuration.
306
+ * Resets the stage and recreates all the views.
307
+ *
308
+ * @param {Object<string, ViewConfig[]>} configs The configuration list.
309
+ */
310
+ setDataViewConfigs(configs: {
311
+ [x: string]: ViewConfig[];
312
+ }): void;
313
+ /**
314
+ * Add a data view config.
315
+ *
316
+ * @param {string} dataId The data id.
317
+ * @param {ViewConfig} config The view configuration.
318
+ */
319
+ addDataViewConfig(dataId: string, config: ViewConfig): void;
320
+ /**
321
+ * Remove a data view config.
322
+ *
323
+ * @param {string} dataId The data id.
324
+ * @param {ViewConfig} config The view configuration.
294
325
  */
295
- getDataViewConfig(): object;
326
+ removeDataViewConfig(dataId: string, config: ViewConfig): void;
296
327
  /**
297
- * Set the data view configuration (see the init options for details).
328
+ * Update a data view config.
329
+ * Removes and re-creates the layer if found.
298
330
  *
299
- * @param {object} configs The configuration list.
331
+ * @param {string} dataId The data id.
332
+ * @param {string} divId The div id.
333
+ * @param {ViewConfig} config The view configuration.
300
334
  */
301
- setDataViewConfig(configs: object): void;
335
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
302
336
  /**
303
337
  * Set the layer groups binders.
304
338
  *
@@ -308,9 +342,10 @@ export declare class App {
308
342
  /**
309
343
  * Render the current data.
310
344
  *
311
- * @param {number} dataIndex The data index to render.
345
+ * @param {string} dataId The data id to render.
346
+ * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
312
347
  */
313
- render(dataIndex: number): void;
348
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
314
349
  /**
315
350
  * Zoom to the layers.
316
351
  *
@@ -355,6 +390,8 @@ export declare class App {
355
390
  * Handle resize: fit the display to the window.
356
391
  * To be called once the image is loaded.
357
392
  * Can be connected to a window 'resize' event.
393
+ *
394
+ * @function
358
395
  */
359
396
  onResize: () => void;
360
397
  /**
@@ -362,6 +399,7 @@ export declare class App {
362
399
  *
363
400
  * @param {KeyboardEvent} event The key down event.
364
401
  * @fires App#keydown
402
+ * @function
365
403
  */
366
404
  onKeydown: (event: KeyboardEvent) => void;
367
405
  /**
@@ -376,6 +414,7 @@ export declare class App {
376
414
  * @param {KeyboardEvent} event The key down event.
377
415
  * @fires UndoStack#undo
378
416
  * @fires UndoStack#redo
417
+ * @function
379
418
  */
380
419
  defaultOnKeydown: (event: KeyboardEvent) => void;
381
420
  /**
@@ -389,9 +428,9 @@ export declare class App {
389
428
  /**
390
429
  * Set the colour map.
391
430
  *
392
- * @param {string} colourMap The colour map name.
431
+ * @param {string} name The colour map name.
393
432
  */
394
- setColourMap(colourMap: string): void;
433
+ setColourMap(name: string): void;
395
434
  /**
396
435
  * Set the window/level preset.
397
436
  *
@@ -435,21 +474,77 @@ export declare class App {
435
474
  */
436
475
  getCurrentStackIndex(): number;
437
476
  /**
438
- * Get the overlay data for a data index.
477
+ * Get the overlay data for a data id.
439
478
  *
440
- * @param {number} dataIndex The data index.
441
- * @returns {OverlayData} The overlay data.
479
+ * @param {string} dataId The data id.
480
+ * @returns {OverlayData|undefined} The overlay data.
442
481
  */
443
- getOverlayData(dataIndex: number): OverlayData;
482
+ getOverlayData(dataId: string): OverlayData | undefined;
444
483
  /**
445
484
  * Toggle overlay listeners.
446
485
  *
447
- * @param {number} dataIndex The data index.
486
+ * @param {string} dataId The data id.
448
487
  */
449
- toggleOverlayListeners(dataIndex: number): void;
488
+ toggleOverlayListeners(dataId: string): void;
450
489
  #private;
451
490
  }
452
491
 
492
+ /**
493
+ * Application options.
494
+ */
495
+ export declare class AppOptions {
496
+ /**
497
+ * @param {Object<string, ViewConfig[]>} [dataViewConfigs] Optional dataId
498
+ * indexed object containing the data view configurations.
499
+ */
500
+ constructor(dataViewConfigs?: {
501
+ [x: string]: ViewConfig[];
502
+ });
503
+ /**
504
+ * DataId indexed object containing the data view configurations.
505
+ *
506
+ * @type {Object<string, ViewConfig[]>|undefined}
507
+ */
508
+ dataViewConfigs: {
509
+ [x: string]: ViewConfig[];
510
+ } | undefined;
511
+ /**
512
+ * Tool name indexed object containing individual tool configurations.
513
+ *
514
+ * @type {Object<string, ToolConfig>|undefined}
515
+ */
516
+ tools: {
517
+ [x: string]: ToolConfig;
518
+ } | undefined;
519
+ /**
520
+ * Optional array of layerGroup binder names.
521
+ *
522
+ * @type {string[]|undefined}
523
+ */
524
+ binders: string[] | undefined;
525
+ /**
526
+ * Optional boolean flag to trigger the first data render
527
+ * after the first loaded data or not. Defaults to true;
528
+ *
529
+ * @type {boolean|undefined}
530
+ */
531
+ viewOnFirstLoadItem: boolean | undefined;
532
+ /**
533
+ * Optional default chraracter set string used for DICOM parsing if
534
+ * not passed in DICOM file.
535
+ * Valid values: https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
536
+ *
537
+ * @type {string|undefined}
538
+ */
539
+ defaultCharacterSet: string | undefined;
540
+ /**
541
+ * Optional overlay config.
542
+ *
543
+ * @type {object|undefined}
544
+ */
545
+ overlayConfig: object | undefined;
546
+ }
547
+
453
548
  /**
454
549
  * Build a multipart message.
455
550
  * See: https://en.wikipedia.org/wiki/MIME#Multipart_messages
@@ -462,6 +557,37 @@ export declare class App {
462
557
  */
463
558
  export declare function buildMultipart(parts: any[], boundary: string): Uint8Array;
464
559
 
560
+ /**
561
+ * Colour map: red, green and blue components
562
+ * to associate with intensity values.
563
+ */
564
+ export declare class ColourMap {
565
+ /**
566
+ * @param {number[]} red Red component.
567
+ * @param {number[]} green Green component.
568
+ * @param {number[]} blue Blue component.
569
+ */
570
+ constructor(red: number[], green: number[], blue: number[]);
571
+ /**
572
+ * Red component: 256 values in the [0, 255] range.
573
+ *
574
+ * @type {number[]}
575
+ */
576
+ red: number[];
577
+ /**
578
+ * Green component: 256 values in the [0, 255] range.
579
+ *
580
+ * @type {number[]}
581
+ */
582
+ green: number[];
583
+ /**
584
+ * Blue component: 256 values in the [0, 255] range.
585
+ *
586
+ * @type {number[]}
587
+ */
588
+ blue: number[];
589
+ }
590
+
465
591
  /**
466
592
  * Create an Image from DICOM elements.
467
593
  *
@@ -497,6 +623,68 @@ export declare namespace customUI {
497
623
  export function openRoiDialog(data: any, callback: Function): void;
498
624
  }
499
625
 
626
+ /**
627
+ * DICOM data element.
628
+ */
629
+ export declare class DataElement {
630
+ /**
631
+ * @param {string} vr The element VR (Value Representation).
632
+ */
633
+ constructor(vr: string);
634
+ /**
635
+ * The element Value Representation.
636
+ *
637
+ * @type {string}
638
+ */
639
+ vr: string;
640
+ /**
641
+ * The element value.
642
+ *
643
+ * @type {Array}
644
+ */
645
+ value: any[];
646
+ /**
647
+ * The element dicom tag.
648
+ *
649
+ * @type {Tag}
650
+ */
651
+ tag: Tag;
652
+ /**
653
+ * The element Value Length.
654
+ *
655
+ * @type {number}
656
+ */
657
+ vl: number;
658
+ /**
659
+ * Flag to know if defined or undefined sequence length.
660
+ *
661
+ * @type {boolean}
662
+ */
663
+ undefinedLength: boolean;
664
+ /**
665
+ * The element start offset.
666
+ *
667
+ * @type {number}
668
+ */
669
+ startOffset: number;
670
+ /**
671
+ * The element end offset.
672
+ *
673
+ * @type {number}
674
+ */
675
+ endOffset: number;
676
+ /**
677
+ * The sequence items.
678
+ *
679
+ * @type {Array}
680
+ */
681
+ items: any[];
682
+ }
683
+
684
+ declare type DataElements = {
685
+ [x: string]: DataElement;
686
+ };
687
+
500
688
  /**
501
689
  * Decoder scripts to be passed to web workers for image decoding.
502
690
  */
@@ -521,7 +709,13 @@ export declare const defaultPresets: {
521
709
  };
522
710
  };
523
711
 
524
- export declare const defaults: {};
712
+ export declare namespace defaults {
713
+ let labelText: {
714
+ [x: string]: {
715
+ [x: string]: string;
716
+ };
717
+ };
718
+ }
525
719
 
526
720
  /**
527
721
  * DicomParser class.
@@ -569,14 +763,16 @@ export declare class DicomParser {
569
763
  */
570
764
  setDecoderCharacterSet(characterSet: string): void;
571
765
  /**
572
- * Get the raw DICOM data elements.
766
+ * Get the DICOM data elements.
573
767
  *
574
- * @returns {object} The raw DICOM elements.
768
+ * @returns {Object<string, DataElement>} The data elements.
575
769
  */
576
- getDicomElements(): object;
770
+ getDicomElements(): {
771
+ [x: string]: DataElement;
772
+ };
577
773
  /**
578
774
  * Parse the complete DICOM file (given as input to the class).
579
- * Fills in the member object 'dicomElements'.
775
+ * Fills in the member object 'dataElements'.
580
776
  *
581
777
  * @param {ArrayBuffer} buffer The input array buffer.
582
778
  */
@@ -587,16 +783,33 @@ export declare class DicomParser {
587
783
  /**
588
784
  * DICOM writer.
589
785
  *
590
- * Example usage:
591
- * const parser = new DicomParser();
592
- * parser.parse(this.response);
593
- *
594
- * const writer = new DicomWriter(parser.getDicomElements());
595
- * const blob = new Blob([writer.getBuffer()], {type: 'application/dicom'});
596
- *
597
- * const element = document.getElementById("download");
598
- * element.href = URL.createObjectURL(blob);
599
- * element.download = "anonym.dcm";
786
+ * @example
787
+ * // add link to html
788
+ * const link = document.createElement("a");
789
+ * link.appendChild(document.createTextNode("download"));
790
+ * const div = document.getElementById("dwv");
791
+ * div.appendChild(link);
792
+ * // XMLHttpRequest onload callback
793
+ * const onload = function (event) {
794
+ * const parser = new dwv.DicomParser();
795
+ * parser.parse(event.target.response);
796
+ * // create writer
797
+ * const writer = new dwv.DicomWriter();
798
+ * // get buffer using default rules
799
+ * const dicomBuffer = writer.getBuffer(parser.getDicomElements());
800
+ * // create blob
801
+ * const blob = new Blob([dicomBuffer], {type: 'application/dicom'});
802
+ * // add blob to download link
803
+ * link.href = URL.createObjectURL(blob);
804
+ * link.download = "anonym.dcm";
805
+ * };
806
+ * // DICOM file request
807
+ * const request = new XMLHttpRequest();
808
+ * const url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';
809
+ * request.open('GET', url);
810
+ * request.responseType = 'arraybuffer';
811
+ * request.onload = onload;
812
+ * request.send();
600
813
  */
601
814
  export declare class DicomWriter {
602
815
  /**
@@ -607,10 +820,16 @@ export declare class DicomWriter {
607
820
  setUseUnVrForPrivateSq(flag: boolean): void;
608
821
  /**
609
822
  * Set the writing rules.
823
+ * List of writer rules indexed by either `default`, tagName or groupName.
824
+ * Each DICOM element will be checked to see if a rule is applicable.
825
+ * First checked by tagName and then by groupName,
826
+ * if nothing is found the default rule is applied.
610
827
  *
611
- * @param {object} rules The input rules.
828
+ * @param {Object<string, WriterRule>} rules The input rules.
612
829
  */
613
- setRules(rules: object): void;
830
+ setRules(rules: {
831
+ [x: string]: WriterRule;
832
+ }): void;
614
833
  /**
615
834
  * Use a TextEncoder instead of the default text decoder.
616
835
  */
@@ -619,16 +838,153 @@ export declare class DicomWriter {
619
838
  * Use default anonymisation rules.
620
839
  */
621
840
  useDefaultAnonymisationRules(): void;
841
+ /**
842
+ * Get the element to write according to the class rules.
843
+ * Priority order: tagName, groupName, default.
844
+ *
845
+ * @param {DataElement} element The element to check
846
+ * @returns {DataElement|null} The element to write, can be null.
847
+ */
848
+ getElementToWrite(element: DataElement): DataElement | null;
622
849
  /**
623
850
  * Get the ArrayBuffer corresponding to input DICOM elements.
624
851
  *
625
- * @param {Array} dicomElements The wrapped elements to write.
852
+ * @param {Object<string, DataElement>} dataElements The elements to write.
626
853
  * @returns {ArrayBuffer} The elements as a buffer.
627
854
  */
628
- getBuffer(dicomElements: any[]): ArrayBuffer;
855
+ getBuffer(dataElements: {
856
+ [x: string]: DataElement;
857
+ }): ArrayBuffer;
858
+ #private;
859
+ }
860
+
861
+ /**
862
+ * Draw controller.
863
+ */
864
+ export declare class DrawController {
865
+ /**
866
+ * @param {DrawLayer} drawLayer The draw layer.
867
+ */
868
+ constructor(drawLayer: DrawLayer);
869
+ /**
870
+ * Get the current position group.
871
+ *
872
+ * @returns {Konva.Group|undefined} The Konva.Group.
873
+ */
874
+ getCurrentPosGroup(): Konva.Group | undefined;
875
+ /**
876
+ * Reset: clear the layers array.
877
+ */
878
+ reset(): void;
879
+ /**
880
+ * Get a Konva group using its id.
881
+ *
882
+ * @param {string} id The group id.
883
+ * @returns {object|undefined} The Konva group.
884
+ */
885
+ getGroup(id: string): object | undefined;
886
+ /**
887
+ * Activate the current draw layer.
888
+ *
889
+ * @param {Index} index The current position.
890
+ * @param {number} scrollIndex The scroll index.
891
+ */
892
+ activateDrawLayer(index: Index, scrollIndex: number): void;
893
+ /**
894
+ * Get a list of drawing display details.
895
+ *
896
+ * @returns {DrawDetails[]} A list of draw details.
897
+ */
898
+ getDrawDisplayDetails(): DrawDetails[];
899
+ /**
900
+ * Get a list of drawing store details. Used in state.
901
+ *
902
+ * @returns {object} A list of draw details including id, text, quant...
903
+ * TODO Unify with getDrawDisplayDetails?
904
+ */
905
+ getDrawStoreDetails(): object;
906
+ /**
907
+ * Set the drawings on the current stage.
908
+ *
909
+ * @param {Array} drawings An array of drawings.
910
+ * @param {DrawDetails[]} drawingsDetails An array of drawings details.
911
+ * @param {object} cmdCallback The DrawCommand callback.
912
+ * @param {object} exeCallback The callback to call once the
913
+ * DrawCommand has been executed.
914
+ */
915
+ setDrawings(drawings: any[], drawingsDetails: DrawDetails[], cmdCallback: object, exeCallback: object): void;
916
+ /**
917
+ * Update a drawing from its details.
918
+ *
919
+ * @param {DrawDetails} drawDetails Details of the drawing to update.
920
+ */
921
+ updateDraw(drawDetails: DrawDetails): void;
922
+ /**
923
+ * Delete a Draw from the stage.
924
+ *
925
+ * @param {Konva.Group} group The group to delete.
926
+ * @param {object} cmdCallback The DeleteCommand callback.
927
+ * @param {object} exeCallback The callback to call once the
928
+ * DeleteCommand has been executed.
929
+ */
930
+ deleteDrawGroup(group: Konva.Group, cmdCallback: object, exeCallback: object): void;
931
+ /**
932
+ * Delete a Draw from the stage.
933
+ *
934
+ * @param {string} id The id of the group to delete.
935
+ * @param {Function} cmdCallback The DeleteCommand callback.
936
+ * @param {Function} exeCallback The callback to call once the
937
+ * DeleteCommand has been executed.
938
+ * @returns {boolean} False if the group cannot be found.
939
+ */
940
+ deleteDraw(id: string, cmdCallback: Function, exeCallback: Function): boolean;
941
+ /**
942
+ * Delete all Draws from the stage.
943
+ *
944
+ * @param {Function} cmdCallback The DeleteCommand callback.
945
+ * @param {Function} exeCallback The callback to call once the
946
+ * DeleteCommand has been executed.
947
+ */
948
+ deleteDraws(cmdCallback: Function, exeCallback: Function): void;
629
949
  #private;
630
950
  }
631
951
 
952
+ /**
953
+ * Draw details.
954
+ */
955
+ export declare class DrawDetails {
956
+ /**
957
+ * The draw ID.
958
+ *
959
+ * @type {number}
960
+ */
961
+ id: number;
962
+ /**
963
+ * The draw position: an Index converted to string.
964
+ *
965
+ * @type {string}
966
+ */
967
+ position: string;
968
+ /**
969
+ * The draw type.
970
+ *
971
+ * @type {string}
972
+ */
973
+ type: string;
974
+ /**
975
+ * The draw color: for example 'green', '#00ff00' or 'rgb(0,255,0)'.
976
+ *
977
+ * @type {string}
978
+ */
979
+ color: string;
980
+ /**
981
+ * The draw meta.
982
+ *
983
+ * @type {DrawMeta}
984
+ */
985
+ meta: DrawMeta;
986
+ }
987
+
632
988
  /**
633
989
  * Draw layer.
634
990
  */
@@ -639,23 +995,23 @@ export declare class DrawLayer {
639
995
  */
640
996
  constructor(containerDiv: HTMLDivElement);
641
997
  /**
642
- * Get the associated data index.
998
+ * Get the associated data id.
643
999
  *
644
- * @returns {number} The index.
1000
+ * @returns {string} The id.
645
1001
  */
646
- getDataIndex(): number;
1002
+ getDataId(): string;
647
1003
  /**
648
1004
  * Get the Konva stage.
649
1005
  *
650
- * @returns {object} The stage.
1006
+ * @returns {Konva.Stage} The stage.
651
1007
  */
652
- getKonvaStage(): object;
1008
+ getKonvaStage(): Konva.Stage;
653
1009
  /**
654
1010
  * Get the Konva layer.
655
1011
  *
656
- * @returns {object} The layer.
1012
+ * @returns {Konva.Layer} The layer.
657
1013
  */
658
- getKonvaLayer(): object;
1014
+ getKonvaLayer(): Konva.Layer;
659
1015
  /**
660
1016
  * Get the draw controller.
661
1017
  *
@@ -700,13 +1056,17 @@ export declare class DrawLayer {
700
1056
  * Add a flip offset along the layer Y axis.
701
1057
  */
702
1058
  addFlipOffsetY(): void;
1059
+ /**
1060
+ * Flip the scale along the layer Z axis.
1061
+ */
1062
+ flipScaleZ(): void;
703
1063
  /**
704
1064
  * Set the layer scale.
705
1065
  *
706
1066
  * @param {object} newScale The scale as {x,y}.
707
- * @param {Point3D} center The scale center.
1067
+ * @param {Point3D} [center] The scale center.
708
1068
  */
709
- setScale(newScale: object, center: Point3D): void;
1069
+ setScale(newScale: object, center?: Point3D): void;
710
1070
  /**
711
1071
  * Set the layer offset.
712
1072
  *
@@ -743,9 +1103,9 @@ export declare class DrawLayer {
743
1103
  *
744
1104
  * @param {object} size The image size as {x,y}.
745
1105
  * @param {object} spacing The image spacing as {x,y}.
746
- * @param {number} index The associated data index.
1106
+ * @param {string} dataId The associated data id.
747
1107
  */
748
- initialise(size: object, spacing: object, index: number): void;
1108
+ initialise(size: object, spacing: object, dataId: string): void;
749
1109
  /**
750
1110
  * Fit the layer to its parent container.
751
1111
  *
@@ -767,7 +1127,7 @@ export declare class DrawLayer {
767
1127
  * @param {string} id The id of the group.
768
1128
  * @returns {boolean} False if the group cannot be found.
769
1129
  */
770
- toogleGroupVisibility(id: string): boolean;
1130
+ toggleGroupVisibility(id: string): boolean;
771
1131
  /**
772
1132
  * Delete a Draw from the stage.
773
1133
  *
@@ -803,21 +1163,40 @@ export declare class DrawLayer {
803
1163
  * Add an event listener to this class.
804
1164
  *
805
1165
  * @param {string} type The event type.
806
- * @param {object} callback The method associated with the provided
1166
+ * @param {Function} callback The function associated with the provided
807
1167
  * event type, will be called with the fired event.
808
1168
  */
809
- addEventListener(type: string, callback: object): void;
1169
+ addEventListener(type: string, callback: Function): void;
810
1170
  /**
811
1171
  * Remove an event listener from this class.
812
1172
  *
813
1173
  * @param {string} type The event type.
814
- * @param {object} callback The method associated with the provided
1174
+ * @param {Function} callback The function associated with the provided
815
1175
  * event type.
816
1176
  */
817
- removeEventListener(type: string, callback: object): void;
1177
+ removeEventListener(type: string, callback: Function): void;
818
1178
  #private;
819
1179
  }
820
1180
 
1181
+ /**
1182
+ * Draw meta data.
1183
+ */
1184
+ export declare class DrawMeta {
1185
+ /**
1186
+ * Draw quantification.
1187
+ *
1188
+ * @type {object}
1189
+ */
1190
+ quantification: object;
1191
+ /**
1192
+ * Draw text expression. Can contain variables surrounded with '{}' that will
1193
+ * be extracted from the quantification object.
1194
+ *
1195
+ * @type {string}
1196
+ */
1197
+ textExpr: string;
1198
+ }
1199
+
821
1200
  /**
822
1201
  * 2D/3D Geometry class.
823
1202
  */
@@ -870,9 +1249,9 @@ export declare class Geometry {
870
1249
  /**
871
1250
  * Get the object origins.
872
1251
  *
873
- * @returns {Array} The object origins.
1252
+ * @returns {Point3D[]} The object origins.
874
1253
  */
875
- getOrigins(): any[];
1254
+ getOrigins(): Point3D[];
876
1255
  /**
877
1256
  * Check if a point is in the origin list.
878
1257
  *
@@ -965,10 +1344,10 @@ export declare class Geometry {
965
1344
  * Check that a index is within bounds.
966
1345
  *
967
1346
  * @param {Index} index The index to check.
968
- * @param {Array} [dirs] Optional list of directions to check.
1347
+ * @param {number[]} [dirs] Optional list of directions to check.
969
1348
  * @returns {boolean} True if the given coordinates are within bounds.
970
1349
  */
971
- isIndexInBounds(index: Index, dirs?: any[]): boolean;
1350
+ isIndexInBounds(index: Index, dirs?: number[]): boolean;
972
1351
  /**
973
1352
  * Convert an index into world coordinates.
974
1353
  *
@@ -1000,6 +1379,19 @@ export declare class Geometry {
1000
1379
  #private;
1001
1380
  }
1002
1381
 
1382
+ /**
1383
+ * Get the default DICOM seg tags as an object.
1384
+ *
1385
+ * @returns {object} The default tags.
1386
+ */
1387
+ export declare function getDefaultDicomSegJson(): object;
1388
+
1389
+ /**
1390
+ * List of DICOM data elements indexed via a 8 character string formed from
1391
+ * the group and element numbers.
1392
+ *
1393
+ * @typedef {Object<string, DataElement>} DataElements
1394
+ */
1003
1395
  /**
1004
1396
  * Get the version of the library.
1005
1397
  *
@@ -1008,15 +1400,40 @@ export declare class Geometry {
1008
1400
  export declare function getDwvVersion(): string;
1009
1401
 
1010
1402
  /**
1011
- * Get the DICOM elements from a DICOM json tags object.
1403
+ * Get the DICOM elements from a 'simple' DICOM json tags object.
1012
1404
  * The json is a simplified version of the oficial DICOM json with
1013
1405
  * tag names instead of keys and direct values (no value property) for
1014
- * simple tags.
1406
+ * simple tags. See synthetic test data (in tests/dicom) for examples.
1407
+ *
1408
+ * @param {Object<string, any>} jsonTags The DICOM
1409
+ * json tags object.
1410
+ * @returns {Object<string, DataElement>} The DICOM elements.
1411
+ */
1412
+ export declare function getElementsFromJSONTags(jsonTags: {
1413
+ [x: string]: any;
1414
+ }): {
1415
+ [x: string]: DataElement;
1416
+ };
1417
+
1418
+ /**
1419
+ * Get the indices that form a ellpise.
1420
+ *
1421
+ * @param {Index} center The ellipse center.
1422
+ * @param {Array} radius The 2 ellipse radiuses.
1423
+ * @param {Array} dir The 2 ellipse directions.
1424
+ * @returns {Array} The indices of the ellipse.
1425
+ */
1426
+ export declare function getEllipseIndices(center: Index, radius: any[], dir: any[]): any[];
1427
+
1428
+ /**
1429
+ * Get the layer details from a mouse event.
1015
1430
  *
1016
- * @param {object} jsonTags The DICOM json tags object.
1017
- * @returns {object} The DICOM elements.
1431
+ * @param {object} event The event to get the layer div id from. Expecting
1432
+ * an event origininating from a canvas inside a layer HTML div
1433
+ * with the 'layer' class and id generated with `getLayerDivId`.
1434
+ * @returns {object} The layer details as {groupDivId, layerId}.
1018
1435
  */
1019
- export declare function getElementsFromJSONTags(jsonTags: object): object;
1436
+ export declare function getLayerDetailsFromEvent(event: object): object;
1020
1437
 
1021
1438
  /**
1022
1439
  * Get the name of an image orientation patient.
@@ -1074,6 +1491,16 @@ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation
1074
1491
  */
1075
1492
  export declare function getUID(tagName: string): string;
1076
1493
 
1494
+ /**
1495
+ * Check that an input buffer includes the DICOM prefix 'DICM'
1496
+ * after the 128 bytes preamble.
1497
+ * Ref: [DICOM File Meta]{@link https://dicom.nema.org/dicom/2013/output/chtml/part10/chapter_7.html#sect_7.1}
1498
+ *
1499
+ * @param {ArrayBuffer} buffer The buffer to check.
1500
+ * @returns {boolean} True if the buffer includes the prefix.
1501
+ */
1502
+ export declare function hasDicomPrefix(buffer: ArrayBuffer): boolean;
1503
+
1077
1504
  export declare namespace i18n {
1078
1505
  /**
1079
1506
  * Get the translated text.
@@ -1318,18 +1745,18 @@ declare class Image_2 {
1318
1745
  * Add an event listener to this class.
1319
1746
  *
1320
1747
  * @param {string} type The event type.
1321
- * @param {object} callback The method associated with the provided
1748
+ * @param {Function} callback The function associated with the provided
1322
1749
  * event type, will be called with the fired event.
1323
1750
  */
1324
- addEventListener(type: string, callback: object): void;
1751
+ addEventListener(type: string, callback: Function): void;
1325
1752
  /**
1326
1753
  * Remove an event listener from this class.
1327
1754
  *
1328
1755
  * @param {string} type The event type.
1329
- * @param {object} callback The method associated with the provided
1756
+ * @param {Function} callback The function associated with the provided
1330
1757
  * event type.
1331
1758
  */
1332
- removeEventListener(type: string, callback: object): void;
1759
+ removeEventListener(type: string, callback: Function): void;
1333
1760
  /**
1334
1761
  * Set the inner buffer values at given offsets.
1335
1762
  *
@@ -1471,9 +1898,9 @@ export { Image_2 as Image }
1471
1898
  */
1472
1899
  export declare class Index {
1473
1900
  /**
1474
- * @param {Array} values The index values.
1901
+ * @param {number[]} values The index values.
1475
1902
  */
1476
- constructor(values: any[]);
1903
+ constructor(values: number[]);
1477
1904
  /**
1478
1905
  * Get the index value at the given array index.
1479
1906
  *
@@ -1496,9 +1923,9 @@ export declare class Index {
1496
1923
  /**
1497
1924
  * Get the values of this index.
1498
1925
  *
1499
- * @returns {Array} The array of values.
1926
+ * @returns {number[]} The array of values.
1500
1927
  */
1501
- getValues(): any[];
1928
+ getValues(): number[];
1502
1929
  /**
1503
1930
  * Check if the input index can be compared to this one.
1504
1931
  *
@@ -1517,9 +1944,9 @@ export declare class Index {
1517
1944
  * Compare indices and return different dimensions.
1518
1945
  *
1519
1946
  * @param {Index} rhs The index to compare to.
1520
- * @returns {Array} The list of different dimensions.
1947
+ * @returns {number[]} The list of different dimensions.
1521
1948
  */
1522
- compare(rhs: Index): any[];
1949
+ compare(rhs: Index): number[];
1523
1950
  /**
1524
1951
  * Add another index to this one.
1525
1952
  *
@@ -1538,13 +1965,22 @@ export declare class Index {
1538
1965
  /**
1539
1966
  * Get a string id from the index values in the form of: '#0-1_#1-2'.
1540
1967
  *
1541
- * @param {Array} [dims] Optional list of dimensions to use.
1968
+ * @param {number[]} [dims] Optional list of dimensions to use.
1542
1969
  * @returns {string} The string id.
1543
1970
  */
1544
- toStringId(dims?: any[]): string;
1971
+ toStringId(dims?: number[]): string;
1545
1972
  #private;
1546
1973
  }
1547
1974
 
1975
+ /**
1976
+ * CIE LAB value (L: [0, 100], a: [-128, 127], b: [-128, 127]) to
1977
+ * unsigned int CIE LAB ([0, 65535]).
1978
+ *
1979
+ * @param {object} triplet CIE XYZ triplet as {x,y,z} with CIE LAB range.
1980
+ * @returns {object} CIE LAB triplet as {l,a,b} with unsigned range.
1981
+ */
1982
+ export declare function labToUintLab(triplet: object): object;
1983
+
1548
1984
  /**
1549
1985
  * Layer group.
1550
1986
  *
@@ -1566,18 +2002,6 @@ export declare class LayerGroup {
1566
2002
  * @param {HTMLElement} containerDiv The associated HTML div.
1567
2003
  */
1568
2004
  constructor(containerDiv: HTMLElement);
1569
- /**
1570
- * Get the target orientation.
1571
- *
1572
- * @returns {Matrix33} The orientation matrix.
1573
- */
1574
- getTargetOrientation(): Matrix33;
1575
- /**
1576
- * Set the target orientation.
1577
- *
1578
- * @param {Matrix33} orientation The orientation matrix.
1579
- */
1580
- setTargetOrientation(orientation: Matrix33): void;
1581
2005
  /**
1582
2006
  * Get the showCrosshair flag.
1583
2007
  *
@@ -1590,6 +2014,12 @@ export declare class LayerGroup {
1590
2014
  * @param {boolean} flag True to display the crosshair.
1591
2015
  */
1592
2016
  setShowCrosshair(flag: boolean): void;
2017
+ /**
2018
+ * Set the imageSmoothing flag value.
2019
+ *
2020
+ * @param {boolean} flag True to enable smoothing.
2021
+ */
2022
+ setImageSmoothing(flag: boolean): void;
1593
2023
  /**
1594
2024
  * Get the Id of the container div.
1595
2025
  *
@@ -1626,19 +2056,25 @@ export declare class LayerGroup {
1626
2056
  * @returns {number} The number of layers.
1627
2057
  */
1628
2058
  getNumberOfLayers(): number;
2059
+ /**
2060
+ * Get the number of view layers handled by this class.
2061
+ *
2062
+ * @returns {number} The number of layers.
2063
+ */
2064
+ getNumberOfViewLayers(): number;
1629
2065
  /**
1630
2066
  * Get the active image layer.
1631
2067
  *
1632
- * @returns {ViewLayer} The layer.
2068
+ * @returns {ViewLayer|undefined} The layer.
1633
2069
  */
1634
- getActiveViewLayer(): ViewLayer;
2070
+ getActiveViewLayer(): ViewLayer | undefined;
1635
2071
  /**
1636
- * Get the view layers associated to a data index.
2072
+ * Get the view layers associated to a data id.
1637
2073
  *
1638
- * @param {number} index The data index.
2074
+ * @param {string} dataId The data id.
1639
2075
  * @returns {ViewLayer[]} The layers.
1640
2076
  */
1641
- getViewLayersByDataIndex(index: number): ViewLayer[];
2077
+ getViewLayersByDataId(dataId: string): ViewLayer[];
1642
2078
  /**
1643
2079
  * Search view layers for equal imae meta data.
1644
2080
  *
@@ -1655,16 +2091,16 @@ export declare class LayerGroup {
1655
2091
  /**
1656
2092
  * Get the active draw layer.
1657
2093
  *
1658
- * @returns {DrawLayer} The layer.
2094
+ * @returns {DrawLayer|undefined} The layer.
1659
2095
  */
1660
- getActiveDrawLayer(): DrawLayer;
2096
+ getActiveDrawLayer(): DrawLayer | undefined;
1661
2097
  /**
1662
- * Get the draw layers associated to a data index.
2098
+ * Get the draw layers associated to a data id.
1663
2099
  *
1664
- * @param {number} index The data index.
2100
+ * @param {string} dataId The data id.
1665
2101
  * @returns {DrawLayer[]} The layers.
1666
2102
  */
1667
- getDrawLayersByDataIndex(index: number): DrawLayer[];
2103
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
1668
2104
  /**
1669
2105
  * Set the active view layer.
1670
2106
  *
@@ -1672,11 +2108,11 @@ export declare class LayerGroup {
1672
2108
  */
1673
2109
  setActiveViewLayer(index: number): void;
1674
2110
  /**
1675
- * Set the active view layer with a data index.
2111
+ * Set the active view layer with a data id.
1676
2112
  *
1677
- * @param {number} index The data index.
2113
+ * @param {string} dataId The data id.
1678
2114
  */
1679
- setActiveViewLayerByDataIndex(index: number): void;
2115
+ setActiveViewLayerByDataId(dataId: string): void;
1680
2116
  /**
1681
2117
  * Set the active draw layer.
1682
2118
  *
@@ -1684,11 +2120,11 @@ export declare class LayerGroup {
1684
2120
  */
1685
2121
  setActiveDrawLayer(index: number): void;
1686
2122
  /**
1687
- * Set the active draw layer with a data index.
2123
+ * Set the active draw layer with a data id.
1688
2124
  *
1689
- * @param {number} index The data index.
2125
+ * @param {string} dataId The data id.
1690
2126
  */
1691
- setActiveDrawLayerByDataIndex(index: number): void;
2127
+ setActiveDrawLayerByDataId(dataId: string): void;
1692
2128
  /**
1693
2129
  * Add a view layer.
1694
2130
  *
@@ -1705,10 +2141,20 @@ export declare class LayerGroup {
1705
2141
  * Empty the layer list.
1706
2142
  */
1707
2143
  empty(): void;
2144
+ /**
2145
+ * Remove a layer from this layer group.
2146
+ * Warning: if current active layer, the index will
2147
+ * be set to `undefined`. Call one of the setActive
2148
+ * methods to define the active index.
2149
+ *
2150
+ * @param {ViewLayer | DrawLayer} layer The layer to remove.
2151
+ */
2152
+ removeLayer(layer: ViewLayer | DrawLayer): void;
1708
2153
  /**
1709
2154
  * Update layers (but not the active view layer) to a position change.
1710
2155
  *
1711
2156
  * @param {object} event The position change event.
2157
+ * @function
1712
2158
  */
1713
2159
  updateLayersToPositionChange: (event: object) => void;
1714
2160
  /**
@@ -1779,18 +2225,18 @@ export declare class LayerGroup {
1779
2225
  * Add an event listener to this class.
1780
2226
  *
1781
2227
  * @param {string} type The event type.
1782
- * @param {object} callback The method associated with the provided
2228
+ * @param {Function} callback The function associated with the provided
1783
2229
  * event type, will be called with the fired event.
1784
2230
  */
1785
- addEventListener(type: string, callback: object): void;
2231
+ addEventListener(type: string, callback: Function): void;
1786
2232
  /**
1787
2233
  * Remove an event listener from this class.
1788
2234
  *
1789
2235
  * @param {string} type The event type.
1790
- * @param {object} callback The method associated with the provided
2236
+ * @param {Function} callback The function associated with the provided
1791
2237
  * event type.
1792
2238
  */
1793
- removeEventListener(type: string, callback: object): void;
2239
+ removeEventListener(type: string, callback: Function): void;
1794
2240
  #private;
1795
2241
  }
1796
2242
 
@@ -1813,32 +2259,45 @@ export declare namespace logger {
1813
2259
  /**
1814
2260
  * List of available lookup tables (lut).
1815
2261
  *
1816
- * @type {Object<string, {red: number[], green: number[], blue: number[]}>}
2262
+ * @type {Object<string, ColourMap>}
1817
2263
  */
1818
- export declare const lut: {
1819
- [x: string]: {
1820
- red: number[];
1821
- green: number[];
1822
- blue: number[];
1823
- };
2264
+ export declare const luts: {
2265
+ [x: string]: ColourMap;
1824
2266
  };
1825
2267
 
2268
+ /**
2269
+ * Mask {@link Image} factory.
2270
+ */
2271
+ export declare class MaskFactory {
2272
+ checkElements(_dicomElements: any): void;
2273
+ /**
2274
+ * Get an {@link Image} object from the read DICOM file.
2275
+ *
2276
+ * @param {DataElements} dataElements The DICOM tags.
2277
+ * @param {Uint8Array | Int8Array |
2278
+ * Uint16Array | Int16Array |
2279
+ * Uint32Array | Int32Array} pixelBuffer The pixel buffer.
2280
+ * @returns {Image} A new Image.
2281
+ */
2282
+ create(dataElements: DataElements, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array): Image_2;
2283
+ }
2284
+
1826
2285
  /**
1827
2286
  * Immutable 3x3 Matrix.
1828
2287
  */
1829
2288
  export declare class Matrix33 {
1830
2289
  /**
1831
- * @param {Array} values row-major ordered 9 values.
2290
+ * @param {number[]} values row-major ordered 9 values.
1832
2291
  */
1833
- constructor(values: any[]);
2292
+ constructor(values: number[]);
1834
2293
  /**
1835
2294
  * Get a value of the matrix.
1836
2295
  *
1837
2296
  * @param {number} row The row at wich to get the value.
1838
2297
  * @param {number} col The column at wich to get the value.
1839
- * @returns {number} The value at the position.
2298
+ * @returns {number|undefined} The value at the position.
1840
2299
  */
1841
- get(row: number, col: number): number;
2300
+ get(row: number, col: number): number | undefined;
1842
2301
  /**
1843
2302
  * Get the inverse of this matrix.
1844
2303
  *
@@ -1877,10 +2336,10 @@ export declare class Matrix33 {
1877
2336
  /**
1878
2337
  * Multiply this matrix by a 3D array.
1879
2338
  *
1880
- * @param {Array} array3D The input 3D array.
1881
- * @returns {Array} The result 3D array.
2339
+ * @param {number[]} array3D The input 3D array.
2340
+ * @returns {number[]} The result 3D array.
1882
2341
  */
1883
- multiplyArray3D(array3D: any[]): any[];
2342
+ multiplyArray3D(array3D: number[]): number[];
1884
2343
  /**
1885
2344
  * Multiply this matrix by a 3D vector.
1886
2345
  *
@@ -1937,10 +2396,10 @@ export declare class Matrix33 {
1937
2396
  export declare class OverlayData {
1938
2397
  /**
1939
2398
  * @param {App} app The associated application.
1940
- * @param {number} dataId The associated data ID.
2399
+ * @param {string} dataId The associated data id.
1941
2400
  * @param {object} configs The overlay config.
1942
2401
  */
1943
- constructor(app: App, dataId: number, configs: object);
2402
+ constructor(app: App, dataId: string, configs: object);
1944
2403
  /**
1945
2404
  * Reset the data.
1946
2405
  */
@@ -1991,9 +2450,9 @@ export declare class OverlayData {
1991
2450
  */
1992
2451
  export declare class Point {
1993
2452
  /**
1994
- * @param {Array} values The point values.
2453
+ * @param {number[]} values The point values.
1995
2454
  */
1996
- constructor(values: any[]);
2455
+ constructor(values: number[]);
1997
2456
  /**
1998
2457
  * Get the index value at the given array index.
1999
2458
  *
@@ -2016,9 +2475,9 @@ export declare class Point {
2016
2475
  /**
2017
2476
  * Get the values of this index.
2018
2477
  *
2019
- * @returns {Array} The array of values.
2478
+ * @returns {number[]} The array of values.
2020
2479
  */
2021
- getValues(): any[];
2480
+ getValues(): number[];
2022
2481
  /**
2023
2482
  * Check if the input point can be compared to this one.
2024
2483
  *
@@ -2037,9 +2496,9 @@ export declare class Point {
2037
2496
  * Compare points and return different dimensions.
2038
2497
  *
2039
2498
  * @param {Point} rhs The point to compare to.
2040
- * @returns {Array} The list of different dimensions.
2499
+ * @returns {number[]} The list of different dimensions.
2041
2500
  */
2042
- compare(rhs: Point): any[];
2501
+ compare(rhs: Point): number[];
2043
2502
  /**
2044
2503
  * Get the 3D part of this point.
2045
2504
  *
@@ -2432,6 +2891,14 @@ export declare class Spacing {
2432
2891
  #private;
2433
2892
  }
2434
2893
 
2894
+ /**
2895
+ * Convert sRGB to CIE LAB (standard illuminant D65).
2896
+ *
2897
+ * @param {object} triplet sRGB triplet as {r,g,b}.
2898
+ * @returns {object} CIE LAB triplet as {l,a,b}.
2899
+ */
2900
+ export declare function srgbToCielab(triplet: object): object;
2901
+
2435
2902
  /**
2436
2903
  * Immutable tag.
2437
2904
  */
@@ -2524,12 +2991,95 @@ export declare class TagValueExtractor {
2524
2991
  /**
2525
2992
  * Get the time.
2526
2993
  *
2527
- * @param {object} _elements The DICOM elements.
2994
+ * @param {Object<string, DataElement>} _elements The DICOM elements.
2528
2995
  * @returns {number|undefined} The time value if available.
2529
2996
  */
2530
- getTime(_elements: object): number | undefined;
2997
+ getTime(_elements: {
2998
+ [x: string]: DataElement;
2999
+ }): number | undefined;
2531
3000
  }
2532
3001
 
3002
+ /**
3003
+ * Toolbox controller.
3004
+ */
3005
+ export declare class ToolboxController {
3006
+ /**
3007
+ * @param {object} toolList The list of tool objects.
3008
+ */
3009
+ constructor(toolList: object);
3010
+ /**
3011
+ * Initialise.
3012
+ */
3013
+ init(): void;
3014
+ /**
3015
+ * Get the tool list.
3016
+ *
3017
+ * @returns {Array} The list of tool objects.
3018
+ */
3019
+ getToolList(): any[];
3020
+ /**
3021
+ * Check if a tool is in the tool list.
3022
+ *
3023
+ * @param {string} name The name to check.
3024
+ * @returns {boolean} The tool list element for the given name.
3025
+ */
3026
+ hasTool(name: string): boolean;
3027
+ /**
3028
+ * Get the selected tool.
3029
+ *
3030
+ * @returns {object} The selected tool.
3031
+ */
3032
+ getSelectedTool(): object;
3033
+ /**
3034
+ * Get the selected tool event handler.
3035
+ *
3036
+ * @param {string} eventType The event type, for example
3037
+ * mousedown, touchstart...
3038
+ * @returns {Function} The event handler.
3039
+ */
3040
+ getSelectedToolEventHandler(eventType: string): Function;
3041
+ /**
3042
+ * Set the selected tool.
3043
+ *
3044
+ * @param {string} name The name of the tool.
3045
+ */
3046
+ setSelectedTool(name: string): void;
3047
+ /**
3048
+ * Set the selected tool live features.
3049
+ *
3050
+ * @param {object} list The list of features.
3051
+ */
3052
+ setToolFeatures(list: object): void;
3053
+ /**
3054
+ * Listen to layer interaction events.
3055
+ *
3056
+ * @param {LayerGroup} layerGroup The associated layer group.
3057
+ * @param {ViewLayer|DrawLayer} layer The layer to listen to.
3058
+ */
3059
+ bindLayerGroup(layerGroup: LayerGroup, layer: ViewLayer | DrawLayer): void;
3060
+ #private;
3061
+ }
3062
+
3063
+ /**
3064
+ * Tool configuration.
3065
+ */
3066
+ export declare class ToolConfig {
3067
+ /**
3068
+ * @param {string[]} [options] Optional tool options.
3069
+ */
3070
+ constructor(options?: string[]);
3071
+ /**
3072
+ * Optional tool options.
3073
+ * For Draw: list of shape names.
3074
+ * For Filter: list of filter names.
3075
+ *
3076
+ * @type {string[]|undefined}
3077
+ */
3078
+ options: string[] | undefined;
3079
+ }
3080
+
3081
+ export declare const toolList: {};
3082
+
2533
3083
  /**
2534
3084
  * Immutable 3D vector.
2535
3085
  */
@@ -2561,10 +3111,10 @@ export declare class Vector3D {
2561
3111
  /**
2562
3112
  * Check for Vector3D equality.
2563
3113
  *
2564
- * @param {object} rhs The other vector to compare to.
3114
+ * @param {Vector3D} rhs The other vector to compare to.
2565
3115
  * @returns {boolean} True if both vectors are equal.
2566
3116
  */
2567
- equals(rhs: object): boolean;
3117
+ equals(rhs: Vector3D): boolean;
2568
3118
  /**
2569
3119
  * Get a string representation of the Vector3D.
2570
3120
  *
@@ -2611,9 +3161,9 @@ export declare class Vector3D {
2611
3161
  * const dicomParser = new dwv.DicomParser();
2612
3162
  * dicomParser.parse(event.target.response);
2613
3163
  * // create the image object
2614
- * const image = createImage(dicomParser.getDicomElements());
3164
+ * const image = dwv.createImage(dicomParser.getDicomElements());
2615
3165
  * // create the view
2616
- * const view = createView(dicomParser.getDicomElements(), image);
3166
+ * const view = dwv.createView(dicomParser.getDicomElements(), image);
2617
3167
  * // setup canvas
2618
3168
  * const canvas = document.createElement('canvas');
2619
3169
  * canvas.width = 256;
@@ -2724,12 +3274,6 @@ export declare class View {
2724
3274
  * @param {object} presets The window presets.
2725
3275
  */
2726
3276
  setWindowPresets(presets: object): void;
2727
- /**
2728
- * Set the default colour map.
2729
- *
2730
- * @param {object} map The colour map.
2731
- */
2732
- setDefaultColourMap(map: object): void;
2733
3277
  /**
2734
3278
  * Add window presets to the existing ones.
2735
3279
  *
@@ -2745,16 +3289,16 @@ export declare class View {
2745
3289
  /**
2746
3290
  * Get the colour map of the image.
2747
3291
  *
2748
- * @returns {object} The colour map of the image.
3292
+ * @returns {string} The colour map name.
2749
3293
  */
2750
- getColourMap(): object;
3294
+ getColourMap(): string;
2751
3295
  /**
2752
3296
  * Set the colour map of the image.
2753
3297
  *
2754
- * @param {object} map The colour map of the image.
2755
- * @fires View#colourchange
3298
+ * @param {string} name The colour map name.
3299
+ * @fires View#colourmapchange
2756
3300
  */
2757
- setColourMap(map: object): void;
3301
+ setColourMap(name: string): void;
2758
3302
  /**
2759
3303
  * Get the current position.
2760
3304
  *
@@ -2775,12 +3319,12 @@ export declare class View {
2775
3319
  */
2776
3320
  canSetPosition(position: Point): boolean;
2777
3321
  /**
2778
- * Get the origin at a given position.
3322
+ * Get the first origin or at a given position.
2779
3323
  *
2780
- * @param {Point} position The position.
2781
- * @returns {Point} The origin.
3324
+ * @param {Point} [position] Optional position.
3325
+ * @returns {Point3D} The origin.
2782
3326
  */
2783
- getOrigin(position: Point): Point;
3327
+ getOrigin(position?: Point): Point3D;
2784
3328
  /**
2785
3329
  * Set the current position.
2786
3330
  *
@@ -2828,18 +3372,18 @@ export declare class View {
2828
3372
  * Add an event listener to this class.
2829
3373
  *
2830
3374
  * @param {string} type The event type.
2831
- * @param {object} callback The method associated with the provided
3375
+ * @param {Function} callback The function associated with the provided
2832
3376
  * event type, will be called with the fired event.
2833
3377
  */
2834
- addEventListener(type: string, callback: object): void;
3378
+ addEventListener(type: string, callback: Function): void;
2835
3379
  /**
2836
3380
  * Remove an event listener from this class.
2837
3381
  *
2838
3382
  * @param {string} type The event type.
2839
- * @param {object} callback The method associated with the provided
3383
+ * @param {Function} callback The function associated with the provided
2840
3384
  * event type.
2841
3385
  */
2842
- removeEventListener(type: string, callback: object): void;
3386
+ removeEventListener(type: string, callback: Function): void;
2843
3387
  /**
2844
3388
  * Get the image window/level that covers the full data range.
2845
3389
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -2899,15 +3443,51 @@ export declare class View {
2899
3443
  #private;
2900
3444
  }
2901
3445
 
3446
+ /**
3447
+ * View configuration: mainly defines the ´divId´
3448
+ * of the associated HTML div.
3449
+ */
3450
+ export declare class ViewConfig {
3451
+ /**
3452
+ * @param {string} divId The associated HTML div id.
3453
+ */
3454
+ constructor(divId: string);
3455
+ /**
3456
+ * Associated HTML div id.
3457
+ *
3458
+ * @type {string}
3459
+ */
3460
+ divId: string;
3461
+ /**
3462
+ * Optional orientation of the data; 'axial', 'coronal' or 'sagittal'.
3463
+ * If undefined, will use the data aquisition plane.
3464
+ *
3465
+ * @type {string|undefined}
3466
+ */
3467
+ orientation: string | undefined;
3468
+ /**
3469
+ * Optional view colour map name.
3470
+ *
3471
+ * @type {string|undefined}
3472
+ */
3473
+ colourMap: string | undefined;
3474
+ /**
3475
+ * Optional layer opacity; in [0, 1] range.
3476
+ *
3477
+ * @type {number|undefined}
3478
+ */
3479
+ opacity: number | undefined;
3480
+ }
3481
+
2902
3482
  /**
2903
3483
  * View controller.
2904
3484
  */
2905
3485
  export declare class ViewController {
2906
3486
  /**
2907
3487
  * @param {View} view The associated view.
2908
- * @param {number} index The associated data index.
3488
+ * @param {string} dataId The associated data id.
2909
3489
  */
2910
- constructor(view: View, index: number);
3490
+ constructor(view: View, dataId: string);
2911
3491
  /**
2912
3492
  * Get the plane helper.
2913
3493
  *
@@ -3010,12 +3590,12 @@ export declare class ViewController {
3010
3590
  */
3011
3591
  getCurrentScrollIndexValue(): object;
3012
3592
  /**
3013
- * Get the origin at a given posittion.
3593
+ * Get the first origin or at a given position.
3014
3594
  *
3015
- * @param {Point} position The input position.
3016
- * @returns {Point} The origin.
3595
+ * @param {Point} [position] Opitonal position.
3596
+ * @returns {Point3D} The origin.
3017
3597
  */
3018
- getOrigin(position: Point): Point;
3598
+ getOrigin(position?: Point): Point3D;
3019
3599
  /**
3020
3600
  * Get the current scroll position value.
3021
3601
  *
@@ -3034,13 +3614,13 @@ export declare class ViewController {
3034
3614
  * Set the associated image.
3035
3615
  *
3036
3616
  * @param {Image} img The associated image.
3037
- * @param {number} index The data index of the image.
3617
+ * @param {string} dataId The data id of the image.
3038
3618
  */
3039
- setImage(img: Image_2, index: number): void;
3619
+ setImage(img: Image_2, dataId: string): void;
3040
3620
  /**
3041
- * Get the current spacing.
3621
+ * Get the current view (2D) spacing.
3042
3622
  *
3043
- * @returns {Array} The 2D spacing.
3623
+ * @returns {Array} The spacing as a 2D array.
3044
3624
  */
3045
3625
  get2DSpacing(): any[];
3046
3626
  /**
@@ -3230,15 +3810,15 @@ export declare class ViewController {
3230
3810
  /**
3231
3811
  * Get the colour map.
3232
3812
  *
3233
- * @returns {object} The colour map.
3813
+ * @returns {string} The colour map name.
3234
3814
  */
3235
- getColourMap(): object;
3815
+ getColourMap(): string;
3236
3816
  /**
3237
3817
  * Set the colour map.
3238
3818
  *
3239
- * @param {object} colourMap The colour map.
3819
+ * @param {string} name The colour map name.
3240
3820
  */
3241
- setColourMap(colourMap: object): void;
3821
+ setColourMap(name: string): void;
3242
3822
  /**
3243
3823
  * @callback alphaFn@callback alphaFn
3244
3824
  * @param {object} value The pixel value.
@@ -3251,28 +3831,22 @@ export declare class ViewController {
3251
3831
  * @param {alphaFn} func The function.
3252
3832
  */
3253
3833
  setViewAlphaFunction(func: (value: object, index: object) => number): void;
3254
- /**
3255
- * Set the colour map from a name.
3256
- *
3257
- * @param {string} name The name of the colour map to set.
3258
- */
3259
- setColourMapFromName(name: string): void;
3260
3834
  /**
3261
3835
  * Add an event listener to this class.
3262
3836
  *
3263
3837
  * @param {string} type The event type.
3264
- * @param {object} callback The method associated with the provided
3838
+ * @param {Function} callback The function associated with the provided
3265
3839
  * event type, will be called with the fired event.
3266
3840
  */
3267
- addEventListener(type: string, callback: object): void;
3841
+ addEventListener(type: string, callback: Function): void;
3268
3842
  /**
3269
3843
  * Remove an event listener from this class.
3270
3844
  *
3271
3845
  * @param {string} type The event type.
3272
- * @param {object} callback The method associated with the provided
3846
+ * @param {Function} callback The function associated with the provided
3273
3847
  * event type.
3274
3848
  */
3275
- removeEventListener(type: string, callback: object): void;
3849
+ removeEventListener(type: string, callback: Function): void;
3276
3850
  #private;
3277
3851
  }
3278
3852
 
@@ -3286,24 +3860,24 @@ export declare class ViewLayer {
3286
3860
  */
3287
3861
  constructor(containerDiv: HTMLElement);
3288
3862
  /**
3289
- * Get the associated data index.
3863
+ * Get the associated data id.
3290
3864
  *
3291
- * @returns {number} The index.
3865
+ * @returns {string} The data id.
3292
3866
  */
3293
- getDataIndex(): number;
3867
+ getDataId(): string;
3294
3868
  /**
3295
- * Set the imageSmoothingEnabled flag value.
3869
+ * Set the imageSmoothing flag value.
3296
3870
  *
3297
3871
  * @param {boolean} flag True to enable smoothing.
3298
3872
  */
3299
- enableImageSmoothing(flag: boolean): void;
3873
+ setImageSmoothing(flag: boolean): void;
3300
3874
  /**
3301
3875
  * Set the associated view.
3302
3876
  *
3303
3877
  * @param {object} view The view.
3304
- * @param {number} index The associated data index.
3878
+ * @param {string} dataId The associated data id.
3305
3879
  */
3306
- setView(view: object, index: number): void;
3880
+ setView(view: object, dataId: string): void;
3307
3881
  /**
3308
3882
  * Get the view controller.
3309
3883
  *
@@ -3320,12 +3894,14 @@ export declare class ViewLayer {
3320
3894
  * Handle an image set event.
3321
3895
  *
3322
3896
  * @param {object} event The event.
3897
+ * @function
3323
3898
  */
3324
3899
  onimageset: (event: object) => void;
3325
3900
  /**
3326
3901
  * Handle an image change event.
3327
3902
  *
3328
3903
  * @param {object} event The event.
3904
+ * @function
3329
3905
  */
3330
3906
  onimagechange: (event: object) => void;
3331
3907
  /**
@@ -3366,13 +3942,17 @@ export declare class ViewLayer {
3366
3942
  * Add a flip offset along the layer Y axis.
3367
3943
  */
3368
3944
  addFlipOffsetY(): void;
3945
+ /**
3946
+ * Flip the scale along the layer Z axis.
3947
+ */
3948
+ flipScaleZ(): void;
3369
3949
  /**
3370
3950
  * Set the layer scale.
3371
3951
  *
3372
3952
  * @param {object} newScale The scale as {x,y}.
3373
- * @param {Point3D} center The scale center.
3953
+ * @param {Point3D} [center] The scale center.
3374
3954
  */
3375
- setScale(newScale: object, center: Point3D): void;
3955
+ setScale(newScale: object, center?: Point3D): void;
3376
3956
  /**
3377
3957
  * Set the base layer offset. Updates the layer offset.
3378
3958
  *
@@ -3416,7 +3996,8 @@ export declare class ViewLayer {
3416
3996
  *
3417
3997
  * @param {number} x The X position.
3418
3998
  * @param {number} y The Y position.
3419
- * @returns {object} The display position as {x,y}.
3999
+ * @returns {object} The display position as {x,y}, can be individually
4000
+ * undefined if out of bounds.
3420
4001
  */
3421
4002
  planePosToDisplay(x: number, y: number): object;
3422
4003
  /**
@@ -3475,18 +4056,18 @@ export declare class ViewLayer {
3475
4056
  * Add an event listener to this class.
3476
4057
  *
3477
4058
  * @param {string} type The event type.
3478
- * @param {object} callback The method associated with the provided
4059
+ * @param {Function} callback The function associated with the provided
3479
4060
  * event type, will be called with the fired event.
3480
4061
  */
3481
- addEventListener(type: string, callback: object): void;
4062
+ addEventListener(type: string, callback: Function): void;
3482
4063
  /**
3483
4064
  * Remove an event listener from this class.
3484
4065
  *
3485
4066
  * @param {string} type The event type.
3486
- * @param {object} callback The method associated with the provided
4067
+ * @param {Function} callback The function associated with the provided
3487
4068
  * event type.
3488
4069
  */
3489
- removeEventListener(type: string, callback: object): void;
4070
+ removeEventListener(type: string, callback: Function): void;
3490
4071
  /**
3491
4072
  * Set the current position.
3492
4073
  *
@@ -3600,4 +4181,26 @@ export declare class WindowLut {
3600
4181
  #private;
3601
4182
  }
3602
4183
 
4184
+ /**
4185
+ * Writer rule.
4186
+ */
4187
+ export declare class WriterRule {
4188
+ /**
4189
+ * @param {string} action The rule action.
4190
+ */
4191
+ constructor(action: string);
4192
+ /**
4193
+ * Rule action: `copy`, `remove`, `clear` or `replace`.
4194
+ *
4195
+ * @type {string}
4196
+ */
4197
+ action: string;
4198
+ /**
4199
+ * Optional value to use for replace action.
4200
+ *
4201
+ * @type {any|undefined}
4202
+ */
4203
+ value: any | undefined;
4204
+ }
4205
+
3603
4206
  export { }