All files / packages/tools/src/drawingSvg drawLinkedTextBox.ts

100% Statements 5/5
75% Branches 3/4
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                                  44x 44x                       44x                   44x                                       44x        
import type { Types } from '@cornerstonejs/core';
 
import drawTextBox from './drawTextBox';
import drawLink from './drawLink';
import { SVGDrawingHelper } from '../types';
 
function drawLinkedTextBox(
  svgDrawingHelper: SVGDrawingHelper,
  annotationUID: string,
  textBoxUID: string,
  //
  textLines: Array<string>,
  textBoxPosition: Types.Point2,
  annotationAnchorPoints: Array<Types.Point2>,
  textBox: unknown,
  options = {}
  // TODO: yCenter as an option
): SVGRect {
  const mergedOptions = Object.assign(
    {
      handleRadius: '6',
      centering: {
        x: false,
        y: true, // yCenter,
      },
    },
    options
  );
 
  // Draw the text box
  const canvasBoundingBox = drawTextBox(
    svgDrawingHelper,
    annotationUID,
    textBoxUID,
    textLines,
    textBoxPosition,
    mergedOptions
  );
  // if (textBox.hasMoved) {
  //   // Draw dashed link line between tool and text
  drawLink(
    svgDrawingHelper,
    annotationUID,
    textBoxUID,
    annotationAnchorPoints, // annotationAnchorPoints
    textBoxPosition, // refPoint (text)
    canvasBoundingBox, // textBoxBoundingBox
    mergedOptions
  );
  // }
 
  // const { top, left, width, height } = canvasBoundingBox
 
  // textBox.worldBoundingBox = {
  //   topLeft: canvasToWorld([left, top]),
  //   topRight: canvasToWorld([left + width, top]),
  //   bottomLeft: canvasToWorld([left, top + height]),
  //   bottomRight: canvasToWorld([left + width, top + height]),
  // }
 
  return canvasBoundingBox;
}
 
export default drawLinkedTextBox;