Add button/hotkey to show/hide tools in viewports
This commit is contained in:
1 parent
ba05a3d21e
commit
b2d4812dd0
8 files changed
+119
-99
No files matched your search
@@ -0,0 +1,29 @@
|
||||
clearTools = function() {
|
||||
var patientId = template.data.studies[0].patientId;
|
||||
var toolTypes = ["lesion", "nonTarget"];
|
||||
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
var toolStateKeys = Object.keys(toolState).slice(0);
|
||||
|
||||
// Set null array for toolState data found by imageId and toolType
|
||||
toolStateKeys.forEach(function (imageId) {
|
||||
toolTypes.forEach(function (toolType) {
|
||||
var toolTypeData = toolState[imageId][toolType];
|
||||
if(toolTypeData && toolTypeData.data.length > 0) {
|
||||
if(toolTypeData.data[0].patientId === patientId) {
|
||||
toolState[imageId][toolType] = {
|
||||
data: []
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Update imageViewerViewport elements to remove lesions on current image
|
||||
var viewportElements = $(".imageViewerViewport").not('.empty');
|
||||
viewportElements.each(function(index, element) {
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
|
||||
// Remove patient's measurements
|
||||
Meteor.call('removeMeasurementsByPatientId', patientId);
|
||||
};
|
||||
@@ -1,15 +1,9 @@
|
||||
|
||||
// Resize viewport elements
|
||||
resizeViewportElements = function() {
|
||||
viewportResizeTimer = setTimeout(function() {
|
||||
var elements = $('.imageViewerViewport');
|
||||
elements.each(function(index) {
|
||||
var element = this;
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
var elements = $('.imageViewerViewport').not('.empty');
|
||||
elements.each(function(index, element) {
|
||||
cornerstone.resize(element, true);
|
||||
});
|
||||
}, 1);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Show / hide lesion tracker tools
|
||||
*/
|
||||
|
||||
var previousStates;
|
||||
var previousActiveTool;
|
||||
|
||||
var toolsShown = true;
|
||||
|
||||
toggleLesionTrackerTools = function() {
|
||||
if (toolsShown === true) {
|
||||
// Save the current settings for later
|
||||
previousStates = toolManager.getToolDefaultStates();
|
||||
previousActiveTool = toolManager.getActiveTool();
|
||||
|
||||
// Hide the tools (set them all to disabled)
|
||||
var toolDefaultStates = {
|
||||
activate: [],
|
||||
deactivate: [],
|
||||
enable: [],
|
||||
disable: ['lesion', 'nonTarget']
|
||||
};
|
||||
|
||||
toolManager.setToolDefaultStates(toolDefaultStates);
|
||||
|
||||
// Using setActiveTool with no arguments activates the
|
||||
// default tool on all available viewports
|
||||
toolManager.setActiveTool();
|
||||
|
||||
toolsShown = false;
|
||||
} else {
|
||||
// Show the tools (reload previous states)
|
||||
toolManager.setToolDefaultStates(previousStates);
|
||||
|
||||
// Using setActiveTool with no elements specified activates
|
||||
// the specified tool on all available viewports
|
||||
toolManager.setActiveTool(previousActiveTool);
|
||||
|
||||
toolsShown = true;
|
||||
}
|
||||
};
|
||||
@@ -63,11 +63,14 @@ Package.onUse(function (api) {
|
||||
// Library functions
|
||||
api.addFiles('lib/uuid.js', 'client');
|
||||
api.addFiles('lib/resizeViewportElements.js', 'client');
|
||||
|
||||
api.addFiles('lib/toggleLesionTrackerTools.js', 'client');
|
||||
api.addFiles('lib/clearTools.js', 'client');
|
||||
|
||||
// Export lesionTable function for activate measurements
|
||||
api.export('activateLesion','client');
|
||||
api.export('resizeViewportElements','client');
|
||||
api.export('toggleLesionTrackerTools', 'client');
|
||||
api.export('clearTools', 'client');
|
||||
api.export('measurementManagerDAL', 'client');
|
||||
|
||||
// Export client-side collections
|
||||
|
||||
Reference in new issue
Block a user