diff --git a/extensions/dicom-sr/src/getSopClassHandlerModule.js b/extensions/dicom-sr/src/getSopClassHandlerModule.js index 51ebd5963..cd1467510 100644 --- a/extensions/dicom-sr/src/getSopClassHandlerModule.js +++ b/extensions/dicom-sr/src/getSopClassHandlerModule.js @@ -523,7 +523,12 @@ function _getLabelFromMeasuredValueSequence( const { NumericValue, MeasurementUnitsCodeSequence } = MeasuredValueSequence; const { CodeValue } = MeasurementUnitsCodeSequence; - return { label: CodeMeaning, value: `${NumericValue} ${CodeValue}` }; // E.g. Long Axis: 31.0 mm + const formatedNumericValue = NumericValue ? NumericValue.toFixed(2) : ''; + + return { + label: CodeMeaning, + value: `${formatedNumericValue} ${CodeValue}`, + }; // E.g. Long Axis: 31.0 mm } function _getReferencedImagesList(ImagingMeasurementReportContentSequence) { diff --git a/extensions/dicom-sr/src/tools/DICOMSRDisplayTool.js b/extensions/dicom-sr/src/tools/DICOMSRDisplayTool.js index f78c053dc..3400f0d21 100644 --- a/extensions/dicom-sr/src/tools/DICOMSRDisplayTool.js +++ b/extensions/dicom-sr/src/tools/DICOMSRDisplayTool.js @@ -62,10 +62,6 @@ export default class DICOMSRDisplayTool extends BaseTool { trackingUniqueIdentifiers.includes(td.TrackingUniqueIdentifier) ); - // First: Render annotations with textboxes moved to closest side - // TODO: Render all annotations and get their locations. - // TODO: Find suitable places for textboxes that aren't covered. - let shouldRepositionTextBoxes = false; for (let i = 0; i < filteredToolData.length; i++) { @@ -171,6 +167,30 @@ export default class DICOMSRDisplayTool extends BaseTool { ); }); } + + // TOOD -> text boxes may overlap with other annotations at the moment. + // To be fixed after we get requirements. + // if (shouldRepositionTextBoxes) { + // this.repositionTextBox(filteredToolData, eventData); + // } + } + + repositionTextBox(toolData, eventData) { + debugger; + + const toolBoundingBoxes = []; + + for (let i = 0; i < toolData.length; i++) { + const toolDataI = toolData[i]; + + const { textBox } = toolDataI.handles; + const { anchorPoints } = textBox; + + const boundingBox = _getBoundingBoxFromAnchorPoints(anchorPoints); + // Get the textbox bounding locations. + // Get the tool extents. + debugger; + } } renderPolyLine(renderableData, eventData, options) { @@ -363,3 +383,26 @@ function _getTextBoxAnchorPointsForRenderableData(renderableData, eventData) { return anchorPoints; } + +function _getBoundingBoxFromAnchorPoints(anchorPoints) { + let minX = Infinity; + let maxX = -Infinity; + let minY = Infinity; + let maxY = -Infinity; + + anchorPoints.forEach(point => { + const { x, y } = point; + + if (x > maxX) { + maxX = x; + } else if (x < minX) { + minX = x; + } + + if (y > maxX) { + maxY = y; + } else if (y < minY) { + minY = y; + } + }); +}