Fixed distance settings in lesionTool. Might need to be done in cornerstoneTools as well
This commit is contained in:
parent
571eb90eb8
commit
54076fbe33
@ -214,7 +214,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (distanceToPoint < 25);
|
return (distanceToPoint < 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pointNearTextBox(element, handle, coords) {
|
function pointNearTextBox(element, handle, coords) {
|
||||||
@ -231,7 +231,7 @@
|
|||||||
end: cornerstone.pixelToCanvas(element, handles.perpendicularEnd)
|
end: cornerstone.pixelToCanvas(element, handles.perpendicularEnd)
|
||||||
};
|
};
|
||||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||||
return (distanceToPoint < 25);
|
return (distanceToPoint < 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move long-axis start point
|
// Move long-axis start point
|
||||||
@ -431,9 +431,17 @@
|
|||||||
// Sets position of handles(start, end, perpendicularStart, perpendicularEnd)
|
// Sets position of handles(start, end, perpendicularStart, perpendicularEnd)
|
||||||
function setHandlesPosition(handle, eventData, data) {
|
function setHandlesPosition(handle, eventData, data) {
|
||||||
|
|
||||||
|
var movedPoint,
|
||||||
|
outOfBounds,
|
||||||
|
result,
|
||||||
|
intersection,
|
||||||
|
d1,
|
||||||
|
d2;
|
||||||
|
|
||||||
|
|
||||||
if (handle.index === 0) {
|
if (handle.index === 0) {
|
||||||
// if long-axis start point is moved
|
// if long-axis start point is moved
|
||||||
var result = perpendicularBothFixedLeft(eventData, data);
|
result = perpendicularBothFixedLeft(eventData, data);
|
||||||
if (result) {
|
if (result) {
|
||||||
handle.x = eventData.currentPoints.image.x;
|
handle.x = eventData.currentPoints.image.x;
|
||||||
handle.y = eventData.currentPoints.image.y;
|
handle.y = eventData.currentPoints.image.y;
|
||||||
@ -444,7 +452,7 @@
|
|||||||
|
|
||||||
} else if (handle.index === 1) {
|
} else if (handle.index === 1) {
|
||||||
// if long-axis end point is moved
|
// if long-axis end point is moved
|
||||||
var result = perpendicularBothFixedRight(eventData, data);
|
result = perpendicularBothFixedRight(eventData, data);
|
||||||
if (result) {
|
if (result) {
|
||||||
handle.x = eventData.currentPoints.image.x;
|
handle.x = eventData.currentPoints.image.x;
|
||||||
handle.y = eventData.currentPoints.image.y;
|
handle.y = eventData.currentPoints.image.y;
|
||||||
@ -454,24 +462,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (handle.index === 2) {
|
} else if (handle.index === 2) {
|
||||||
var outOfBounce = false;
|
outOfBounds = false;
|
||||||
// if perpendicular start point is moved
|
// if perpendicular start point is moved
|
||||||
|
|
||||||
var intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, eventData.currentPoints.image);
|
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, eventData.currentPoints.image);
|
||||||
if (!intersection.intersected) {
|
if (!intersection.intersected) {
|
||||||
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, data.handles.perpendicularStart);
|
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, data.handles.perpendicularStart);
|
||||||
|
|
||||||
var d1 = getDistance(intersection, data.handles.start);
|
d1 = getDistance(intersection, data.handles.start);
|
||||||
var d2 = getDistance(intersection, data.handles.end);
|
d2 = getDistance(intersection, data.handles.end);
|
||||||
|
|
||||||
if (!intersection.intersected || d1 < 3 || d2 < 3) {
|
if (!intersection.intersected || d1 < 3 || d2 < 3) {
|
||||||
outOfBounce = true;
|
outOfBounds = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var movedPoint = false;
|
movedPoint = false;
|
||||||
|
|
||||||
if (!outOfBounce) {
|
if (!outOfBounds) {
|
||||||
movedPoint = perpendicularLeftFixedPoint(eventData, data);
|
movedPoint = perpendicularLeftFixedPoint(eventData, data);
|
||||||
|
|
||||||
if (!movedPoint) {
|
if (!movedPoint) {
|
||||||
@ -481,25 +489,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (handle.index === 3) {
|
} else if (handle.index === 3) {
|
||||||
|
outOfBounds = false;
|
||||||
var outOfBounce = false;
|
|
||||||
// if perpendicular end point is moved
|
// if perpendicular end point is moved
|
||||||
|
|
||||||
var intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularStart, eventData.currentPoints.image);
|
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularStart, eventData.currentPoints.image);
|
||||||
if (!intersection.intersected) {
|
if (!intersection.intersected) {
|
||||||
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, data.handles.perpendicularStart);
|
intersection = getLineIntersection(data.handles.start, data.handles.end, data.handles.perpendicularEnd, data.handles.perpendicularStart);
|
||||||
|
|
||||||
var d1 = getDistance(intersection, data.handles.start);
|
d1 = getDistance(intersection, data.handles.start);
|
||||||
var d2 = getDistance(intersection, data.handles.end);
|
d2 = getDistance(intersection, data.handles.end);
|
||||||
|
|
||||||
if (!intersection.intersected || d1 < 3 || d2 < 3) {
|
if (!intersection.intersected || d1 < 3 || d2 < 3) {
|
||||||
outOfBounce = true;
|
outOfBounds = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var movedPoint = false;
|
movedPoint = false;
|
||||||
|
|
||||||
if (!outOfBounce) {
|
if (!outOfBounds) {
|
||||||
movedPoint = perpendicularRightFixedPoint(eventData, data);
|
movedPoint = perpendicularRightFixedPoint(eventData, data);
|
||||||
|
|
||||||
if (!movedPoint) {
|
if (!movedPoint) {
|
||||||
@ -507,9 +514,7 @@
|
|||||||
eventData.currentPoints.image.y = data.handles.perpendicularEnd.y;
|
eventData.currentPoints.image.y = data.handles.perpendicularEnd.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets drawnIndependently property of control points(handles)
|
// Sets drawnIndependently property of control points(handles)
|
||||||
@ -650,8 +655,8 @@
|
|||||||
data = toolData.data[i];
|
data = toolData.data[i];
|
||||||
// Hide control points
|
// Hide control points
|
||||||
setControlPoints(data.handles, true);
|
setControlPoints(data.handles, true);
|
||||||
var distanceSq = 25;
|
var distance = 5;
|
||||||
var handle = cornerstoneTools.getHandleNearImagePoint(element, data.handles, coords, distanceSq);
|
var handle = cornerstoneTools.getHandleNearImagePoint(element, data.handles, coords, distance);
|
||||||
if (handle) {
|
if (handle) {
|
||||||
$(element).off('CornerstoneToolsMouseMove', mouseMoveCallback);
|
$(element).off('CornerstoneToolsMouseMove', mouseMoveCallback);
|
||||||
data.active = true;
|
data.active = true;
|
||||||
@ -722,6 +727,7 @@
|
|||||||
// Draw perpendicular line
|
// Draw perpendicular line
|
||||||
var perpendicularStartCanvas = cornerstone.pixelToCanvas(element, data.handles.perpendicularStart);
|
var perpendicularStartCanvas = cornerstone.pixelToCanvas(element, data.handles.perpendicularStart);
|
||||||
var perpendicularEndCanvas = cornerstone.pixelToCanvas(element, data.handles.perpendicularEnd);
|
var perpendicularEndCanvas = cornerstone.pixelToCanvas(element, data.handles.perpendicularEnd);
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.strokeStyle = color;
|
context.strokeStyle = color;
|
||||||
context.lineWidth = lineWidth;
|
context.lineWidth = lineWidth;
|
||||||
@ -732,7 +738,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function findDottedLinePosition(data) {
|
function findDottedLinePosition(data) {
|
||||||
|
|
||||||
var distancesArr = [];
|
var distancesArr = [];
|
||||||
var minDistance;
|
var minDistance;
|
||||||
|
|
||||||
@ -749,9 +754,8 @@
|
|||||||
distance: distanceToEnd,
|
distance: distanceToEnd,
|
||||||
point: data.handles.end
|
point: data.handles.end
|
||||||
});
|
});
|
||||||
if (distanceToEnd < minDistance) {
|
|
||||||
minDistance = distanceToEnd;
|
minDistance = Math.min(distanceToEnd, minDistance);
|
||||||
}
|
|
||||||
|
|
||||||
if (data.handles.perpendicularStart.x && data.handles.perpendicularStart.y) {
|
if (data.handles.perpendicularStart.x && data.handles.perpendicularStart.y) {
|
||||||
var distanceToPerpendicularStart = getDistance(data.handles.perpendicularStart, data.handles.textBox);
|
var distanceToPerpendicularStart = getDistance(data.handles.perpendicularStart, data.handles.textBox);
|
||||||
@ -759,9 +763,8 @@
|
|||||||
distance: distanceToPerpendicularStart,
|
distance: distanceToPerpendicularStart,
|
||||||
point: data.handles.perpendicularStart
|
point: data.handles.perpendicularStart
|
||||||
});
|
});
|
||||||
if (distanceToPerpendicularStart < minDistance) {
|
|
||||||
minDistance = distanceToPerpendicularStart;
|
minDistance = Math.min(distanceToPerpendicularStart, minDistance);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,9 +774,8 @@
|
|||||||
distance: distanceToPerpendicularEnd,
|
distance: distanceToPerpendicularEnd,
|
||||||
point: data.handles.perpendicularEnd
|
point: data.handles.perpendicularEnd
|
||||||
});
|
});
|
||||||
if (distanceToPerpendicularEnd < minDistance) {
|
|
||||||
minDistance = distanceToPerpendicularEnd;
|
minDistance = Math.min(distanceToPerpendicularEnd, minDistance);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < distancesArr.length; i++) {
|
for (var i = 0; i < distancesArr.length; i++) {
|
||||||
@ -849,16 +851,17 @@
|
|||||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 40);
|
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 40);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
|
|
||||||
// Draw the Length text
|
// Calculate the long axis length
|
||||||
var dx = (data.handles.start.x - data.handles.end.x) * (eventData.image.columnPixelSpacing || 1);
|
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 dy = (data.handles.start.y - data.handles.end.y) * (eventData.image.rowPixelSpacing || 1);
|
||||||
var length = Math.sqrt(dx * dx + dy * dy);
|
var length = Math.sqrt(dx * dx + dy * dy);
|
||||||
|
|
||||||
// Draw the Length text
|
// Calculate the short axis length
|
||||||
var wx = (data.handles.perpendicularStart.x - data.handles.perpendicularEnd.x) * (eventData.image.columnPixelSpacing || 1);
|
var wx = (data.handles.perpendicularStart.x - data.handles.perpendicularEnd.x) * (eventData.image.columnPixelSpacing || 1);
|
||||||
var wy = (data.handles.perpendicularStart.y - data.handles.perpendicularEnd.y) * (eventData.image.rowPixelSpacing || 1);
|
var wy = (data.handles.perpendicularStart.y - data.handles.perpendicularEnd.y) * (eventData.image.rowPixelSpacing || 1);
|
||||||
var width = Math.sqrt(wx * wx + wy * wy);
|
var width = Math.sqrt(wx * wx + wy * wy);
|
||||||
|
|
||||||
|
// Draw the textbox
|
||||||
var suffix = ' mm';
|
var suffix = ' mm';
|
||||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||||
suffix = ' pixels';
|
suffix = ' pixels';
|
||||||
|
|||||||
@ -64,6 +64,9 @@ Template.lesionTable.onCreated(function() {
|
|||||||
this.dragging = new ReactiveVar(false);
|
this.dragging = new ReactiveVar(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Temporary until we have a real window manager with events for series/study changed
|
||||||
|
Session.setDefault('NewSeriesLoaded', false);
|
||||||
|
|
||||||
Template.lesionTable.onRendered(function() {
|
Template.lesionTable.onRendered(function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -73,8 +76,8 @@ Template.lesionTable.onRendered(function() {
|
|||||||
self.autorun(function() {
|
self.autorun(function() {
|
||||||
// Temporary until we have a real window manager with events for series/study changed
|
// Temporary until we have a real window manager with events for series/study changed
|
||||||
Session.get('NewSeriesLoaded');
|
Session.get('NewSeriesLoaded');
|
||||||
|
|
||||||
console.log('ViewerData changed, check for displayed timepoints');
|
console.log('ViewerData changed, check for displayed timepoints');
|
||||||
|
|
||||||
// Get study dates of imageViewerViewport elements
|
// Get study dates of imageViewerViewport elements
|
||||||
var loadedStudyDates = {
|
var loadedStudyDates = {
|
||||||
patientId: '',
|
patientId: '',
|
||||||
|
|||||||
@ -321,6 +321,9 @@ function loadSeriesIntoViewport(data, templateData) {
|
|||||||
setActiveViewport(element);
|
setActiveViewport(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary until we have a real window manager with events for series/study changed
|
||||||
|
Session.set('NewSeriesLoaded', Random.id());
|
||||||
|
|
||||||
// Run any renderedCallback that exists in the data context
|
// Run any renderedCallback that exists in the data context
|
||||||
if (data.renderedCallback && typeof data.renderedCallback === 'function') {
|
if (data.renderedCallback && typeof data.renderedCallback === 'function') {
|
||||||
data.renderedCallback(element);
|
data.renderedCallback(element);
|
||||||
@ -329,9 +332,6 @@ function loadSeriesIntoViewport(data, templateData) {
|
|||||||
// If something goes wrong while loading the image, fire the error handler.
|
// If something goes wrong while loading the image, fire the error handler.
|
||||||
errorLoadingHandler(element, imageId, error);
|
errorLoadingHandler(element, imageId, error);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Temporary until we have a real window manager with events for series/study changed
|
|
||||||
Session.set('NewSeriesLoaded', Random.id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user