src/tools/DragProbeTool.js
/**
 * Default strategy will pick the exactly point of mouse/touch interact and display the probe data.
 *
 * @param  {Object} evt Image rendered event
 * @returns {void}
 */
Default strategy will pick the exactly point of mouse/touch interact and display the probe data.
@param  {Object} evt Image rendered event
@returns {void}
Default strategy will pick the exactly point of mouse / touch interact and display the probe data . @param { Object } evt Image rendered event @returns { void }
function defaultStrategy(evt) {
  const config = this.configuration;
  const cornerstone = external.cornerstone;
  const eventData = evt.detail;
  const { element, image, currentPoints, canvasContext } = eventData;
  const context = getNewContext(canvasContext.canvas);
  const color = toolColors.getActiveColor();
  const fontHeight = textStyle.getFontSize();
  const x = Math.round(currentPoints.image.x);
  const y = Math.round(currentPoints.image.y);
  if (x < 0 || y < 0 || x >= image.columns || y >= image.rows) {
    return;
  }
  draw(context, context => {
    setShadow(context, config);
    const text = `${x}, ${y}`;
    let storedPixels;
    let str;
    if (image.color) {
      storedPixels = getRGBPixels(element, x, y, 1, 1);
      str = `R: ${storedPixels[0]} G: ${storedPixels[1]} B: ${
        storedPixels[2]
      } A: ${storedPixels[3]}`;
    } else {
      storedPixels = cornerstone.getStoredPixels(element, x, y, 1, 1);
      const sp = storedPixels[0];
      const mo = sp * image.slope + image.intercept;
      const suv = calculateSUV(image, sp);
      str = `SP: ${sp} MO: ${parseFloat(mo.toFixed(3))}`;
      if (suv) {
        str += ` SUV: ${parseFloat(suv.toFixed(3))}`;
      }
    }
     5px away from cursor
    const textCoords = {
      x: currentPoints.canvas.x + 5,
      y: currentPoints.canvas.y - 5,
    };
    drawTextBox(
      context,
      str,
      textCoords.x,
      textCoords.y + fontHeight + 5,
      color
    );
    drawTextBox(context, text, textCoords.x, textCoords.y, color);
  });
}
function defaultStrategy ( evt ) { const config = this . configuration ; const cornerstone = external . cornerstone ; const eventData = evt . detail ; const { element , image , currentPoints , canvasContext } = eventData ; const context = getNewContext ( canvasContext . canvas ) ; const color = toolColors . getActiveColor ( ) ; const fontHeight = textStyle . getFontSize ( ) ; const x = Math . round ( currentPoints . image . x ) ; const y = Math . round ( currentPoints . image . y ) ; if ( x < 0 || y < 0 || x >= image . columns || y >= image . rows ) { return ; } draw ( context , context => { setShadow ( context , config ) ; const text = ` ${ x } ${ y } ` ; let storedPixels ; let str ; if ( image . color ) { storedPixels = getRGBPixels ( element , x , y , 1 , 1 ) ; str = ` ${ storedPixels [ 0 ] } ${ storedPixels [ 1 ] } ${ storedPixels [ 2 ] } ${ storedPixels [ 3 ] } ` ; } else { storedPixels = cornerstone . getStoredPixels ( element , x , y , 1 , 1 ) ; const sp = storedPixels [ 0 ] ; const mo = sp * image . slope + image . intercept ; const suv = calculateSUV ( image , sp ) ; str = ` ${ sp } ${ parseFloat ( mo . toFixed ( 3 ) ) } ` ; if ( suv ) { str += ` ${ parseFloat ( suv . toFixed ( 3 ) ) } ` ; } } const textCoords = { x : currentPoints . canvas . x + 5 , y : currentPoints . canvas . y - 5 , } ; drawTextBox ( context , str , textCoords . x , textCoords . y + fontHeight + 5 , color ) ; drawTextBox ( context , text , textCoords . x , textCoords . y , color ) ; } ) ; }
Default strategy will pick the exactly point of mouse/touch interact and display the probe data.
Default strategy will pick the exactly point of mouse / touch interact and display the probe data .
// Draw text // Draw text 5px away from cursor