Class: IToolGroup
ToolGroup class which is a container for tools and their modes and states. In Cornerstone3DTools, you need to create a tool group in order to use the tools. ToolGroup is a way to share tool configuration, state (enabled, disabled, etc.) across a set of viewports. Tools can set to be activated, enabled or disabled in a toolGroup. You should not directly instantiate a ToolGroup. You need to use ToolGroupManager helpers to create a new toolGroup or get a reference to an existing toolGroup.
const toolGroup = csTools.ToolGroupManager.createToolGroup('toolGroupId')
Constructors
new IToolGroup()
new IToolGroup(
id
):IToolGroup
Parameters
• id: string
Returns
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:57
Properties
_toolInstances
_toolInstances:
object
={}
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:55
currentActivePrimaryToolName
currentActivePrimaryToolName:
string
=null
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:49
id
id:
string
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:46
prevActivePrimaryToolName
prevActivePrimaryToolName:
string
=null
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:50
restoreToolOptions
restoreToolOptions:
object
={}
Options used for restoring a tool
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:54
toolOptions
toolOptions:
object
={}
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:48
viewportsInfo
viewportsInfo:
any
[] =[]
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:47
Methods
_setCursorForViewports()
_setCursorForViewports(
cursor
):void
Parameters
• cursor: MouseCursor
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:665
addTool()
addTool(
toolName
,configuration
):void
Add a tool to the tool group with the given tool name and tool configuration. Note that adding a tool to a tool group will not automatically set the tool to be active. You must call setToolActive or setToolPassive and other methods to set the tool to be active or passive or in other states.
Parameters
• toolName: string
string
• configuration: ToolConfiguration
= {}
Tool configuration objects and a custom statistics calculator if needed
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:120
addToolInstance()
addToolInstance(
toolName
,parentClassName
,configuration
):void
Parameters
• toolName: string
• parentClassName: string
• configuration = {}
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:164
addViewport()
addViewport(
viewportId
,renderingEngineId
?):void
Add a viewport to the ToolGroup. It accepts viewportId and optional renderingEngineId parameter. If renderingEngineId is not provided, it checks if cornerstone-core has more than one renderingEngine; If so, it will throw an error. If cornerstone-core has only one renderingEngine, it will use that renderingEngine.
Parameters
• viewportId: string
The unique identifier for the viewport.
• renderingEngineId?: string
The rendering engine to use.
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:205
clone()
clone(
newToolGroupId
,fnToolFilter
):IToolGroup
Parameters
• newToolGroupId: any
Id of the new (clone) tool group
• fnToolFilter = null
Function to filter which tools from this tool group should be added to the new (clone) one. Example: only annotations tools can be filtered and added to the new tool group.
Returns
A new tool group that is a clone of this one
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:792
getActivePrimaryMouseButtonTool()
getActivePrimaryMouseButtonTool():
string
Find the name of the tool that is Active and has a primary button binding (Mouse primary click)
Returns
string
The name of the tool
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:609
getCurrentActivePrimaryToolName()
getCurrentActivePrimaryToolName():
string
Returns
string
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:780
getDefaultMousePrimary()
getDefaultMousePrimary():
MouseBindings
Returns the default mouse primary button.
Returns
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:723
getDefaultPrimaryBindings()
getDefaultPrimaryBindings():
IToolBinding
[]
Gets an array of bindings that is the full primary binding. Currently this is just the primary mouse button, but may be extended in the future to include touch or other binding types.
Returns
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:732
getPrevActivePrimaryToolName()
getPrevActivePrimaryToolName():
string
Gets the name of the previously active tool.
Returns
string
The name of the previously active tool.
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:763
getToolConfiguration()
getToolConfiguration(
toolName
,configurationPath
?):unknown
Get the configuration of tool. It returns only the config for the given path (in case exists). ConfigurationPath is the the path of the property to get separated by '.'.
Parameters
• toolName: string
• configurationPath?: string
Returns
unknown
Example
getToolConfiguration('LengthTool', 'firstLevel.secondLevel')
// get from LengthTool instance the configuration value as being LengthToolInstance[configuration][firstLevel][secondLevel]
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:744
getToolInstance()
getToolInstance(
toolInstanceName
):any
Get the tool instance for a given tool name in the toolGroup
Parameters
• toolInstanceName: string
Returns
any
A tool instance.
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:81
getToolInstances()
getToolInstances():
Record
<string
,unknown
>
Retrieves the tool instances associated with this tool group.
Returns
Record
<string
, unknown
>
A record containing the tool instances, where the keys are the tool names and the values are the tool instances.
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:98
getToolOptions()
getToolOptions(
toolName
):ToolOptionsType
Get the options for a given tool
Parameters
• toolName: string
The name of the tool.
Returns
the tool options
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:593
getViewportIds()
getViewportIds():
string
[]
Get the viewport IDs of all the viewports in the current viewport
Returns
string
[]
An array of viewport IDs.
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:65
getViewportsInfo()
getViewportsInfo():
IViewportId
[]
Returns the toolGroup viewports info which is an array of {viewportId, renderingEngineId}
Returns
IViewportId
[]
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:72
hasTool()
hasTool(
toolName
):boolean
Check if a tool is already added to the tool group
Parameters
• toolName: string
Tool name
Returns
boolean
True if the tool is already added or false otherwise
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:107
removeViewports()
removeViewports(
renderingEngineId
,viewportId
?):void
Removes viewport from the toolGroup. If only renderingEngineId is defined it removes all the viewports with the same renderingEngineId, if viewportId is also provided, it will remove that specific viewport from the ToolGroup.
Parameters
• renderingEngineId: string
renderingEngine id
• viewportId?: string
viewport id
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:250
setActivePrimaryTool()
setActivePrimaryTool(
toolName
):void
Set Primary tool active Get the current active primary tool name and disable that And set the new tool active
Parameters
• toolName: string
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:772
setActiveStrategy()
setActiveStrategy(
toolName
,strategyName
):void
Parameters
• toolName: string
• strategyName: string
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:284
setToolActive()
setToolActive(
toolName
,toolBindingsOptions
):void
Set the tool mode on the toolGroup to be Active. This means the tool can be actively used by the defined bindings (e.g., Mouse primary click)
- Can be actively used by mouse/touch events mapped to its
ToolBinding
s. - Can add data if an annotation tool.
- Can be passively interacted by grabbing a tool or its handles.
- Renders data if the tool has a
renderAnnotation
method.
Parameters
• toolName: string
tool name
• toolBindingsOptions: SetToolBindingsType
= ...
tool bindings
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:346
setToolConfiguration()
setToolConfiguration(
toolName
,configuration
,overwrite
?):boolean
Set a configuration of a tool by the given toolName. Use overwrite as true in case you want to overwrite any existing configuration (be careful, depending on config change it might break the annotation flow).
Parameters
• toolName: string
• configuration: ToolConfiguration
• overwrite?: boolean
Returns
boolean
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:685
setToolDisabled()
setToolDisabled(
toolName
):void
Set the tool mode on the toolGroup to be Disabled.
- Annotation does not render.
Parameters
• toolName: string
tool name
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:560
setToolEnabled()
setToolEnabled(
toolName
):void
Set the tool mode on the toolGroup to be Enabled.
- Renders data if the tool has a
renderAnnotation
method..
Parameters
• toolName: string
tool name
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:526
setToolMode()
setToolMode(
toolName
,mode
,options
):void
Parameters
• toolName: string
• mode: ToolModes
• options: SetToolBindingsType
= ...
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:298
setToolPassive()
setToolPassive(
toolName
,options
?):void
Set the tool mode on the toolGroup to be Passive.
- Can be passively interacted by grabbing a tool or its handles.
- Renders data if the tool has a
renderAnnotation
method.
Parameters
• toolName: string
tool name
• options?
Options used when setting the tool as passive
- removeAllBindings: only the primary button bindings are removed but if this parameter is set to true all bindings are removed.
• options.removeAllBindings?: boolean
| IToolBinding
[]
Returns
void
Defined in
tools/src/store/ToolGroupManager/ToolGroup.ts:456
setViewportsCursorByToolName()
setViewportsCursorByToolName(
toolName
,strategyName
?):void
Parameters
• toolName: string
• strategyName?: string
Returns
void