2016-11-10 18:33:42 +01:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
|
import { Template } from 'meteor/templating';
|
2016-09-20 22:47:44 +02:00
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
2016-11-11 13:32:40 +01:00
|
|
|
import { _ } from 'meteor/underscore';
|
2016-09-20 22:47:44 +02:00
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
function doneCallback(measurementData, deleteTool) {
|
|
|
|
|
// If a Lesion or Non-Target is removed via a dialog
|
|
|
|
|
// opened by the Lesion Table, we should clear the data for
|
|
|
|
|
// the specified Timepoint Cell
|
|
|
|
|
if (deleteTool === true) {
|
2016-01-11 11:32:20 +01:00
|
|
|
Meteor.call('removeMeasurement', measurementData.id, function(error, response) {
|
2016-01-09 23:04:22 +01:00
|
|
|
if (error) {
|
2016-09-20 22:47:44 +02:00
|
|
|
OHIF.log.warn(error);
|
2016-01-09 23:04:22 +01:00
|
|
|
}
|
2015-12-19 04:24:00 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-21 00:52:17 +01:00
|
|
|
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
2016-11-10 18:33:42 +01:00
|
|
|
const keys = {
|
2015-12-21 00:52:17 +01:00
|
|
|
D: 68,
|
|
|
|
|
DELETE: 46
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-15 15:34:36 +02:00
|
|
|
Template.measurementTableRow.events({
|
2016-11-06 16:17:35 +01:00
|
|
|
'click .measurementRowSidebar'(event, instance) {
|
2016-08-15 15:34:36 +02:00
|
|
|
const $row = instance.$('.measurementTableRow');
|
|
|
|
|
$row.closest('.measurementTableView').find('.measurementTableRow').not($row).removeClass('active');
|
2016-07-04 20:17:27 +02:00
|
|
|
$row.toggleClass('active');
|
|
|
|
|
},
|
2016-08-08 18:37:32 +02:00
|
|
|
|
2016-11-10 18:33:42 +01:00
|
|
|
'click .js-rename'(event, instance) {
|
2016-11-15 13:43:17 +01:00
|
|
|
const rowItem = instance.data.rowItem;
|
|
|
|
|
|
|
|
|
|
// Show the measure flow for targets
|
2016-11-10 18:33:42 +01:00
|
|
|
OHIF.measurements.toggleLabelButton({
|
|
|
|
|
instance,
|
2016-11-15 13:43:17 +01:00
|
|
|
measurementId: rowItem.entries[0]._id,
|
|
|
|
|
measurementTypeId: rowItem.measurementTypeId,
|
2016-11-10 18:33:42 +01:00
|
|
|
element: document.body,
|
|
|
|
|
measurementApi: instance.data.measurementApi,
|
|
|
|
|
position: {
|
|
|
|
|
x: event.clientX,
|
|
|
|
|
y: event.clientY
|
|
|
|
|
},
|
|
|
|
|
autoClick: true
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2016-11-11 13:32:40 +01:00
|
|
|
'click .js-delete'(event, instance) {
|
|
|
|
|
const dialogSettings = {
|
|
|
|
|
title: 'Delete measurements',
|
2016-11-15 17:41:08 +01:00
|
|
|
message: 'Are you sure you want to delete the measurement across all timepoints?'
|
2016-11-11 13:32:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
OHIF.ui.showFormDialog('dialogConfirm', dialogSettings).then(formData => {
|
2016-11-11 15:30:18 +01:00
|
|
|
const measurementTypeId = instance.data.rowItem.measurementTypeId;
|
|
|
|
|
const measurement = instance.data.rowItem.entries[0];
|
|
|
|
|
const toolType = measurement.toolType;
|
|
|
|
|
const measurementNumber = measurement.measurementNumber;
|
2016-11-15 15:02:38 +01:00
|
|
|
const measurementApi = instance.data.measurementApi;
|
|
|
|
|
const timepointApi = instance.data.timepointApi;
|
2016-11-11 13:32:40 +01:00
|
|
|
|
2016-11-11 15:30:18 +01:00
|
|
|
// Remove all the measurements with the given type and number
|
2016-11-15 15:02:38 +01:00
|
|
|
measurementApi.deleteMeasurements(measurementTypeId, {
|
2016-11-14 18:22:51 +01:00
|
|
|
toolType,
|
|
|
|
|
measurementNumber
|
|
|
|
|
});
|
2016-11-11 13:32:40 +01:00
|
|
|
|
2016-11-15 15:02:38 +01:00
|
|
|
// Update the Overall Measurement Numbers for all Measurements
|
|
|
|
|
const baseline = timepointApi.baseline();
|
|
|
|
|
measurementApi.sortMeasurements(baseline.timepointId);
|
|
|
|
|
|
2016-11-11 15:30:18 +01:00
|
|
|
// Repaint the images on all viewports without the removed measurements
|
|
|
|
|
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
2016-11-11 13:32:40 +01:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2016-11-10 18:33:42 +01:00
|
|
|
'keydown .location'(event) {
|
|
|
|
|
const keyCode = event.which;
|
2015-12-21 15:29:19 +01:00
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
if (keyCode === keys.DELETE ||
|
2016-11-10 18:33:42 +01:00
|
|
|
(keyCode === keys.D && event.ctrlKey === true)) {
|
|
|
|
|
const currentMeasurement = this;
|
|
|
|
|
const options = {
|
2016-01-10 15:40:51 +01:00
|
|
|
keyPressAllowed: false,
|
|
|
|
|
title: 'Remove measurement?',
|
|
|
|
|
text: 'Are you sure you would like to remove the entire measurement?'
|
2015-12-21 15:29:19 +01:00
|
|
|
};
|
2015-12-19 04:24:00 +01:00
|
|
|
|
2016-08-08 18:37:32 +02:00
|
|
|
showConfirmDialog(() => {
|
|
|
|
|
Meteor.call('removeMeasurement', currentMeasurement._id, (error, response) => {
|
2015-12-21 15:29:19 +01:00
|
|
|
if (error) {
|
2016-09-20 22:47:44 +02:00
|
|
|
OHIF.log.warn(error);
|
2015-12-21 15:29:19 +01:00
|
|
|
}
|
2015-12-21 00:52:17 +01:00
|
|
|
});
|
2015-12-21 15:29:19 +01:00
|
|
|
}, options);
|
2015-12-19 04:24:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|