fix: Inconsistencies and update the style setting on load for embedded styles from codingValues (#4599)

This commit is contained in:
Bill Wallace authored and GitHub committed 2025-01-09 09:28:02 -05:00
1 parent 3c848c6d34
commit e0088ec918
4 files changed
+58 -5

No files matched your search

+29 -1
View File
@@ -11,6 +11,7 @@ import {
Enums,
utilities as cstUtils,
ReferenceLinesTool,
annotation,
} from '@cornerstonejs/tools';
import { Types as OhifTypes } from '@ohif/core';
@@ -30,6 +31,7 @@ import { getFirstAnnotationSelected } from './utils/measurementServiceMappings/u
import getActiveViewportEnabledElement from './utils/getActiveViewportEnabledElement';
import toggleVOISliceSync from './utils/toggleVOISliceSync';
import { usePositionPresentationStore, useSegmentationPresentationStore } from './stores';
import { toolNames } from './initCornerstoneTools';
const toggleSyncFunctions = {
imageSlice: toggleImageSliceSync,
@@ -218,6 +220,8 @@ function commandsModule({
* * CodingSchemeDesignator - the issue of the code value
* * CodeMeaning - the text value shown to the user
* * ref - a string reference in the form `<designator>:<codeValue>`
* * type - defaulting to 'finding'. Will replace other codes of same type
* * style - a styling object to use
* * Other fields
* Note it is a valid option to remove the finding or site values by
* supplying null for the code.
@@ -233,7 +237,12 @@ function commandsModule({
*/
updateMeasurement: props => {
const { code, uid, textLabel, label } = props;
let { style } = props;
const measurement = measurementService.getMeasurement(uid);
if (!measurement) {
console.warn('No measurement found to update', uid);
return;
}
const updatedMeasurement = {
...measurement,
};
@@ -252,7 +261,6 @@ function commandsModule({
code.CodingSchemeDesignator = code.ref.substring(0, split);
}
updatedMeasurement[measurementKey] = code;
// TODO - remove this line once the measurements table customizations are in
if (measurementKey !== 'finding') {
if (updatedMeasurement.findingSites) {
updatedMeasurement.findingSites = updatedMeasurement.findingSites.filter(
@@ -264,6 +272,26 @@ function commandsModule({
}
}
}
style ||= updatedMeasurement.finding?.style;
style ||= updatedMeasurement.findingSites?.find(site => site?.style)?.style;
if (style) {
// Reset the selected values to preserve appearance on selection
style.lineDashSelected ||= style.lineDash;
annotation.config.style.setAnnotationStyles(measurement.uid, style);
// this is a bit ugly, but given the underlying behavior, this is how it needs to work.
switch (measurement.toolName) {
case toolNames.PlanarFreehandROI: {
const targetAnnotation = annotation.state.getAnnotation(measurement.uid);
targetAnnotation.data.isOpenUShapeContour = !!style.isOpenUShapeContour;
break;
}
default:
break;
}
}
measurementService.update(updatedMeasurement.uid, updatedMeasurement, true);
},