-
Notifications
You must be signed in to change notification settings - Fork 456
DataManagement
This documentation is for a much older version of
cornerstone-tools
. While it may still loosely apply, more recent information can be found at https://tools.cornerstonejs.org
Tools often have data associated with them. For example, a length measurement tool might need to keep track of the starting and ending pixel coordinates of the length measurement and which ImageId it is associated with. The cornerstone tools library addresses this by providing the following API functions to work with tool specific data:
The addToolState api call is used to add tool specific data to the tool data context associated with an enabled element
function addToolState(element, toolType, data)
Parameters:
- element - the DOM element that has been enabled (DOM node)
- toolType - a unique string identifying this tool data. This needs to be unique to avoid conflicts with other tools so consider using a GUID, project name or other strings as part of the toolType.
- data - a javascript object to add to the tool data context for this enabled
Returns: nothing
The getToolState api call is used to get tool specific data for the tool data context associated with an enabled element
function getToolState(element, toolType)
Parameters:
- element - the DOM element that has been enabled (DOM node)
- toolType - a unique string identifying this tool data. This needs to be unique to avoid conflicts with other tools so consider using a GUID, project name or other strings as part of the toolType.
Returns: a javascript object added previously via the addToolState API for this enabled
Note that the above API's can also be called by modules that are responsible for tool data persistence. For example, a module that is restoring a DICOM GSPS object may call addToolState to add the geometry objects in the DICOM GSPS object so the associated tools can display them. Likewise, a module that is responsible for saving tool data to a DICOM Structure Report would call getToolState to access the underlying tool data. TODO: these apis depend on the enabled element which is probably not the right thing for persistence modules to work with.