110 lines
4.3 KiB
JavaScript
110 lines
4.3 KiB
JavaScript
// Note: This component is not in use, but the functions below are still being used. This
|
|
// is in the process of being moved into another location
|
|
import { OHIF } from 'meteor/ohif:core';
|
|
|
|
// This event sets measurement number for new measurement
|
|
function getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
|
return (measurementData, eventData, doneCallback) => {
|
|
// Get the current element's timepointId from the study date metadata
|
|
var element = eventData.element;
|
|
var enabledElement = cornerstone.getEnabledElement(element);
|
|
var imageId = enabledElement.image.imageId;
|
|
|
|
var study = cornerstoneTools.metaData.get('study', imageId);
|
|
if (!timepointApi) {
|
|
return;
|
|
}
|
|
|
|
// Find the relevant timepoint given the current study
|
|
var timepoint = timepointApi.study(study.studyInstanceUid)[0];
|
|
if (!timepoint) {
|
|
return;
|
|
}
|
|
|
|
// Get a measurement number for this measurement, depending on whether or not the same measurement previously
|
|
// exists at a different timepoint
|
|
const timepointId = timepoint.timepointId;
|
|
const collection = measurementApi[measurementTypeId];
|
|
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
|
|
measurementData.measurementNumber = measurementNumber;
|
|
|
|
// Set measurement number
|
|
doneCallback(measurementNumber);
|
|
};
|
|
}
|
|
|
|
Template.measurementLocationDialog.onCreated(() => {
|
|
const instance = Template.instance();
|
|
const measurementTypeId = 'targets';
|
|
const measurementApi = instance.data.measurementApi;
|
|
const timepointApi = instance.data.timepointApi;
|
|
|
|
const toggleLabel = (measurementData, eventdata, doneCallback) => {
|
|
OHIF.measurements.toggleLabelButton({
|
|
instance,
|
|
measurementId: measurementData._id,
|
|
toolType: measurementData.toolType,
|
|
element: eventdata.element,
|
|
measurementApi: instance.data.measurementApi,
|
|
position: eventdata.currentPoints.page
|
|
});
|
|
};
|
|
|
|
const callbackConfig = {
|
|
setMeasurementNumberCallback: getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
|
// TODO: Check the position for these, the Add Label button position seems very awkward
|
|
getMeasurementLocationCallback: toggleLabel,
|
|
changeMeasurementLocationCallback: toggleLabel,
|
|
};
|
|
|
|
|
|
// TODO: Reconcile this with the configuration in toolManager
|
|
// it would be better to have this all in one place.
|
|
const bidirectionalConfig = cornerstoneTools.bidirectional.getConfiguration();
|
|
const config = {
|
|
...bidirectionalConfig,
|
|
...callbackConfig
|
|
};
|
|
|
|
cornerstoneTools.bidirectional.setConfiguration(config);
|
|
|
|
// Set CR-Tool, UN-Tool, EX-Tool configurations
|
|
cornerstoneTools.crTool.setConfiguration(config);
|
|
cornerstoneTools.exTool.setConfiguration(config);
|
|
cornerstoneTools.unTool.setConfiguration(config);
|
|
|
|
});
|
|
|
|
// Note: None of these events work anymore
|
|
Template.measurementLocationDialog.events({
|
|
'click #removeMeasurement': function() {
|
|
var measurementData = Template.measurementLocationDialog.measurementData;
|
|
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
|
var dialog = Template.measurementLocationDialog.dialog;
|
|
|
|
var options = {
|
|
keyPressAllowed: false,
|
|
title: 'Remove measurement?',
|
|
text: 'Are you sure you would like to remove the entire measurement?'
|
|
};
|
|
|
|
showConfirmDialog(function() {
|
|
if (doneCallback && typeof doneCallback === 'function') {
|
|
var deleteTool = true;
|
|
doneCallback(measurementData, deleteTool);
|
|
}
|
|
}, options);
|
|
|
|
closeHandler(dialog);
|
|
},
|
|
'click #convertToNonTarget': function() {
|
|
var measurementData = Template.measurementLocationDialog.measurementData;
|
|
var dialog = Template.measurementLocationDialog.dialog;
|
|
|
|
const instance = Template.instance();
|
|
const measurementApi = instance.data.measurementApi;
|
|
OHIF.measurementTracker.convertToNonTarget(measurementApi, measurementData);
|
|
|
|
closeHandler(dialog);
|
|
}
|
|
}); |