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 | 87x 87x 87x 87x 87x 87x 52x 35x 35x 35x 35x 87x | import { getAnnotations } from '../stateManagement/annotation/annotationState';
import { ToolAnnotationsPair } from '../types/InternalToolTypes';
import type AnnotationTool from '../tools/base/AnnotationTool';
import BaseTool from '../tools/base/BaseTool';
/**
* Filters an array of tools, returning only tools which have annotation.
*
* @param element - The cornerstone3D enabled element.
* @param tools - The array of tools to check.
*
* @returns The array of tools with their found annotations.
*/
export default function filterToolsWithAnnotationsForElement(
element: HTMLDivElement,
tools: AnnotationTool[]
): ToolAnnotationsPair[] {
const result = [];
for (let i = 0; i < tools.length; i++) {
const tool = tools[i];
Iif (!tool) {
console.warn('undefined tool in filterToolsWithAnnotationsForElement');
continue;
}
let annotations = getAnnotations(
element,
(tool.constructor as typeof BaseTool).toolName
);
if (!annotations) {
continue;
}
Eif (typeof tool.filterInteractableAnnotationsForElement === 'function') {
// If the tool has a annotations filter (e.g. with in-plane-annotations-only filtering), use it.
annotations = tool.filterInteractableAnnotationsForElement(
element,
annotations
);
}
Eif (annotations.length > 0) {
result.push({ tool, annotations });
}
}
return result;
}
|