Prevent default measurementpanel crash
This commit is contained in:
parent
e82b6b3c5e
commit
eb0f38ebf2
@ -1,37 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Button, ButtonGroup, Icon, IconButton } from '@ohif/ui';
|
|
||||||
|
|
||||||
function ActionButtons() {
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<ButtonGroup onClick={() => alert('Export')}>
|
|
||||||
<Button
|
|
||||||
className="px-2 py-2 text-base text-white bg-black border-primary-main"
|
|
||||||
size="initial"
|
|
||||||
color="inherit"
|
|
||||||
>
|
|
||||||
Export
|
|
||||||
</Button>
|
|
||||||
<IconButton
|
|
||||||
className="px-2 text-white bg-black border-primary-main"
|
|
||||||
color="inherit"
|
|
||||||
size="initial"
|
|
||||||
>
|
|
||||||
<Icon name="arrow-down" />
|
|
||||||
</IconButton>
|
|
||||||
</ButtonGroup>
|
|
||||||
<Button
|
|
||||||
className="px-2 py-2 ml-2 text-base text-white bg-black border border-primary-main"
|
|
||||||
variant="outlined"
|
|
||||||
size="initial"
|
|
||||||
color="inherit"
|
|
||||||
onClick={() => alert('Create Report')}
|
|
||||||
>
|
|
||||||
Create Report
|
|
||||||
</Button>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ActionButtons;
|
|
||||||
@ -1,55 +1,135 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { StudySummary, MeasurementTable } from '@ohif/ui';
|
import PropTypes from 'prop-types';
|
||||||
import ActionButtons from './ActionButtons.jsx';
|
import { MeasurementTable } from '@ohif/ui';
|
||||||
|
import { DicomMetadataStore } from '@ohif/core';
|
||||||
|
|
||||||
export default function PanelMeasurementTable({
|
export default function PanelMeasurementTable({
|
||||||
servicesManager,
|
servicesManager,
|
||||||
commandsManager,
|
// commandsManager,
|
||||||
}) {
|
}) {
|
||||||
const { MeasurementService } = servicesManager.services;
|
const { MeasurementService } = servicesManager.services;
|
||||||
|
const [displayMeasurements, setDisplayMeasurements] = useState([]);
|
||||||
|
|
||||||
console.log('MeasurementTable rendering!!!!!!!!!!!!!');
|
useEffect(() => {
|
||||||
|
const measurements = MeasurementService.getMeasurements();
|
||||||
|
const mappedMeasurements = measurements.map((m, index) =>
|
||||||
|
_mapMeasurementToDisplay(m, index, MeasurementService.VALUE_TYPES)
|
||||||
|
);
|
||||||
|
setDisplayMeasurements(mappedMeasurements);
|
||||||
|
}, [MeasurementService]);
|
||||||
|
|
||||||
const descriptionData = {
|
// const activeMeasurementItem = 0;
|
||||||
date: '07-Sep-2010',
|
|
||||||
modality: 'CT',
|
|
||||||
description: 'CHEST/ABD/PELVIS W CONTRAST',
|
|
||||||
};
|
|
||||||
|
|
||||||
const activeMeasurementItem = 0;
|
|
||||||
|
|
||||||
const measurementTableData = {
|
|
||||||
title: 'Measurements',
|
|
||||||
amount: 10,
|
|
||||||
data: new Array(10).fill({}).map((el, i) => ({
|
|
||||||
id: i + 1,
|
|
||||||
label: 'Label short description',
|
|
||||||
displayText: '24.0 x 24.0 mm (S:4, I:22)',
|
|
||||||
isActive: activeMeasurementItem === i + 1,
|
|
||||||
})),
|
|
||||||
onClick: id => setActiveMeasurementItem(s => (s === id ? null : id)),
|
|
||||||
onEdit: id => alert(`Edit: ${id}`),
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="overflow-x-hidden overflow-y-auto invisible-scrollbar">
|
<div className="overflow-x-hidden overflow-y-auto invisible-scrollbar">
|
||||||
<StudySummary
|
|
||||||
date={descriptionData.date}
|
|
||||||
modality={descriptionData.modality}
|
|
||||||
description={descriptionData.description}
|
|
||||||
/>
|
|
||||||
<MeasurementTable
|
<MeasurementTable
|
||||||
title="Measurements"
|
title="Measurements"
|
||||||
amount={measurementTableData.data.length}
|
amount={displayMeasurements.length}
|
||||||
data={measurementTableData.data}
|
data={displayMeasurements}
|
||||||
onClick={() => {}}
|
onClick={() => {}}
|
||||||
onEdit={id => alert(`Edit: ${id}`)}
|
onEdit={id => alert(`Edit: ${id}`)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-center p-4">
|
|
||||||
<ActionButtons />
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PanelMeasurementTable.propTypes = {
|
||||||
|
servicesManager: PropTypes.shape({
|
||||||
|
services: PropTypes.shape({
|
||||||
|
MeasurementService: PropTypes.shape({
|
||||||
|
getMeasurements: PropTypes.func.isRequired,
|
||||||
|
VALUE_TYPES: PropTypes.object.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
function _mapMeasurementToDisplay(measurement, index, types) {
|
||||||
|
const {
|
||||||
|
id,
|
||||||
|
label,
|
||||||
|
description,
|
||||||
|
// Reference IDs
|
||||||
|
referenceStudyUID,
|
||||||
|
referenceSeriesUID,
|
||||||
|
SOPInstanceUID,
|
||||||
|
} = measurement;
|
||||||
|
const instance = DicomMetadataStore.getInstance(
|
||||||
|
referenceStudyUID,
|
||||||
|
referenceSeriesUID,
|
||||||
|
SOPInstanceUID
|
||||||
|
);
|
||||||
|
const { PixelSpacing, SeriesNumber, InstanceNumber } = instance;
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: index + 1,
|
||||||
|
label: '(empty)', // 'Label short description',
|
||||||
|
displayText:
|
||||||
|
_getDisplayText(
|
||||||
|
measurement,
|
||||||
|
PixelSpacing,
|
||||||
|
SeriesNumber,
|
||||||
|
InstanceNumber,
|
||||||
|
types
|
||||||
|
) || [],
|
||||||
|
// TODO: handle one layer down
|
||||||
|
isActive: false, // activeMeasurementItem === i + 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getDisplayText(
|
||||||
|
measurement,
|
||||||
|
pixelSpacing,
|
||||||
|
seriesNumber,
|
||||||
|
instanceNumber,
|
||||||
|
types
|
||||||
|
) {
|
||||||
|
const { type, points } = measurement;
|
||||||
|
const hasPixelSpacing =
|
||||||
|
pixelSpacing !== undefined &&
|
||||||
|
Array.isArray(pixelSpacing) &&
|
||||||
|
pixelSpacing.length === 2;
|
||||||
|
const [rowPixelSpacing, colPixelSpacing] = hasPixelSpacing
|
||||||
|
? pixelSpacing
|
||||||
|
: [1, 1];
|
||||||
|
const unit = hasPixelSpacing ? 'mm' : 'px';
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case types.POLYLINE: {
|
||||||
|
const { length } = measurement;
|
||||||
|
const roundedLength = _round(length, 1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
`${roundedLength} ${unit} (S:${seriesNumber}, I:${instanceNumber})`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
case types.BIDIRECTIONAL: {
|
||||||
|
const { shortestDiameter, longestDiameter } = measurement;
|
||||||
|
const roundedShortestDiameter = _round(shortestDiameter, 1);
|
||||||
|
const roundedLongestDiameter = _round(longestDiameter, 1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
`l: ${roundedLongestDiameter} ${unit} (S:${seriesNumber}, I:${instanceNumber})`,
|
||||||
|
`s: ${roundedShortestDiameter} ${unit}`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
case types.ELLIPSE: {
|
||||||
|
const { area } = measurement;
|
||||||
|
const roundedArea = _round(area, 1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
`${roundedArea} ${unit}2 (S:${seriesNumber}, I:${instanceNumber})`,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
case types.POINT: {
|
||||||
|
const { text } = measurement;
|
||||||
|
return [`${text} (S:${seriesNumber}, I:${instanceNumber})`];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _round(value, decimals) {
|
||||||
|
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user