Add button/hotkey to show/hide tools in viewports

This commit is contained in:
Erik Ziegler committed 2015-12-11 17:55:26 +01:00
1 parent ba05a3d21e
commit b2d4812dd0
8 files changed
+119 -99

No files matched your search

+29
View File
@@ -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;
}
};
+4 -1
View File
@@ -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
+6 -26
View File
@@ -433,10 +433,6 @@ Meteor.startup(function() {
var tool = toolManager.getDefaultTool();
toolManager.setActiveTool(tool);
},
toggleTools: function() {
//TODO= Write this function in toolManager?
console.log("Show/hide all tools");
},
toggleOverlayTags: function() {
var dicomTags = $('.imageViewerViewportOverlay .dicomTag');
if (dicomTags.eq(0).css('display') === 'none') {
@@ -501,28 +497,6 @@ function flashButton(button) {
}, 100);
}
function setActiveViewportContainer(container) {
if (!container) {
return;
}
var container = $(container);
container.addClass('active');
var element = container.find(".imageViewerViewport").get(0);
if (!element) {
return;
}
var viewportIndex = $('.imageViewerViewport').index(element);
Session.set
// Finally, enable stack prefetching and hide the reference lines from
// the newly activated viewport
enablePrefetchOnElement(element);
displayReferenceLines(element);
}
function bindHotkey(hotkey, task) {
var hotkeyFunctions = OHIF.viewer.hotkeyFunctions;
@@ -539,6 +513,12 @@ function bindHotkey(hotkey, task) {
};
} else {
fn = hotkeyFunctions[task];
// If the function doesn't exist in the
// hotkey function list, try the viewer-specific function list
if (!fn && OHIF.viewer && OHIF.viewer.functionList) {
fn = OHIF.viewer.functionList[task];
}
}
if (!fn) {
+4
View File
@@ -171,6 +171,10 @@ toolManager = {
toolManager.init();
}
if (!tool) {
tool = defaultTool;
}
if (!elements || !elements.length) {
elements = $('.imageViewerViewport');
}