11import { getToolGroup } from '../../store/ToolGroupManager' ;
22import type BrushTool from '../../tools/segmentation/BrushTool' ;
33import triggerAnnotationRenderForViewportIds from '../triggerAnnotationRenderForViewportIds' ;
4- import { getRenderingEngine } from '@cornerstonejs/core' ;
54import { getBrushToolInstances } from './getBrushToolInstances' ;
65
76/**
@@ -25,31 +24,21 @@ export function setBrushSizeForToolGroup(
2524 const brushBasedToolInstances = getBrushToolInstances ( toolGroupId , toolName ) ;
2625
2726 brushBasedToolInstances . forEach ( ( tool : BrushTool ) => {
28- tool . configuration . brushSize = brushSize ;
27+ const minRadius = tool . configuration . minRadius ;
28+ const maxRadius = tool . configuration . maxRadius ;
29+
30+ let newBrushSize = minRadius ? Math . max ( brushSize , minRadius ) : brushSize ;
31+ newBrushSize = maxRadius ? Math . min ( newBrushSize , maxRadius ) : newBrushSize ;
32+
33+ tool . configuration . brushSize = newBrushSize ;
2934
3035 // Invalidate the brush being rendered so it can update.
3136 tool . invalidateBrushCursor ( ) ;
3237 } ) ;
3338
3439 // Trigger an annotation render for any viewports on the toolgroup
35- const viewportsInfo = toolGroup . getViewportsInfo ( ) ;
36-
37- const viewportsInfoArray = Object . keys ( viewportsInfo ) . map (
38- ( key ) => viewportsInfo [ key ]
39- ) ;
40-
41- if ( ! viewportsInfoArray . length ) {
42- return ;
43- }
44-
45- const { renderingEngineId } = viewportsInfoArray [ 0 ] ;
46-
47- // Use helper to get array of viewportIds, or we just end up doing this mapping
48- // ourselves here.
4940 const viewportIds = toolGroup . getViewportIds ( ) ;
5041
51- const renderingEngine = getRenderingEngine ( renderingEngineId ) ;
52-
5342 triggerAnnotationRenderForViewportIds ( viewportIds ) ;
5443}
5544
@@ -63,7 +52,7 @@ export function setBrushSizeForToolGroup(
6352export function getBrushSizeForToolGroup (
6453 toolGroupId : string ,
6554 toolName ?: string
66- ) : void {
55+ ) : number {
6756 const toolGroup = getToolGroup ( toolGroupId ) ;
6857
6958 if ( toolGroup === undefined ) {
0 commit comments