LT-40: Recalculating text call-outs position when creating measurments without dragging
This commit is contained in:
parent
8df077f046
commit
888c337f84
@ -28,7 +28,12 @@ OHIF.cornerstone.pixelToPage = (element, position) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) => {
|
OHIF.cornerstone.repositionTextBox = (eventData, measurementData) => {
|
||||||
|
// Stop here if it's not a measurement creating
|
||||||
|
if (!measurementData.isCreating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const element = eventData.element;
|
const element = eventData.element;
|
||||||
const enabledElement = cornerstone.getEnabledElement(element);
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
const $element = $(element);
|
const $element = $(element);
|
||||||
@ -96,7 +101,6 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) =
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const modifiedCallback = () => {
|
|
||||||
const handles = measurementData.handles;
|
const handles = measurementData.handles;
|
||||||
const textBox = handles.textBox;
|
const textBox = handles.textBox;
|
||||||
|
|
||||||
@ -204,16 +208,4 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) =
|
|||||||
const pixelPosition = cornerstone.pageToPixel(element, x, y);
|
const pixelPosition = cornerstone.pageToPixel(element, x, y);
|
||||||
textBox[toolAxis] = pixelPosition[toolAxis];
|
textBox[toolAxis] = pixelPosition[toolAxis];
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const mouseUpCallback = () => {
|
|
||||||
$element.off('CornerstoneToolsMeasurementModified', modifiedCallback);
|
|
||||||
};
|
|
||||||
|
|
||||||
$element.one('CornerstoneToolsMouseDrag', () => {
|
|
||||||
$element.on('CornerstoneToolsMeasurementModified', modifiedCallback);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Using mouseup because sometimes the CornerstoneToolsMouseUp event is not triggered
|
|
||||||
$element.one('mouseup', mouseUpCallback);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -44,6 +44,7 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
function createNewMeasurement(mouseEventData) {
|
function createNewMeasurement(mouseEventData) {
|
||||||
// Create the measurement data for this tool with the end handle activated
|
// Create the measurement data for this tool with the end handle activated
|
||||||
const measurementData = {
|
const measurementData = {
|
||||||
|
isCreating: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
active: true,
|
active: true,
|
||||||
handles: {
|
handles: {
|
||||||
@ -99,8 +100,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
toolType: 'bidirectional'
|
toolType: 'bidirectional'
|
||||||
};
|
};
|
||||||
|
|
||||||
OHIF.cornerstone.repositionTextBoxWhileDragging(mouseEventData, measurementData);
|
|
||||||
|
|
||||||
return measurementData;
|
return measurementData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1040,6 +1039,8 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
|
|
||||||
data.handles.textBox.boundingBox = boundingBox;
|
data.handles.textBox.boundingBox = boundingBox;
|
||||||
|
|
||||||
|
OHIF.cornerstone.repositionTextBox(eventData, data);
|
||||||
|
|
||||||
// Draw linked line as dashed
|
// Draw linked line as dashed
|
||||||
var link = {
|
var link = {
|
||||||
start: {},
|
start: {},
|
||||||
|
|||||||
@ -38,6 +38,8 @@ import { toolManager } from 'meteor/ohif:viewerbase';
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete measurementData.isCreating;
|
||||||
|
|
||||||
OHIF.ui.showFormDialog('dialogNonTargetMeasurement', {
|
OHIF.ui.showFormDialog('dialogNonTargetMeasurement', {
|
||||||
position: getPosition(eventData),
|
position: getPosition(eventData),
|
||||||
title: 'Select Lesion Location',
|
title: 'Select Lesion Location',
|
||||||
@ -142,6 +144,7 @@ import { toolManager } from 'meteor/ohif:viewerbase';
|
|||||||
|
|
||||||
// create the measurement data for this tool with the end handle activated
|
// create the measurement data for this tool with the end handle activated
|
||||||
var measurementData = {
|
var measurementData = {
|
||||||
|
isCreating: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
active: true,
|
active: true,
|
||||||
handles: {
|
handles: {
|
||||||
@ -178,8 +181,6 @@ import { toolManager } from 'meteor/ohif:viewerbase';
|
|||||||
toolType: 'nonTarget'
|
toolType: 'nonTarget'
|
||||||
};
|
};
|
||||||
|
|
||||||
OHIF.cornerstone.repositionTextBoxWhileDragging(mouseEventData, measurementData);
|
|
||||||
|
|
||||||
return measurementData;
|
return measurementData;
|
||||||
}
|
}
|
||||||
///////// END ACTIVE TOOL ///////
|
///////// END ACTIVE TOOL ///////
|
||||||
@ -255,6 +256,8 @@ import { toolManager } from 'meteor/ohif:viewerbase';
|
|||||||
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.measurementNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.measurementNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||||
data.handles.textBox.boundingBox = boundingBox;
|
data.handles.textBox.boundingBox = boundingBox;
|
||||||
|
|
||||||
|
OHIF.cornerstone.repositionTextBox(eventData, data);
|
||||||
|
|
||||||
// Draw linked line as dashed
|
// Draw linked line as dashed
|
||||||
var link = {
|
var link = {
|
||||||
start: {},
|
start: {},
|
||||||
|
|||||||
@ -40,6 +40,8 @@ Template.measurementLocationDialog.onCreated(() => {
|
|||||||
const timepointApi = instance.data.timepointApi;
|
const timepointApi = instance.data.timepointApi;
|
||||||
|
|
||||||
const toggleLabel = (measurementData, eventData, doneCallback) => {
|
const toggleLabel = (measurementData, eventData, doneCallback) => {
|
||||||
|
delete measurementData.isCreating;
|
||||||
|
|
||||||
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user