fix(toolManager) Fix default tools being overwritten (#215)

This commit is contained in:
Gustavo André Lelis 2018-07-03 09:00:01 -03:00 committed by Erik Ziegler
parent e55e2ad05a
commit 85e21181a8

View File

@ -115,17 +115,14 @@ export const toolManager = {
mouse: cornerstoneTools.arrowAnnotate, mouse: cornerstoneTools.arrowAnnotate,
touch: cornerstoneTools.arrowAnnotateTouch touch: cornerstoneTools.arrowAnnotateTouch
}); });
toolManager.addTool('rotate', { toolManager.addTool('rotate', {
mouse: cornerstoneTools.rotate, mouse: cornerstoneTools.rotate,
touch: cornerstoneTools.rotateTouchDrag touch: cornerstoneTools.rotateTouchDrag
}); });
toolManager.addTool('spine', { toolManager.addTool('spine', {
mouse: cornerstoneTools.textMarker, mouse: cornerstoneTools.textMarker,
touch: cornerstoneTools.textMarkerTouch touch: cornerstoneTools.textMarkerTouch
}); });
toolManager.addTool('crosshairs', { toolManager.addTool('crosshairs', {
mouse: cornerstoneTools.crosshairs, mouse: cornerstoneTools.crosshairs,
touch: cornerstoneTools.crosshairsTouch touch: cornerstoneTools.crosshairsTouch
@ -133,20 +130,23 @@ export const toolManager = {
// if a default tool is globally defined, make it the default tool... // if a default tool is globally defined, make it the default tool...
if (OHIF.viewer.defaultTool) { if (OHIF.viewer.defaultTool) {
defaultTool.left = OHIF.viewer.defaultTool; this.setDefaultTool(OHIF.viewer.defaultTool);
} }
defaultMouseButtonTools = Meteor.settings && Meteor.settings.public && Meteor.settings.public.defaultMouseButtonTools; defaultMouseButtonTools = Meteor.settings && Meteor.settings.public && Meteor.settings.public.defaultMouseButtonTools;
// Override default tool if defined in settings // Override default tool if defined in settings
const defaultLeft = (defaultMouseButtonTools && defaultMouseButtonTools.left) || 'wwwc'; if (defaultMouseButtonTools) {
const defaultRight = (defaultMouseButtonTools && defaultMouseButtonTools.right) || 'zoom'; if (defaultMouseButtonTools.left) {
const defaultMiddle = (defaultMouseButtonTools && defaultMouseButtonTools.middle) || 'pan'; this.setDefaultTool(defaultMouseButtonTools.left);
defaultTool = { }
left: defaultLeft, if (defaultMouseButtonTools.right) {
right: defaultRight, this.setDefaultTool(defaultMouseButtonTools.right, 'right');
middle: defaultMiddle }
}; if (defaultMouseButtonTools.middle) {
this.setDefaultTool(defaultMouseButtonTools.middle, 'middle');
}
}
this.configureTools(); this.configureTools();
initialized = true; initialized = true;
@ -565,7 +565,7 @@ export const toolManager = {
} }
if (!toolId) { if (!toolId) {
toolId = defaultTool[button]; toolId = this.getDefaultTool(button);
} }
// Otherwise, set the active tool for all viewport elements // Otherwise, set the active tool for all viewport elements