Fixing delete lesion tool
This commit is contained in:
parent
5330ba5982
commit
5af752a122
@ -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
|
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||||
var keys = {
|
const keys = {
|
||||||
D: 68,
|
D: 68,
|
||||||
DELETE: 46
|
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) {
|
function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||||
var imageId = data.imageId;
|
let { imageId } = data;
|
||||||
if (!imageId) {
|
if (!imageId) {
|
||||||
var enabledElement = cornerstone.getEnabledElement(element);
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
imageId = enabledElement.image.imageId;
|
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
|
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||||
function getNearbyToolData(element, coords, toolTypes) {
|
function getNearbyToolData(element, coords) {
|
||||||
var allTools = Viewerbase.toolManager.getTools();
|
const Viewerbase = OHIF.viewerbase;
|
||||||
var pointNearTool = false;
|
const allTools = Viewerbase.toolManager.getTools();
|
||||||
var touchDevice = Viewerbase.helpers.isTouchDevice();
|
let pointNearTool = false;
|
||||||
var nearbyTool = {},
|
const isTouchDevice = Viewerbase.helpers.isTouchDevice();
|
||||||
nearbyToolIndex,
|
const nearbyTool = {};
|
||||||
nearbyToolType;
|
|
||||||
|
|
||||||
toolTypes.forEach(function(toolType) {
|
toolTypes.forEach(toolType => {
|
||||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
const toolData = cornerstoneTools.getToolState(element, toolType);
|
||||||
if (!toolData) {
|
if (!toolData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < toolData.data.length; i++) {
|
for (let i = 0; i < toolData.data.length; i++) {
|
||||||
var data = toolData.data[i];
|
const data = toolData.data[i];
|
||||||
|
|
||||||
var toolInterface;
|
let toolInterface;
|
||||||
if (touchDevice) {
|
if (isTouchDevice) {
|
||||||
toolInterface = allTools[toolType].touch;
|
toolInterface = allTools[toolType].touch;
|
||||||
} else {
|
} else {
|
||||||
toolInterface = allTools[toolType].mouse;
|
toolInterface = allTools[toolType].mouse;
|
||||||
@ -59,20 +70,20 @@ function getNearbyToolData(element, coords, toolTypes) {
|
|||||||
return pointNearTool ? nearbyTool : undefined;
|
return pointNearTool ? nearbyTool : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyDownCallback(e, eventData) {
|
function keyDownCallback(event, eventData) {
|
||||||
var keyCode = eventData.which;
|
const keyCode = eventData.which;
|
||||||
|
|
||||||
if (keyCode === keys.DELETE ||
|
if (keyCode === keys.DELETE ||
|
||||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||||
|
|
||||||
var toolTypes = [ 'bidirectional', 'nonTarget', 'length', 'targetCR', 'targetUN', 'targetEX'];
|
const nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas);
|
||||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
|
||||||
|
|
||||||
if (!nearbyToolData) {
|
if (!nearbyToolData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dialogSettings = {
|
const dialogSettings = {
|
||||||
|
class: 'themed',
|
||||||
title: 'Delete measurements',
|
title: 'Delete measurements',
|
||||||
message: 'Are you sure you want to delete this measurement?'
|
message: 'Are you sure you want to delete this measurement?'
|
||||||
};
|
};
|
||||||
|
|||||||
@ -376,17 +376,20 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
|||||||
// since this callback function is called multiple times (eg: when a tool is
|
// since this callback function is called multiple times (eg: when a tool is
|
||||||
// enabled/disabled -> cornerstone[toolName].tool.enable)
|
// enabled/disabled -> cornerstone[toolName].tool.enable)
|
||||||
|
|
||||||
|
// Reset the focus, even if we don't need to re-enable reference lines or prefetching
|
||||||
|
const element = (eventData && eventData.element) || (event && event.currentTarget);
|
||||||
|
if (!element) return;
|
||||||
|
const $element = $(element);
|
||||||
|
$element.focus();
|
||||||
|
|
||||||
|
// Stop here if we don't have eventData set
|
||||||
|
if (!eventData) return;
|
||||||
|
|
||||||
// Check if the current active viewport in the Meteor Session
|
// Check if the current active viewport in the Meteor Session
|
||||||
// Is the same as the viewport in which the activation event was fired.
|
// Is the same as the viewport in which the activation event was fired.
|
||||||
// If it was, no changes are necessary, so stop here.
|
// If it was, no changes are necessary, so stop here.
|
||||||
const activeViewportIndex = Session.get('activeViewport');
|
const activeViewportIndex = Session.get('activeViewport');
|
||||||
if (viewportIndex === activeViewportIndex) {
|
if (viewportIndex === activeViewportIndex) return;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the focus, even if we don't need to re-enable reference lines or prefetching
|
|
||||||
const element = eventData.element;
|
|
||||||
$(element).focus();
|
|
||||||
|
|
||||||
OHIF.log.info('imageViewerViewport sendActivationTrigger');
|
OHIF.log.info('imageViewerViewport sendActivationTrigger');
|
||||||
|
|
||||||
@ -397,12 +400,14 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
|||||||
|
|
||||||
// Need to overwrite the type set in the original event
|
// Need to overwrite the type set in the original event
|
||||||
customEvent.type = 'OHIFActivateViewport';
|
customEvent.type = 'OHIFActivateViewport';
|
||||||
$(event.target).trigger(customEvent, eventData);
|
$element.trigger(customEvent, eventData);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attach the sendActivationTrigger function to all of the Cornerstone interaction events
|
// Attach the sendActivationTrigger function to all of the Cornerstone interaction events
|
||||||
$element.off(allCornerstoneEvents, sendActivationTrigger);
|
$element.off(allCornerstoneEvents, sendActivationTrigger);
|
||||||
$element.on(allCornerstoneEvents, sendActivationTrigger);
|
$element.on(allCornerstoneEvents, sendActivationTrigger);
|
||||||
|
$element.off('mouseenter', sendActivationTrigger);
|
||||||
|
$element.on('mouseenter', sendActivationTrigger);
|
||||||
|
|
||||||
OHIF.viewer.data.loadedSeriesData = layoutManager.viewportData;
|
OHIF.viewer.data.loadedSeriesData = layoutManager.viewportData;
|
||||||
|
|
||||||
@ -522,6 +527,11 @@ Template.imageViewerViewport.onRendered(function() {
|
|||||||
// add the CSS 'active' class to highlight this viewport.
|
// add the CSS 'active' class to highlight this viewport.
|
||||||
const activeViewport = Session.get('activeViewport');
|
const activeViewport = Session.get('activeViewport');
|
||||||
|
|
||||||
|
// Focus the viewport if it's the active one
|
||||||
|
if (templateData.viewportIndex === activeViewport) {
|
||||||
|
this.$element.focus();
|
||||||
|
}
|
||||||
|
|
||||||
let { currentImageIdIndex } = templateData;
|
let { currentImageIdIndex } = templateData;
|
||||||
const { viewport, studyInstanceUid, seriesInstanceUid, renderedCallback, displaySetInstanceUid } = templateData;
|
const { viewport, studyInstanceUid, seriesInstanceUid, renderedCallback, displaySetInstanceUid } = templateData;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Session } from 'meteor/session';
|
import { Session } from 'meteor/session';
|
||||||
import { $ } from 'meteor/jquery';
|
import { $ } from 'meteor/jquery';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { _ } from 'meteor/underscore';
|
|
||||||
import { getFrameOfReferenceUID } from './getFrameOfReferenceUID';
|
import { getFrameOfReferenceUID } from './getFrameOfReferenceUID';
|
||||||
import { updateCrosshairsSynchronizer } from './updateCrosshairsSynchronizer';
|
import { updateCrosshairsSynchronizer } from './updateCrosshairsSynchronizer';
|
||||||
import { crosshairsSynchronizers } from './crosshairsSynchronizers';
|
import { crosshairsSynchronizers } from './crosshairsSynchronizers';
|
||||||
@ -129,7 +129,7 @@ export const toolManager = {
|
|||||||
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
|
||||||
defaultTool = (defaultMouseButtonTools && defaultMouseButtonTools.left) || "wwwc";
|
defaultTool = (defaultMouseButtonTools && defaultMouseButtonTools.left) || 'wwwc';
|
||||||
|
|
||||||
this.configureTools();
|
this.configureTools();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -310,10 +310,10 @@ export const toolManager = {
|
|||||||
// Get the imageIds for this element
|
// Get the imageIds for this element
|
||||||
const imageIds = toolData.data[0].imageIds;
|
const imageIds = toolData.data[0].imageIds;
|
||||||
|
|
||||||
const defaultMouseButtonToolNameMiddle = (defaultMouseButtonTools && defaultMouseButtonTools.middle) || "pan";
|
const defaultMouseButtonToolNameMiddle = (defaultMouseButtonTools && defaultMouseButtonTools.middle) || 'pan';
|
||||||
const defaultMouseButtonToolMiddle = cornerstoneTools[defaultMouseButtonToolNameMiddle];
|
const defaultMouseButtonToolMiddle = cornerstoneTools[defaultMouseButtonToolNameMiddle];
|
||||||
|
|
||||||
const defaultMouseButtonToolNameRight = (defaultMouseButtonTools && defaultMouseButtonTools.right) || "zoom";
|
const defaultMouseButtonToolNameRight = (defaultMouseButtonTools && defaultMouseButtonTools.right) || 'zoom';
|
||||||
const defaultMouseButtonToolRight = cornerstoneTools[defaultMouseButtonToolNameRight];
|
const defaultMouseButtonToolRight = cornerstoneTools[defaultMouseButtonToolNameRight];
|
||||||
|
|
||||||
// Deactivate all the middle mouse, right click, and scroll wheel tools
|
// Deactivate all the middle mouse, right click, and scroll wheel tools
|
||||||
@ -483,9 +483,9 @@ export const toolManager = {
|
|||||||
|
|
||||||
// Edge cases where the tool is not the same as the typeName
|
// Edge cases where the tool is not the same as the typeName
|
||||||
if (toolType === 'simpleAngle') {
|
if (toolType === 'simpleAngle') {
|
||||||
toolInterfaceName = 'angle';
|
toolInterfaceName = 'angle';
|
||||||
} else if (toolType === 'arrowAnnotate') {
|
} else if (toolType === 'arrowAnnotate') {
|
||||||
toolInterfaceName = 'annotate';
|
toolInterfaceName = 'annotate';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (touchDevice) {
|
if (touchDevice) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user