LT-404: Fixing Target undefined label when start creating a measurement
This commit is contained in:
parent
20bd3f443c
commit
5c316bf334
@ -997,12 +997,6 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
width = 0;
|
width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the textbox
|
|
||||||
var suffix = ' mm';
|
|
||||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
|
||||||
suffix = ' pixels';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Length is always longer than width
|
// Length is always longer than width
|
||||||
if (width > length) {
|
if (width > length) {
|
||||||
var tempW = width;
|
var tempW = width;
|
||||||
@ -1011,64 +1005,72 @@ import { OHIF } from 'meteor/ohif:core';
|
|||||||
width = tempL;
|
width = tempL;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lengthText = ' L ' + length.toFixed(1) + suffix;
|
if (data.measurementNumber) {
|
||||||
var widthText = ' W ' + width.toFixed(1) + suffix;
|
// Draw the textbox
|
||||||
var textLines = [ 'Target ' + data.measurementNumber, lengthText, widthText ];
|
var suffix = ' mm';
|
||||||
|
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||||
|
suffix = ' pixels';
|
||||||
|
}
|
||||||
|
|
||||||
var boundingBox = cornerstoneTools.drawTextBox(context,
|
var lengthText = ' L ' + length.toFixed(1) + suffix;
|
||||||
textLines,
|
var widthText = ' W ' + width.toFixed(1) + suffix;
|
||||||
canvasTextLocation.x, canvasTextLocation.y, color);
|
var textLines = [`Target ${data.measurementNumber}`, lengthText, widthText];
|
||||||
|
|
||||||
data.handles.textBox.boundingBox = boundingBox;
|
var boundingBox = cornerstoneTools.drawTextBox(context,
|
||||||
|
textLines,
|
||||||
|
canvasTextLocation.x, canvasTextLocation.y, color);
|
||||||
|
|
||||||
OHIF.cornerstone.repositionTextBox(eventData, data);
|
data.handles.textBox.boundingBox = boundingBox;
|
||||||
|
|
||||||
// Draw linked line as dashed
|
OHIF.cornerstone.repositionTextBox(eventData, data);
|
||||||
var link = {
|
|
||||||
start: {},
|
|
||||||
end: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
var midpointCanvas = {
|
// Draw linked line as dashed
|
||||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
var link = {
|
||||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2,
|
start: {},
|
||||||
};
|
end: {}
|
||||||
|
};
|
||||||
|
|
||||||
var points = [ handleStartCanvas, handleEndCanvas, midpointCanvas ];
|
var midpointCanvas = {
|
||||||
|
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||||
|
y: (handleStartCanvas.y + handleEndCanvas.y) / 2,
|
||||||
|
};
|
||||||
|
|
||||||
link.end.x = canvasTextLocation.x;
|
var points = [ handleStartCanvas, handleEndCanvas, midpointCanvas ];
|
||||||
link.end.y = canvasTextLocation.y;
|
|
||||||
|
|
||||||
link.start = cornerstoneMath.point.findClosestPoint(points, link.end);
|
link.end.x = canvasTextLocation.x;
|
||||||
|
link.end.y = canvasTextLocation.y;
|
||||||
|
|
||||||
var boundingBoxPoints = [ {
|
link.start = cornerstoneMath.point.findClosestPoint(points, link.end);
|
||||||
// Top middle point of bounding box
|
|
||||||
x: boundingBox.left + boundingBox.width / 2,
|
|
||||||
y: boundingBox.top
|
|
||||||
}, {
|
|
||||||
// Left middle point of bounding box
|
|
||||||
x: boundingBox.left,
|
|
||||||
y: boundingBox.top + boundingBox.height / 2
|
|
||||||
}, {
|
|
||||||
// Bottom middle point of bounding box
|
|
||||||
x: boundingBox.left + boundingBox.width / 2,
|
|
||||||
y: boundingBox.top + boundingBox.height
|
|
||||||
}, {
|
|
||||||
// Right middle point of bounding box
|
|
||||||
x: boundingBox.left + boundingBox.width,
|
|
||||||
y: boundingBox.top + boundingBox.height / 2
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start);
|
var boundingBoxPoints = [ {
|
||||||
context.beginPath();
|
// Top middle point of bounding box
|
||||||
context.strokeStyle = color;
|
x: boundingBox.left + boundingBox.width / 2,
|
||||||
context.lineWidth = lineWidth;
|
y: boundingBox.top
|
||||||
context.setLineDash([ 2, 3 ]);
|
}, {
|
||||||
|
// Left middle point of bounding box
|
||||||
|
x: boundingBox.left,
|
||||||
|
y: boundingBox.top + boundingBox.height / 2
|
||||||
|
}, {
|
||||||
|
// Bottom middle point of bounding box
|
||||||
|
x: boundingBox.left + boundingBox.width / 2,
|
||||||
|
y: boundingBox.top + boundingBox.height
|
||||||
|
}, {
|
||||||
|
// Right middle point of bounding box
|
||||||
|
x: boundingBox.left + boundingBox.width,
|
||||||
|
y: boundingBox.top + boundingBox.height / 2
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
context.moveTo(link.start.x, link.start.y);
|
link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start);
|
||||||
context.lineTo(link.end.x, link.end.y);
|
context.beginPath();
|
||||||
context.stroke();
|
context.strokeStyle = color;
|
||||||
|
context.lineWidth = lineWidth;
|
||||||
|
context.setLineDash([ 2, 3 ]);
|
||||||
|
|
||||||
|
context.moveTo(link.start.x, link.start.y);
|
||||||
|
context.lineTo(link.end.x, link.end.y);
|
||||||
|
context.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
// Set measurement text to show lesion table
|
// Set measurement text to show lesion table
|
||||||
data.longestDiameter = length.toFixed(1);
|
data.longestDiameter = length.toFixed(1);
|
||||||
|
|||||||
@ -253,7 +253,7 @@ import { toolManager } from 'meteor/ohif:viewerbase';
|
|||||||
// Draw the text
|
// Draw the text
|
||||||
if (data.measurementNumber) {
|
if (data.measurementNumber) {
|
||||||
|
|
||||||
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);
|
OHIF.cornerstone.repositionTextBox(eventData, data);
|
||||||
|
|||||||
@ -290,7 +290,7 @@
|
|||||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
|
|
||||||
var boundingBox = cornerstoneTools.drawTextBox(context, "Target " + +data.measurementNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
var boundingBox = cornerstoneTools.drawTextBox(context, `Target ${data.measurementNumber}`, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||||
data.handles.textBox.boundingBox = boundingBox;
|
data.handles.textBox.boundingBox = boundingBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user