import * as cornerstoneTools from 'cornerstone-tools' import renderToolData from './renderToolData' // import getPixelSpacing from './getPixelSpacing' import calculateLongestAndShortestDiameters from './calculateLongestAndShortestDiameters' // const throttle = cornerstoneTools.import('util/throttle') /** * @public * @class BidirectionalTool * @memberof Tools.Annotation * @classdesc Create and position an annotation that measures the * length and width of a region. * @extends Tools.Base.BaseAnnotationTool */ export default class BidirectionalTool extends cornerstoneTools.BidirectionalTool { constructor(props) { const defaultProps = { name: 'Bidirectional' } super(props, defaultProps) this.digits = props && props.digits ? props.digits : 1 this.renderToolData = renderToolData.bind(this) } updateCachedStats(image, element, data) { // Prevent updating other tools' data if (data.toolName !== this.name) { return } // const pixelSpacing = getPixelSpacing(image) const { longestDiameter, shortestDiameter } = calculateLongestAndShortestDiameters(data, image, this.digits) // Set measurement text to show lesion table data.longestDiameter = longestDiameter data.shortestDiameter = shortestDiameter data.invalidated = false } }