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
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user