All files / tools/src/utilities/segmentation getBrushToolInstances.ts

72.72% Statements 8/11
50% Branches 4/8
100% Functions 2/2
72.72% Lines 8/11

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        40x   40x       40x   40x       40x         40x 316x     40x    
import { getToolGroup } from '../../store/ToolGroupManager';
import BrushTool from '../../tools/segmentation/BrushTool';
 
export function getBrushToolInstances(toolGroupId: string, toolName?: string) {
  const toolGroup = getToolGroup(toolGroupId);
 
  Iif (toolGroup === undefined) {
    return [];
  }
 
  const toolInstances = toolGroup._toolInstances;
 
  Iif (!Object.keys(toolInstances).length) {
    return [];
  }
 
  Iif (toolName && toolInstances[toolName]) {
    return [toolInstances[toolName]];
  }
 
  // For each tool that has BrushTool as base class, set the brush size.
  const brushBasedToolInstances = Object.values(toolInstances).filter(
    (toolInstance) => toolInstance instanceof BrushTool
  ) as BrushTool[];
 
  return brushBasedToolInstances;
}