Work on refactoring measurements out of Lesion Tracker package
- Removed AssociatedStudies Collection - Measurement API is generated from configuration files - Data exchange methods are defined in configuration
This commit is contained in:
1 parent
c511edd419
commit
ab4d4c9008
537 files changed
+5122
-3545
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,105 @@
|
||||
(function(cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
D: 68,
|
||||
DELETE: 46
|
||||
};
|
||||
|
||||
function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||
var imageId = data.imageId;
|
||||
if (!imageId) {
|
||||
var enabledElement = cornerstone.getEnabledElement(element);
|
||||
imageId = enabledElement.image.imageId;
|
||||
}
|
||||
|
||||
var enabledElements = cornerstone.getEnabledElementsByImageId(imageId);
|
||||
enabledElements.forEach(function(enabledElement) {
|
||||
var element = enabledElement.element;
|
||||
|
||||
// The HandleMeasurementRemoved handler should do the rest
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
|
||||
//Update element
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
}
|
||||
|
||||
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||
function getNearbyToolData(element, coords, toolTypes) {
|
||||
var allTools = toolManager.getTools();
|
||||
var pointNearTool = false;
|
||||
var touchDevice = isTouchDevice();
|
||||
var nearbyTool,
|
||||
nearbyToolIndex,
|
||||
nearbyToolType;
|
||||
|
||||
toolTypes.forEach(function(toolType) {
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
var toolInterface;
|
||||
if (touchDevice) {
|
||||
toolInterface = allTools[toolType].touch;
|
||||
} else {
|
||||
toolInterface = allTools[toolType].mouse;
|
||||
}
|
||||
|
||||
if (toolInterface.pointNearTool(element, data, coords)) {
|
||||
pointNearTool = true;
|
||||
nearbyTool = data;
|
||||
nearbyToolIndex = i;
|
||||
nearbyToolType = toolType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (pointNearTool === true) {
|
||||
return {
|
||||
nearbyTool: nearbyTool,
|
||||
nearbyToolIndex: nearbyToolIndex,
|
||||
nearbyToolType: nearbyToolType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function keyDownCallback(e, eventData) {
|
||||
var keyCode = eventData.which;
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||
|
||||
var toolTypes = [ 'bidirectional', 'nonTarget', 'length', 'crTool', 'unTool', 'exTool'];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
|
||||
if (!nearbyToolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO= Refactor this so the confirmation dialog is an
|
||||
// optional settable callback in the tool's configuration
|
||||
showConfirmDialog(function() {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType,
|
||||
eventData.element
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
|
||||
|
||||
})(cornerstoneTools);
|
||||
@@ -0,0 +1,361 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var toolType = 'nonTarget';
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: true,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// Set lesion number
|
||||
// Get Non-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) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: '',
|
||||
isTarget: false,
|
||||
toolType: 'nonTarget'
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
cornerstoneTools.drawArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.start ], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ lesion.handles.end ], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([ 2, 3 ]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, 'Non-Target ' + data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(configuration);
|
||||
|
||||
cornerstoneTools.nonTargetTouch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,436 @@
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
var responseByToolType = [{
|
||||
"toolType": "crTool",
|
||||
"toolResponse": "CR"
|
||||
}, {
|
||||
"toolType": "unTool",
|
||||
"toolResponse": "UN"
|
||||
}, {
|
||||
"toolType": "exTool",
|
||||
"toolResponse": "EX"
|
||||
}];
|
||||
|
||||
var configuration = {
|
||||
setLesionNumberCallback: setLesionNumberCallback,
|
||||
getLesionLocationCallback: getLesionLocationCallback,
|
||||
changeLesionLocationCallback: changeLesionLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: false,
|
||||
arrowFirst: true
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// Set lesion number
|
||||
// Get Non-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) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeLesionLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
|
||||
function createQualitativeTargetTool(toolType) {
|
||||
var toolInterface = {
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
var response;
|
||||
|
||||
responseByToolType.forEach(function(tool) {
|
||||
if (tool.toolType === toolInterface.toolType) {
|
||||
response = tool.toolResponse;
|
||||
}
|
||||
});
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionNumber === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: response,
|
||||
isTarget: true,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
function drawDottedArrow(context, start, end, color, lineWidth) {
|
||||
//variables to be used when creating the arrow
|
||||
var headLength = 10;
|
||||
|
||||
var angle = Math.atan2(end.y - start.y, end.x - start.x);
|
||||
|
||||
//starting path of the arrow from the start square to the end square and drawing the stroke
|
||||
context.beginPath();
|
||||
context.moveTo(start.x, start.y);
|
||||
context.lineTo(end.x, end.y);
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
//context.setLineDash([ 2, 3 ]);
|
||||
context.stroke();
|
||||
|
||||
//starting a new path from the head of the arrow to one of the sides of the point
|
||||
context.beginPath();
|
||||
context.moveTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//path from the side point of the arrow, to the other side point
|
||||
context.lineTo(end.x - headLength * Math.cos(angle + Math.PI / 7), end.y - headLength * Math.sin(angle + Math.PI / 7));
|
||||
|
||||
//path from the side point back to the tip of the arrow, and then again to the opposite side point
|
||||
context.lineTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//draws the paths created above
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.stroke();
|
||||
context.fillStyle = color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var font = cornerstoneTools.textStyle.getFont();
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
context.font = font;
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = '#000000';
|
||||
context.shadowOffsetX = 1;
|
||||
context.shadowOffsetY = 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
drawDottedArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.start], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.end], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.lesionNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, "Target " + +data.lesionNumber, canvasTextLocation.x, canvasTextLocation.y, color);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(lesionNumber) {
|
||||
measurementData.lesionNumber = lesionNumber;
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// Set lesion number and lesion name
|
||||
if (measurementData.lesionName === undefined) {
|
||||
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
|
||||
}
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getLesionLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeLesionLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolInterface.mouse = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
toolInterface.touch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
return toolInterface;
|
||||
}
|
||||
|
||||
var crToolInterface = createQualitativeTargetTool('crTool');
|
||||
cornerstoneTools.crTool = crToolInterface.mouse;
|
||||
cornerstoneTools.crTool.setConfiguration(configuration);
|
||||
cornerstoneTools.crToolTouch = crToolInterface.touch;
|
||||
|
||||
var unToolInterface = createQualitativeTargetTool('unTool');
|
||||
cornerstoneTools.unTool = unToolInterface.mouse;
|
||||
cornerstoneTools.unTool.setConfiguration(configuration);
|
||||
cornerstoneTools.unToolTouch = unToolInterface.touch;
|
||||
|
||||
var exToolInterface = createQualitativeTargetTool('exTool');
|
||||
cornerstoneTools.exTool = exToolInterface.mouse;
|
||||
cornerstoneTools.exTool.setConfiguration(configuration);
|
||||
cornerstoneTools.exToolTouch = exToolInterface.touch;
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
@@ -0,0 +1,254 @@
|
||||
|
||||
(function($, cornerstone, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Draw Intervals
|
||||
function drawIntervals (context, config) {
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (config.verticalLine.start.y + i * config.verticalMinorTick <= config.vscaleBounds.bottomRight.y) {
|
||||
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
|
||||
var endPoint = {
|
||||
x: 0,
|
||||
y: config.verticalLine.start.y + i * config.verticalMinorTick
|
||||
};
|
||||
if (i% 5 === 0) {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.majorTickLength;
|
||||
} else {
|
||||
|
||||
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.bottomRight.x) {
|
||||
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
|
||||
endPoint = {
|
||||
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
|
||||
y: 0
|
||||
};
|
||||
|
||||
if (i% 5 === 0) {
|
||||
endPoint.y = config.horizontalLine.start.y - config.majorTickLength;
|
||||
} else {
|
||||
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
|
||||
}
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Draws long horizontal and vertical lines
|
||||
function drawFrameLines(context, config){
|
||||
|
||||
// Vertical Line
|
||||
var startPoint = {
|
||||
x: config.verticalLine.start.x,
|
||||
y: config.verticalLine.start.y
|
||||
};
|
||||
var endPoint = {
|
||||
x: config.verticalLine.end.x,
|
||||
y: config.verticalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Horizontal line
|
||||
startPoint = {
|
||||
x: config.horizontalLine.start.x ,
|
||||
y: config.horizontalLine.start.y
|
||||
};
|
||||
endPoint = {
|
||||
x: config.horizontalLine.end.x,
|
||||
y: config.horizontalLine.end.y
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = config.color;
|
||||
context.lineWidth = config.lineWidth;
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
|
||||
// Draw intervals
|
||||
drawIntervals(context, config);
|
||||
|
||||
}
|
||||
|
||||
// Computes the max bound for scales on the image
|
||||
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
|
||||
|
||||
var canvasBounds = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: canvasSize.width,
|
||||
height: canvasSize.height
|
||||
};
|
||||
|
||||
var hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
|
||||
var vReduction = verticalReduction * Math.min(1000, canvasSize.height);
|
||||
canvasBounds = {
|
||||
left: canvasBounds.left + hReduction,
|
||||
top: canvasBounds.top + vReduction,
|
||||
width: canvasBounds.width - 2 * hReduction,
|
||||
height: canvasBounds.height - 2 * vReduction
|
||||
};
|
||||
|
||||
var startPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var startPointImageBounds = {
|
||||
x: startPoint.x,
|
||||
y: startPoint.y
|
||||
};
|
||||
var endPointImageBounds = {
|
||||
x: startPoint.x + imageSize.width,
|
||||
y: startPoint.y + imageSize.height
|
||||
};
|
||||
|
||||
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
|
||||
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
|
||||
|
||||
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
|
||||
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
|
||||
|
||||
hReduction = horizontalReduction * imageBoundsWidth;
|
||||
vReduction = verticalReduction * imageBoundsHeight;
|
||||
|
||||
var imageBounds = {
|
||||
left: startPointCanvasImageBounds.x + hReduction,
|
||||
top: startPointCanvasImageBounds.y + vReduction,
|
||||
width: imageBoundsWidth - 2 * hReduction,
|
||||
height: imageBoundsHeight - 2 * vReduction
|
||||
};
|
||||
|
||||
return cornerstoneMath.rect.getIntersectionRect(canvasBounds, imageBounds);
|
||||
|
||||
}
|
||||
|
||||
function onImageRendered(e, eventData) {
|
||||
|
||||
// Check whether pixel spacing is defined
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
return;
|
||||
}
|
||||
|
||||
var viewport = cornerstone.getViewport(eventData.enabledElement.element);
|
||||
if (!viewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
var canvasSize = {
|
||||
width: eventData.enabledElement.canvas.width,
|
||||
height: eventData.enabledElement.canvas.height
|
||||
};
|
||||
var imageSize = {
|
||||
width: eventData.enabledElement.image.width ,
|
||||
height: eventData.enabledElement.image.height
|
||||
};
|
||||
|
||||
// Distance between intervals is 10mm
|
||||
var verticalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
var horizontalIntervalScale = (10.0 / eventData.enabledElement.image.rowPixelSpacing) * eventData.viewport.scale;
|
||||
|
||||
// 0.1 and 0.05 gives margin to horizontal and vertical lines
|
||||
var hscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.1, 0.05);
|
||||
var vscaleBounds = computeScaleBounds(eventData, canvasSize, imageSize, 0.05, 0.1);
|
||||
|
||||
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height || !hscaleBounds || !vscaleBounds) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = {
|
||||
hscaleBounds: hscaleBounds,
|
||||
vscaleBounds: vscaleBounds,
|
||||
verticalMinorTick: verticalIntervalScale,
|
||||
horizontalMinorTick: horizontalIntervalScale,
|
||||
minorTickLength: 12.5,
|
||||
majorTickLength: 25,
|
||||
verticalLine: {
|
||||
start: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.topLeft.y
|
||||
},
|
||||
end: {
|
||||
x: vscaleBounds.bottomRight.x,
|
||||
y: vscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
horizontalLine: {
|
||||
start: {
|
||||
x: hscaleBounds.topLeft.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
},
|
||||
end: {
|
||||
x: hscaleBounds.bottomRight.x,
|
||||
y: hscaleBounds.bottomRight.y
|
||||
}
|
||||
},
|
||||
color: 'white', // TODO: fix this later
|
||||
lineWidth: cornerstoneTools.toolStyle.getToolWidth()
|
||||
};
|
||||
|
||||
var context = eventData.enabledElement.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
context.save();
|
||||
|
||||
// Draw frame lines
|
||||
drawFrameLines(context, config);
|
||||
|
||||
context.restore();
|
||||
|
||||
}
|
||||
|
||||
///////// END IMAGE RENDERING ///////
|
||||
|
||||
function disable(element) {
|
||||
// TODO: displayTool does not have cornerstone.updateImage(element) method to hide tool
|
||||
$(element).off('CornerstoneImageRendered', onImageRendered);
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
// module exports
|
||||
cornerstoneTools.scaleOverlayTool = cornerstoneTools.displayTool(onImageRendered);
|
||||
cornerstoneTools.scaleOverlayTool.disable = disable;
|
||||
|
||||
})($, cornerstone, cornerstoneTools);
|
||||
Reference in new issue
Block a user