Fixing delete lesion tool
This commit is contained in:
1 parent
5330ba5982
commit
5af752a122
3 files changed
+56
-35
No files matched your search
@@ -1,15 +1,27 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
const keys = {
|
||||
D: 68,
|
||||
DELETE: 46
|
||||
};
|
||||
|
||||
// Defined the toolTypes for which the delete dialog will be displayed when the keys are pressed
|
||||
const toolTypes = [
|
||||
'bidirectional',
|
||||
'targetCR',
|
||||
'targetUN',
|
||||
'targetEX',
|
||||
'nonTarget',
|
||||
'length',
|
||||
'ellipticalRoi',
|
||||
'rectangleRoi'
|
||||
];
|
||||
|
||||
function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||
var imageId = data.imageId;
|
||||
let { imageId } = data;
|
||||
if (!imageId) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
const enabledElement = cornerstone.getEnabledElement(element);
|
||||
imageId = enabledElement.image.imageId;
|
||||
}
|
||||
|
||||
@@ -18,25 +30,24 @@ function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||
}
|
||||
|
||||
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||
function getNearbyToolData(element, coords, toolTypes) {
|
||||
var allTools = Viewerbase.toolManager.getTools();
|
||||
var pointNearTool = false;
|
||||
var touchDevice = Viewerbase.helpers.isTouchDevice();
|
||||
var nearbyTool = {},
|
||||
nearbyToolIndex,
|
||||
nearbyToolType;
|
||||
function getNearbyToolData(element, coords) {
|
||||
const Viewerbase = OHIF.viewerbase;
|
||||
const allTools = Viewerbase.toolManager.getTools();
|
||||
let pointNearTool = false;
|
||||
const isTouchDevice = Viewerbase.helpers.isTouchDevice();
|
||||
const nearbyTool = {};
|
||||
|
||||
toolTypes.forEach(function(toolType) {
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
toolTypes.forEach(toolType => {
|
||||
const toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
for (let i = 0; i < toolData.data.length; i++) {
|
||||
const data = toolData.data[i];
|
||||
|
||||
var toolInterface;
|
||||
if (touchDevice) {
|
||||
let toolInterface;
|
||||
if (isTouchDevice) {
|
||||
toolInterface = allTools[toolType].touch;
|
||||
} else {
|
||||
toolInterface = allTools[toolType].mouse;
|
||||
@@ -59,20 +70,20 @@ function getNearbyToolData(element, coords, toolTypes) {
|
||||
return pointNearTool ? nearbyTool : undefined;
|
||||
}
|
||||
|
||||
function keyDownCallback(e, eventData) {
|
||||
var keyCode = eventData.which;
|
||||
function keyDownCallback(event, eventData) {
|
||||
const keyCode = eventData.which;
|
||||
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||
|
||||
var toolTypes = [ 'bidirectional', 'nonTarget', 'length', 'targetCR', 'targetUN', 'targetEX'];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
const nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas);
|
||||
|
||||
if (!nearbyToolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dialogSettings = {
|
||||
class: 'themed',
|
||||
title: 'Delete measurements',
|
||||
message: 'Are you sure you want to delete this measurement?'
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user