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 | 22028x 22028x 9736x 22028x 22028x 22028x 22028x 22028x 51407x 51407x 22028x | import type { StyleSpecifier } from '../../../types/AnnotationStyle';
import type { ToolModes, AnnotationStyleStates } from '../../../enums';
import toolStyle from './ToolStyle';
/**
* Build a list of hierarchal property names in ascending order of priority
* @param property - The base property name -- e.g., 'color'
* @param state - An optional state to determine the final property name
* @param mode - An optional mode to determine the final property name
* @returns A list of property names
*/
function getHierarchalPropertyStyles(
property: string,
state?: AnnotationStyleStates,
mode?: ToolModes
): string[] {
const list = [`${property}`];
if (state) {
list.push(`${list[0]}${state}`);
}
Eif (mode) {
list.push(`${list[list.length - 1]}${mode}`);
}
return list;
}
/**
* Get the value of a style property from the ToolStyle config
* @param property - The name of the property to get.
* @param styleSpecifier - An object containing the specifications such as viewportId,
* toolGroupId, toolName and annotationUID which are used to get the style if the level of specificity is
* met (hierarchy is checked from most specific to least specific which is
* annotationLevel -> viewportLevel -> toolGroupLevel -> default.
* @param state - The state of the tool (Default, Locked etc.)
* @param mode - The current tool mode. (Active, Passive etc.)
* @returns The value of the property.
*/
function getStyleProperty(
property: string,
styleSpecifier: StyleSpecifier,
state?: AnnotationStyleStates,
mode?: ToolModes
): string {
// Hierarchal property styles is a list of property names with priority in ascending
// order like: ['color', 'colorSelected', 'colorSelectedActive'], if in the toolStyle
// config, the `colorSelectedActive` property is defined, it will be used, otherwise
// the `colorSelected` property will be used, and if that is not defined, the `color`
// property will be used. This is done to ensure that the most specific property is used.
// Thus, we attempt resolving property names in reverse order
const alternatives = getHierarchalPropertyStyles(property, state, mode);
for (let i = alternatives.length - 1; i >= 0; --i) {
const style = toolStyle.getStyleProperty(alternatives[i], styleSpecifier);
if (style !== undefined) {
return style;
}
}
}
export { getStyleProperty };
|