Bug fixing: First measurement of target tool is shown as 0 in the table until it is moved
This commit is contained in:
parent
6ebff476a2
commit
5010307b6e
@ -7,10 +7,18 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
}
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
// Set lesion number
|
||||
// Get Target lesions on image
|
||||
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
var lesionNumber = 1;
|
||||
doneCallback(lesionNumber);
|
||||
}
|
||||
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
@ -40,7 +48,8 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools.lesion.getConfiguration();
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
|
||||
@ -50,6 +59,11 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.lesion.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.lesion.mouseDownActivateCallback);
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
@ -57,8 +71,7 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
} else {
|
||||
// Set lesionMeasurementData Session
|
||||
var config = cornerstoneTools.lesion.getConfiguration();
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData);
|
||||
}
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.lesion.mouseMoveCallback);
|
||||
@ -232,45 +245,44 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
// draw the handles
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
|
||||
if (data.lesionName) {
|
||||
//Draw linked line as dashed
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
//Draw linked line as dashed
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
// Draw the text
|
||||
var dx = (data.handles.start.x - data.handles.end.x) * (eventData.image.columnPixelSpacing || 1);
|
||||
var dy = (data.handles.start.y - data.handles.end.y) * (eventData.image.rowPixelSpacing || 1);
|
||||
var length = Math.sqrt(dx * dx + dy * dy);
|
||||
// Draw the text
|
||||
var dx = (data.handles.start.x - data.handles.end.x) * (eventData.image.columnPixelSpacing || 1);
|
||||
var dy = (data.handles.start.y - data.handles.end.y) * (eventData.image.rowPixelSpacing || 1);
|
||||
var length = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
var suffix = ' mm';
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
suffix = ' pixels';
|
||||
}
|
||||
|
||||
var text = '' + length.toFixed(2) + suffix;
|
||||
var textLines = [data.lesionName, text];
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context,
|
||||
textLines,
|
||||
canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
|
||||
// Set measurement text to show lesion table
|
||||
data.measurementText = length.toFixed(1);
|
||||
var suffix = ' mm';
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
suffix = ' pixels';
|
||||
}
|
||||
|
||||
var text = '' + length.toFixed(2) + suffix;
|
||||
var textLines = [data.lesionName, text];
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context,
|
||||
textLines,
|
||||
canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
|
||||
// Set measurement text to show lesion table
|
||||
data.measurementText = length.toFixed(1);
|
||||
|
||||
|
||||
context.restore();
|
||||
|
||||
updateLesionCollection(toolData.data[i]);
|
||||
@ -278,6 +290,7 @@ var cornerstoneTools = (function($, cornerstone, cornerstoneMath, cornerstoneToo
|
||||
}
|
||||
|
||||
function updateLesionCollection(lesionData) {
|
||||
console.log(lesionData.measurementText);
|
||||
// TODO = Remove this in favour of measurement events
|
||||
if (!lesionData.active) {
|
||||
return;
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
@ -70,9 +70,10 @@
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
}else{
|
||||
config.getNonTargetLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
|
||||
config.getNonTargetLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
$(mouseEventData.element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(mouseEventData.element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
|
||||
@ -1,21 +1,17 @@
|
||||
// This event determines whether or not to show the lesion dialog
|
||||
// If there already exists a lesion with this specific lesion number,
|
||||
// related to the chosen location.
|
||||
function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
// Get the lesion location dialog
|
||||
var lesionDialog = $("#lesionLocationDialog");
|
||||
|
||||
// Find the select option box
|
||||
var selector = lesionDialog.find("select#selectLesionLocation");
|
||||
// This event sets lesion number for new lesion
|
||||
|
||||
function setLesionNumberCallback(measurementData, eventData, doneCallback) {
|
||||
// Get the current element's timepointID from the study date metadata
|
||||
var element = eventData.element;
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
var study = cornerstoneTools.metaData.get('study', enabledElement.image.imageId);
|
||||
var imageId = enabledElement.image.imageId;
|
||||
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var timepoint = Timepoints.findOne({timepointName: study.studyDate});
|
||||
if (!timepoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
measurementData.timepointID = timepoint.timepointID;
|
||||
|
||||
// Get a lesion number for this lesion, depending on whether or not the same lesion previously
|
||||
@ -23,6 +19,20 @@ function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
var lesionNumber = measurementManagerDAL.getNewLesionNumber(measurementData.timepointID, isTarget=true);
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
|
||||
// Set lesion number
|
||||
doneCallback(lesionNumber);
|
||||
}
|
||||
|
||||
// This event determines whether or not to show the lesion dialog
|
||||
// If there already exists a lesion with this specific lesion number,
|
||||
// related to the chosen location.
|
||||
function getLesionLocationCallback(measurementData, eventData) {
|
||||
// Get the lesion location dialog
|
||||
var lesionDialog = $("#lesionLocationDialog");
|
||||
|
||||
// Find the select option box
|
||||
var selector = lesionDialog.find("select#selectLesionLocation");
|
||||
|
||||
// Find out if this lesion number is already added in the lesion manager for another timepoint
|
||||
// If it is, stop here because we don't need the dialog.
|
||||
var locationUID = measurementManagerDAL.lesionNumberExists(measurementData);
|
||||
@ -45,9 +55,6 @@ function getLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
// Hide the lesion dialog
|
||||
lesionDialog.css('display', 'none');
|
||||
|
||||
// Fire the doneCallback with the lesion number
|
||||
doneCallback(lesionNumber);
|
||||
|
||||
// Select the first option for the next time the dialog is opened
|
||||
selector.find("option:first").prop("selected", true);
|
||||
|
||||
@ -135,6 +142,7 @@ function changeLesionLocationCallback(measurementData, eventData, doneCallback)
|
||||
}
|
||||
|
||||
var config = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user