- Fixed by setting all tools to passive mode after instantiate then all

- Fixed the default tool that was not being set correctly.
- Fixed some callouts done by Erik into my PR related with keeping old tool list
This commit is contained in:
Gustavo Lelis authored and Evren Ozkan committed 2018-11-09 13:24:47 -05:00
1 parent 51c5c76eb9
commit c30cdbe625
5 files changed
+25 -50

No files matched your search

@@ -284,7 +284,7 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
// Use the tool manager to enable the currently active tool for this
// newly rendered element
const activeTool = toolManager.getActiveTool();
toolManager.cTools.setToolActive(element, activeTool);
toolManager.setActiveTool(activeTool);
// Define a function to run whenever the Cornerstone viewport is rendered
// (e.g. following a change of window or zoom)
@@ -111,11 +111,12 @@ Meteor.startup(function() {
zoom: 'Zoom',
angle: 'Angle Measurement',
probe: 'Pixel Probe',
stackScroll: 'Stack Scroll',
ellipticalRoi: 'Elliptical ROI',
rectangleRoi: 'Rectangle ROI',
magnify: 'Magnify',
arrowAnnotate: 'Annotate',
stackScrollMouseWheel: 'Scroll Stack',
stackScrollMouseWheel: 'Scroll Stack Mouse Wheel',
pan: 'Pan',
length: 'Length Measurement',
wwwcRegion: 'W/L by Region',
@@ -12,7 +12,7 @@ import { textMarkerUtils } from './textMarkerUtils';
import { isTouchDevice } from './helpers/isTouchDevice';
let defaultTool = {
left: 'wwwcTool',
left: 'wwwc',
right: 'zoom',
middle: 'pan'
};
@@ -29,10 +29,10 @@ export const toolManager = {
init() {
// if a default tool is globally defined, make it the default tool...
if (OHIF.viewer.defaultTool) {
this.setDefaultTool(OHIF.viewer.defaultTool);
toolManager.setDefaultTool(OHIF.viewer.defaultTool);
}
this.cTools = cornerstoneTools.init();
toolManager.cTools = cornerstoneTools.init();
tools = [
'length',
@@ -41,9 +41,10 @@ export const toolManager = {
'wwwc',
'zoom',
'pan',
'probe',
'dragProbe',
'magnify',
'crosshairs',
'stackScroll',
'stackScrollMouseWheel',
'zoomTouchPinch',
'zoomMouseWheel',
@@ -91,14 +92,20 @@ export const toolManager = {
return tools;
},
setActiveToolForElement(toolName) {
this.setAllToolsPassive();
this.cTools.setToolActive(toolName, { mouseButtonMask: 1 });
setActiveTool(toolName, button = 1) {
toolManager.setAllToolsPassive();
toolManager.cTools.setToolActive(toolName, { mouseButtonMask: button });
// TODO: add the active tool with the correct button
activeTool['left'] = toolName;
// Enable reactivity
Session.set('ToolManagerActiveToolUpdated', Random.id());
},
setAllToolsPassive() {
this.cTools.store.state.tools.forEach((tool) => {
this.cTools.setToolPassive(tool.name)
toolManager.cTools.store.state.tools.forEach((tool) => {
toolManager.cTools.setToolPassive(tool.name)
})
},
@@ -106,43 +113,10 @@ export const toolManager = {
Array.from(tools).forEach(toolName => {
const apiTool = cornerstoneTools[`${toolName}Tool`];
if (apiTool) {
this.cTools.addTool(apiTool);
toolManager.cTools.addTool(apiTool);
}
});
},
setActiveTool(toolId, elements, button) {
let $elements;
if (!elements || !elements.length) {
$elements = $('.imageViewerViewport');
} else {
$elements = $(elements);
}
const checkElementEnabled = function(allElementsEnabled, element) {
try {
cornerstone.getEnabledElement(element);
return allElementsEnabled;
} catch (error) {
return true;
}
};
// Otherwise, set the active tool for all viewport elements
$elements.each((index, element) => {
if (checkElementEnabled(element) === false) {
return;
}
toolManager.setActiveToolForElement(toolId, element);
});
activeTool['left'] = toolId;
// Enable reactivity
Session.set('ToolManagerActiveToolUpdated', Random.id());
toolManager.setAllToolsPassive();
},
getNearbyToolData(element, coords, toolTypes) {