Applied JSCS and added JSCS/jsHint config files

This commit is contained in:
Erik Ziegler committed 2016-01-11 11:32:20 +01:00
1 parent a9266608d2
commit 90a16a8059
68 files changed
+24956 -6399

No files matched your search

@@ -29,7 +29,9 @@ var LesionManager = (function() {
function updateLesionData(lesionData) {
// Find the related Timepoint from the Timepoints Collection
var timepointID = lesionData.timepointID;
var timepoint = Timepoints.findOne({timepointID: timepointID});
var timepoint = Timepoints.findOne({
timepointID: timepointID
});
if (!timepoint) {
log.warn('Timepoint in an image is not present in the Timepoints Collection?');
return;
@@ -126,7 +128,9 @@ var LesionManager = (function() {
var measurements = Measurements.find({
isTarget: isTarget
}, {
sort: {lesionNumber: 1}
sort: {
lesionNumber: 1
}
}).fetch();
// If measurements exist, find the last lesion number
@@ -176,4 +180,4 @@ var LesionManager = (function() {
lesionNumberExists: lesionNumberExists,
getLocationName: getLocationName
};
})();
})();
@@ -31,7 +31,7 @@
nearbyToolIndex,
nearbyToolType;
toolTypes.forEach(function(toolType){
toolTypes.forEach(function(toolType) {
var toolData = cornerstoneTools.getToolState(element, toolType);
if (!toolData) {
return;
@@ -75,7 +75,7 @@
if (keyCode === keys.DELETE ||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
var toolTypes = ["lesion", "nonTarget"];
var toolTypes = [ 'lesion', 'nonTarget' ];
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
if (!nearbyToolData) {
@@ -95,4 +95,4 @@
// module/private exports
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
})(cornerstoneTools);
})(cornerstoneTools);
@@ -1,8 +1,8 @@
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
"use strict";
'use strict';
var toolType = "lesion";
var toolType = 'lesion';
var configuration = {
setLesionNumberCallback: setLesionNumberCallback,
@@ -221,6 +221,7 @@
if (!handle.boundingBox) {
return;
}
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
}
@@ -514,7 +515,7 @@
// Sets drawnIndependently property of control points(handles)
function setControlPoints(handles, value) {
Object.keys(handles).forEach(function(name) {
if (name !== "textBox") {
if (name !== 'textBox') {
var handle = handles[name];
handle.drawnIndependently = value;
}
@@ -730,7 +731,6 @@
}
function findDottedLinePosition(data) {
var distancesArr = [];
@@ -775,6 +775,7 @@
minDistance = distanceToPerpendicularEnd;
}
}
for (var i = 0; i < distancesArr.length; i++) {
var obj = distancesArr[i];
if (obj.distance === minDistance) {
@@ -840,7 +841,7 @@
context.beginPath();
context.strokeStyle = color;
context.lineWidth = lineWidth;
context.setLineDash([2, 3]);
context.setLineDash([ 2, 3 ]);
// Set position of text
var perpendicularStartCanvas = cornerstone.pixelToCanvas(element, findDottedLinePosition(data));
@@ -858,7 +859,6 @@
var wy = (data.handles.perpendicularStart.y - data.handles.perpendicularEnd.y) * (eventData.image.rowPixelSpacing || 1);
var width = Math.sqrt(wx * wx + wy * wy);
var suffix = ' mm';
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
suffix = ' pixels';
@@ -866,7 +866,7 @@
var lengthText = ' L ' + length.toFixed(1) + suffix;
var widthText = ' W ' + width.toFixed(1) + suffix;
var textLines = ['Target ' + data.lesionNumber, lengthText, widthText];
var textLines = [ 'Target ' + data.lesionNumber, lengthText, widthText ];
var boundingBox = cornerstoneTools.drawTextBox(context,
textLines,
@@ -948,4 +948,4 @@
cornerstoneTools.lesion.setConfiguration(configuration);
})($, cornerstone, cornerstoneMath, cornerstoneTools);
})($, cornerstone, cornerstoneMath, cornerstoneTools);
@@ -68,7 +68,7 @@
if (cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
// delete the measurement
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
}else{
}else {
config.getLesionLocationCallback(measurementData, mouseEventData, doneCallback);
}
@@ -150,6 +150,7 @@
if (!handle.boundingBox) {
return;
}
return cornerstoneMath.point.insideRect(coords, handle.boundingBox);
}
@@ -217,7 +218,7 @@
context.beginPath();
context.strokeStyle = color;
context.lineWidth = lineWidth;
context.setLineDash([2, 3]);
context.setLineDash([ 2, 3 ]);
context.moveTo(mid.x, mid.y);
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
@@ -254,6 +255,7 @@
if (measurementData.lesionName === undefined) {
config.setLesionNumberCallback(measurementData, touchEventData, doneCallback);
}
cornerstone.updateImage(element);
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
@@ -266,14 +268,12 @@
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;
@@ -339,5 +339,4 @@
// pressCallback: doubleClickCallback
});
})($, cornerstone, cornerstoneMath, cornerstoneTools);
@@ -1,331 +1,348 @@
(function($, cornerstone, cornerstoneTools) {
'use strict';
'use strict';
// Draw Intervals
function drawIntervals (context, config) {
// Draw Intervals
function drawIntervals (context, config) {
var i = 0;
var i = 0;
while (config.verticalLine.start.y + i * config.verticalMinorTick <= config.vscaleBounds.bottom) {
while (config.verticalLine.start.y + i * config.verticalMinorTick <= config.vscaleBounds.bottom) {
var startPoint = {
x: config.verticalLine.start.x,
y: config.verticalLine.start.y + i*config.verticalMinorTick
};
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) {
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.majorTickLength;
} else {
endPoint.x = config.verticalLine.start.x - config.minorTickLength;
}
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();
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++;
}
i = 0;
i = 0;
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.right) {
while (config.horizontalLine.start.x + i * config.horizontalMinorTick <= config.hscaleBounds.right) {
startPoint = {
x: config.horizontalLine.start.x + i * config.horizontalMinorTick,
y: config.horizontalLine.start.y
};
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 = {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.majorTickLength;
} else{
endPoint.y = config.horizontalLine.start.y - config.minorTickLength;
}
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();
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++;
}
}
}
// Draws long horizontal and vertical lines
function drawFrameLines(context, config){
// 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
};
// 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();
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();
// 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);
}
function doesIntersect(canvasBounds, imageBounds) {
var intersectLeftRight;
var intersectTopBottom;
if (canvasBounds.width >= 0)
{
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.right <= imageBounds.left) || (imageBounds.right <= canvasBounds.left));
else
intersectLeftRight = !((canvasBounds.right <= imageBounds.right) || (imageBounds.left <= canvasBounds.left));
}
else
{
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.left <= imageBounds.left) || (imageBounds.right <= canvasBounds.right));
else
intersectLeftRight = !((canvasBounds.left <= imageBounds.right) || (imageBounds.left <= canvasBounds.right));
}
if (canvasBounds.height >= 0)
{
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.top));
else
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.top));
}
else
{
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.top <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.bottom));
else
intersectTopBottom = !((canvasBounds.top <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.bottom));
}
return intersectLeftRight && intersectTopBottom;
}
function getIntersectionRectangle(canvasBounds, imageBounds) {
var intersectPoints = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
if(!doesIntersect(canvasBounds, imageBounds)) {
return intersectPoints;
// Draw intervals
drawIntervals(context, config);
}
if (canvasBounds.width >= 0)
{
if (imageBounds.width >= 0)
{
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.right);
}
else
{
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.left);
}
}
else
{
if (imageBounds.width >= 0)
{
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.left);
}
else
{
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.right);
}
function doesIntersect(canvasBounds, imageBounds) {
var intersectLeftRight;
var intersectTopBottom;
if (canvasBounds.width >= 0) {
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.right <= imageBounds.left) || (imageBounds.right <= canvasBounds.left));
else
intersectLeftRight = !((canvasBounds.right <= imageBounds.right) || (imageBounds.left <= canvasBounds.left));
} else {
if (imageBounds.width >= 0)
intersectLeftRight = !((canvasBounds.left <= imageBounds.left) || (imageBounds.right <= canvasBounds.right));
else
intersectLeftRight = !((canvasBounds.left <= imageBounds.right) || (imageBounds.left <= canvasBounds.right));
}
if (canvasBounds.height >= 0) {
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.top));
else
intersectTopBottom = !((canvasBounds.bottom <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.top));
} else {
if (imageBounds.height >= 0)
intersectTopBottom = !((canvasBounds.top <= imageBounds.top) || (imageBounds.bottom <= canvasBounds.bottom));
else
intersectTopBottom = !((canvasBounds.top <= imageBounds.bottom) || (imageBounds.top <= canvasBounds.bottom));
}
return intersectLeftRight && intersectTopBottom;
}
if (canvasBounds.height >= 0)
{
if (imageBounds.height >= 0)
{
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.bottom);
}
else
{
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.top);
}
}
else
{
if (imageBounds.height >= 0)
{
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.top);
}
else
{
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.bottom);
}
function getIntersectionRectangle(canvasBounds, imageBounds) {
var intersectPoints = {
left: 0,
top: 0,
right: 0,
bottom: 0
};
if (!doesIntersect(canvasBounds, imageBounds)) {
return intersectPoints;
}
if (canvasBounds.width >= 0) {
if (imageBounds.width >= 0) {
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.right);
} else {
intersectPoints.left = Math.max(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.min(canvasBounds.right, imageBounds.left);
}
} else {
if (imageBounds.width >= 0) {
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.right);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.left);
} else {
intersectPoints.left = Math.min(canvasBounds.left, imageBounds.left);
intersectPoints.right = Math.max(canvasBounds.right, imageBounds.right);
}
}
if (canvasBounds.height >= 0) {
if (imageBounds.height >= 0) {
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.bottom);
} else {
intersectPoints.top = Math.max(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.min(canvasBounds.bottom, imageBounds.top);
}
} else {
if (imageBounds.height >= 0) {
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.bottom);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.top);
} else {
intersectPoints.top = Math.min(canvasBounds.top, imageBounds.top);
intersectPoints.bottom = Math.max(canvasBounds.bottom, imageBounds.bottom);
}
}
return intersectPoints;
}
return intersectPoints;
// Computes the max bound for scales on the image
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
}
var canvasBounds = {
left: 0,
top: 0,
right: canvasSize.width,
bottom: canvasSize.height,
width: canvasSize.width,
height: canvasSize.height
};
// Computes the max bound for scales on the image
function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReduction, verticalReduction) {
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,
right: (canvasBounds.left + hReduction) + (canvasBounds.width - 2 * hReduction),
bottom: (canvasBounds.top + vReduction) + (canvasBounds.height - 2 * vReduction),
width: canvasBounds.width - 2 * hReduction,
height: canvasBounds.height - 2 * vReduction
};
var canvasBounds = {
left: 0,
top: 0,
right: canvasSize.width,
bottom: canvasSize.height,
width: canvasSize.width,
height: canvasSize.height
};
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 hReduction = horizontalReduction * Math.min(1000, canvasSize.width);
var vReduction = verticalReduction * Math.min(1000, canvasSize.height);
canvasBounds = {
left: canvasBounds.left + hReduction,
top: canvasBounds.top + vReduction,
right: (canvasBounds.left + hReduction) + (canvasBounds.width - 2 * hReduction),
bottom: (canvasBounds.top + vReduction) + (canvasBounds.height - 2 * vReduction),
width: canvasBounds.width - 2 * hReduction,
height: canvasBounds.height - 2 * vReduction
};
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
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 imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
var startPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, startPointImageBounds);
var endPointCanvasImageBounds = cornerstone.pixelToCanvas(eventData.element, endPointImageBounds);
hReduction = horizontalReduction * imageBoundsWidth;
vReduction = verticalReduction * imageBoundsHeight;
var imageBoundsWidth = Math.abs(startPointCanvasImageBounds.x - endPointCanvasImageBounds.x);
var imageBoundsHeight = Math.abs(startPointCanvasImageBounds.y - endPointCanvasImageBounds.y);
var imageBounds = {
left: startPointCanvasImageBounds.x + hReduction,
top: startPointCanvasImageBounds.y + vReduction,
right: (startPointCanvasImageBounds.x + hReduction) + (imageBoundsWidth - 2 * hReduction),
bottom: (startPointCanvasImageBounds.y + vReduction) + (imageBoundsHeight - 2 * vReduction),
width: imageBoundsWidth - 2 * hReduction,
height: imageBoundsHeight - 2 * vReduction
};
hReduction = horizontalReduction * imageBoundsWidth;
vReduction = verticalReduction * imageBoundsHeight;
return getIntersectionRectangle(canvasBounds, imageBounds);
var imageBounds = {
left: startPointCanvasImageBounds.x + hReduction,
top: startPointCanvasImageBounds.y + vReduction,
right: (startPointCanvasImageBounds.x + hReduction) + (imageBoundsWidth - 2 * hReduction),
bottom: (startPointCanvasImageBounds.y + vReduction) + (imageBoundsHeight - 2 * vReduction),
width: imageBoundsWidth - 2 * hReduction,
height: imageBoundsHeight - 2 * vReduction
};
return getIntersectionRectangle(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;
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;
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height ) {
return false;
}
// 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);
var config = {
width: imageSize.width,
height: imageSize.height,
hscaleBounds: hscaleBounds,
vscaleBounds: vscaleBounds,
verticalMinorTick: verticalIntervalScale,
horizontalMinorTick: horizontalIntervalScale,
minorTickLength: 12.5,
majorTickLength: 25,
verticalLine: {
start: {
x: vscaleBounds.right ,
y: vscaleBounds.top
},
end: {
x: vscaleBounds.right,
y: vscaleBounds.bottom
}
},
horizontalLine: {
start: {
x: hscaleBounds.left,
y: hscaleBounds.bottom
},
end: {
x: hscaleBounds.right,
y: hscaleBounds.bottom
}
},
color: cornerstoneTools.toolColors.getToolColor(),
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();
}
var canvasSize = { width: eventData.enabledElement.canvas.width, height: eventData.enabledElement.canvas.height};
var imageSize = {width: eventData.enabledElement.image.width , height: eventData.enabledElement.image.height};
///////// END IMAGE RENDERING ///////
// 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;
if (!canvasSize.width || !canvasSize.height || !imageSize.width || !imageSize.height ) {
return false;
function disable(element) {
// TODO: displayTool does not have cornerstone.updateImage(element) method to hide tool
$(element).off('CornerstoneImageRendered', onImageRendered);
cornerstone.updateImage(element);
}
// 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);
// module exports
cornerstoneTools.scaleOverlayTool = cornerstoneTools.displayTool(onImageRendered);
cornerstoneTools.scaleOverlayTool.disable = disable;
var config = {
width: imageSize.width,
height: imageSize.height,
hscaleBounds: hscaleBounds,
vscaleBounds: vscaleBounds,
verticalMinorTick: verticalIntervalScale,
horizontalMinorTick: horizontalIntervalScale,
minorTickLength: 12.5,
majorTickLength: 25,
verticalLine: {
start: {x: vscaleBounds.right , y: vscaleBounds.top},
end: {x: vscaleBounds.right, y: vscaleBounds.bottom}
},
horizontalLine: {
start: {x: hscaleBounds.left, y: hscaleBounds.bottom},
end: {x: hscaleBounds.right, y: hscaleBounds.bottom}
},
color: cornerstoneTools.toolColors.getToolColor(),
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);
})($, cornerstone, cornerstoneTools);