- 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:
parent
44cb47f64a
commit
5865f542f8
@ -43,7 +43,7 @@ OHIF.measurements.getImageDataUrl = ({
|
||||
});
|
||||
|
||||
cornerstoneTools.addToolState(element, measurement.toolType, state);
|
||||
cornerstoneTools[measurement.toolType].enable(element);
|
||||
OHIF.viewerbase.toolManager.cTools.setToolEnabled(measurement.toolType);
|
||||
}
|
||||
|
||||
// Set the viewport voi if present
|
||||
@ -59,7 +59,7 @@ OHIF.measurements.getImageDataUrl = ({
|
||||
|
||||
// Disable the tool and clear the measurement state if a measurement was given
|
||||
if (measurement) {
|
||||
cornerstoneTools[measurement.toolType].disable(element);
|
||||
OHIF.viewerbase.toolManager.cTools.setToolDisabled(measurement.toolType);
|
||||
cornerstoneTools.clearToolState(element, measurement.toolType);
|
||||
}
|
||||
|
||||
|
||||
@ -274,7 +274,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) {
|
||||
|
||||
@ -68,7 +68,7 @@ Template.toolbarSection.helpers({
|
||||
});
|
||||
|
||||
extraTools.push({
|
||||
id: 'probe',
|
||||
id: 'dragProbe',
|
||||
title: 'Probe',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-dot-circle-o'
|
||||
@ -126,7 +126,7 @@ Template.toolbarSection.helpers({
|
||||
const buttonData = [];
|
||||
|
||||
buttonData.push({
|
||||
id: 'stackScrollMouseWheel',
|
||||
id: 'stackScroll',
|
||||
title: 'Stack Scroll',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-bars'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user