dwv 0.33.0-beta.1 → 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,33 +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.
294
300
  */
295
- getDataViewConfig(): object;
301
+ getDataViewConfigs(): {
302
+ [x: string]: ViewConfig[];
303
+ };
296
304
  /**
297
- * Set the data view configuration (see the init options for details).
305
+ * Set the data view configuration.
306
+ * Resets the stage and recreates all the views.
298
307
  *
299
- * @param {object} configs The configuration list.
308
+ * @param {Object<string, ViewConfig[]>} configs The configuration list.
300
309
  */
301
- setDataViewConfig(configs: object): void;
310
+ setDataViewConfigs(configs: {
311
+ [x: string]: ViewConfig[];
312
+ }): void;
302
313
  /**
303
314
  * Add a data view config.
304
315
  *
305
- * @param {number} dataId The data id.
306
- * @param {object} config The view configuration.
316
+ * @param {string} dataId The data id.
317
+ * @param {ViewConfig} config The view configuration.
307
318
  */
308
- addDataViewConfig(dataId: number, config: object): void;
319
+ addDataViewConfig(dataId: string, config: ViewConfig): void;
309
320
  /**
310
321
  * Remove a data view config.
311
322
  *
312
- * @param {number} dataId The data id.
313
- * @param {object} config The view configuration.
323
+ * @param {string} dataId The data id.
324
+ * @param {ViewConfig} config The view configuration.
314
325
  */
315
- removeDataViewConfig(dataId: number, config: object): void;
326
+ removeDataViewConfig(dataId: string, config: ViewConfig): void;
327
+ /**
328
+ * Update a data view config.
329
+ * Removes and re-creates the layer if found.
330
+ *
331
+ * @param {string} dataId The data id.
332
+ * @param {string} divId The div id.
333
+ * @param {ViewConfig} config The view configuration.
334
+ */
335
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
316
336
  /**
317
337
  * Set the layer groups binders.
318
338
  *
@@ -322,9 +342,10 @@ export declare class App {
322
342
  /**
323
343
  * Render the current data.
324
344
  *
325
- * @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.
326
347
  */
327
- render(dataIndex: number): void;
348
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
328
349
  /**
329
350
  * Zoom to the layers.
330
351
  *
@@ -369,6 +390,8 @@ export declare class App {
369
390
  * Handle resize: fit the display to the window.
370
391
  * To be called once the image is loaded.
371
392
  * Can be connected to a window 'resize' event.
393
+ *
394
+ * @function
372
395
  */
373
396
  onResize: () => void;
374
397
  /**
@@ -376,6 +399,7 @@ export declare class App {
376
399
  *
377
400
  * @param {KeyboardEvent} event The key down event.
378
401
  * @fires App#keydown
402
+ * @function
379
403
  */
380
404
  onKeydown: (event: KeyboardEvent) => void;
381
405
  /**
@@ -390,6 +414,7 @@ export declare class App {
390
414
  * @param {KeyboardEvent} event The key down event.
391
415
  * @fires UndoStack#undo
392
416
  * @fires UndoStack#redo
417
+ * @function
393
418
  */
394
419
  defaultOnKeydown: (event: KeyboardEvent) => void;
395
420
  /**
@@ -403,9 +428,9 @@ export declare class App {
403
428
  /**
404
429
  * Set the colour map.
405
430
  *
406
- * @param {string} colourMap The colour map name.
431
+ * @param {string} name The colour map name.
407
432
  */
408
- setColourMap(colourMap: string): void;
433
+ setColourMap(name: string): void;
409
434
  /**
410
435
  * Set the window/level preset.
411
436
  *
@@ -449,21 +474,77 @@ export declare class App {
449
474
  */
450
475
  getCurrentStackIndex(): number;
451
476
  /**
452
- * Get the overlay data for a data index.
477
+ * Get the overlay data for a data id.
453
478
  *
454
- * @param {number} dataIndex The data index.
455
- * @returns {OverlayData} The overlay data.
479
+ * @param {string} dataId The data id.
480
+ * @returns {OverlayData|undefined} The overlay data.
456
481
  */
457
- getOverlayData(dataIndex: number): OverlayData;
482
+ getOverlayData(dataId: string): OverlayData | undefined;
458
483
  /**
459
484
  * Toggle overlay listeners.
460
485
  *
461
- * @param {number} dataIndex The data index.
486
+ * @param {string} dataId The data id.
462
487
  */
463
- toggleOverlayListeners(dataIndex: number): void;
488
+ toggleOverlayListeners(dataId: string): void;
464
489
  #private;
465
490
  }
466
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
+
467
548
  /**
468
549
  * Build a multipart message.
469
550
  * See: https://en.wikipedia.org/wiki/MIME#Multipart_messages
@@ -476,6 +557,37 @@ export declare class App {
476
557
  */
477
558
  export declare function buildMultipart(parts: any[], boundary: string): Uint8Array;
