All files / tools/src/utilities triggerAnnotationRenderForToolGroupIds.ts

71.42% Statements 10/14
50% Branches 2/4
100% Functions 3/3
71.42% Lines 10/14

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 34 35 36 37 38 39                        607x 607x   607x         607x   607x 607x   607x 607x         607x 607x            
import { getRenderingEngine, type Types } from '@cornerstonejs/core';
import triggerAnnotationRender from './triggerAnnotationRender';
import { getToolGroup } from '../store/ToolGroupManager';
 
/**
 * Triggers annotation rendering for the specified tool group IDs.
 *
 * @param toolGroupIds - An array of tool group IDs.
 */
export function triggerAnnotationRenderForToolGroupIds(
  toolGroupIds: string[]
): void {
  toolGroupIds.forEach((toolGroupId) => {
    const toolGroup = getToolGroup(toolGroupId);
 
    Iif (!toolGroup) {
      console.warn(`ToolGroup not available for ${toolGroupId}`);
      return;
    }
 
    const viewportsInfo = toolGroup.getViewportsInfo();
 
    viewportsInfo.forEach((viewportInfo) => {
      const { renderingEngineId, viewportId } = viewportInfo;
 
      const renderingEngine = getRenderingEngine(renderingEngineId);
      Iif (!renderingEngine) {
        console.warn(`RenderingEngine not available for ${renderingEngineId}`);
        return;
      }
 
      const viewport = renderingEngine.getViewport(viewportId);
      triggerAnnotationRender(viewport.element);
    });
  });
}
 
export default triggerAnnotationRenderForToolGroupIds;