dwv 0.37.0-beta.3 → 0.37.0-beta.4

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.
Files changed (88) hide show
  1. package/dev/bench/bench.html +94 -0
  2. package/dev/bench/bench.js +316 -0
  3. package/dev/bench/benchFunctionRunner.js +83 -0
  4. package/dev/bench/dataRunner.js +171 -0
  5. package/dev/bench/gui.js +184 -0
  6. package/dev/bench/listen.js +70 -0
  7. package/dev/bench/parsers/dwv-current.html +45 -0
  8. package/dev/bench/parsers/dwv-previous.html +45 -0
  9. package/dev/dicom/binaryPixGenerator.js +108 -0
  10. package/dev/dicom/dicomGenerator.js +215 -0
  11. package/dev/dicom/filePixGenerator.js +96 -0
  12. package/dev/dicom/gradSquarePixGenerator.js +107 -0
  13. package/dev/dicom/mprPixGenerator.js +247 -0
  14. package/dev/dicom/pages/anonymiser.html +86 -0
  15. package/dev/dicom/pages/anonymiser.js +154 -0
  16. package/dev/dicom/pages/generator.html +92 -0
  17. package/dev/dicom/pages/generator.js +329 -0
  18. package/dev/dicom/pages/synthetic-data.html +19 -0
  19. package/dev/dicom/pages/synthetic-data.js +164 -0
  20. package/dev/dicom/squarePixGenerator.js +233 -0
  21. package/dev/favicon.ico +0 -0
  22. package/dev/image/pages/colourmaps.html +16 -0
  23. package/dev/image/pages/colourmaps.js +65 -0
  24. package/dev/index.html +37 -0
  25. package/dev/pacs/dcmweb.html +80 -0
  26. package/dev/pacs/dcmweb.js +577 -0
  27. package/dev/pacs/images/acute_leukemia.png +0 -0
  28. package/dev/pacs/images/babymri-dcmdir.png +0 -0
  29. package/dev/pacs/images/babymri-rect.png +0 -0
  30. package/dev/pacs/images/babymri-zip.png +0 -0
  31. package/dev/pacs/images/babymri.png +0 -0
  32. package/dev/pacs/images/brainmri-png.png +0 -0
  33. package/dev/pacs/images/brainpet-jpg.png +0 -0
  34. package/dev/pacs/images/cerebrix.png +0 -0
  35. package/dev/pacs/images/goudurix.png +0 -0
  36. package/dev/pacs/images/multiframe-test1.png +0 -0
  37. package/dev/pacs/images/toutatix.png +0 -0
  38. package/dev/pacs/images/us.png +0 -0
  39. package/dev/pacs/index.html +97 -0
  40. package/dev/pacs/index.js +287 -0
  41. package/dev/pacs/overlays.js +51 -0
  42. package/dev/pacs/viewer.html +401 -0
  43. package/dev/pacs/viewer.js +1275 -0
  44. package/dev/pacs/viewer.rendertest.js +96 -0
  45. package/dev/pacs/viewer.ui.annot.js +607 -0
  46. package/dev/pacs/viewer.ui.brush.js +181 -0
  47. package/dev/pacs/viewer.ui.datatable.js +674 -0
  48. package/dev/pacs/viewer.ui.draw.js +141 -0
  49. package/dev/pacs/viewer.ui.icons.js +88 -0
  50. package/dev/pacs/viewer.ui.js +198 -0
  51. package/dev/pacs/viewer.ui.segment.js +1263 -0
  52. package/dev/visual/appgui.js +125 -0
  53. package/dev/visual/images/dicompyler-ct.0.jpg +0 -0
  54. package/dev/visual/images/gdcm-CR-MONO1-10-chest.jpg +0 -0
  55. package/dev/visual/images/gdcm-CT-MONO2-8-abdo.jpg +0 -0
  56. package/dev/visual/images/gdcm-US-RGB-8-epicard.jpg +0 -0
  57. package/dev/visual/images/gdcm-US-RGB-8-esopecho.jpg +0 -0
  58. package/dev/visual/images/leadtools-8BitsJpegLossyGrayScale.jpg +0 -0
  59. package/dev/visual/images/leadtools-flowers-16-mono2-rle.jpg +0 -0
  60. package/dev/visual/images/leadtools-flowers-8-mono2-rle.jpg +0 -0
  61. package/dev/visual/images/nema-ct1_j2ki.jpg +0 -0
  62. package/dev/visual/images/nema-ct1_jpll.jpg +0 -0
  63. package/dev/visual/images/nema-mr1_jply.jpg +0 -0
  64. package/dev/visual/images/nema-nm1_j2kr.jpg +0 -0
  65. package/dev/visual/images/nema-nm1_jpll.jpg +0 -0
  66. package/dev/visual/images/nema-nm1_jply.jpg +0 -0
  67. package/dev/visual/images/nema-us1_j2ki.jpg +0 -0
  68. package/dev/visual/images/nema-vl2_j2kr.jpg +0 -0
  69. package/dev/visual/images/osirix-cerebrix.jpg +0 -0
  70. package/dev/visual/images/osirix-goudurix.jpg +0 -0
  71. package/dev/visual/images/osirix-toutatix-100.jpg +0 -0
  72. package/dev/visual/index-jpeg.js +104 -0
  73. package/dev/visual/index-jpeg2000.js +103 -0
  74. package/dev/visual/index-rle.js +70 -0
  75. package/dev/visual/index.html +20 -0
  76. package/dev/visual/index.js +123 -0
  77. package/dev/visual/style.css +37 -0
  78. package/dist/assets/workers/jpeg2000.worker.min.js.map +1 -1
  79. package/dist/assets/workers/labeling.worker.min.js +1 -1
  80. package/dist/assets/workers/labeling.worker.min.js.map +1 -1
  81. package/dist/assets/workers/resampling.worker.min.js +1 -1
  82. package/dist/assets/workers/resampling.worker.min.js.map +1 -1
  83. package/dist/dwv.d.ts +1048 -198
  84. package/dist/dwv.min.js +1 -1
  85. package/dist/dwv.min.js.map +1 -1
  86. package/dist/dwv.node.min.js +1 -1
  87. package/dist/dwv.node.min.js.map +1 -1
  88. package/package.json +11 -11
