From 5c316bf33427cc75def846c0a7f348f58545694b Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 26 Jan 2017 15:25:11 -0200 Subject: [PATCH] LT-404: Fixing Target undefined label when start creating a measurement --- .../client/compatibility/bidirectionalTool.js | 108 +++++++++--------- .../client/compatibility/nonTargetTool.js | 2 +- .../compatibility/qualitativeTargetTools.js | 2 +- 3 files changed, 57 insertions(+), 55 deletions(-) diff --git a/Packages/ohif-lesiontracker/client/compatibility/bidirectionalTool.js b/Packages/ohif-lesiontracker/client/compatibility/bidirectionalTool.js index 715a4f40e..7648ae721 100644 --- a/Packages/ohif-lesiontracker/client/compatibility/bidirectionalTool.js +++ b/Packages/ohif-lesiontracker/client/compatibility/bidirectionalTool.js @@ -997,12 +997,6 @@ import { OHIF } from 'meteor/ohif:core'; width = 0; } - // Draw the textbox - var suffix = ' mm'; - if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) { - suffix = ' pixels'; - } - // Length is always longer than width if (width > length) { var tempW = width; @@ -1011,64 +1005,72 @@ import { OHIF } from 'meteor/ohif:core'; width = tempL; } - var lengthText = ' L ' + length.toFixed(1) + suffix; - var widthText = ' W ' + width.toFixed(1) + suffix; - var textLines = [ 'Target ' + data.measurementNumber, lengthText, widthText ]; + if (data.measurementNumber) { + // Draw the textbox + var suffix = ' mm'; + if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) { + suffix = ' pixels'; + } - var boundingBox = cornerstoneTools.drawTextBox(context, - textLines, - canvasTextLocation.x, canvasTextLocation.y, color); + var lengthText = ' L ' + length.toFixed(1) + suffix; + var widthText = ' W ' + width.toFixed(1) + suffix; + 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 - var link = { - start: {}, - end: {} - }; + OHIF.cornerstone.repositionTextBox(eventData, data); - var midpointCanvas = { - x: (handleStartCanvas.x + handleEndCanvas.x) / 2, - y: (handleStartCanvas.y + handleEndCanvas.y) / 2, - }; + // Draw linked line as dashed + var link = { + 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; - link.end.y = canvasTextLocation.y; + var points = [ handleStartCanvas, handleEndCanvas, midpointCanvas ]; - link.start = cornerstoneMath.point.findClosestPoint(points, link.end); + link.end.x = canvasTextLocation.x; + link.end.y = canvasTextLocation.y; - var boundingBoxPoints = [ { - // 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.start = cornerstoneMath.point.findClosestPoint(points, link.end); - link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start); - context.beginPath(); - context.strokeStyle = color; - context.lineWidth = lineWidth; - context.setLineDash([ 2, 3 ]); + var boundingBoxPoints = [ { + // 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 + }, + ]; - context.moveTo(link.start.x, link.start.y); - context.lineTo(link.end.x, link.end.y); - context.stroke(); + link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start); + context.beginPath(); + 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 data.longestDiameter = length.toFixed(1); diff --git a/Packages/ohif-lesiontracker/client/compatibility/nonTargetTool.js b/Packages/ohif-lesiontracker/client/compatibility/nonTargetTool.js index 483bb83b6..861cea9f2 100644 --- a/Packages/ohif-lesiontracker/client/compatibility/nonTargetTool.js +++ b/Packages/ohif-lesiontracker/client/compatibility/nonTargetTool.js @@ -253,7 +253,7 @@ import { toolManager } from 'meteor/ohif:viewerbase'; // Draw the text 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; OHIF.cornerstone.repositionTextBox(eventData, data); diff --git a/Packages/ohif-lesiontracker/client/compatibility/qualitativeTargetTools.js b/Packages/ohif-lesiontracker/client/compatibility/qualitativeTargetTools.js index f24c30607..5c0149c47 100644 --- a/Packages/ohif-lesiontracker/client/compatibility/qualitativeTargetTools.js +++ b/Packages/ohif-lesiontracker/client/compatibility/qualitativeTargetTools.js @@ -290,7 +290,7 @@ context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20); 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; }