478
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
+
479
591
  /**
480
592
  * Create an Image from DICOM elements.
481
593
  *
@@ -511,6 +623,68 @@ export declare namespace customUI {
511
623
  export function openRoiDialog(data: any, callback: Function): void;
512
624
  }
513
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
+
514
688
  /**
515
689
  * Decoder scripts to be passed to web workers for image decoding.
516
690
  */
@@ -589,14 +763,16 @@ export declare class DicomParser {
589
763
  */
590
764
  setDecoderCharacterSet(characterSet: string): void;
591
765
  /**
592
- * Get the raw DICOM data elements.
766
+ * Get the DICOM data elements.
593
767
  *
594
- * @returns {object} The raw DICOM elements.
768
+ * @returns {Object<string, DataElement>} The data elements.
595
769
  */
596
- getDicomElements(): object;
770
+ getDicomElements(): {
771
+ [x: string]: DataElement;
772
+ };
597
773
  /**
598
774
  * Parse the complete DICOM file (given as input to the class).
599
- * Fills in the member object 'dicomElements'.
775
+ * Fills in the member object 'dataElements'.
600
776
  *
601
777
  * @param {ArrayBuffer} buffer The input array buffer.
602
778
  */
@@ -607,16 +783,33 @@ export declare class DicomParser {
607
783
  /**
608
784
  * DICOM writer.
609
785
  *
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";
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();
620
813
  */
621
814
  export declare class DicomWriter {
622
815
  /**
@@ -627,10 +820,16 @@ export declare class DicomWriter {
627
820
  setUseUnVrForPrivateSq(flag: boolean): void;
628
821
  /**
629
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.
630
827
  *
631
- * @param {object} rules The input rules.
828
+ * @param {Object<string, WriterRule>} rules The input rules.
632
829
  */
633
- setRules(rules: object): void;
830
+ setRules(rules: {
831
+ [x: string]: WriterRule;
832
+ }): void;
634
833
  /**
635
834
  * Use a TextEncoder instead of the default text decoder.
636
835
  */
@@ -639,16 +838,153 @@ export declare class DicomWriter {
639
838
  * Use default anonymisation rules.
640
839
  */
641
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;
642
849
  /**
643
850
  * Get the ArrayBuffer corresponding to input DICOM elements.
644
851
  *
645
- * @param {Array} dicomElements The wrapped elements to write.
852
+ * @param {Object<string, DataElement>} dataElements The elements to write.
646
853
  * @returns {ArrayBuffer} The elements as a buffer.
647
854
  */
648
- getBuffer(dicomElements: any[]): ArrayBuffer;
855
+ getBuffer(dataElements: {
856
+ [x: string]: DataElement;
857
+ }): ArrayBuffer;
649
858
  #private;
650
859
  }
651
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;
949
+ #private;
950
+ }
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
+
652
988
  /**
653
989
  * Draw layer.
654
990
  */
@@ -659,23 +995,23 @@ export declare class DrawLayer {
659
995
  */
660
996
  constructor(containerDiv: HTMLDivElement);
661
997
  /**
662
- * Get the associated data index.
998
+ * Get the associated data id.
663
999
  *
664
- * @returns {number} The index.
1000
+ * @returns {string} The id.
665
1001
  */
666
- getDataIndex(): number;
1002
+ getDataId(): string;
667
1003
  /**
668
1004
  * Get the Konva stage.
669
1005
  *
670
- * @returns {object} The stage.
1006
+ * @returns {Konva.Stage} The stage.
671
1007
  */
672
- getKonvaStage(): object;
1008
+ getKonvaStage(): Konva.Stage;
673
1009
  /**
674
1010
  * Get the Konva layer.
675
1011
  *
676
- * @returns {object} The layer.
1012
+ * @returns {Konva.Layer} The layer.
677
1013
  */
678
- getKonvaLayer(): object;
1014
+ getKonvaLayer(): Konva.Layer;
679
1015
  /**
680
1016
  * Get the draw controller.
681
1017
  *
@@ -720,13 +1056,17 @@ export declare class DrawLayer {
720
1056
  * Add a flip offset along the layer Y axis.
721
1057
  */
722
1058
  addFlipOffsetY(): void;
1059
+ /**
1060
+ * Flip the scale along the layer Z axis.
1061
+ */
1062
+ flipScaleZ(): void;
723
1063
  /**
724
1064
  * Set the layer scale.
725
1065
  *
726
1066
  * @param {object} newScale The scale as {x,y}.
727
- * @param {Point3D} center The scale center.
1067
+ * @param {Point3D} [center] The scale center.
728
1068
  */
729
- setScale(newScale: object, center: Point3D): void;
1069
+ setScale(newScale: object, center?: Point3D): void;
730
1070
  /**
731
1071
  * Set the layer offset.
732
1072
  *
@@ -763,9 +1103,9 @@ export declare class DrawLayer {
763
1103
  *
764
1104
  * @param {object} size The image size as {x,y}.
765
1105
  * @param {object} spacing The image spacing as {x,y}.
766
- * @param {number} index The associated data index.
1106
+ * @param {string} dataId The associated data id.
767
1107
  */
768
- initialise(size: object, spacing: object, index: number): void;
1108
+ initialise(size: object, spacing: object, dataId: string): void;
769
1109
  /**
770
1110
  * Fit the layer to its parent container.
771
1111
  *
@@ -787,7 +1127,7 @@ export declare class DrawLayer {
787
1127
  * @param {string} id The id of the group.
788
1128
  * @returns {boolean} False if the group cannot be found.
789
1129
  */
790
- toogleGroupVisibility(id: string): boolean;
1130
+ toggleGroupVisibility(id: string): boolean;
791
1131
  /**
792
1132
  * Delete a Draw from the stage.
793
1133
  *
@@ -823,21 +1163,40 @@ export declare class DrawLayer {
823
1163
  * Add an event listener to this class.
824
1164
  *
825
1165
  * @param {string} type The event type.
826
- * @param {object} callback The method associated with the provided
1166
+ * @param {Function} callback The function associated with the provided
827
1167
  * event type, will be called with the fired event.
828
1168
  */
829
- addEventListener(type: string, callback: object): void;
1169
+ addEventListener(type: string, callback: Function): void;
830
1170
  /**
831
1171
  * Remove an event listener from this class.
832
1172
  *
833
1173
  * @param {string} type The event type.
834
- * @param {object} callback The method associated with the provided
1174
+ * @param {Function} callback The function associated with the provided
835
1175
  * event type.
836
1176
  */
837
- removeEventListener(type: string, callback: object): void;
1177
+ removeEventListener(type: string, callback: Function): void;
838
1178
  #private;
839
1179
  }
840
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
+
841
1200
  /**
842
1201
  * 2D/3D Geometry class.
843
1202
  */
@@ -890,9 +1249,9 @@ export declare class Geometry {
890
1249
  /**
891
1250
  * Get the object origins.
892
1251
  *
893
- * @returns {Array} The object origins.
1252
+ * @returns {Point3D[]} The object origins.
894
1253
  */
895
- getOrigins(): any[];
1254
+ getOrigins(): Point3D[];
896
1255
  /**
897
1256
  * Check if a point is in the origin list.
898
1257
  *
@@ -985,10 +1344,10 @@ export declare class Geometry {
985
1344
  * Check that a index is within bounds.
986
1345
  *
987
1346
  * @param {Index} index The index to check.
988
- * @param {Array} [dirs] Optional list of directions to check.
1347
+ * @param {number[]} [dirs] Optional list of directions to check.
989
1348
  * @returns {boolean} True if the given coordinates are within bounds.
990
1349
  */
991
- isIndexInBounds(index: Index, dirs?: any[]): boolean;
1350
+ isIndexInBounds(index: Index, dirs?: number[]): boolean;
992
1351
  /**
993
1352
  * Convert an index into world coordinates.
994
1353
  *
@@ -1020,6 +1379,19 @@ export declare class Geometry {
1020
1379
  #private;
1021
1380
  }
1022
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
+ */
1023
1395
  /**
1024
1396
  * Get the version of the library.
1025
1397
  *
@@ -1028,15 +1400,40 @@ export declare class Geometry {
1028
1400
  export declare function getDwvVersion(): string;
1029
1401
 
1030
1402
  /**
1031
- * Get the DICOM elements from a DICOM json tags object.
1403
+ * Get the DICOM elements from a 'simple' DICOM json tags object.
1032
1404
  * The json is a simplified version of the oficial DICOM json with
1033
1405
  * tag names instead of keys and direct values (no value property) for
1034
- * 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.
1035
1420
  *
1036
- * @param {object} jsonTags The DICOM json tags object.
1037
- * @returns {object} The DICOM elements.
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.
1038
1425
  */
1039
- export declare function getElementsFromJSONTags(jsonTags: object): object;
1426
+ export declare function getEllipseIndices(center: Index, radius: any[], dir: any[]): any[];
1427
+
1428
+ /**
1429
+ * Get the layer details from a mouse event.
1430
+ *
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}.
1435
+ */
1436
+ export declare function getLayerDetailsFromEvent(event: object): object;
1040
1437
 
1041
1438
  /**
1042
1439
  * Get the name of an image orientation patient.
@@ -1094,6 +1491,16 @@ export declare function getTypedArray(bitsAllocated: number, pixelRepresentation
1094
1491
  */
1095
1492
  export declare function getUID(tagName: string): string;
1096
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
+
1097
1504
  export declare namespace i18n {
1098
1505
  /**
1099
1506
  * Get the translated text.
@@ -1338,18 +1745,18 @@ declare class Image_2 {
1338
1745
  * Add an event listener to this class.
1339
1746
  *
1340
1747
  * @param {string} type The event type.
1341
- * @param {object} callback The method associated with the provided
1748
+ * @param {Function} callback The function associated with the provided
1342
1749
  * event type, will be called with the fired event.
1343
1750
  */
1344
- addEventListener(type: string, callback: object): void;
1751
+ addEventListener(type: string, callback: Function): void;
1345
1752
  /**
1346
1753
  * Remove an event listener from this class.
1347
1754
  *
1348
1755
  * @param {string} type The event type.
1349
- * @param {object} callback The method associated with the provided
1756
+ * @param {Function} callback The function associated with the provided
1350
1757
  * event type.
1351
1758
  */
1352
- removeEventListener(type: string, callback: object): void;
1759
+ removeEventListener(type: string, callback: Function): void;
1353
1760
  /**
1354
1761
  * Set the inner buffer values at given offsets.
1355
1762
  *
@@ -1491,9 +1898,9 @@ export { Image_2 as Image }
1491
1898
  */
1492
1899
  export declare class Index {
1493
1900
  /**
1494
- * @param {Array} values The index values.
1901
+ * @param {number[]} values The index values.
1495
1902
  */
1496
- constructor(values: any[]);
1903
+ constructor(values: number[]);
1497
1904
  /**
1498
1905
  * Get the index value at the given array index.
1499
1906
  *
@@ -1516,9 +1923,9 @@ export declare class Index {
1516
1923
  /**
1517
1924
  * Get the values of this index.
1518
1925
  *
1519
- * @returns {Array} The array of values.
1926
+ * @returns {number[]} The array of values.
1520
1927
  */
1521
- getValues(): any[];
1928
+ getValues(): number[];
1522
1929
  /**
1523
1930
  * Check if the input index can be compared to this one.
1524
1931
  *
@@ -1537,9 +1944,9 @@ export declare class Index {
1537
1944
  * Compare indices and return different dimensions.
1538
1945
  *
1539
1946
  * @param {Index} rhs The index to compare to.
1540
- * @returns {Array} The list of different dimensions.
1947
+ * @returns {number[]} The list of different dimensions.
1541
1948
  */
1542
- compare(rhs: Index): any[];
1949
+ compare(rhs: Index): number[];
1543
1950
  /**
1544
1951
  * Add another index to this one.
1545
1952
  *
@@ -1558,13 +1965,22 @@ export declare class Index {
1558
1965
  /**
1559
1966
  * Get a string id from the index values in the form of: '#0-1_#1-2'.
1560
1967
  *
1561
- * @param {Array} [dims] Optional list of dimensions to use.
1968
+ * @param {number[]} [dims] Optional list of dimensions to use.
1562
1969
  * @returns {string} The string id.
1563
1970
  */
1564
- toStringId(dims?: any[]): string;
1971
+ toStringId(dims?: number[]): string;
1565
1972
  #private;
1566
1973
  }
1567
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
+
1568
1984
  /**
1569
1985
  * Layer group.
1570
1986
  *
@@ -1586,18 +2002,6 @@ export declare class LayerGroup {
1586
2002
  * @param {HTMLElement} containerDiv The associated HTML div.
1587
2003
  */
1588
2004
  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
2005
  /**
1602
2006
  * Get the showCrosshair flag.
1603
2007
  *
@@ -1610,6 +2014,12 @@ export declare class LayerGroup {
1610
2014
  * @param {boolean} flag True to display the crosshair.
1611
2015
  */
1612
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;
1613
2023
  /**
1614
2024
  * Get the Id of the container div.
1615
2025
  *
@@ -1646,19 +2056,25 @@ export declare class LayerGroup {
1646
2056
  * @returns {number} The number of layers.
1647
2057
  */
1648
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;
1649
2065
  /**
1650
2066
  * Get the active image layer.
1651
2067
  *
1652
- * @returns {ViewLayer} The layer.
2068
+ * @returns {ViewLayer|undefined} The layer.
1653
2069
  */
1654
- getActiveViewLayer(): ViewLayer;
2070
+ getActiveViewLayer(): ViewLayer | undefined;
1655
2071
  /**
1656
- * Get the view layers associated to a data index.
2072
+ * Get the view layers associated to a data id.
1657
2073
  *
1658
- * @param {number} index The data index.
2074
+ * @param {string} dataId The data id.
1659
2075
  * @returns {ViewLayer[]} The layers.
1660
2076
  */
1661
- getViewLayersByDataIndex(index: number): ViewLayer[];
2077
+ getViewLayersByDataId(dataId: string): ViewLayer[];
1662
2078
  /**
1663
2079
  * Search view layers for equal imae meta data.
1664
2080
  *
@@ -1675,16 +2091,16 @@ export declare class LayerGroup {
1675
2091
  /**
1676
2092
  * Get the active draw layer.
1677
2093
  *
1678
- * @returns {DrawLayer} The layer.
2094
+ * @returns {DrawLayer|undefined} The layer.
1679
2095
  */
1680
- getActiveDrawLayer(): DrawLayer;
2096
+ getActiveDrawLayer(): DrawLayer | undefined;
1681
2097
  /**
1682
- * Get the draw layers associated to a data index.
2098
+ * Get the draw layers associated to a data id.
1683
2099
  *
1684
- * @param {number} index The data index.
2100
+ * @param {string} dataId The data id.
1685
2101
  * @returns {DrawLayer[]} The layers.
1686
2102
  */
1687
- getDrawLayersByDataIndex(index: number): DrawLayer[];
2103
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
1688
2104
  /**
1689
2105
  * Set the active view layer.
1690
2106
  *
@@ -1692,11 +2108,11 @@ export declare class LayerGroup {
1692
2108
  */
1693
2109
  setActiveViewLayer(index: number): void;
1694
2110
  /**
1695
- * Set the active view layer with a data index.
2111
+ * Set the active view layer with a data id.
1696
2112
  *
1697
- * @param {number} index The data index.
2113
+ * @param {string} dataId The data id.
1698
2114
  */
1699
- setActiveViewLayerByDataIndex(index: number): void;
2115
+ setActiveViewLayerByDataId(dataId: string): void;
1700
2116
  /**
1701
2117
  * Set the active draw layer.
1702
2118
  *
@@ -1704,11 +2120,11 @@ export declare class LayerGroup {
1704
2120
  */
1705
2121
  setActiveDrawLayer(index: number): void;
1706
2122
  /**
1707
- * Set the active draw layer with a data index.
2123
+ * Set the active draw layer with a data id.
1708
2124
  *
1709
- * @param {number} index The data index.
2125
+ * @param {string} dataId The data id.
1710
2126
  */
1711
- setActiveDrawLayerByDataIndex(index: number): void;
2127
+ setActiveDrawLayerByDataId(dataId: string): void;
1712
2128
  /**
1713
2129
  * Add a view layer.
1714
2130
  *
@@ -1727,6 +2143,9 @@ export declare class LayerGroup {
1727
2143
  empty(): void;
1728
2144
  /**
1729
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.
1730
2149
  *
1731
2150
  * @param {ViewLayer | DrawLayer} layer The layer to remove.
1732
2151
  */
@@ -1735,6 +2154,7 @@ export declare class LayerGroup {
1735
2154
  * Update layers (but not the active view layer) to a position change.
1736
2155
  *
1737
2156
  * @param {object} event The position change event.
2157
+ * @function
1738
2158
  */
1739
2159
  updateLayersToPositionChange: (event: object) => void;
1740
2160
  /**
@@ -1805,18 +2225,18 @@ export declare class LayerGroup {
1805
2225
  * Add an event listener to this class.
1806
2226
  *
1807
2227
  * @param {string} type The event type.
1808
- * @param {object} callback The method associated with the provided
2228
+ * @param {Function} callback The function associated with the provided
1809
2229
  * event type, will be called with the fired event.
1810
2230
  */
1811
- addEventListener(type: string, callback: object): void;
2231
+ addEventListener(type: string, callback: Function): void;
1812
2232
  /**
1813
2233
  * Remove an event listener from this class.
1814
2234
  *
1815
2235
  * @param {string} type The event type.
1816
- * @param {object} callback The method associated with the provided
2236
+ * @param {Function} callback The function associated with the provided
1817
2237
  * event type.
1818
2238
  */
1819
- removeEventListener(type: string, callback: object): void;
2239
+ removeEventListener(type: string, callback: Function): void;
1820
2240
  #private;
1821
2241
  }
1822
2242
 
@@ -1839,32 +2259,45 @@ export declare namespace logger {
1839
2259
  /**
1840
2260
  * List of available lookup tables (lut).
1841
2261
  *
1842
- * @type {Object<string, {red: number[], green: number[], blue: number[]}>}
2262
+ * @type {Object<string, ColourMap>}
1843
2263
  */
1844
- export declare const lut: {
1845
- [x: string]: {
1846
- red: number[];
1847
- green: number[];
1848
- blue: number[];
1849
- };
2264
+ export declare const luts: {
2265
+ [x: string]: ColourMap;
1850
2266
  };
1851
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
+
1852
2285
  /**
1853
2286
  * Immutable 3x3 Matrix.
1854
2287
  */
1855
2288
  export declare class Matrix33 {
1856
2289
  /**
1857
- * @param {Array} values row-major ordered 9 values.
2290
+ * @param {number[]} values row-major ordered 9 values.
1858
2291
  */
1859
- constructor(values: any[]);
2292
+ constructor(values: number[]);
1860
2293
  /**
1861
2294
  * Get a value of the matrix.
1862
2295
  *
1863
2296
  * @param {number} row The row at wich to get the value.
1864
2297
  * @param {number} col The column at wich to get the value.
1865
- * @returns {number} The value at the position.
2298
+ * @returns {number|undefined} The value at the position.
1866
2299
  */
1867
- get(row: number, col: number): number;
2300
+ get(row: number, col: number): number | undefined;
1868
2301
  /**
1869
2302
  * Get the inverse of this matrix.
1870
2303
  *
@@ -1903,10 +2336,10 @@ export declare class Matrix33 {
1903
2336
  /**
1904
2337
  * Multiply this matrix by a 3D array.
1905
2338
  *
1906
- * @param {Array} array3D The input 3D array.
1907
- * @returns {Array} The result 3D array.
2339
+ * @param {number[]} array3D The input 3D array.
2340
+ * @returns {number[]} The result 3D array.
1908
2341
  */
1909
- multiplyArray3D(array3D: any[]): any[];
2342
+ multiplyArray3D(array3D: number[]): number[];
1910
2343
  /**
1911
2344
  * Multiply this matrix by a 3D vector.
1912
2345
  *
@@ -1963,10 +2396,10 @@ export declare class Matrix33 {
1963
2396
  export declare class OverlayData {
1964
2397
  /**
1965
2398
  * @param {App} app The associated application.
1966
- * @param {number} dataId The associated data ID.
2399
+ * @param {string} dataId The associated data id.
1967
2400
  * @param {object} configs The overlay config.
1968
2401
  */
1969
- constructor(app: App, dataId: number, configs: object);
2402
+ constructor(app: App, dataId: string, configs: object);
1970
2403
  /**
1971
2404
  * Reset the data.
1972
2405
  */
@@ -2017,9 +2450,9 @@ export declare class OverlayData {
2017
2450
  */
2018
2451
  export declare class Point {
2019
2452
  /**
2020
- * @param {Array} values The point values.
2453
+ * @param {number[]} values The point values.
2021
2454
  */
2022
- constructor(values: any[]);
2455
+ constructor(values: number[]);
2023
2456
  /**
2024
2457
  * Get the index value at the given array index.
2025
2458
  *
@@ -2042,9 +2475,9 @@ export declare class Point {
2042
2475
  /**
2043
2476
  * Get the values of this index.
2044
2477
  *
2045
- * @returns {Array} The array of values.
2478
+ * @returns {number[]} The array of values.
2046
2479
  */
2047
- getValues(): any[];
2480
+ getValues(): number[];
2048
2481
  /**
2049
2482
  * Check if the input point can be compared to this one.
2050
2483
  *
@@ -2063,9 +2496,9 @@ export declare class Point {
2063
2496
  * Compare points and return different dimensions.
2064
2497
  *
2065
2498
  * @param {Point} rhs The point to compare to.
2066
- * @returns {Array} The list of different dimensions.
2499
+ * @returns {number[]} The list of different dimensions.
2067
2500
  */
2068
- compare(rhs: Point): any[];
2501
+ compare(rhs: Point): number[];
2069
2502
  /**
2070
2503
  * Get the 3D part of this point.
2071
2504
  *
@@ -2458,6 +2891,14 @@ export declare class Spacing {
2458
2891
  #private;
2459
2892
  }
2460
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
+
2461
2902
  /**
2462
2903
  * Immutable tag.
2463
2904
  */
@@ -2550,12 +2991,95 @@ export declare class TagValueExtractor {
2550
2991
  /**
2551
2992
  * Get the time.
2552
2993
  *
2553
- * @param {object} _elements The DICOM elements.
2994
+ * @param {Object<string, DataElement>} _elements The DICOM elements.
2554
2995
  * @returns {number|undefined} The time value if available.
2555
2996
  */
2556
- getTime(_elements: object): number | undefined;
2997
+ getTime(_elements: {
2998
+ [x: string]: DataElement;
2999
+ }): number | undefined;
3000
+ }
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;
2557
3061
  }
2558
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
+
2559
3083
  /**
2560
3084
  * Immutable 3D vector.
2561
3085
  */
@@ -2587,10 +3111,10 @@ export declare class Vector3D {
2587
3111
  /**
2588
3112
  * Check for Vector3D equality.
2589
3113
  *
2590
- * @param {object} rhs The other vector to compare to.
3114
+ * @param {Vector3D} rhs The other vector to compare to.
2591
3115
  * @returns {boolean} True if both vectors are equal.
2592
3116
  */
2593
- equals(rhs: object): boolean;
3117
+ equals(rhs: Vector3D): boolean;
2594
3118
  /**
2595
3119
  * Get a string representation of the Vector3D.
2596
3120
  *
@@ -2637,9 +3161,9 @@ export declare class Vector3D {
2637
3161
  * const dicomParser = new dwv.DicomParser();
2638
3162
  * dicomParser.parse(event.target.response);
2639
3163
  * // create the image object
2640
- * const image = createImage(dicomParser.getDicomElements());
3164
+ * const image = dwv.createImage(dicomParser.getDicomElements());
2641
3165
  * // create the view
2642
- * const view = createView(dicomParser.getDicomElements(), image);
3166
+ * const view = dwv.createView(dicomParser.getDicomElements(), image);
2643
3167
  * // setup canvas
2644
3168
  * const canvas = document.createElement('canvas');
2645
3169
  * canvas.width = 256;
@@ -2750,12 +3274,6 @@ export declare class View {
2750
3274
  * @param {object} presets The window presets.
2751
3275
  */
2752
3276
  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
3277
  /**
2760
3278
  * Add window presets to the existing ones.
2761
3279
  *
@@ -2771,16 +3289,16 @@ export declare class View {
2771
3289
  /**
2772
3290
  * Get the colour map of the image.
2773
3291
  *
2774
- * @returns {object} The colour map of the image.
3292
+ * @returns {string} The colour map name.
2775
3293
  */
2776
- getColourMap(): object;
3294
+ getColourMap(): string;
2777
3295
  /**
2778
3296
  * Set the colour map of the image.
2779
3297
  *
2780
- * @param {object} map The colour map of the image.
2781
- * @fires View#colourchange
3298
+ * @param {string} name The colour map name.
3299
+ * @fires View#colourmapchange
2782
3300
  */
2783
- setColourMap(map: object): void;
3301
+ setColourMap(name: string): void;
2784
3302
  /**
2785
3303
  * Get the current position.
2786
3304
  *
@@ -2801,12 +3319,12 @@ export declare class View {
2801
3319
  */
2802
3320
  canSetPosition(position: Point): boolean;
2803
3321
  /**
2804
- * Get the origin at a given position.
3322
+ * Get the first origin or at a given position.
2805
3323
  *
2806
- * @param {Point} position The position.
2807
- * @returns {Point} The origin.
3324
+ * @param {Point} [position] Optional position.
3325
+ * @returns {Point3D} The origin.
2808
3326
  */
2809
- getOrigin(position: Point): Point;
3327
+ getOrigin(position?: Point): Point3D;
2810
3328
  /**
2811
3329
  * Set the current position.
2812
3330
  *
@@ -2854,18 +3372,18 @@ export declare class View {
2854
3372
  * Add an event listener to this class.
2855
3373
  *
2856
3374
  * @param {string} type The event type.
2857
- * @param {object} callback The method associated with the provided
3375
+ * @param {Function} callback The function associated with the provided
2858
3376
  * event type, will be called with the fired event.
2859
3377
  */
2860
- addEventListener(type: string, callback: object): void;
3378
+ addEventListener(type: string, callback: Function): void;
2861
3379
  /**
2862
3380
  * Remove an event listener from this class.
2863
3381
  *
2864
3382
  * @param {string} type The event type.
2865
- * @param {object} callback The method associated with the provided
3383
+ * @param {Function} callback The function associated with the provided
2866
3384
  * event type.
2867
3385
  */
2868
- removeEventListener(type: string, callback: object): void;
3386
+ removeEventListener(type: string, callback: Function): void;
2869
3387
  /**
2870
3388
  * Get the image window/level that covers the full data range.
2871
3389
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -2925,15 +3443,51 @@ export declare class View {
2925
3443
  #private;
2926
3444
  }
2927
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
+
2928
3482
  /**
2929
3483
  * View controller.
2930
3484
  */
2931
3485
  export declare class ViewController {
2932
3486
  /**
2933
3487
  * @param {View} view The associated view.
2934
- * @param {number} index The associated data index.
3488
+ * @param {string} dataId The associated data id.
2935
3489
  */
2936
- constructor(view: View, index: number);
3490
+ constructor(view: View, dataId: string);
2937
3491
  /**
2938
3492
  * Get the plane helper.
2939
3493
  *
@@ -3036,12 +3590,12 @@ export declare class ViewController {
3036
3590
  */
3037
3591
  getCurrentScrollIndexValue(): object;
3038
3592
  /**
3039
- * Get the origin at a given posittion.
3593
+ * Get the first origin or at a given position.
3040
3594
  *
3041
- * @param {Point} position The input position.
3042
- * @returns {Point} The origin.
3595
+ * @param {Point} [position] Opitonal position.
3596
+ * @returns {Point3D} The origin.
3043
3597
  */
3044
- getOrigin(position: Point): Point;
3598
+ getOrigin(position?: Point): Point3D;
3045
3599
  /**
3046
3600
  * Get the current scroll position value.
3047
3601
  *
@@ -3060,13 +3614,13 @@ export declare class ViewController {
3060
3614
  * Set the associated image.
3061
3615
  *
3062
3616
  * @param {Image} img The associated image.
3063
- * @param {number} index The data index of the image.
3617
+ * @param {string} dataId The data id of the image.
3064
3618
  */
3065
- setImage(img: Image_2, index: number): void;
3619
+ setImage(img: Image_2, dataId: string): void;
3066
3620
  /**
3067
- * Get the current spacing.
3621
+ * Get the current view (2D) spacing.
3068
3622
  *
3069
- * @returns {Array} The 2D spacing.
3623
+ * @returns {Array} The spacing as a 2D array.
3070
3624
  */
3071
3625
  get2DSpacing(): any[];
3072
3626
  /**
@@ -3256,15 +3810,15 @@ export declare class ViewController {
3256
3810
  /**
3257
3811
  * Get the colour map.
3258
3812
  *
3259
- * @returns {object} The colour map.
3813
+ * @returns {string} The colour map name.
3260
3814
  */
3261
- getColourMap(): object;
3815
+ getColourMap(): string;
3262
3816
  /**
3263
3817
  * Set the colour map.
3264
3818
  *
3265
- * @param {object} colourMap The colour map.
3819
+ * @param {string} name The colour map name.
3266
3820
  */
3267
- setColourMap(colourMap: object): void;
3821
+ setColourMap(name: string): void;
3268
3822
  /**
3269
3823
  * @callback alphaFn@callback alphaFn
3270
3824
  * @param {object} value The pixel value.
@@ -3277,28 +3831,22 @@ export declare class ViewController {
3277
3831
  * @param {alphaFn} func The function.
3278
3832
  */
3279
3833
  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
3834
  /**
3287
3835
  * Add an event listener to this class.
3288
3836
  *
3289
3837
  * @param {string} type The event type.
3290
- * @param {object} callback The method associated with the provided
3838
+ * @param {Function} callback The function associated with the provided
3291
3839
  * event type, will be called with the fired event.
3292
3840
  */
3293
- addEventListener(type: string, callback: object): void;
3841
+ addEventListener(type: string, callback: Function): void;
3294
3842
  /**
3295
3843
  * Remove an event listener from this class.
3296
3844
  *
3297
3845
  * @param {string} type The event type.
3298
- * @param {object} callback The method associated with the provided
3846
+ * @param {Function} callback The function associated with the provided
3299
3847
  * event type.
3300
3848
  */
3301
- removeEventListener(type: string, callback: object): void;
3849
+ removeEventListener(type: string, callback: Function): void;
3302
3850
  #private;
3303
3851
  }
3304
3852
 
@@ -3312,24 +3860,24 @@ export declare class ViewLayer {
3312
3860
  */
3313
3861
  constructor(containerDiv: HTMLElement);
3314
3862
  /**
3315
- * Get the associated data index.
3863
+ * Get the associated data id.
3316
3864
  *
3317
- * @returns {number} The index.
3865
+ * @returns {string} The data id.
3318
3866
  */
3319
- getDataIndex(): number;
3867
+ getDataId(): string;
3320
3868
  /**
3321
- * Set the imageSmoothingEnabled flag value.
3869
+ * Set the imageSmoothing flag value.
3322
3870
  *
3323
3871
  * @param {boolean} flag True to enable smoothing.
3324
3872
  */
3325
- enableImageSmoothing(flag: boolean): void;
3873
+ setImageSmoothing(flag: boolean): void;
3326
3874
  /**
3327
3875
  * Set the associated view.
3328
3876
  *
3329
3877
  * @param {object} view The view.
3330
- * @param {number} index The associated data index.
3878
+ * @param {string} dataId The associated data id.
3331
3879
  */
3332
- setView(view: object, index: number): void;
3880
+ setView(view: object, dataId: string): void;
3333
3881
  /**
3334
3882
  * Get the view controller.
3335
3883
  *
@@ -3346,12 +3894,14 @@ export declare class ViewLayer {
3346
3894
  * Handle an image set event.
3347
3895
  *
3348
3896
  * @param {object} event The event.
3897
+ * @function
3349
3898
  */
3350
3899
  onimageset: (event: object) => void;
3351
3900
  /**
3352
3901
  * Handle an image change event.
3353
3902
  *
3354
3903
  * @param {object} event The event.
3904
+ * @function
3355
3905
  */
3356
3906
  onimagechange: (event: object) => void;
3357
3907
  /**
@@ -3392,13 +3942,17 @@ export declare class ViewLayer {
3392
3942
  * Add a flip offset along the layer Y axis.
3393
3943
  */
3394
3944
  addFlipOffsetY(): void;
3945
+ /**
3946
+ * Flip the scale along the layer Z axis.
3947
+ */
3948
+ flipScaleZ(): void;
3395
3949
  /**
3396
3950
  * Set the layer scale.
3397
3951
  *
3398
3952
  * @param {object} newScale The scale as {x,y}.
3399
- * @param {Point3D} center The scale center.
3953
+ * @param {Point3D} [center] The scale center.
3400
3954
  */
3401
- setScale(newScale: object, center: Point3D): void;
3955
+ setScale(newScale: object, center?: Point3D): void;
3402
3956
  /**
3403
3957
  * Set the base layer offset. Updates the layer offset.
3404
3958
  *
@@ -3442,7 +3996,8 @@ export declare class ViewLayer {
3442
3996
  *
3443
3997
  * @param {number} x The X position.
3444
3998
  * @param {number} y The Y position.
3445
- * @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.
3446
4001
  */
3447
4002
  planePosToDisplay(x: number, y: number): object;
3448
4003
  /**
@@ -3501,18 +4056,18 @@ export declare class ViewLayer {
3501
4056
  * Add an event listener to this class.
3502
4057
  *
3503
4058
  * @param {string} type The event type.
3504
- * @param {object} callback The method associated with the provided
4059
+ * @param {Function} callback The function associated with the provided
3505
4060
  * event type, will be called with the fired event.
3506
4061
  */
3507
- addEventListener(type: string, callback: object): void;
4062
+ addEventListener(type: string, callback: Function): void;
3508
4063
  /**
3509
4064
  * Remove an event listener from this class.
3510
4065
  *
3511
4066
  * @param {string} type The event type.
3512
- * @param {object} callback The method associated with the provided
4067
+ * @param {Function} callback The function associated with the provided
3513
4068
  * event type.
3514
4069
  */
3515
- removeEventListener(type: string, callback: object): void;
4070
+ removeEventListener(type: string, callback: Function): void;
3516
4071
  /**
3517
4072
  * Set the current position.
3518
4073
  *
@@ -3626,4 +4181,26 @@ export declare class WindowLut {
3626
4181
  #private;
3627
4182
  }
3628
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
+
3629
4206
  export { }