package/dist/dwv.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare function addTagsToDictionary(group: string, tags: Record<string,
13
13
  /**
14
14
  * @import {Point2D} from '../math/point.js';
15
15
  * @import {Index} from '../math/index.js';
16
- * @import {Value} from '../math/value.js';
16
+ * @import {NumberValue} from '../math/number.js';
17
17
  * @import {ViewController} from '../app/viewController.js';
18
18
  * @import {PlaneHelper} from './planeHelper.js';
19
19
  * @import {DicomCode} from '../dicom/dicomCode.js';
@@ -73,9 +73,9 @@ export declare class Annotation {
73
73
  /**
74
74
  * Annotation quantification.
75
75
  *
76
- * @type {Record<string, Value>|undefined}
76
+ * @type {Record<string, NumberValue>|undefined}
77
77
  */
78
- quantification: Record<string, Value> | undefined;
78
+ quantification: Record<string, NumberValue> | undefined;
79
79
  /**
80
80
  * Text expression. Can contain variables surrounded with '{}' that will
81
81
  * be extracted from the quantification object.
@@ -198,7 +198,7 @@ export declare class Annotation {
198
198
  /**
199
199
  * Annotation group.
200
200
  */
201
- export declare class AnnotationGroup {
201
+ export declare class AnnotationGroup extends EventTarget {
202
202
  /**
203
203
  * @param {Annotation[]} [list] Optional list, will
204
204
  * create new if not provided.
@@ -305,22 +305,6 @@ export declare class AnnotationGroup {
305
305
  * @param {string|object} value The value of the meta data.
306
306
  */
307
307
  setMetaValue(key: string, value: string | object): void;
308
- /**
309
- * Add an event listener to this class.
310
- *
311
- * @param {string} type The event type.
312
- * @param {Function} callback The function associated with the provided
313
- * event type, will be called with the fired event.
314
- */
315
- addEventListener(type: string, callback: Function): void;
316
- /**
317
- * Remove an event listener from this class.
318
- *
319
- * @param {string} type The event type.
320
- * @param {Function} callback The function associated with the provided
321
- * event type.
322
- */
323
- removeEventListener(type: string, callback: Function): void;
324
308
  #private;
325
309
  }
326
310
 
@@ -400,12 +384,19 @@ export declare class AnnotationGroupFactory {
400
384
  * 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm'
401
385
  * ]);
402
386
  */
403
- export declare class App {
387
+ export declare class App extends EventTarget {
388
+ /**
389
+ * Get the data controller.
390
+ *
391
+ * @returns {DataController} The data controller.
392
+ */
393
+ getDataController(): DataController;
404
394
  /**
405
395
  * Get a DicomData.
406
396
  *
407
397
  * @param {string} dataId The data id.
408
398
  * @returns {DicomData|undefined} The data.
399
+ * @deprecated Since v0.37, please use via app.getDataController.
409
400
  */
410
401
  getData(dataId: string): DicomData | undefined;
411
402
  /**
@@ -421,12 +412,14 @@ export declare class App {
421
412
  *
422
413
  * @param {string} dataId The data id.
423
414
  * @param {Image} img The associated image.
415
+ * @deprecated Since v0.37, please use via app.getDataController.
424
416
  */
425
417
  setImage(dataId: string, img: Image_2): void;
426
418
  /**
427
419
  * Get the next data id.
428
420
  *
429
421
  * @returns {string} The data id.
422
+ * @deprecated Since v0.37, please use via app.getDataController.
430
423
  */
431
424
  getNextDataId(): string;
432
425
  /**
@@ -435,6 +428,7 @@ export declare class App {
435
428
  * @param {string} dataId The data id.
436
429
  * @param {DicomData} data The new data.
437
430
  * @returns {boolean} False if the data cannot be added.
431
+ * @deprecated Since v0.37, please use via app.getDataController.
438
432
  */
439
433
  addData(dataId: string, data: DicomData): boolean;
440
434
  /**
@@ -442,12 +436,14 @@ export declare class App {
442
436
  *
443
437
  * @param {string} dataId The data id.
444
438
  * @returns {Record<string, DataElement>|undefined} The list of meta data.
439
+ * @deprecated Since v0.37, please use via app.getDataController.
445
440
  */
446
441
  getMetaData(dataId: string): Record<string, DataElement> | undefined;
447
442
  /**
448
443
  * Get the list of ids in the data storage.
449
444
  *
450
445
  * @returns {string[]} The list of data ids.
446
+ * @deprecated Since v0.37, please use via app.getDataController.
451
447
  */
452
448
  getDataIds(): string[];
453
449
  /**
@@ -455,6 +451,7 @@ export declare class App {
455
451
  *
456
452
  * @param {string[]} uids A list of UIDs.
457
453
  * @returns {string[]} The list of dataIds that contain the UIDs.
454
+ * @deprecated Since v0.37, please use via app.getDataController.
458
455
  */
459
456
  getDataIdsFromSopUids(uids: string[]): string[];
460
457
  /**
@@ -462,6 +459,7 @@ export declare class App {
462
459
  *
463
460
  * @param {string} uid The SeriesInstanceUID.
464
461
  * @returns {string} The data id.
462
+ * @deprecated Since v0.37, please use via app.getDataController.
465
463
  */
466
464
  getDataIdFromSeriesUid(uid: string): string;
467
465
  /**
@@ -485,18 +483,21 @@ export declare class App {
485
483
  * Get the active layer group scale on top of the base scale.
486
484
  *
487
485
  * @returns {Scalar3D} The scale as {x,y,z}.
486
+ * @deprecated Since v0.37, please access from the active layer group.
488
487
  */
489
488
  getAddedScale(): Scalar3D;
490
489
  /**
491
490
  * Get the base scale of the active layer group.
492
491
  *
493
492
  * @returns {Scalar3D} The scale as {x,y,z}.
493
+ * @deprecated Since v0.37, please access from the active layer group.
494
494
  */
495
495
  getBaseScale(): Scalar3D;
496
496
  /**
497
497
  * Get the layer offset of the active layer group.
498
498
  *
499
499
  * @returns {Scalar3D} The offset as {x,y,z}.
500
+ * @deprecated Since v0.37, please access from the active layer group.
500
501
  */
501
502
  getOffset(): Scalar3D;
502
503
  /**
@@ -505,17 +506,33 @@ export declare class App {
505
506
  * @returns {ToolboxController} The controller.
506
507
  */
507
508
  getToolboxController(): ToolboxController;
509
+ /**
510
+ * Get the stage controller.
511
+ *
512
+ * @returns {StageController} The stage controller.
513
+ */
514
+ getStageController(): StageController;
515
+ /**
516
+ * Get the undo controller.
517
+ *
518
+ * @returns {UndoController} The undo controller.
519
+ */
520
+ getUndoController(): UndoController;
508
521
  /**
509
522
  * Get the active layer group.
510
523
  * The layer is available after the first loaded item.
511
524
  *
512
525
  * @returns {LayerGroup|undefined} The layer group.
526
+ * @deprecated Since v0.37, use
527
+ * `app.getStageController().getActiveLayerGroup()` instead.
513
528
  */
514
529
  getActiveLayerGroup(): LayerGroup | undefined;
515
530
  /**
516
531
  * Set the active layer group.
517
532
  *
518
533
  * @param {number} index The layer group index.
534
+ * @deprecated Since v0.37, use
535
+ * `app.getStageController().setActiveLayerGroup()` instead.
519
536
  */
520
537
  setActiveLayerGroup(index: number): void;
521
538
  /**
@@ -524,6 +541,8 @@ export declare class App {
524
541
  *
525
542
  * @param {string} dataId The data id.
526
543
  * @returns {ViewLayer[]} The layers.
544
+ * @deprecated Since v0.37, use
545
+ * `app.getStageController().getViewLayersByDataId()` instead.
527
546
  */
528
547
  getViewLayersByDataId(dataId: string): ViewLayer[];
529
548
  /**
@@ -534,6 +553,8 @@ export declare class App {
534
553
  * returns all view layers.
535
554
  * @returns {ViewLayer[]} The layers that
536
555
  * satisfy the callbackFn.
556
+ * @deprecated Since v0.37, use
557
+ * `app.getStageController().getViewLayers()` instead.
537
558
  */
538
559
  getViewLayers(callbackFn?: Function): ViewLayer[];
539
560
  /**
@@ -542,6 +563,8 @@ export declare class App {
542
563
  *
543
564
  * @param {string} dataId The data id.
544
565
  * @returns {DrawLayer[]} The layers.
566
+ * @deprecated Since v0.37, use
567
+ * `app.getStageController().getDrawLayersByDataId()` instead.
545
568
  */
546
569
  getDrawLayersByDataId(dataId: string): DrawLayer[];
547
570
  /**
@@ -552,6 +575,8 @@ export declare class App {
552
575
  * returns all draw layers.
553
576
  * @returns {DrawLayer[]} The layers that
554
577
  * satisfy the callbackFn.
578
+ * @deprecated Since v0.37, use
579
+ * `app.getStageController().getDrawLayers()` instead.
555
580
  */
556
581
  getDrawLayers(callbackFn?: Function): DrawLayer[];
557
582
  /**
@@ -560,12 +585,16 @@ export declare class App {
560
585
  *
561
586
  * @param {string} divId The div id.
562
587
  * @returns {LayerGroup|undefined} The layer group.
588
+ * @deprecated Since v0.37, use
589
+ * `app.getStageController().getLayerGroupByDivId()` instead.
563
590
  */
564
591
  getLayerGroupByDivId(divId: string): LayerGroup | undefined;
565
592
  /**
566
593
  * Get the number of layer groups.
567
594
  *
568
595
  * @returns {number} The number of groups.
596
+ * @deprecated Since v0.37, use
597
+ * `app.getStageController().getNumberOfLayerGroups()` instead.
569
598
  */
570
599
  getNumberOfLayerGroups(): number;
571
600
  /**
@@ -579,6 +608,7 @@ export declare class App {
579
608
  *
580
609
  * @param {Command} cmd The command to add.
581
610
  * @fires UndoStack#undoadd
611
+ * @deprecated Since v0.37, please use via app.getUndoController.
582
612
  * @function
583
613
  */
584
614
  addToUndoStack: (cmd: Command) => void;
@@ -588,6 +618,7 @@ export declare class App {
588
618
  * @param {string} name The name of the command to remove.
589
619
  * @returns {boolean} True if the command was found and removed.
590
620
  * @fires UndoStack#undoremove
621
+ * @deprecated Since v0.37, please use via app.getUndoController.
591
622
  * @function
592
623
  */
593
624
  removeFromUndoStack: (name: string) => boolean;
@@ -616,7 +647,7 @@ export declare class App {
616
647
  * button.disabled = false;
617
648
  * button.onclick = function () {
618
649
  * // render data #0
619
- * app.render(0);
650
+ * app.getStageController().render(0);
620
651
  * };
621
652
  * });
622
653
  * // load dicom data
@@ -637,28 +668,114 @@ export declare class App {
637
668
  resetLayout(): void;
638
669
  /**
639
670
  * Reset the zoom and pan of the stage.
671
+ *
672
+ * @deprecated Since v0.37, use
673
+ * `app.getStageController().resetZoomPan()` instead.
640
674
  */
641
675
  resetZoomPan(): void;
642
676
  /**
643
677
  * Reset the position and window level of the stage.
678
+ *
679
+ * @deprecated Since v0.37, use
680
+ * `app.getStageController().resetViews()` instead.
644
681
  */
645
682
  resetViews(): void;
646
683
  /**
647
- * Add an event listener to this class.
684
+ * Load start event.
648
685
  *
649
- * @param {string} type The event type.
650
- * @param {Function} callback The function associated with the provided
651
- * event type, will be called with the fired event.
686
+ * @event App#loadstart
687
+ * @type {CustomEvent}
688
+ * @property {object} detail The event detail.
689
+ * @property {string} detail.dataid The data id.
690
+ * @property {string} detail.loadtype The load type: image or state.
691
+ * @property {*} detail.source The load source: string for an url,
692
+ * File for a file.
652
693
  */
653
- addEventListener(type: string, callback: Function): void;
654
694
  /**
655
- * Remove an event listener from this class.
695
+ * Load progress event.
656
696
  *
657
- * @param {string} type The event type.
658
- * @param {Function} callback The function associated with the provided
659
- * event type.
697
+ * @event App#loadprogress
698
+ * @type {CustomEvent}
699
+ * @property {object} detail The event detail.
700
+ * @property {string} detail.dataid The data id.
701
+ * @property {string} detail.loadtype The load type: image or state.
702
+ * @property {*} detail.source The load source: string for an url,
703
+ * File for a file.
704
+ * @property {number} detail.loaded The loaded percentage.
705
+ * @property {number} detail.total The total percentage.
706
+ */
707
+ /**
708
+ * Load item event: fired when an item has been successfully loaded.
709
+ *
710
+ * @event App#loaditem
711
+ * @type {CustomEvent}
712
+ * @property {object} detail The event detail.
713
+ * @property {string} detail.dataid The data id.
714
+ * @property {string} detail.loadtype The load type: image or state.
715
+ * @property {*} detail.source The load source: string for an url,
716
+ * File for a file.
717
+ * @property {object} detail.data The loaded meta data.
718
+ * @property {boolean} detail.isfirstitem True if the item is the first
719
+ * one loaded for the data id.
720
+ */
721
+ /**
722
+ * Load event: fired when a load finishes successfully.
723
+ *
724
+ * @event App#load
725
+ * @type {CustomEvent}
726
+ * @property {object} detail The event detail.
727
+ * @property {string} detail.dataid The data id.
728
+ * @property {string} detail.loadtype The load type: image or state.
729
+ * @property {*} detail.source The load source: string for an url,
730
+ * File for a file.
731
+ */
732
+ /**
733
+ * Load end event: fired when the load finishes,
734
+ * successfully or not.
735
+ *
736
+ * @event App#loadend
737
+ * @type {CustomEvent}
738
+ * @property {object} detail The event detail.
739
+ * @property {string} detail.dataid The data id.
740
+ * @property {string} detail.loadtype The load type: image or state.
741
+ * @property {*} detail.source The load source: string for an url,
742
+ * File for a file.
743
+ */
744
+ /**
745
+ * Load error event.
746
+ *
747
+ * @event App#error
748
+ * @type {CustomEvent}
749
+ * @property {object} detail The event detail.
750
+ * @property {string} detail.dataid The data id.
751
+ * @property {string} detail.loadtype The load type: image or state.
752
+ * @property {*} detail.source The load source: string for an url,
753
+ * File for a file.
754
+ * @property {object} detail.error The error.
755
+ * @property {object} detail.target The event target.
756
+ */
757
+ /**
758
+ * Load timeout event.
759
+ *
760
+ * @event App#timeout
761
+ * @type {CustomEvent}
762
+ * @property {object} detail The event detail.
763
+ * @property {string} detail.dataid The data id.
764
+ * @property {string} detail.loadtype The load type: image or state.
765
+ * @property {*} detail.source The load source: an url as a string.
766
+ * @property {object} detail.target The event target.
767
+ */
768
+ /**
769
+ * Load abort event.
770
+ *
771
+ * @event App#abort
772
+ * @type {CustomEvent}
773
+ * @property {object} detail The event detail.
774
+ * @property {string} detail.dataid The data id.
775
+ * @property {string} detail.loadtype The load type: image or state.
776
+ * @property {*} detail.source The load source: string for an url,
777
+ * File for a file.
660
778
  */
661
- removeEventListener(type: string, callback: Function): void;
662
779
  /**
663
780
  * Load a list of files. Can be image files or a state file.
664
781
  *
@@ -729,6 +846,9 @@ export declare class App {
729
846
  /**
730
847
  * Fit the display to the data of each layer group.
731
848
  * To be called once the image is loaded.
849
+ *
850
+ * @deprecated Since v0.37, use
851
+ * `app.getStageController().fitToContainer()` instead.
732
852
  */
733
853
  fitToContainer(): void;
734
854
  /**
@@ -743,6 +863,8 @@ export declare class App {
743
863
  * Set the imageSmoothing flag value. Default is false.
744
864
  *
745
865
  * @param {boolean} flag True to enable smoothing.
866
+ * @deprecated Since v0.37, use
867
+ * `app.getStageController().setImageSmoothing()` instead.
746
868
  */
747
869
  setImageSmoothing(flag: boolean): void;
748
870
  /**
@@ -752,24 +874,29 @@ export declare class App {
752
874
  * @param {boolean} [excludeStarConfig] Exclude the star config
753
875
  * (default to false).
754
876
  * @returns {ViewConfig[]} The list of associated configs.
877
+ * @deprecated Since v0.37, use
878
+ * `app.getStageController().getViewConfigs()` instead.
755
879
  */
756
880
  getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
757
881
  /**
758
- * Get the layer group configuration for a data id and group
759
- * div id.
882
+ * Get the layer group configuration for a data id and group div id.
760
883
  *
761
884
  * @param {string} dataId The data id.
762
885
  * @param {string} groupDivId The layer group div id.
763
886
  * @param {boolean} [excludeStarConfig] Exclude the star config
764
887
  * (default to false).
765
888
  * @returns {ViewConfig|undefined} The associated config.
889
+ * @deprecated Since v0.37, use
890
+ * `app.getStageController().getViewConfig()` instead.
766
891
  */
767
892
  getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
768
893
  /**
769
894
  * Get the data view config.
770
- * Carefull, returns a reference, do not modify without resetting.
895
+ * Careful, returns a reference; do not modify without resetting.
771
896
  *
772
897
  * @returns {Record<string, ViewConfig[]>} The configuration list.
898
+ * @deprecated Since v0.37, use
899
+ * `app.getStageController().getDataViewConfigs()` instead.
773
900
  */
774
901
  getDataViewConfigs(): Record<string, ViewConfig[]>;
775
902
  /**
@@ -777,6 +904,8 @@ export declare class App {
777
904
  * Resets the stage and recreates all the views.
778
905
  *
779
906
  * @param {Record<string, ViewConfig[]>} configs The configuration list.
907
+ * @deprecated Since v0.37, use
908
+ * `app.getStageController().setDataViewConfigs()` instead.
780
909
  */
781
910
  setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
782
911
  /**
@@ -786,6 +915,8 @@ export declare class App {
786
915
  * @param {ViewConfig} config The view configuration.
787
916
  * @param {boolean} [doRender] Render data after configuration
788
917
  * add. Defaults to true.
918
+ * @deprecated Since v0.37, use
919
+ * `app.getStageController().addDataViewConfig()` instead.
789
920
  */
790
921
  addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
791
922
  /**
@@ -795,6 +926,8 @@ export declare class App {
795
926
  *
796
927
  * @param {string} dataId The data id.
797
928
  * @param {string} divId The div id.
929
+ * @deprecated Since v0.37, use
930
+ * `app.getStageController().removeDataViewConfig()` instead.
798
931
  */
799
932
  removeDataViewConfig(dataId: string, divId: string): void;
800
933
  /**
@@ -804,6 +937,8 @@ export declare class App {
804
937
  * @param {string} dataId The data id.
805
938
  * @param {string} divId The div id.
806
939
  * @param {ViewConfig} config The view configuration.
940
+ * @deprecated Since v0.37, use
941
+ * `app.getStageController().updateDataViewConfig()` instead.
807
942
  */
808
943
  updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
809
944
  /**
@@ -817,6 +952,8 @@ export declare class App {
817
952
  *
818
953
  * @param {string} dataId The data id to render.
819
954
  * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
955
+ * @deprecated Since v0.37, use
956
+ * `app.getStageController().render()` instead.
820
957
  */
821
958
  render(dataId: string, viewConfigs?: ViewConfig[]): void;
822
959
  /**
@@ -825,6 +962,7 @@ export declare class App {
825
962
  * @param {number} step The step to add to the current zoom.
826
963
  * @param {number} cx The zoom center X coordinate.
827
964
  * @param {number} cy The zoom center Y coordinate.
965
+ * @deprecated Since v0.37, please access from the active layer group.
828
966
  */
829
967
  zoom(step: number, cx: number, cy: number): void;
830
968
  /**
@@ -832,6 +970,7 @@ export declare class App {
832
970
  *
833
971
  * @param {number} tx The translation along X.
834
972
  * @param {number} ty The translation along Y.
973
+ * @deprecated Since v0.37, please access from the active layer group.
835
974
  */
836
975
  translate(tx: number, ty: number): void;
837
976
  /**
@@ -892,11 +1031,12 @@ export declare class App {
892
1031
  /**
893
1032
  * Key down callback. Meant to be used in tools.
894
1033
  *
895
- * @param {KeyboardEvent} event The key down event.
1034
+ * @param {object} event The KeyboardEvent down event
1035
+ * augmented with a context.
896
1036
  * @fires App#keydown
897
1037
  * @function
898
1038
  */
899
- onKeydown: (event: KeyboardEvent) => void;
1039
+ onKeydown: (event: object) => void;
900
1040
  /**
901
1041
  * Key down event handler example.
902
1042
  * - CRTL-Z: undo,
@@ -954,24 +1094,28 @@ export declare class App {
954
1094
  * Undo the last action.
955
1095
  *
956
1096
  * @fires UndoStack#undo
1097
+ * @deprecated Since v0.37, please use via app.getUndoController.
957
1098
  */
958
1099
  undo(): void;
959
1100
  /**
960
1101
  * Redo the last action.
961
1102
  *
962
1103
  * @fires UndoStack#redo
1104
+ * @deprecated Since v0.37, please use via app.getUndoController.
963
1105
  */
964
1106
  redo(): void;
965
1107
  /**
966
1108
  * Get the undo stack size.
967
1109
  *
968
1110
  * @returns {number} The size of the stack.
1111
+ * @deprecated Since v0.37, please use via app.getUndoController.
969
1112
  */
970
1113
  getStackSize(): number;
971
1114
  /**
972
1115
  * Get the current undo stack index.
973
1116
  *
974
1117
  * @returns {number} The stack index.
1118
+ * @deprecated Since v0.37, please use via app.getUndoController.
975
1119
  */
976
1120
  getCurrentStackIndex(): number;
977
1121
  /**
@@ -1003,13 +1147,6 @@ export declare class App {
1003
1147
  * @param {string} refDataId The reference data id.
1004
1148
  */
1005
1149
  addAndRenderAnnotationData(data: DicomData, divId: string, refDataId: string): void;
1006
- /**
1007
- * Add a draw layer.
1008
- *
1009
- * @param {string} dataId The data id.
1010
- * @param {ViewConfig} viewConfig The data view config.
1011
- */
1012
- addDrawLayer(dataId: string, viewConfig: ViewConfig): void;
1013
1150
  #private;
1014
1151
  }
1015
1152
 
@@ -1088,6 +1225,23 @@ export declare class BooleanResult {
1088
1225
  message: string | undefined;
1089
1226
  }
1090
1227
 
1228
+ /**
1229
+ * Extract polygon contours from a mask slice using Moore neighborhood tracing.
1230
+ * Returns one polygon per connected region with the given segment value.
1231
+ *
1232
+ * @param {Uint8Array} buffer The mask buffer (all slices).
1233
+ * @param {number} sliceOffset Byte offset of the slice in buffer.
1234
+ * @param {number} width Slice width in pixels.
1235
+ * @param {number} height Slice height in pixels.
1236
+ * @param {number} value Segment value to trace.
1237
+ * @returns {Array.<Array.<{x: number, y: number}>>} One polygon per
1238
+ * connected region.
1239
+ */
1240
+ export declare function bufferToPolygons(buffer: Uint8Array, sliceOffset: number, width: number, height: number, value: number): Array<Array<{
1241
+ x: number;
1242
+ y: number;
1243
+ }>>;
1244
+
1091
1245
  /**
1092
1246
  * Build a multipart message.
1093
1247
  *
@@ -1226,9 +1380,9 @@ export declare class Circle {
1226
1380
  * @param {Index} index The index at which to get the
1227
1381
  * image values.
1228
1382
  * @param {string[]} flags A list of stat values to calculate.
1229
- * @returns {Record<string, Value>} A quantification object.
1383
+ * @returns {Record<string, NumberValue>} A quantification object.
1230
1384
  */
1231
- quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, Value>;
1385
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
1232
1386
  #private;
1233
1387
  }
1234
1388
 
@@ -1318,6 +1472,112 @@ export declare namespace custom {
1318
1472
  let getTagPixelUnit: any;
1319
1473
  }
1320
1474
 
1475
+ /**
1476
+ * DicomData controller.
1477
+ */
1478
+ export declare class DataController extends EventTarget {
1479
+ /**
1480
+ * Get the next data id.
1481
+ *
1482
+ * @returns {string} The data id.
1483
+ */
1484
+ getNextDataId(): string;
1485
+ /**
1486
+ * Get the list of ids in the data storage.
1487
+ *
1488
+ * @returns {string[]} The list of data ids.
1489
+ */
1490
+ getDataIds(): string[];
1491
+ /**
1492
+ * Reset the class: empty the data storage.
1493
+ */
1494
+ reset(): void;
1495
+ /**
1496
+ * Get a data at a given index.
1497
+ *
1498
+ * @param {string} dataId The data id.
1499
+ * @returns {DicomData|undefined} The DICOM data.
1500
+ */
1501
+ get(dataId: string): DicomData | undefined;
1502
+ /**
1503
+ * Get the list of dataIds that contain the input UIDs.
1504
+ *
1505
+ * @param {string[]} uids A list of UIDs.
1506
+ * @returns {string[]} The list of dataIds that contain the UIDs.
1507
+ */
1508
+ getDataIdsFromSopUids(uids: string[]): string[];
1509
+ /**
1510
+ * Get the first data id with the given SeriesInstanceUID.
1511
+ *
1512
+ * @param {string} uid The SeriesInstanceUID.
1513
+ * @returns {string} The data id.
1514
+ */
1515
+ getDataIdFromSeriesUid(uid: string): string;
1516
+ /**
1517
+ * Set the image at a given index.
1518
+ *
1519
+ * @param {string} dataId The data id.
1520
+ * @param {Image} image The image to set.
1521
+ */
1522
+ setImage(dataId: string, image: Image_2): void;
1523
+ /**
1524
+ * Add a new data.
1525
+ *
1526
+ * @param {string} dataId The data id.
1527
+ * @param {DicomData} data The data.
1528
+ * @returns {boolean} False if the data cannot be added.
1529
+ */
1530
+ add(dataId: string, data: DicomData): boolean;
1531
+ /**
1532
+ * Remove a data from the list.
1533
+ *
1534
+ * @param {string} dataId The data id.
1535
+ */
1536
+ remove(dataId: string): void;
1537
+ /**
1538
+ * Stash a data from the list.
1539
+ *
1540
+ * @param {string} dataId The data id.
1541
+ */
1542
+ stash(dataId: string): void;
1543
+ /**
1544
+ * Unstash a data from the list.
1545
+ *
1546
+ * @param {string} dataId The data id.
1547
+ */
1548
+ unstash(dataId: string): void;
1549
+ /**
1550
+ * Get the list of ids in the stashed data storage.
1551
+ *
1552
+ * @returns {string[]} The list of data ids.
1553
+ */
1554
+ getStashedDataIds(): string[];
1555
+ /**
1556
+ * Get a stashed data at a given index.
1557
+ *
1558
+ * @param {string} dataId The data id.
1559
+ * @returns {DicomData|undefined} The DICOM data.
1560
+ */
1561
+ getStashed(dataId: string): DicomData | undefined;
1562
+ /**
1563
+ * Update the current data.
1564
+ *
1565
+ * @param {string} dataId The data id.
1566
+ * @param {DicomData} data The data.
1567
+ */
1568
+ update(dataId: string, data: DicomData): void;
1569
+ /**
1570
+ * Mark a data a complete (fully loaded).
1571
+ *
1572
+ * @param {string} dataId The data id.
1573
+ * @returns {{imageHasChanged}} An object with an imageHasChanged property.
1574
+ */
1575
+ markDataAsComplete(dataId: string): {
1576
+ imageHasChanged: any;
1577
+ };
1578
+ #private;
1579
+ }
1580
+
1321
1581
  /**
1322
1582
  * @import {Tag} from './dicomTag.js';
1323
1583
  */
@@ -1430,7 +1690,7 @@ export declare class DeleteSegmentCommand extends Command {
1430
1690
 
1431
1691
  /**
1432
1692
  * @import {Point} from '../math/point.js';
1433
- * @import {Value} from '../math/value.js';
1693
+ * @import {NumberValue} from '../math/number.js';
1434
1694
  */
1435
1695
  /**
1436
1696
  * Diameter type.
@@ -1439,9 +1699,9 @@ export declare class Diameter {
1439
1699
  /**
1440
1700
  * The scaled diameter value.
1441
1701
  *
1442
- * @type {Value}
1702
+ * @type {NumberValue}
1443
1703
  */
1444
- diameter: Value;
1704
+ diameter: NumberValue;
1445
1705
  /**
1446
1706
  * The offset of the pixel at the start
1447
1707
  * of the line used to calculate this diameter.
@@ -1840,15 +2100,42 @@ export declare class DrawBrushCommand extends Command {
1840
2100
  #private;
1841
2101
  }
1842
2102
 
2103
+ /**
2104
+ * @import {Image} from '../image/image.js';
2105
+ */
1843
2106
  export declare class DrawBrushCommandProperties {
1844
- mask: any;
1845
- dataId: any;
1846
- offsetsLists: any;
1847
- mode: any;
1848
- segmentNumber: any;
1849
- srclayerid: any;
1850
- originalValuesLists: any;
1851
- isSilent: any;
2107
+ /**
2108
+ * @type {Image}
2109
+ */
2110
+ mask: Image_2;
2111
+ /**
2112
+ * @type {string}
2113
+ */
2114
+ dataId: string;
2115
+ /**
2116
+ * @type {number[][]}
2117
+ */
2118
+ offsetsLists: number[][];
2119
+ /**
2120
+ * @type {string}
2121
+ */
2122
+ mode: string;
2123
+ /**
2124
+ * @type {number}
2125
+ */
2126
+ segmentNumber: number;
2127
+ /**
2128
+ * @type {string}
2129
+ */
2130
+ srclayerid: string;
2131
+ /**
2132
+ * @type {Array}
2133
+ */
2134
+ originalValuesLists: any[];
2135
+ /**
2136
+ * @type {boolean}
2137
+ */
2138
+ isSilent: boolean;
1852
2139
  }
1853
2140
 
1854
2141
  /**
@@ -1967,6 +2254,9 @@ export declare class DrawController {
1967
2254
  */
1968
2255
  /**
1969
2256
  * Draw layer.
2257
+ *
2258
+ * Not an EventTarget in order to forward native DOM events while
2259
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
1970
2260
  */
1971
2261
  export declare class DrawLayer {
1972
2262
  /**
@@ -2363,9 +2653,9 @@ export declare class Ellipse {
2363
2653
  * @param {Index} index The index at which to get the
2364
2654
  * image values.
2365
2655
  * @param {string[]} flags A list of stat values to calculate.
2366
- * @returns {Record<string, Value>} A quantification object.
2656
+ * @returns {Record<string, NumberValue>} A quantification object.
2367
2657
  */
2368
- quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, Value>;
2658
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
2369
2659
  #private;
2370
2660
  }
2371
2661
 
@@ -2613,6 +2903,13 @@ export declare class Geometry {
2613
2903
  */
2614
2904
  export declare function getAsSimpleElements(metaData: Record<string, DataElement>): Record<string, any>;
2615
2905
 
2906
+ /**
2907
+ * Get the default DICOM RT Structure Set tags as an object.
2908
+ *
2909
+ * @returns {object} The default tags.
2910
+ */
2911
+ export declare function getDefaultDicomRTStructJson(): object;
2912
+
2616
2913
  /**
2617
2914
  * Get the default DICOM seg tags as an object.
2618
2915
  *
@@ -2684,10 +2981,10 @@ export declare function getManufacturer(elements: Record<string, DataElement>):
2684
2981
  /**
2685
2982
  * Get the offset of an input mouse event.
2686
2983
  *
2687
- * @param {object} event The event to get the offset from.
2984
+ * @param {MouseEvent} event The event to get the offset from.
2688
2985
  * @returns {Point2D} The 2D point.
2689
2986
  */
2690
- export declare function getMousePoint(event: object): Point2D;
2987
+ export declare function getMousePoint(event: MouseEvent): Point2D;
2691
2988
 
2692
2989
  /**
2693
2990
  * Get the normalised manufacturer.
@@ -2733,6 +3030,19 @@ export declare function getRectangleIndices(center: Index, size: number[], dir:
2733
3030
  */
2734
3031
  export declare function getReferencedSeriesUID(dataElements: Record<string, DataElement>): string | undefined;
2735
3032
 
3033
+ /**
3034
+ * Get the referenced series UID from an RT Structure Set.
3035
+ *
3036
+ * Path: ReferencedFrameOfReferenceSequence (3006,0010) →
3037
+ * RTReferencedStudySequence (3006,0012) →
3038
+ * RTReferencedSeriesSequence (3006,0014) →
3039
+ * SeriesInstanceUID (0020,000E).
3040
+ *
3041
+ * @param {Record<string, DataElement>} dataElements The data elements.
3042
+ * @returns {string|undefined} The referenced series UID.
3043
+ */
3044
+ export declare function getReferencedSeriesUIDFromRTStruct(dataElements: Record<string, DataElement>): string | undefined;
3045
+
2736
3046
  /**
2737
3047
  * Get patient orientation label in the reverse direction.
2738
3048
  *
@@ -2741,6 +3051,14 @@ export declare function getReferencedSeriesUID(dataElements: Record<string, Data
2741
3051
  */
2742
3052
  export declare function getReverseOrientation(ori: string): string;
2743
3053
 
3054
+ /**
3055
+ * Get a list of {@link RTROI} objects from RTSTRUCT DICOM elements.
3056
+ *
3057
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
3058
+ * @returns {RTROI[]} The list of RT ROIs.
3059
+ */
3060
+ export declare function getRTStructFromElements(dataElements: Record<string, DataElement>): RTROI[];
3061
+
2744
3062
  /**
2745
3063
  * Get a segmentation DICOM code.
2746
3064
  *
@@ -2767,10 +3085,10 @@ export declare function getTagFromKey(key: string): Tag;
2767
3085
  /**
2768
3086
  * Get the offsets of an input touch event.
2769
3087
  *
2770
- * @param {object} event The event to get the offset from.
3088
+ * @param {TouchEvent} event The event to get the offset from.
2771
3089
  * @returns {Point2D[]} The array of points.
2772
3090
  */
2773
- export declare function getTouchPoints(event: object): Point2D[];
3091
+ export declare function getTouchPoints(event: TouchEvent): Point2D[];
2774
3092
 
2775
3093
  /**
2776
3094
  * Get the appropriate TypedArray in function of arguments.
@@ -2887,7 +3205,7 @@ export declare namespace i18n {
2887
3205
  * request.onload = onload;
2888
3206
  * request.send();
2889
3207
  */
2890
- declare class Image_2 {
3208
+ declare class Image_2 extends EventTarget {
2891
3209
  /**
2892
3210
  * @param {Geometry} geometry The geometry of the image.
2893
3211
  * @param {TypedArray} buffer The image data as a one dimensional buffer.
@@ -2906,6 +3224,29 @@ declare class Image_2 {
2906
3224
  * @returns {boolean} True if the data is complete.
2907
3225
  */
2908
3226
  getComplete(): boolean;
3227
+ /**
3228
+ * Set up a segment collection from the existing image buffer.
3229
+ * Used for brush-painted masks (not created via MaskFactory).
3230
+ */
3231
+ setupSegmentCollection(): void;
3232
+ /**
3233
+ * Set the segment collection.
3234
+ *
3235
+ * @param {SegmentCollection} collection The segment collection.
3236
+ */
3237
+ setSegmentCollection(collection: SegmentCollection): void;
3238
+ /**
3239
+ * Get the segment collection.
3240
+ *
3241
+ * @returns {SegmentCollection|undefined} The segment collection.
3242
+ */
3243
+ getSegmentCollection(): SegmentCollection | undefined;
3244
+ /**
3245
+ * Check whether the mask has overlapping segments.
3246
+ *
3247
+ * @returns {boolean} True if any two segments share at least one voxel.
3248
+ */
3249
+ getHasOverlap(): boolean;
2909
3250
  /**
2910
3251
  * Get the image UID at a given index.
2911
3252
  *
@@ -2966,6 +3307,18 @@ declare class Image_2 {
2966
3307
  * @returns {boolean} True if the data is monochrome.
2967
3308
  */
2968
3309
  isMonochrome(): boolean;
3310
+ /**
3311
+ * Check is the image is a mask.
3312
+ *
3313
+ * @returns {boolean} True if mask.
3314
+ */
3315
+ isMask(): boolean;
3316
+ /**
3317
+ * Get the UID of the series referenced by the mask, if any.
3318
+ *
3319
+ * @returns {string|undefined} The UID.
3320
+ */
3321
+ getMaskReferencedSeriesUID(): string | undefined;
2969
3322
  /**
2970
3323
  * Can the data be scrolled?
2971
3324
  *
@@ -3147,22 +3500,6 @@ declare class Image_2 {
3147
3500
  * @returns {Array} The histogram.
3148
3501
  */
3149
3502
  getHistogram(): any[];
3150
- /**
3151
- * Add an event listener to this class.
3152
- *
3153
- * @param {string} type The event type.
3154
- * @param {Function} callback The function associated with the provided
3155
- * event type, will be called with the fired event.
3156
- */
3157
- addEventListener(type: string, callback: Function): void;
3158
- /**
3159
- * Remove an event listener from this class.
3160
- *
3161
- * @param {string} type The event type.
3162
- * @param {Function} callback The function associated with the provided
3163
- * event type.
3164
- */
3165
- removeEventListener(type: string, callback: Function): void;
3166
3503
  /**
3167
3504
  * Set the inner buffer values at given offsets.
3168
3505
  *
@@ -3302,22 +3639,18 @@ declare class Image_2 {
3302
3639
  */
3303
3640
  initializeContour(): void;
3304
3641
  /**
3305
- * Get whether or not the contour buffer has been initialized.
3306
- *
3307
- * @returns {boolean} True if buffer has been initialized.
3308
- */
3309
- countourIsInitialized(): boolean;
3310
- /**
3311
- * Calculate the distance to the nearest border pixel.
3312
- * (or return the cached distance).
3642
+ * Get the image contour. Should only be available
3643
+ * for segmentation images, but can be initialized
3644
+ * for any Uint8Array image.
3313
3645
  *
3314
- * @param {number} index Index/offset of the pixel to check.
3315
- * @param {Matrix33} viewOrientation The orientation of the view.
3316
- * @returns {number} The distance to the nearest border pixel or 0.
3646
+ * @returns {ImageContour} The image contour.
3317
3647
  */
3318
- getContourDistance(index: number, viewOrientation: Matrix33): number;
3648
+ getContour(): ImageContour;
3319
3649
  /**
3320
3650
  * Recalculate labels.
3651
+ *
3652
+ * @fires Image#labelingstart
3653
+ * @fires Image#labelschanged
3321
3654
  */
3322
3655
  recalculateLabels(): void;
3323
3656
  /**
@@ -3344,44 +3677,102 @@ declare class Image_2 {
3344
3677
  export { Image_2 as Image }
3345
3678
 
3346
3679
  /**
3347
- * Immutable index.
3348
- * Warning: the input array is NOT cloned, modifying it will
3349
- * modify the index values.
3680
+ * Image contour buffer manager.
3681
+ * Caches per-pixel distance-to-border values for contour rendering.
3682
+ * Stores 3 distance values per pixel (one per orientation: x, y, z).
3350
3683
  */
3351
- export declare class Index {
3684
+ export declare class ImageContour {
3352
3685
  /**
3353
- * @param {number[]} values The index values.
3686
+ * Initialize the contour buffer.
3687
+ * Should be called on every segmentation image, or any image where
3688
+ * contour rendering needs to be supported.
3689
+ *
3690
+ * @param {Uint8Array} imageBuffer The image data buffer.
3691
+ * @param {Size} imageSize The image size.
3354
3692
  */
3355
- constructor(values: number[]);
3693
+ initialize(imageBuffer: Uint8Array, imageSize: Size): void;
3356
3694
  /**
3357
- * Get the index value at the given array index.
3695
+ * Get whether or not the contour buffer has been initialized.
3358
3696
  *
3359
- * @param {number} i The index to get.
3360
- * @returns {number|undefined} The value or undefined if not in range.
3697
+ * @returns {boolean} True if buffer has been initialized.
3361
3698
  */
3362
- get(i: number): number | undefined;
3699
+ isInitialized(): boolean;
3363
3700
  /**
3364
- * Get the length of the index.
3701
+ * Re-allocate contour buffer memory after an image buffer resize.
3702
+ * Updates the stored image buffer and size references.
3365
3703
  *
3366
- * @returns {number} The length.
3704
+ * @param {Uint8Array} imageBuffer The new image data buffer.
3705
+ * @param {Size} imageSize The new image size.
3367
3706
  */
3368
- length(): number;
3707
+ realloc(imageBuffer: Uint8Array, imageSize: Size): void;
3369
3708
  /**
3370
- * Get a string representation of the Index.
3709
+ * Shift contour buffer content to make room for an inserted slice.
3371
3710
  *
3372
- * @returns {string} The Index as a string.
3711
+ * @param {number} contourIndexOffset Start offset of the slice to shift.
3712
+ * @param {number} contourSliceSize Size of one contour slice.
3713
+ * @param {number} contourMaxOffset End offset of content to shift.
3373
3714
  */
3374
- toString(): string;
3715
+ shiftSlice(contourIndexOffset: number, contourSliceSize: number, contourMaxOffset: number): void;
3375
3716
  /**
3376
- * Get the values of this index.
3717
+ * Reset contour buffer for the values around an offset.
3718
+ * Prevents certain artifacts, especially at small brush sizes
3719
+ * and when erasing.
3377
3720
  *
3378
- * @returns {number[]} The array of values.
3721
+ * @param {number} offset The offset to reset.
3379
3722
  */
3380
- getValues(): number[];
3723
+ resetAroundOffset(offset: number): void;
3381
3724
  /**
3382
- * Check if the input index can be compared to this one.
3725
+ * Calculate the distance to the nearest border pixel
3726
+ * (or return the cached distance).
3727
+ * Returns 0 if the contour buffer is not initialized.
3383
3728
  *
3384
- * @param {Index} rhs The index to compare to.
3729
+ * @param {number} index Index/offset of the pixel to check.
3730
+ * @param {Matrix33} viewOrientation The orientation of the view.
3731
+ * @returns {number} The distance to the nearest border pixel or 0.
3732
+ */
3733
+ getDistance(index: number, viewOrientation: Matrix33): number;
3734
+ #private;
3735
+ }
3736
+
3737
+ /**
3738
+ * Immutable index.
3739
+ * Warning: the input array is NOT cloned, modifying it will
3740
+ * modify the index values.
3741
+ */
3742
+ export declare class Index {
3743
+ /**
3744
+ * @param {number[]} values The index values.
3745
+ */
3746
+ constructor(values: number[]);
3747
+ /**
3748
+ * Get the index value at the given array index.
3749
+ *
3750
+ * @param {number} i The index to get.
3751
+ * @returns {number|undefined} The value or undefined if not in range.
3752
+ */
3753
+ get(i: number): number | undefined;
3754
+ /**
3755
+ * Get the length of the index.
3756
+ *
3757
+ * @returns {number} The length.
3758
+ */
3759
+ length(): number;
3760
+ /**
3761
+ * Get a string representation of the Index.
3762
+ *
3763
+ * @returns {string} The Index as a string.
3764
+ */
3765
+ toString(): string;
3766
+ /**
3767
+ * Get the values of this index.
3768
+ *
3769
+ * @returns {number[]} The array of values.
3770
+ */
3771
+ getValues(): number[];
3772
+ /**
3773
+ * Check if the input index can be compared to this one.
3774
+ *
3775
+ * @param {Index} rhs The index to compare to.
3385
3776
  * @returns {boolean} True if both indices are comparable.
3386
3777
  */
3387
3778
  canCompare(rhs: Index): boolean;
@@ -3438,7 +3829,7 @@ export declare class Index {
3438
3829
  /**
3439
3830
  * DICOM Header info data.
3440
3831
  */
3441
- export declare class InfoData {
3832
+ export declare class InfoData extends EventTarget {
3442
3833
  /**
3443
3834
  * @param {App} app The associated application.
3444
3835
  * @param {string} dataId The associated data id.
@@ -3458,9 +3849,9 @@ export declare class InfoData {
3458
3849
  /**
3459
3850
  * Handle a changed slice event.
3460
3851
  *
3461
- * @param {object} event The slicechange event.
3852
+ * @param {CustomEvent} event The slicechange event.
3462
3853
  */
3463
- onSliceChange: (event: object) => void;
3854
+ onSliceChange: (event: CustomEvent) => void;
3464
3855
  /**
3465
3856
  * Is this class listening to app events.
3466
3857
  *
@@ -3475,22 +3866,6 @@ export declare class InfoData {
3475
3866
  * Toggle info listeners.
3476
3867
  */
3477
3868
  removeAppListeners(): void;
3478
- /**
3479
- * Add an event listener to this class.
3480
- *
3481
- * @param {string} type The event type.
3482
- * @param {object} callback The method associated with the provided
3483
- * event type, will be called with the fired event.
3484
- */
3485
- addEventListener(type: string, callback: object): void;
3486
- /**
3487
- * Remove an event listener from this class.
3488
- *
3489
- * @param {string} type The event type.
3490
- * @param {object} callback The method associated with the provided
3491
- * event type.
3492
- */
3493
- removeEventListener(type: string, callback: object): void;
3494
3869
  #private;
3495
3870
  }
3496
3871
 
@@ -3558,9 +3933,9 @@ export declare class Label {
3558
3933
  /**
3559
3934
  * The volume of the labeled segment.
3560
3935
  *
3561
- * @type {Value}
3936
+ * @type {NumberValue}
3562
3937
  */
3563
- volume: Value;
3938
+ volume: NumberValue;
3564
3939
  /**
3565
3940
  * The voxel count of the labeled segment.
3566
3941
  *
@@ -3576,9 +3951,9 @@ export declare class Label {
3576
3951
  /**
3577
3952
  * The scaled height of the segment.
3578
3953
  *
3579
- * @type {Value}
3954
+ * @type {NumberValue}
3580
3955
  */
3581
- height: Value;
3956
+ height: NumberValue;
3582
3957
  /**
3583
3958
  * The segment label id.
3584
3959
  *
@@ -3618,7 +3993,7 @@ export declare function labToUintLab(triplet: object): object;
3618
3993
  * - planePos = viewController.getOffset3DFromPlaneOffset(pos)
3619
3994
  * no need yet for a planePos to displayPos...
3620
3995
  */
3621
- export declare class LayerGroup {
3996
+ export declare class LayerGroup extends EventTarget {
3622
3997
  /**
3623
3998
  * @param {HTMLElement} containerDiv The associated HTML div.
3624
3999
  * @param {boolean} [withInfoLayer] Optional with info layer flag,
@@ -3925,10 +4300,10 @@ export declare class LayerGroup {
3925
4300
  /**
3926
4301
  * Update layers (but not the event source layer) to a position change.
3927
4302
  *
3928
- * @param {object} event The position change event.
4303
+ * @param {CustomEvent} event The position change event.
3929
4304
  * @function
3930
4305
  */
3931
- updateLayersToPositionChange: (event: object) => void;
4306
+ updateLayersToPositionChange: (event: CustomEvent) => void;
3932
4307
  /**
3933
4308
  * Calculate the div to world size ratio needed to fit
3934
4309
  * the largest data.
@@ -4004,22 +4379,6 @@ export declare class LayerGroup {
4004
4379
  * @param {boolean} flag Whether to display the layer or not.
4005
4380
  */
4006
4381
  display(flag: boolean): void;
4007
- /**
4008
- * Add an event listener to this class.
4009
- *
4010
- * @param {string} type The event type.
4011
- * @param {Function} callback The function associated with the provided
4012
- * event type, will be called with the fired event.
4013
- */
4014
- addEventListener(type: string, callback: Function): void;
4015
- /**
4016
- * Remove an event listener from this class.
4017
- *
4018
- * @param {string} type The event type.
4019
- * @param {Function} callback The function associated with the provided
4020
- * event type.
4021
- */
4022
- removeEventListener(type: string, callback: Function): void;
4023
4382
  #private;
4024
4383
  }
4025
4384
 
@@ -4094,15 +4453,13 @@ export declare class MaskFactory {
4094
4453
  * Get an {@link Image} object from the read DICOM file.
4095
4454
  *
4096
4455
  * @param {Record<string, DataElement>} dataElements The DICOM tags.
4097
- * @param {Uint8Array | Int8Array |
4098
- * Uint16Array | Int16Array |
4099
- * Uint32Array | Int32Array} pixelBuffer The pixel buffer.
4456
+ * @param {Uint8Array} pixelBuffer The pixel buffer.
4100
4457
  * @param {Image} [refImage] Reference image, code will use its
4101
4458
  * origins if present (best) or try to calculate them.
4102
4459
  * @returns {Image} A new Image.
4103
4460
  * @throws {Error} Error for missing or wrong data.
4104
4461
  */
4105
- create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array, refImage?: Image_2): Image_2;
4462
+ create(dataElements: Record<string, DataElement>, pixelBuffer: Uint8Array, refImage?: Image_2): Image_2;
4106
4463
  /**
4107
4464
  * Convert a mask image into a DICOM segmentation object.
4108
4465
  *
@@ -4392,6 +4749,15 @@ export declare class Matrix33 {
4392
4749
  * @returns {boolean} True if both matrices are similar.
4393
4750
  */
4394
4751
  isSimilar(rhs: Matrix33, tol?: number): boolean;
4752
+ /**
4753
+ * Check for Matrix33 similarity with progressive tolerance (up to 10*tol).
4754
+ *
4755
+ * @param {Matrix33} rhs The other matrix to compare to.
4756
+ * @param {number} [tol] Optional number comparison tolerance,
4757
+ * defaults to Number.EPSILON.
4758
+ * @returns {boolean} True if both matrices are similar.
4759
+ */
4760
+ isSimilarProgressive(rhs: Matrix33, tol?: number): boolean;
4395
4761
  /**
4396
4762
  * Get a string representation of the Matrix33.
4397
4763
  *
@@ -4495,7 +4861,7 @@ export declare namespace NormalisedManufacturers {
4495
4861
  }
4496
4862
 
4497
4863
  /**
4498
- * Number range.
4864
+ * Number range: [min, max].
4499
4865
  */
4500
4866
  export declare class NumberRange {
4501
4867
  /**
@@ -4513,6 +4879,20 @@ export declare class NumberRange {
4513
4879
  max: number;
4514
4880
  }
4515
4881
 
4882
+ /**
4883
+ * Class to store a number value and a unit.
4884
+ */
4885
+ export declare class NumberValue {
4886
+ /**
4887
+ * @type {number}
4888
+ */
4889
+ value: number;
4890
+ /**
4891
+ * @type {string|undefined}
4892
+ */
4893
+ unit: string | undefined;
4894
+ }
4895
+
4516
4896
  export declare namespace Orientation {
4517
4897
  let Axial: string;
4518
4898
  let Coronal: string;
@@ -5069,7 +5449,7 @@ export declare function precisionRound(number: number, precision: number): numbe
5069
5449
 
5070
5450
  /**
5071
5451
  * @import {Point2D} from '../math/point.js';
5072
- * @import {Value} from './value.js';
5452
+ * @import {NumberValue} from './number.js';
5073
5453
  * @import {ViewController} from '../app/viewController.js';
5074
5454
  */
5075
5455
  /**
@@ -5106,9 +5486,9 @@ export declare class Protractor {
5106
5486
  *
5107
5487
  * @param {ViewController} _viewController The associated view controller.
5108
5488
  * @param {string[]} _flags A list of stat values to calculate.
5109
- * @returns {Record<string, Value>} A quantification object.
5489
+ * @returns {Record<string, NumberValue>} A quantification object.
5110
5490
  */
5111
- quantify(_viewController: ViewController, _flags: string[]): Record<string, Value>;
5491
+ quantify(_viewController: ViewController, _flags: string[]): Record<string, NumberValue>;
5112
5492
  #private;
5113
5493
  }
5114
5494
 
@@ -5199,9 +5579,9 @@ export declare class Rectangle {
5199
5579
  * @param {Index} index The index at which to get the
5200
5580
  * image values.
5201
5581
  * @param {string[]} flags A list of stat values to calculate.
5202
- * @returns {Record<string, Value>} A quantification object.
5582
+ * @returns {Record<string, NumberValue>} A quantification object.
5203
5583
  */
5204
- quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, Value>;
5584
+ quantify(viewController: ViewController, index: Index, flags: string[]): Record<string, NumberValue>;
5205
5585
  #private;
5206
5586
  }
5207
5587
 
@@ -5360,6 +5740,112 @@ export declare class ROI {
5360
5740
  #private;
5361
5741
  }
5362
5742
 
5743
+ /**
5744
+ * An RT Region of Interest with its display colour and contours.
5745
+ */
5746
+ export declare class RTROI {
5747
+ /**
5748
+ * ROI number as stored in the DICOM file.
5749
+ *
5750
+ * @type {number}
5751
+ */
5752
+ number: number;
5753
+ /**
5754
+ * ROI name.
5755
+ *
5756
+ * @type {string}
5757
+ */
5758
+ name: string;
5759
+ /**
5760
+ * Display colour as {r, g, b} values in [0, 255].
5761
+ *
5762
+ * @type {{r: number, g: number, b: number}}
5763
+ */
5764
+ colour: {
5765
+ r: number;
5766
+ g: number;
5767
+ b: number;
5768
+ };
5769
+ /**
5770
+ * List of contours belonging to this ROI.
5771
+ *
5772
+ * @type {RTROIContour[]}
5773
+ */
5774
+ contours: RTROIContour[];
5775
+ }
5776
+
5777
+ /**
5778
+ * A single planar contour of an RT ROI.
5779
+ */
5780
+ export declare class RTROIContour {
5781
+ /**
5782
+ * Contour geometric type (e.g. 'CLOSED_PLANAR').
5783
+ *
5784
+ * @type {string}
5785
+ */
5786
+ type: string;
5787
+ /**
5788
+ * Flat array of 3D patient-space coordinates in mm:
5789
+ * [x0,y0,z0, x1,y1,z1, ...].
5790
+ *
5791
+ * @type {number[]}
5792
+ */
5793
+ points3D: number[];
5794
+ }
5795
+
5796
+ /**
5797
+ * {@link Image} factory for DICOM RT Structure Set (RTSTRUCT).
5798
+ *
5799
+ * Rasterizes ROI contour polygons into a PALETTE COLOR mask image using
5800
+ * the same geometry as the reference CT/MR image so that the result can
5801
+ * be rendered by the existing mask pipeline.
5802
+ */
5803
+ export declare class RtStructFactory {
5804
+ /**
5805
+ * Get a warning string if elements are not as expected.
5806
+ *
5807
+ * @returns {string|undefined} The warning.
5808
+ */
5809
+ getWarning(): string | undefined;
5810
+ /**
5811
+ * Check dicom elements.
5812
+ *
5813
+ * @param {Record<string, DataElement>} _dataElements The DICOM data elements.
5814
+ * @returns {string|undefined} A possible warning.
5815
+ */
5816
+ checkElements(_dataElements: Record<string, DataElement>): string | undefined;
5817
+ /**
5818
+ * Get a mask {@link Image} from RTSTRUCT DICOM elements.
5819
+ *
5820
+ * Contours are rasterized into a Uint8Array whose voxel values are
5821
+ * segment numbers (0 = background, 1..N = ROI index).
5822
+ * A PALETTE COLOR colour map maps each segment number to the ROI's
5823
+ * display colour.
5824
+ *
5825
+ * @param {Record<string, DataElement>} dataElements The DICOM data elements.
5826
+ * @param {Image} refImage The reference image (CT/MR) that was loaded first.
5827
+ * @returns {Image} The mask image.
5828
+ * @throws {Error} If the reference image geometry cannot be used.
5829
+ */
5830
+ create(dataElements: Record<string, DataElement>, refImage: Image_2): Image_2;
5831
+ /**
5832
+ * Convert a mask {@link Image} into DICOM RT Structure Set elements.
5833
+ *
5834
+ * Traces each segment's pixel regions per slice using Moore neighborhood
5835
+ * contour tracing, simplifies with Ramer-Douglas-Peucker, then maps the
5836
+ * 2D pixel coordinates back to 3D patient-space coordinates.
5837
+ *
5838
+ * @param {Image} image The mask image.
5839
+ * @param {MaskSegment[]} [segments] The mask segments; if omitted, taken
5840
+ * from image meta.
5841
+ * @param {Image} [sourceImage] Source image (provides StudyInstanceUID).
5842
+ * @param {Record<string, any>} [extraTags] Optional extra tags to merge.
5843
+ * @returns {Record<string, DataElement>} The DICOM data elements.
5844
+ */
5845
+ toDicom(image: Image_2, segments?: MaskSegment[], sourceImage?: Image_2, extraTags?: Record<string, any>): Record<string, DataElement>;
5846
+ #private;
5847
+ }
5848
+
5363
5849
  /**
5364
5850
  * @import {App} from '../app/application.js';
5365
5851
  */
@@ -5436,6 +5922,102 @@ export declare class Scalar3D {
5436
5922
  export declare class ScrollWheelBehavior extends WheelBehavior {
5437
5923
  }
5438
5924
 
5925
+ /**
5926
+ * Collection of mask segments: stores per-segment, per-slice pixel data
5927
+ * and segment metadata. Builds the combined label map on demand.
5928
+ * TODO: check if mergeable with MaskSegmentHelper.
5929
+ */
5930
+ export declare class SegmentCollection {
5931
+ /**
5932
+ * @param {Geometry} geometry The mask geometry, used to size the label map.
5933
+ */
5934
+ constructor(geometry: Geometry);
5935
+ /**
5936
+ * Get all the segments.
5937
+ *
5938
+ * @returns {Map<number, Map<number, Uint8Array>>} The segment buffers,
5939
+ * indexed by segment number and slice index.
5940
+ */
5941
+ getAll(): Map<number, Map<number, Uint8Array>>;
5942
+ /**
5943
+ * Set the label map directly.
5944
+ * Used when the buffer already exists, for brush-painted masks.
5945
+ *
5946
+ * @param {Uint8Array} buffer The label map buffer.
5947
+ */
5948
+ setLabelMap(buffer: Uint8Array): void;
5949
+ /**
5950
+ * Add pixel data for one DICOM frame to the appropriate segment and slice.
5951
+ * Allocates a Uint8Array(sliceSize) on first use for each
5952
+ * (segNumber, sliceIndex) pair; merges if the same pair appears again.
5953
+ *
5954
+ * @param {number} segNumber The segment number.
5955
+ * @param {Uint8Array} pixelBuffer The raw DICOM pixel buffer.
5956
+ * @param {number} frameOffset Offset of this frame within pixelBuffer.
5957
+ * @param {number} sliceIndex The slice index in the full label map geometry.
5958
+ * @param {number} sliceSize Number of pixels per slice (ncols * nrows).
5959
+ * @param {number} value The value to write for non-zero pixels.
5960
+ */
5961
+ addFrame(segNumber: number, pixelBuffer: Uint8Array, frameOffset: number, sliceIndex: number, sliceSize: number, value: number): void;
5962
+ /**
5963
+ * Build and return the combined label map (lazy cached).
5964
+ * Iterates segments in insertion order so lower segment numbers win
5965
+ * at overlapping positions. Sets the hasOverlap flag if any voxel
5966
+ * already carries a different segment's value.
5967
+ *
5968
+ * @returns {Uint8Array} The full-volume label map.
5969
+ */
5970
+ getLabelMap(): Uint8Array;
5971
+ /**
5972
+ * Check whether any two segments share at least one voxel.
5973
+ *
5974
+ * @returns {boolean} True if overlap was detected.
5975
+ */
5976
+ getHasOverlap(): boolean;
5977
+ /**
5978
+ * Get the segment buffers. Using input image and segments since they
5979
+ * could have been modified (for example by brush).
5980
+ *
5981
+ * When per-segment data is available (MaskFactory path), builds ROI buffers
5982
+ * directly from #segments so that overlap pixels for every segment are
5983
+ * included. Falls back to label-map reconstruction for masks created via
5984
+ * setupSegmentCollection (brush path), where #segments is empty and the
5985
+ * label map is the only source of truth.
5986
+ *
5987
+ * @param {MaskSegment[]} segments The mask segments.
5988
+ * @returns {Record<string, Record<number, Uint8Array>>} The segment buffers,
5989
+ * indexed by segment index (segment.number - 1) and slice index.
5990
+ */
5991
+ getSegmentBuffers(segments: MaskSegment[]): Record<string, Record<number, Uint8Array>>;
5992
+ /**
5993
+ * Get the union ImageContour for the current visibility state,
5994
+ * building it if the set of hidden segments has changed.
5995
+ *
5996
+ * @param {MaskSegmentViewHelper|undefined} segmentViewHelper
5997
+ * Hidden-segment tracker.
5998
+ * @param {Size} imageSize The image size.
5999
+ * @returns {ImageContour} The union ImageContour.
6000
+ */
6001
+ getOrBuildUnionContour(segmentViewHelper: MaskSegmentViewHelper | undefined, imageSize: Size): ImageContour;
6002
+ #private;
6003
+ }
6004
+
6005
+ /**
6006
+ * Simplify a polygon using the Ramer-Douglas-Peucker algorithm.
6007
+ * Ref: {@link https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm}.
6008
+ *
6009
+ * @param {Array.<{x: number, y: number}>} pts Input vertices.
6010
+ * @param {number} epsilon Max allowed deviation in pixels.
6011
+ * @returns {Array.<{x: number, y: number}>} Simplified vertices.
6012
+ */
6013
+ export declare function simplifyPolygon(pts: Array<{
6014
+ x: number;
6015
+ y: number;
6016
+ }>, epsilon: number): Array<{
6017
+ x: number;
6018
+ y: number;
6019
+ }>;
6020
+
5439
6021
  /**
5440
6022
  * @import {Matrix33} from '../math/matrix.js';
5441
6023
  * @import {Scalar2D} from '../math/scalar.js';
@@ -5629,6 +6211,249 @@ export declare class Spacing {
5629
6211
  */
5630
6212
  export declare function srgbToCielab(triplet: RGB): object;
5631
6213
 
6214
+ /**
6215
+ * Stage controller: manages the link between the data view configs
6216
+ * and the stage (layer groups, layers, rendering).
6217
+ */
6218
+ export declare class StageController extends EventTarget {
6219
+ /**
6220
+ * @param {DataController} dataController The data controller.
6221
+ * @param {object} options The app options.
6222
+ */
6223
+ constructor(dataController: DataController, options: object);
6224
+ /**
6225
+ * Set the toolbox controller.
6226
+ *
6227
+ * @param {ToolboxController} tc The toolbox controller.
6228
+ */
6229
+ setToolboxController(tc: ToolboxController): void;
6230
+ /**
6231
+ * Set the add-to-undo-stack callback.
6232
+ *
6233
+ * @param {Function} fn The callback.
6234
+ */
6235
+ setAddToUndoStack(fn: Function): void;
6236
+ /**
6237
+ * Set the info data getter callback.
6238
+ *
6239
+ * @param {Function} fn A function `(dataId) => InfoData`.
6240
+ */
6241
+ setGetInfoData(fn: Function): void;
6242
+ /**
6243
+ * Get the layer group configuration from a data id.
6244
+ *
6245
+ * @param {string} dataId The data id.
6246
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6247
+ * (default to false).
6248
+ * @returns {ViewConfig[]} The list of associated configs.
6249
+ */
6250
+ getViewConfigs(dataId: string, excludeStarConfig?: boolean): ViewConfig[];
6251
+ /**
6252
+ * Get the layer group configuration for a data id and group div id.
6253
+ *
6254
+ * @param {string} dataId The data id.
6255
+ * @param {string} groupDivId The layer group div id.
6256
+ * @param {boolean} [excludeStarConfig] Exclude the star config
6257
+ * (default to false).
6258
+ * @returns {ViewConfig|undefined} The associated config.
6259
+ */
6260
+ getViewConfig(dataId: string, groupDivId: string, excludeStarConfig?: boolean): ViewConfig | undefined;
6261
+ /**
6262
+ * Get the data view config.
6263
+ * Careful, returns a reference; do not modify without resetting.
6264
+ *
6265
+ * @returns {Record<string, ViewConfig[]>} The configuration list.
6266
+ */
6267
+ getDataViewConfigs(): Record<string, ViewConfig[]>;
6268
+ /**
6269
+ * Set the data view configuration.
6270
+ * Resets the stage and recreates all the views.
6271
+ *
6272
+ * @param {Record<string, ViewConfig[]>} configs The configuration list.
6273
+ */
6274
+ setDataViewConfigs(configs: Record<string, ViewConfig[]>): void;
6275
+ /**
6276
+ * Add a data view config.
6277
+ *
6278
+ * @param {string} dataId The data id.
6279
+ * @param {ViewConfig} config The view configuration.
6280
+ * @param {boolean} [doRender] Render data after configuration
6281
+ * add. Defaults to true.
6282
+ */
6283
+ addDataViewConfig(dataId: string, config: ViewConfig, doRender?: boolean): void;
6284
+ /**
6285
+ * Remove a data view config.
6286
+ * Removes the associated layer if found, removes
6287
+ * the layer group if empty.
6288
+ *
6289
+ * @param {string} dataId The data id.
6290
+ * @param {string} divId The div id.
6291
+ */
6292
+ removeDataViewConfig(dataId: string, divId: string): void;
6293
+ /**
6294
+ * Update an existing data view config.
6295
+ * Removes and re-creates the layer if found.
6296
+ *
6297
+ * @param {string} dataId The data id.
6298
+ * @param {string} divId The div id.
6299
+ * @param {ViewConfig} config The view configuration.
6300
+ */
6301
+ updateDataViewConfig(dataId: string, divId: string, config: ViewConfig): void;
6302
+ /**
6303
+ * Get the active layer group.
6304
+ *
6305
+ * @returns {LayerGroup|undefined} The layer group.
6306
+ */
6307
+ getActiveLayerGroup(): LayerGroup | undefined;
6308
+ /**
6309
+ * Set the active layer group.
6310
+ *
6311
+ * @param {number} index The layer group index.
6312
+ */
6313
+ setActiveLayerGroup(index: number): void;
6314
+ /**
6315
+ * Get a layer group by index.
6316
+ *
6317
+ * @param {number} index The index.
6318
+ * @returns {LayerGroup} The layer group.
6319
+ */
6320
+ getLayerGroup(index: number): LayerGroup;
6321
+ /**
6322
+ * Get the number of layer groups.
6323
+ *
6324
+ * @returns {number} The number of groups.
6325
+ */
6326
+ getNumberOfLayerGroups(): number;
6327
+ /**
6328
+ * Get the view layers associated to a data id.
6329
+ *
6330
+ * @param {string} dataId The data id.
6331
+ * @returns {ViewLayer[]} The layers.
6332
+ */
6333
+ getViewLayersByDataId(dataId: string): ViewLayer[];
6334
+ /**
6335
+ * Get a list of view layers according to an input callback function.
6336
+ *
6337
+ * @param {Function} [callbackFn] A function that takes
6338
+ * a ViewLayer as input and returns a boolean. If undefined,
6339
+ * returns all view layers.
6340
+ * @returns {ViewLayer[]} The layers that satisfy the callbackFn.
6341
+ */
6342
+ getViewLayers(callbackFn?: Function): ViewLayer[];
6343
+ /**
6344
+ * Get the draw layers associated to a data id.
6345
+ *
6346
+ * @param {string} dataId The data id.
6347
+ * @returns {DrawLayer[]} The layers.
6348
+ */
6349
+ getDrawLayersByDataId(dataId: string): DrawLayer[];
6350
+ /**
6351
+ * Get a list of draw layers according to an input callback function.
6352
+ *
6353
+ * @param {Function} [callbackFn] A function that takes
6354
+ * a DrawLayer as input and returns a boolean. If undefined,
6355
+ * returns all draw layers.
6356
+ * @returns {DrawLayer[]} The layers that satisfy the callbackFn.
6357
+ */
6358
+ getDrawLayers(callbackFn?: Function): DrawLayer[];
6359
+ /**
6360
+ * Get a layer group by div id.
6361
+ *
6362
+ * @param {string} divId The div id.
6363
+ * @returns {LayerGroup|undefined} The layer group.
6364
+ */
6365
+ getLayerGroupByDivId(divId: string): LayerGroup | undefined;
6366
+ /**
6367
+ * Get the active layer group scale on top of the base scale.
6368
+ *
6369
+ * @returns {Scalar3D} The scale as {x,y,z}.
6370
+ * @deprecated Since v0.37, please access from the active layer group.
6371
+ */
6372
+ getAddedScale(): Scalar3D;
6373
+ /**
6374
+ * Get the base scale of the active layer group.
6375
+ *
6376
+ * @returns {Scalar3D} The scale as {x,y,z}.
6377
+ * @deprecated Since v0.37, please access from the active layer group.
6378
+ */
6379
+ getBaseScale(): Scalar3D;
6380
+ /**
6381
+ * Get the layer offset of the active layer group.
6382
+ *
6383
+ * @returns {Scalar3D} The offset as {x,y,z}.
6384
+ * @deprecated Since v0.37, please access from the active layer group.
6385
+ */
6386
+ getOffset(): Scalar3D;
6387
+ /**
6388
+ * Empty the stage (remove all layer groups).
6389
+ */
6390
+ empty(): void;
6391
+ /**
6392
+ * Remove layers for a specific data id.
6393
+ *
6394
+ * @param {string} dataId The data id.
6395
+ */
6396
+ removeLayersByDataId(dataId: string): void;
6397
+ /**
6398
+ * Set the layer groups binders.
6399
+ *
6400
+ * @param {object[]} instances Binder instances.
6401
+ */
6402
+ setBinders(instances: object[]): void;
6403
+ /**
6404
+ * Fit the display to the data of each layer group.
6405
+ */
6406
+ fitToContainer(): void;
6407
+ /**
6408
+ * Draw all layer groups.
6409
+ */
6410
+ draw(): void;
6411
+ /**
6412
+ * Reset zoom and pan of the stage.
6413
+ *
6414
+ * @deprecated Since v0.35, prefer resetZoomPan.
6415
+ */
6416
+ resetLayout(): void;
6417
+ /**
6418
+ * Reset the zoom and pan of the stage.
6419
+ */
6420
+ resetZoomPan(): void;
6421
+ /**
6422
+ * Reset the position and window level of the stage.
6423
+ */
6424
+ resetViews(): void;
6425
+ /**
6426
+ * Set the imageSmoothing flag value. Default is false.
6427
+ *
6428
+ * @param {boolean} flag True to enable smoothing.
6429
+ */
6430
+ setImageSmoothing(flag: boolean): void;
6431
+ /**
6432
+ * Zoom the layers of the active layer group.
6433
+ *
6434
+ * @param {number} step The step to add to the current zoom.
6435
+ * @param {number} cx The zoom center X coordinate.
6436
+ * @param {number} cy The zoom center Y coordinate.
6437
+ * @deprecated Since v0.37, please access from the active layer group.
6438
+ */
6439
+ zoom(step: number, cx: number, cy: number): void;
6440
+ /**
6441
+ * Apply a translation to the layers of the active layer group.
6442
+ *
6443
+ * @param {number} tx The translation along X.
6444
+ * @param {number} ty The translation along Y.
6445
+ */
6446
+ translate(tx: number, ty: number): void;
6447
+ /**
6448
+ * Render the current data.
6449
+ *
6450
+ * @param {string} dataId The data id to render.
6451
+ * @param {ViewConfig[]} [viewConfigs] The list of configs to render.
6452
+ */
6453
+ render(dataId: string, viewConfigs?: ViewConfig[]): void;
6454
+ #private;
6455
+ }
6456
+
5632
6457
  /**
5633
6458
  * @import {DataElement} from '../dicom/dataElement.js';
5634
6459
  */
@@ -5764,9 +6589,9 @@ export declare class ToolboxController {
5764
6589
  *
5765
6590
  * @param {string} eventType The event type, for example
5766
6591
  * mousedown, touchstart...
5767
- * @returns {Function} The event handler.
6592
+ * @returns {EventListener} The event handler.
5768
6593
  */
5769
- getSelectedToolEventHandler(eventType: string): Function;
6594
+ getSelectedToolEventHandler(eventType: string): EventListener;
5770
6595
  /**
5771
6596
  * Set the selected tool.
5772
6597
  *
@@ -5911,17 +6736,55 @@ export declare const toolList: Record<string, any>;
5911
6736
  export declare const toolOptions: Record<string, Record<string, any>>;
5912
6737
 
5913
6738
  /**
5914
- * Class to store a value and a unit.
6739
+ * Undo controller.
5915
6740
  */
5916
- export declare class Value {
6741
+ export declare class UndoController extends EventTarget {
5917
6742
  /**
5918
- * @type {number}
6743
+ * Add a command to the undo stack.
6744
+ *
6745
+ * @param {object} cmd The command to add.
6746
+ * @fires UndoStack#undoadd
6747
+ * @function
5919
6748
  */
5920
- value: number;
6749
+ addToUndoStack: (cmd: object) => void;
5921
6750
  /**
5922
- * @type {string|undefined}
6751
+ * Remove a command from the undo stack.
6752
+ *
6753
+ * @param {string} name The name of the command to remove.
6754
+ * @returns {boolean} True if the command was found and removed.
6755
+ * @fires UndoStack#undoremove
6756
+ * @function
5923
6757
  */
5924
- unit: string | undefined;
6758
+ removeFromUndoStack: (name: string) => boolean;
6759
+ /**
6760
+ * Undo the last command.
6761
+ *
6762
+ * @fires UndoStack#undo
6763
+ */
6764
+ undo(): void;
6765
+ /**
6766
+ * Redo the next command.
6767
+ *
6768
+ * @fires UndoStack#redo
6769
+ */
6770
+ redo(): void;
6771
+ /**
6772
+ * Get the undo stack size.
6773
+ *
6774
+ * @returns {number} The size of the stack.
6775
+ */
6776
+ getStackSize(): number;
6777
+ /**
6778
+ * Get the current undo stack index.
6779
+ *
6780
+ * @returns {number} The stack index.
6781
+ */
6782
+ getCurrentStackIndex(): number;
6783
+ /**
6784
+ * Reset the undo/redo history.
6785
+ */
6786
+ reset(): void;
6787
+ #private;
5925
6788
  }
5926
6789
 
5927
6790
  /**
@@ -6039,7 +6902,7 @@ export declare class Vector3D {
6039
6902
  * request.onload = onload;
6040
6903
  * request.send();
6041
6904
  */
6042
- export declare class View {
6905
+ export declare class View extends EventTarget {
6043
6906
  /**
6044
6907
  * @param {Image} image The associated image.
6045
6908
  */
@@ -6268,22 +7131,6 @@ export declare class View {
6268
7131
  * @param {boolean} [silent] Flag to launch events with skipGenerate.
6269
7132
  */
6270
7133
  setWindowLevelPresetById(id: number, silent?: boolean): void;
6271
- /**
6272
- * Add an event listener to this class.
6273
- *
6274
- * @param {string} type The event type.
6275
- * @param {Function} callback The function associated with the provided
6276
- * event type, will be called with the fired event.
6277
- */
6278
- addEventListener(type: string, callback: Function): void;
6279
- /**
6280
- * Remove an event listener from this class.
6281
- *
6282
- * @param {string} type The event type.
6283
- * @param {Function} callback The function associated with the provided
6284
- * event type.
6285
- */
6286
- removeEventListener(type: string, callback: Function): void;
6287
7134
  /**
6288
7135
  * Get the image window/level that covers the full data range.
6289
7136
  * Warning: uses the latest set rescale LUT or the default linear one.
@@ -6870,6 +7717,9 @@ export declare class ViewController {
6870
7717
  */
6871
7718
  /**
6872
7719
  * View layer.
7720
+ *
7721
+ * Not an EventTarget in order to forward native DOM events while
7722
+ * preserving `preventDefault()` for tools (see '#fireDomEvent').
6873
7723
  */
6874
7724
  export declare class ViewLayer {
6875
7725
  /**
@@ -6923,10 +7773,10 @@ export declare class ViewLayer {
6923
7773
  /**
6924
7774
  * Handle an image set event.
6925
7775
  *
6926
- * @param {object} event The event.
7776
+ * @param {CustomEvent} event The event.
6927
7777
  * @function
6928
7778
  */
6929
- onimageset: (event: object) => void;
7779
+ onimageset: (event: CustomEvent) => void;
6930
7780
  /**
6931
7781
  * Bind this layer to the view image.
6932
7782
  */
@@ -6938,24 +7788,24 @@ export declare class ViewLayer {
6938
7788
  /**
6939
7789
  * Handle an image content change event.
6940
7790
  *
6941
- * @param {object} event The event.
7791
+ * @param {CustomEvent} event The event.
6942
7792
  * @function
6943
7793
  */
6944
- onimagecontentchange: (event: object) => void;
7794
+ onimagecontentchange: (event: CustomEvent) => void;
6945
7795
  /**
6946
7796
  * Handle an image change event.
6947
7797
  *
6948
- * @param {object} event The event.
7798
+ * @param {CustomEvent} event The event.
6949
7799
  * @function
6950
7800
  */
6951
- onimagegeometrychange: (event: object) => void;
7801
+ onimagegeometrychange: (event: CustomEvent) => void;
6952
7802
  /**
6953
7803
  * Handle an image resampled event.
6954
7804
  *
6955
- * @param {object} event The event.
7805
+ * @param {CustomEvent} event The event.
6956
7806
  * @function
6957
7807
  */
6958
- onimageresampled: (event: object) => void;
7808
+ onimageresampled: (event: CustomEvent) => void;
6959
7809
  /**
6960
7810
  * Get the id of the layer.
6961
7811
  *