Files
ohif-viewer/platform/viewer/src/appExtensions/MeasurementsPanel/index.js
T

87 lines
2.5 KiB
JavaScript
Raw Normal View History

import React from 'react';
2019-07-04 14:09:13 -04:00
import ConnectedMeasurementTable from './ConnectedMeasurementTable.js';
import init from './init.js';
2019-07-04 14:09:13 -04:00
import LabellingFlow from '../../components/Labelling/LabellingFlow';
2019-07-04 14:09:13 -04:00
export default {
/**
* Only required property. Should be a unique value across all extensions.
*/
2019-07-04 14:09:13 -04:00
id: 'measurements-table',
preRegistration({ servicesManager, commandsManager, configuration = {} }) {
init({ servicesManager, commandsManager, configuration });
},
2019-12-11 13:14:01 -03:00
getPanelModule({ servicesManager, commandsManager }) {
const { UINotificationService, UIDialogService } = servicesManager.services;
const showLabellingDialog = (props, measurementData) => {
if (!UIDialogService) {
console.warn('Unable to show dialog; no UI Dialog Service available.');
return;
}
UIDialogService.dismiss({ id: 'labelling' });
UIDialogService.create({
id: 'labelling',
centralize: true,
isDraggable: false,
showOverlay: true,
content: LabellingFlow,
contentProps: {
measurementData,
labellingDoneCallback: () =>
UIDialogService.dismiss({ id: 'labelling' }),
updateLabelling: ({ location, description, response }) => {
measurementData.location = location || measurementData.location;
measurementData.description = description || '';
measurementData.response = response || measurementData.response;
commandsManager.runCommand(
'updateTableWithNewMeasurementData',
measurementData
);
},
...props,
},
});
};
const ExtendedConnectedMeasurementTable = () => (
<ConnectedMeasurementTable
onRelabel={tool =>
showLabellingDialog(
{ editLocation: true, skipAddLabelButton: true },
tool
)
}
onEditDescription={tool =>
showLabellingDialog({ editDescriptionOnDialog: true }, tool)
}
2019-12-11 13:14:01 -03:00
onSaveComplete={message => {
if (UINotificationService) {
UINotificationService.show(message);
}
}}
/>
);
2019-07-04 14:09:13 -04:00
return {
menuOptions: [
{
icon: 'list',
label: 'Measurements',
target: 'measurement-panel',
},
],
components: [
{
id: 'measurement-panel',
component: ExtendedConnectedMeasurementTable,
2019-07-04 14:09:13 -04:00
},
],
defaultContext: ['VIEWER'],
};
},
};