-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: segmentation tools is active after deleting segments
- Loading branch information
1 parent
05e3f22
commit b794564
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const segmentationTools = [ | ||
'CircularBrush', | ||
'SphereBrush', | ||
'CircularEraser', | ||
'SphereEraser', | ||
'CircleScissor', | ||
'RectangleScissor', | ||
'SphereScissor', | ||
'ThresholdCircularBrush', | ||
'ThresholdSphereBrush', | ||
'ThresholdCircularBrushDynamic', | ||
]; | ||
|
||
export { segmentationTools }; |
33 changes: 33 additions & 0 deletions
33
extensions/cornerstone/src/utils/setSegToolModeForToolGroups.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Enums } from '@cornerstonejs/tools'; | ||
import ToolGroupService from '../services/ToolGroupService'; | ||
import { segmentationTools } from './SegmentationTools'; | ||
|
||
/** | ||
* Sets the mode for segmentation tools in all tool groups managed by the tool group service. | ||
* | ||
* @param toolGroupService - The service managing the tool groups. | ||
* @param mode - The mode to set for the tools (e.g., Active, Enabled, Passive, Disabled). | ||
*/ | ||
const setSegToolModeForToolGroups = (toolGroupService: ToolGroupService, mode: Enums.ToolModes) => { | ||
const toolGroupIds = toolGroupService.getToolGroupIds(); | ||
toolGroupIds.forEach(toolGroupId => { | ||
const toolGroup = toolGroupService.getToolGroup(toolGroupId); | ||
if (!toolGroup) { | ||
return; | ||
} | ||
const toolName = toolGroup.currentActivePrimaryToolName; | ||
if (!toolName || !toolGroup.hasTool(toolName) || !segmentationTools.includes(toolName)) { | ||
return; | ||
} | ||
let options; | ||
|
||
if (mode === Enums.ToolModes.Active) { | ||
options = { | ||
bindings: [{ mouseButton: Enums.MouseBindings.Primary }], | ||
}; | ||
} | ||
toolGroup.setToolMode(toolName, mode, options); | ||
}); | ||
}; | ||
|
||
export default setSegToolModeForToolGroups; |