OHIF-110: creating the context-menu for measurements in the viewport for desktop and mobile. Coded action delete (#112)

This commit is contained in:
André Botelho Almeida authored and Erik Ziegler committed 2017-09-27 21:55:14 +02:00
1 parent af4b8b45f5
commit bacfa24216
4 files changed
+129 -2

No files matched your search

@@ -6,6 +6,7 @@ import { updateCrosshairsSynchronizer } from './updateCrosshairsSynchronizer';
import { crosshairsSynchronizers } from './crosshairsSynchronizers';
import { annotateTextUtils } from './annotateTextUtils';
import { textMarkerUtils } from './textMarkerUtils';
import { isTouchDevice } from './helpers/isTouchDevice';
let defaultTool = 'wwwc';
let activeTool;
@@ -446,6 +447,51 @@ export const toolManager = {
Session.set('ToolManagerActiveTool', tool);
},
getNearbyToolData(element, coords, toolTypes) {
const allTools = this.getTools();
const touchDevice = isTouchDevice();
const nearbyTool = {};
let pointNearTool = false;
toolTypes.forEach(function(toolType) {
const toolData = cornerstoneTools.getToolState(element, toolType);
if (!toolData) {
return;
}
toolData.data.forEach(function(data, index) {
let toolInterfaceName = toolType;
let toolInterface;
// Edge cases where the tool is not the same as the typeName
if (toolType === 'simpleAngle') {
toolInterfaceName = 'angle';
} else if (toolType === 'arrowAnnotate') {
toolInterfaceName = 'annotate';
}
if (touchDevice) {
toolInterface = allTools[toolInterfaceName].touch;
} else {
toolInterface = allTools[toolInterfaceName].mouse;
}
if (toolInterface.pointNearTool(element, data, coords)) {
pointNearTool = true;
nearbyTool.tool = data;
nearbyTool.index = index;
nearbyTool.toolType = toolType;
}
});
if (pointNearTool) {
return false;
}
});
return pointNearTool ? nearbyTool : undefined;
},
getActiveTool() {
if (!initialized) {
toolManager.init();