2016-09-20 22:47:44 +02:00
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
|
|
|
|
|
2016-10-17 22:17:31 +02:00
|
|
|
const removeToolDataWithMeasurementId = (imageId, toolType, measurementId) => {
|
2016-09-20 22:47:44 +02:00
|
|
|
OHIF.log.info('removeToolDataWithMeasurementId');
|
2017-06-13 09:59:01 +02:00
|
|
|
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
2016-08-15 15:34:36 +02:00
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
// Find any related toolData
|
|
|
|
|
if (!toolState[imageId] || !toolState[imageId][toolType]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-08-15 15:34:36 +02:00
|
|
|
|
2016-10-17 22:17:31 +02:00
|
|
|
const toolData = toolState[imageId][toolType].data;
|
2015-12-19 04:24:00 +01:00
|
|
|
if (!toolData.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Search toolData for entries linked to the specified Measurement
|
2016-10-17 22:17:31 +02:00
|
|
|
const toRemove = [];
|
2015-12-19 04:24:00 +01:00
|
|
|
toolData.forEach(function(measurement, index) {
|
2016-02-13 18:57:04 +01:00
|
|
|
if (measurement.id === measurementId ||
|
|
|
|
|
measurement._id === measurementId) {
|
2015-12-19 04:24:00 +01:00
|
|
|
toRemove.push(index);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-20 22:47:44 +02:00
|
|
|
OHIF.log.info('Removing Indices: ');
|
|
|
|
|
OHIF.log.info(toRemove);
|
2016-02-12 20:38:00 +01:00
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
// If any toolData entries need to be removed, splice them from
|
|
|
|
|
// the toolData array
|
|
|
|
|
toRemove.forEach(function(index) {
|
|
|
|
|
toolData.splice(index, 1);
|
|
|
|
|
});
|
2017-06-13 09:59:01 +02:00
|
|
|
|
|
|
|
|
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
2016-01-11 11:32:20 +01:00
|
|
|
};
|
2016-10-17 22:17:31 +02:00
|
|
|
|
|
|
|
|
OHIF.lesiontracker.clearMeasurementTimepointData = (measurementId, timepointId) => {
|
|
|
|
|
const data = Measurements.findOne(measurementId);
|
|
|
|
|
|
|
|
|
|
// Clear the Measurement data for this timepoint
|
|
|
|
|
const imageId = data.timepoints[timepointId].imageId;
|
|
|
|
|
const toolType = data.toolType;
|
|
|
|
|
removeToolDataWithMeasurementId(imageId, toolType, measurementId);
|
|
|
|
|
|
|
|
|
|
// Update any viewports that are currently displaying this imageId
|
|
|
|
|
const enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
|
|
|
|
enabledElements.forEach(enabledElement => cornerstone.updateImage(enabledElement.element));
|
|
|
|
|
};
|