All files / tools/src/eventListeners/segmentation renderingPipelineChangedListener.ts

12.5% Statements 1/8
0% Branches 0/4
0% Functions 0/1
12.5% Lines 1/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                      128x                                  
import { triggerSegmentationRender } from '../../stateManagement/segmentation/SegmentationRenderingEngine';
import { getSegmentationRepresentations } from '../../stateManagement/segmentation/getSegmentationRepresentation';
 
/**
 * Listens to the core RENDERING_PIPELINE_CHANGED event, fired after a viewport
 * rebuilds its render paths in place (live render-backend switch). The rebuild
 * replaces the viewport's actors, so any segmentation representations mounted
 * on it must be re-reconciled and restyled against the new actor instances --
 * without this, remounted labelmap overlays render unstyled (invisible).
 * @param evt - The RENDERING_PIPELINE_CHANGED event object
 */
const renderingPipelineChangedListener = function (evt: CustomEvent): void {
  const viewportId = evt.detail?.viewportId as string | undefined;
 
  if (!viewportId) {
    return;
  }
 
  const representations = getSegmentationRepresentations(viewportId);
 
  if (!representations?.length) {
    return;
  }
 
  triggerSegmentationRender(viewportId);
};
 
export default renderingPipelineChangedListener;