Add button/hotkey to show/hide tools in viewports
This commit is contained in:
parent
ba05a3d21e
commit
b2d4812dd0
@ -1,23 +1,19 @@
|
||||
function resizeViewports() {
|
||||
log.info("viewer resizeViewports");
|
||||
var resizeTimer;
|
||||
|
||||
// Handle resizing of image viewer viewports
|
||||
// For some reason, this seems to need to be on
|
||||
// another delay, or the resizing won't work properly
|
||||
viewportResizeTimer = setTimeout(function() {
|
||||
var elements = $('.imageViewerViewport');
|
||||
elements.each(function(index) {
|
||||
var element = this;
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
cornerstone.resize(element, true);
|
||||
});
|
||||
}, 1);
|
||||
// TODO= Move this and resizeViewportElements to viewerbase
|
||||
function handleResize() {
|
||||
// Avoid doing DOM manipulation during the resize handler
|
||||
// because it is fired very often.
|
||||
// Resizing is therefore performed 100 ms after the resize event stops.
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(function() {
|
||||
resizeViewportElements();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
Template.viewer.onCreated(function() {
|
||||
enableHotkeys();
|
||||
// Attach the Window resize listener
|
||||
$(window).on('resize', handleResize);
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -53,9 +49,16 @@ Template.viewer.onCreated(function() {
|
||||
}
|
||||
OHIF.viewer.isPlaying[viewportIndex] = !OHIF.viewer.isPlaying[viewportIndex];
|
||||
Session.set('UpdateCINE', Random.id());
|
||||
}
|
||||
},
|
||||
toggleLesionTrackerTools: toggleLesionTrackerTools,
|
||||
clearTools: clearTools
|
||||
};
|
||||
|
||||
// The hotkey can also be an array (e.g. ["NUMPAD0", "0"])
|
||||
OHIF.viewer.defaultHotkeys.toggleLesionTrackerTools = "Y";
|
||||
|
||||
// Enable hotkeys
|
||||
enableHotkeys();
|
||||
|
||||
if (isTouchDevice()) {
|
||||
OHIF.viewer.tooltipConfig = {
|
||||
@ -71,7 +74,6 @@ Template.viewer.onCreated(function() {
|
||||
|
||||
if (ViewerData[contentId].loadedSeriesData) {
|
||||
log.info('Reloading previous loadedSeriesData');
|
||||
|
||||
OHIF.viewer.loadedSeriesData = ViewerData[contentId].loadedSeriesData;
|
||||
|
||||
} else {
|
||||
@ -179,7 +181,7 @@ function updateRelatedElements(imageId) {
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
// Update the display so the tool is removed
|
||||
var element = enabledElement.element;
|
||||
cornerstone.updateImage(element)
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}
|
||||
|
||||
@ -258,6 +260,10 @@ function addMeasurementAsToolData(data) {
|
||||
|
||||
Template.viewer.onDestroyed(function() {
|
||||
log.info("onDestroyed");
|
||||
|
||||
// Remove the Window resize listener
|
||||
$(window).off('resize', handleResize);
|
||||
|
||||
OHIF.viewer.updateImageSynchronizer.destroy();
|
||||
});
|
||||
|
||||
@ -299,15 +305,4 @@ function handleMeasurementRemoved(e, eventData) {
|
||||
Measurements.remove(databaseEntry._id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid doing DOM manipulation during the resize handler
|
||||
// because it is fired very often.
|
||||
// Resizing is therefore performed 100 ms after the resize event stops.
|
||||
var resizeTimer;
|
||||
$(window).on('resize', function() {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(function() {
|
||||
resizeViewports();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
@ -60,43 +60,17 @@ Template.viewerMain.helpers({
|
||||
iconClasses: 'fa fa-trash'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'toggleLesionTrackerTools',
|
||||
title: 'Show / hide tools',
|
||||
classes: 'imageViewerCommand',
|
||||
iconClasses: 'fa fa-eye'
|
||||
});
|
||||
|
||||
toolbarOptions.buttonData = buttonData;
|
||||
toolbarOptions.includePlayClipButton = false;
|
||||
toolbarOptions.includeLayoutButton = false;
|
||||
toolbarOptions.includeHangingProtocolButtons = false;
|
||||
return toolbarOptions;
|
||||
}
|
||||
});
|
||||
|
||||
Template.viewerMain.events({
|
||||
'click button#clearTools': function(e, template) {
|
||||
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
|
||||
$(".imageViewerViewport").each(function(viewportIndex, element) {
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
|
||||
// Remove patient's measurements
|
||||
Meteor.call('removeMeasurementsByPatientId', patientId);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
29
Packages/lesiontracker/lib/clearTools.js
Normal file
29
Packages/lesiontracker/lib/clearTools.js
Normal 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);
|
||||
|
||||
};
|
||||
41
Packages/lesiontracker/lib/toggleLesionTrackerTools.js
Normal file
41
Packages/lesiontracker/lib/toggleLesionTrackerTools.js
Normal file
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -171,6 +171,10 @@ toolManager = {
|
||||
toolManager.init();
|
||||
}
|
||||
|
||||
if (!tool) {
|
||||
tool = defaultTool;
|
||||
}
|
||||
|
||||
if (!elements || !elements.length) {
|
||||
elements = $('.imageViewerViewport');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user