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 | 937x 1088x 937x 937x 937x | import { state } from '../index';
import { IToolGroup } from '../../types';
/**
* Given a rendering engine Id and a viewport Id, return the tool group that
* contains that rendering engine and viewport. Note: A viewport can only be
* associated with a single tool group. You cannot have a viewport that belongs
* to multiple tool groups. To achieve so, create a new viewport and a new toolGroup
* for it. This will not impact memory usage much as the volume textures are
* shared across all viewports rendering the same image.
*
* @param viewportId - The Id of the viewport that the tool is being
* added to.
* @param renderingEngineId - The Id of the rendering engine that the
* tool group is associated with.
* @returns A tool group.
*/
function getToolGroupForViewport(
viewportId: string,
renderingEngineId: string
): IToolGroup | undefined {
const toolGroupFilteredByIds = state.toolGroups.filter((tg) =>
tg.viewportsInfo.some(
(vp) =>
vp.renderingEngineId === renderingEngineId &&
(!vp.viewportId || vp.viewportId === viewportId)
)
);
Iif (!toolGroupFilteredByIds.length) {
return;
}
Iif (toolGroupFilteredByIds.length > 1) {
throw new Error(
`Multiple tool groups found for renderingEngineId: ${renderingEngineId} and viewportId: ${viewportId}. You should only
have one tool group per viewport in a renderingEngine.`
);
}
return toolGroupFilteredByIds[0];
}
export default getToolGroupForViewport;
|