From 48c5e38cd2f0bc84c6476f326c576d40adad99d7 Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 24 Nov 2016 16:15:18 -0200 Subject: [PATCH] LT-40: Implementing method to search for available space outside image --- Packages/ohif-core/client/lib/cornerstone.js | 33 +++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/Packages/ohif-core/client/lib/cornerstone.js b/Packages/ohif-core/client/lib/cornerstone.js index 3cf781257..7639d2fc7 100644 --- a/Packages/ohif-core/client/lib/cornerstone.js +++ b/Packages/ohif-core/client/lib/cornerstone.js @@ -34,6 +34,32 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) = const $element = $(element); const image = enabledElement.image; + const getAvailableBlankAreas = (enabledElement, labelWidth, labelHeight) => { + const { element, canvas, image } = enabledElement; + + const topLeft = cornerstone.pixelToCanvas(element, { + x: 0, + y: 0 + }); + + const bottomRight = cornerstone.pixelToCanvas(element, { + x: image.width, + y: image.height + }); + + const $canvas = $(canvas); + const canvasWidth = $canvas.outerWidth(); + const canvasHeight = $canvas.outerHeight(); + + const result = {}; + result['x-1'] = topLeft.x > labelWidth; + result['y-1'] = topLeft.y > labelHeight; + result.x1 = canvasWidth - bottomRight.x > labelWidth; + result.y1 = canvasHeight - bottomRight.y > labelHeight; + + return result; + }; + const modifiedCallback = () => { const handles = measurementData.handles; const textBox = handles.textBox; @@ -66,9 +92,6 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) = directions.x = tool.x < mid.x ? -1 : 1; directions.y = tool.y < mid.y ? -1 : 1; - // TODO: REMOVE - Temporary for RSNA (placing always above patient) - directions.y = -1; - const points = {}; points.x = directions.x < 0 ? 0 : image.width; points.y = directions.y < 0 ? 0 : image.height; @@ -79,10 +102,6 @@ OHIF.cornerstone.repositionTextBoxWhileDragging = (eventData, measurementData) = let cornerAxis = diffY < diffX ? 'y' : 'x'; let toolAxis = diffY < diffX ? 'x' : 'y'; - // TODO: REMOVE - Temporary for RSNA (placing always above patient) - cornerAxis = 'y'; - toolAxis = 'x'; - textBox[cornerAxis] = points[cornerAxis]; textBox[toolAxis] = tool[toolAxis];