Clear tools button is added. Removes all target and nonTarget lesions data on image and deletes from Measurements collection

This commit is contained in:
Evren Ozkan 2015-11-24 10:57:02 -05:00
parent dbd7453980
commit ca30e22464
3 changed files with 44 additions and 0 deletions

View File

@ -53,10 +53,44 @@ Template.viewerMain.helpers({
iconClasses: 'fa fa-long-arrow-up'
});
buttonData.push({
id: 'clearTools',
title: 'Clear tools',
classes: 'imageViewerCommand',
iconClasses: 'fa fa-trash'
});
toolbarOptions.buttonData = buttonData;
toolbarOptions.includePlayClipButton = false;
toolbarOptions.includeLayoutButton = false;
toolbarOptions.includeHangingProtocolButtons = false;
return toolbarOptions;
}
});
Template.viewerMain.events({
'click button#clearTools': function(e, template) {
var toolTypes = ["lesion", "nonTarget"];
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
var toolStateKeys = Object.keys(toolState).slice(0);
toolStateKeys.forEach(function (imageId) {
toolTypes.forEach(function (toolType) {
toolState[imageId][toolType] = {
data: []
};
});
});
// Update imageViewerViewport elements
$(".imageViewerViewport").each(function(viewportIndex, element) {
cornerstone.updateImage(element);
});
// Remove patient's measurements
var patientId = template.data.studies[0].patientId;
Meteor.call('removeMeasurementsByPatientId', patientId);
}
});

View File

@ -0,0 +1,8 @@
Meteor.methods({
"removeMeasurementsByPatientId": function(patientId) {
Measurements.remove(
{patientId: patientId},
{multi: true}
);
}
});

View File

@ -51,6 +51,8 @@ Package.onUse(function (api) {
// Both client and server functions
api.addFiles('both/collections.js', ['client', 'server']);
api.addFiles('both/removeCollections.js', ['client', 'server']);
// Library functions
api.addFiles('lib/uuid.js', 'client');