All files / packages/core/src/utilities getViewportModality.ts

0% Statements 0/8
0% Branches 0/8
0% Functions 0/1
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
import type { IViewport, IStackViewport, IVolumeViewport } from '../types';
import cache from '../cache';
 
function getViewportModality(viewport: IViewport, volumeId?: string): string {
  if ((viewport as IStackViewport).modality) {
    return (viewport as IStackViewport).modality;
  }
 
  if ((viewport as IVolumeViewport).setVolumes) {
    volumeId = volumeId ?? viewport.getDefaultActor()?.uid;
 
    if (!volumeId) {
      return;
    }
 
    return cache.getVolume(volumeId)?.metadata.Modality;
  }
 
  throw new Error('Invalid viewport type');
}
 
export { getViewportModality as default, getViewportModality };