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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import { ToolGroupManager } from '../../store'; import { ToolModes } from '../../enums'; import { EventTypes } from '../../types'; type ModesFilter = Array<ToolModes>; /** * Given the normalized touch event and a filter of modes, * find all the tools on the element that are in one of the specified modes. * If the evtButton is specified, only tools with a matching binding will be returned. * @param evt - The normalized touchStart event. * @param modesFilter - An array of entries from the `ToolModes` enum. */ export default function getToolsWithModesForTouchEvent( evt: EventTypes.NormalizedTouchEventType, modesFilter: ModesFilter, numTouchPoints?: number ) { const { renderingEngineId, viewportId } = evt.detail; const toolGroup = ToolGroupManager.getToolGroupForViewport( viewportId, renderingEngineId ); if (!toolGroup) { return []; } const enabledTools = []; const toolGroupToolNames = Object.keys(toolGroup.toolOptions); for (let j = 0; j < toolGroupToolNames.length; j++) { const toolName = toolGroupToolNames[j]; const tool = toolGroup.toolOptions[toolName]; const correctBinding = numTouchPoints != null && tool.bindings.length && tool.bindings.some( (binding) => binding.numTouchPoints === numTouchPoints ); if ( modesFilter.includes(tool.mode) && (!numTouchPoints || correctBinding) ) { const toolInstance = toolGroup.getToolInstance(toolName); enabledTools.push(toolInstance); } } return enabledTools; } |