Fixing issues with bidirectional tool and measure flow
This commit is contained in:
1 parent
797b2f5588
commit
00a76a6ca5
10 files changed
+85
-75
No files matched your search
+9
-5
@@ -6,7 +6,8 @@ import pointNearTool from './pointNearTool';
|
||||
|
||||
// Replaces the cornerstoneTools.handleActivator function by skiping the active handle comparison
|
||||
const handleActivator = (element, handles, canvasPoint, distanceThreshold=6) => {
|
||||
const nearbyHandle = cornerstoneTools.getHandleNearImagePoint(element, handles, canvasPoint, distanceThreshold);
|
||||
const getHandle = cornerstoneTools.getHandleNearImagePoint;
|
||||
const nearbyHandle = getHandle(element, handles, canvasPoint, distanceThreshold);
|
||||
|
||||
let handleActivatorChanged = false;
|
||||
Object.keys(handles).forEach(handleKey => {
|
||||
@@ -26,6 +27,7 @@ const handleActivator = (element, handles, canvasPoint, distanceThreshold=6) =>
|
||||
// mouseMoveCallback is used to hide handles when mouse is away
|
||||
export default function (event) {
|
||||
const eventData = event.detail;
|
||||
const { element } = eventData;
|
||||
cornerstoneTools.toolCoordinates.setCoords(eventData);
|
||||
// if a mouse button is down, do nothing
|
||||
if (eventData.which !== 0) {
|
||||
@@ -33,7 +35,7 @@ export default function (event) {
|
||||
}
|
||||
|
||||
// if we have no tool data for this element, do nothing
|
||||
const toolData = cornerstoneTools.getToolState(eventData.element, toolType);
|
||||
const toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) return;
|
||||
|
||||
// We have tool data, search through all data and see if we can activate a handle
|
||||
@@ -43,7 +45,7 @@ export default function (event) {
|
||||
const coords = eventData.currentPoints.canvas;
|
||||
|
||||
const data = toolData.data[i];
|
||||
const handleActivatorChanged = handleActivator(eventData.element, data.handles, coords);
|
||||
const handleActivatorChanged = handleActivator(element, data.handles, coords);
|
||||
Object.keys(data.handles).forEach(handleKey => {
|
||||
if (handleKey === 'textBox') return;
|
||||
const handle = data.handles[handleKey];
|
||||
@@ -54,7 +56,9 @@ export default function (event) {
|
||||
imageNeedsUpdate = true;
|
||||
}
|
||||
|
||||
if ((pointNearTool(eventData.element, data, coords) && !data.active) || (!pointNearTool(eventData.element, data, coords) && data.active)) {
|
||||
const nearToolAndInactive = pointNearTool(element, data, coords) && !data.active;
|
||||
const notNearToolAndActive = !pointNearTool(element, data, coords) && data.active;
|
||||
if (nearToolAndInactive || notNearToolAndActive) {
|
||||
data.active = !data.active;
|
||||
imageNeedsUpdate = true;
|
||||
}
|
||||
@@ -62,6 +66,6 @@ export default function (event) {
|
||||
|
||||
// Handle activation status changed, redraw the image
|
||||
if (imageNeedsUpdate === true) {
|
||||
cornerstone.updateImage(eventData.element);
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user