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 56 57 58 59 60 61 62 63 64 65 66 | 99x 99x 99x 99x 99x 99x 99x 99x 99x 99x 101x 101x 101x 101x 101x 101x 99x | import { ToolGroupManager } from '../../store'; import { ToolModes } from '../../enums'; import { ToolAction, EventTypes } from '../../types'; import { keyEventListener } from '../../eventListeners'; import getMouseModifier from './getMouseModifier'; /** * Given the mouse event and a list of tool modes, find all tool instances * with actions that were added to the tool group associated with the viewport * that triggered the event. * * @param evt - mouseDown event triggered by a cornerstone viewport * @param toolModes - List of tool modes used to filter the tools registered * in the viewport's tool group */ export default function getToolsWithActionsForMouseEvent( evt: EventTypes.MouseMoveEventType, toolModes: ToolModes[] ): Map<any, ToolAction> { const toolsWithActions = new Map(); const { renderingEngineId, viewportId } = evt.detail; const toolGroup = ToolGroupManager.getToolGroupForViewport( viewportId, renderingEngineId ); Iif (!toolGroup) { return toolsWithActions; } const toolGroupToolNames = Object.keys(toolGroup.toolOptions); const defaultMousePrimary = toolGroup.getDefaultMousePrimary(); const mouseEvent = evt.detail.event; const mouseButton = mouseEvent?.buttons ?? defaultMousePrimary; const modifierKey = getMouseModifier(mouseEvent) || keyEventListener.getModifierKey(); for (let j = 0; j < toolGroupToolNames.length; j++) { const toolName = toolGroupToolNames[j]; const tool = toolGroup.getToolInstance(toolName); const actionsConfig = tool.configuration?.actions ?? {}; const actions = Object.values(actionsConfig); Eif (!actions?.length || !toolModes.includes(tool.mode)) { continue; } const action = actions.find( (action: any) => action.bindings.length && action.bindings.some( (binding) => binding.mouseButton === mouseButton && binding.modifierKey === modifierKey ) ); if (action) { toolsWithActions.set(tool, action); } } return toolsWithActions; } |