All files / extensions/cornerstone/src/utils/presentations getViewportPresentations.ts

87.5% Statements 7/8
0% Branches 0/1
100% Functions 1/1
87.5% Lines 7/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 24 25 26 27 28 29 30 31 32 33                108x 108x 108x       108x   108x               108x   108x            
import { usePositionPresentationStore } from '../../stores/usePositionPresentationStore';
import { useLutPresentationStore } from '../../stores/useLutPresentationStore';
import { useSegmentationPresentationStore } from '../../stores/useSegmentationPresentationStore';
 
export function getViewportPresentations(
  viewportId: string,
  viewportOptions: AppTypes.ViewportGrid.GridViewportOptions
) {
  const { lutPresentationStore } = useLutPresentationStore.getState();
  const { positionPresentationStore } = usePositionPresentationStore.getState();
  const { segmentationPresentationStore } = useSegmentationPresentationStore.getState();
 
  // NOTE: this is the new viewport state, we should not get the presentationIds from the cornerstoneViewportService
  // since that has the old viewport state
  const { presentationIds } = viewportOptions;
 
  Iif (!presentationIds) {
    return {
      positionPresentation: null,
      lutPresentation: null,
      segmentationPresentation: null,
    };
  }
 
  const { lutPresentationId, positionPresentationId, segmentationPresentationId } = presentationIds;
 
  return {
    positionPresentation: positionPresentationStore[positionPresentationId],
    lutPresentation: lutPresentationStore[lutPresentationId],
    segmentationPresentation: segmentationPresentationStore[segmentationPresentationId],
  };
}