103 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
| import * as cornerstoneTools from '@cornerstonejs/tools'
 | |
| const {
 | |
|   utilities
 | |
| 
 | |
| } = cornerstoneTools
 | |
| 
 | |
| const { roundNumber,BasicStatsCalculator } = utilities
 | |
| console.log(BasicStatsCalculator)
 | |
| class CircleROITool extends cornerstoneTools.CircleROITool {
 | |
|   static toolName;
 | |
|   // touchDragCallback: any;
 | |
|   // mouseDragCallback: any;
 | |
|   // _throttledCalculateCachedStats: any;
 | |
|   // editData: {
 | |
|   //   annotation: any;
 | |
|   //   viewportIdsToRender: Array<string>;
 | |
|   //   handleIndex?: number;
 | |
|   //   movingTextBox?: boolean;
 | |
|   //   newAnnotation?: boolean;
 | |
|   //   hasMoved?: boolean;
 | |
|   // } | null;
 | |
|   // isDrawing: boolean;
 | |
|   // isHandleOutsideImage = false;
 | |
| 
 | |
|   constructor(
 | |
|     toolProps = {},
 | |
|     defaultToolProps = {
 | |
|       supportedInteractionTypes: ['Mouse', 'Touch'],
 | |
|       configuration: {
 | |
|         // shadow: true,
 | |
|         // preventHandleOutsideImage: false,
 | |
|         // centerPointRadius: 0
 | |
|         shadow: true,
 | |
|         preventHandleOutsideImage: false,
 | |
|         // Radius of the circle to draw  at the center point of the circle.
 | |
|         // Set this zero(0) in order not to draw the circle.
 | |
|         centerPointRadius: 0,
 | |
|         getTextLines: defaultGetTextLines,
 | |
|         // statsCalculator: BasicStatsCalculator,
 | |
|       }
 | |
|     }
 | |
|   ) {
 | |
|     super(toolProps, defaultToolProps)
 | |
| 
 | |
|     // this._throttledCalculateCachedStats = utilities.throttle(
 | |
|     //   this._calculateCachedStats,
 | |
|     //   100,
 | |
|     //   { trailing: true }
 | |
|     // )
 | |
|     // this._getTextLines = this.getTextLines
 | |
|   }
 | |
|   
 | |
| }
 | |
| function defaultGetTextLines(data, targetId) {
 | |
|   const cachedVolumeStats = data.cachedStats[targetId];
 | |
|   const {
 | |
|     radius,
 | |
|     radiusUnit,
 | |
|     area,
 | |
|     mean,
 | |
|     stdDev,
 | |
|     max,
 | |
|     isEmptyArea,
 | |
|     Modality,
 | |
|     areaUnit,
 | |
|     modalityUnit,
 | |
|   } = cachedVolumeStats;
 | |
| 
 | |
|   const textLines= [];
 | |
| 
 | |
|   if (radius) {
 | |
|     const radiusLine = isEmptyArea
 | |
|       ? `Radius: Oblique not supported`
 | |
|       : `Radius: ${roundNumber(radius)} ${radiusUnit}`;
 | |
|     textLines.push(radiusLine);
 | |
|   }
 | |
| 
 | |
|   if (area) {
 | |
|     const areaLine = isEmptyArea
 | |
|       ? `Area: Oblique not supported`
 | |
|       : `Area: ${roundNumber(area)} ${areaUnit}`;
 | |
|     textLines.push(areaLine);
 | |
|   }
 | |
| 
 | |
|   if (mean) {
 | |
|     textLines.push(`Mean: ${roundNumber(mean)} ${modalityUnit}`);
 | |
|   }
 | |
| 
 | |
|   if (max) {
 | |
|     textLines.push(`Max: ${roundNumber(max)} ${modalityUnit}`);
 | |
|   }
 | |
| 
 | |
|   if (stdDev) {
 | |
|     textLines.push(`Std Dev: ${roundNumber(stdDev)} ${modalityUnit}`);
 | |
|   }
 | |
| 
 | |
|   return textLines
 | |
| }
 | |
| 
 | |
| CircleROITool.toolName = 'CircleROI'
 | |
| export default CircleROITool
 | |
| 
 |