annotation
Index
Namespaces
config
conststyle
getFont
Parameters
styleSpecifier: StyleSpecifier
An object containing the specifications such as viewportId, toolGroupId, toolName and annotationUID which are used to get the style if the level of specificity is met (hierarchy is checked from most specific to least specific which is annotationLevel -> viewportLevel -> toolGroupLevel -> default.
optionalstate: AnnotationStyleStates
An optional state to determine the final property name
optionalmode: ToolModes
An optional mode to determine the final property name
Returns string
The font string.
getState
Given a Annotation object, return the annotationStyle State that it should be in based on its data
Parameters
optionalannotation: Annotation
The annotation that we want to style.
Returns AnnotationStyleStates
The state of the annotation whether it is Default, Highlighted, Locked, or Selected.
locking
checkAndDefineIsLockedProperty
Properly initialize the isLocked on annotation, and set it as locked if isLocked is true.
Parameters
annotation: Annotation
The annotation object to be checked.
Returns void
getAnnotationsLocked
Returns an array of all the annotation that is currently locked
Returns Annotation[]
An array of tool specific annotation objects.
getAnnotationsLockedCount
Get the number of locked annotation objects in the global set of locked annotation objects.
Returns number
The number of locked annotation objects.
isAnnotationLocked
Given a Annotation object, return true if it is locked.
Parameters
annotation: Annotation
Annotation
Returns boolean
A boolean value.
setAnnotationLocked
Set the “Locked” state of a given annotation instance.
Parameters
annotation: Annotation
The annotation instance which will have its locked state changed. An event will only be triggered if the locked state of the given annotation instance changed.
locked: boolean = true
A boolean value indicating if the instance should be locked (true) or not (false)
Returns void
unlockAllAnnotations
Clears all the locked annotation
Returns void
selection
deselectAnnotation
Deselect one or all annotations.
Parameters
optionalannotationUID: string
If an annotation is provided that instance will be removed from the internal selection set. If none is given, ALL selections will be cleared.
Returns void
getAnnotationsSelected
Return an array of ALL the selected annotationUIDs
Returns string[]
An array of Annotation UIDs
getAnnotationsSelectedByToolName
Given a tool name, return ALL the annotationUIDs for that tool that are selected
Parameters
toolName: string
The name of the tool you want to get the selected annotation for
Returns string[]
An array of annotationUIDs
getAnnotationsSelectedCount
Return the number of the selected annotation
Returns number
The size of the selected annotation set
isAnnotationSelected
Given an annotationUID, return true if it is selected, false otherwise.
Parameters
annotationUID: string
Annotation UID
Returns boolean
A boolean value.
setAnnotationSelected
Set a given annotationUID as selected or deselected based on the provided selected value.
Parameters
annotationUID: string
The annotation UID to be selected
selected: boolean = true
When true, the annotation is selected. When false, the annotation is deselected.
preserveSelected: boolean = false
When true, preserves existing selections (i.e., the given annotation is appended to the selection set). When false (the default behavior) the currently selected items are discarded (i.e., the given annotation instance replaces the currently selected ones).
Returns void
state
addAnnotation
Add the annotation to the annotation manager along with the options that is used to filter the annotation manager and the annotation group that the annotation belongs to.
As a result, our default implementation will add the annotation to the default manager using the FrameOfReferenceUID as the group key.
Parameters
annotation: Annotation
The annotation that is being added to the annotations manager.
annotationGroupSelector: AnnotationGroupSelector
element or FrameOfReferenceUID that is used to group annotations in the annotation manager.
Returns string
getAnnotation
Get the Annotation object by its UID
Parameters
annotationUID: string
The unique identifier of the annotation.
Returns Annotation
getAnnotationManager
It returns the default annotations manager.
Returns FrameOfReferenceSpecificAnnotationManager
the singleton default annotations manager.
getAnnotations
Returns the annotations for a given tool with the provided options that is used to filter annotations based on the annotation manager.
In our default implementation, the options are the element and/or the FrameOfReferenceUID. Hence, the getAnnotations function will return the annotations for the given tool that are associated with the FrameOfReferenceUID.
Parameters
toolName: string
The name of the tool.
annotationGroupSelector: AnnotationGroupSelector
element or FrameOfReferenceUID that is used to group annotations in the annotation manager.
Returns Annotations
The annotations corresponding to the Frame of Reference and the toolName.
getNumberOfAnnotations
Get the number of annotations for a given tool with the provided options that is used to filter annotations based on the annotation manager.
In our default implementation, the options are the element and/or the FrameOfReferenceUID. Hence, the getNumberOfAnnotations function will return the number of annotations for the given tool that are associated with the FrameOfReferenceUID.
Parameters
toolName: string
The name of the tool
annotationGroupSelector: AnnotationGroupSelector
element or FrameOfReferenceUID that is used to group annotations in the annotation manager.
Returns number
removeAllAnnotations
It removes all annotations from the default annotation manager
Returns void
removeAnnotation
Remove the annotation by UID of the annotation.
Parameters
annotationUID: string
The unique identifier for the annotation.
Returns void
resetAnnotationManager
Returns void
setAnnotationManager
Set the annotation manager to be used for rendering, adding, removing, etc.
Parameters
annotationManager: any
The annotation manager to be used
Returns void
visibility
checkAndDefineIsVisibleProperty
It decorates given annotation with isVisible property. It properly initializes the isVisible on annotation(the property will be create if does not exist yet)
Parameters
annotation: Annotation
The annotation object to be checked.
Returns void
isAnnotationVisible
Given an annotation UID, return true if it is visible, false if hidden and undefined if does not exist.
Parameters
annotationUID: string
The annotation uid to tell if is visible or not.
Returns boolean | undefined
A boolean value or value if does not exist.
showAllAnnotations
Clears all the hidden annotations.
Returns void
setAnnotationVisibility
Set the “visible” state of a given annotation instance.
ANNOTATION_VISIBILITY_CHANGE
Parameters
annotationUID: string
The annotation uid which will have its visible state changed. An event will only be triggered if the visible state of the given annotation instance changed.
visible: boolean = true
A boolean value indicating if the instance should be visible (true) or not (false)
Returns void
Classes
FrameOfReferenceSpecificAnnotationManager
This is the default annotation manager. It stores annotations by default based on the FrameOfReferenceUID. However, it is possible to override the getAnnotationStateKey function to store annotations based on any other property of the element. When you write your custom annotation manager, you can use the setAnnotationManager function to set your custom annotation.
Note that this class is a singleton and should not be instantiated directly. To get the stored annotations information you can use ToolState helpers.
constructor
Parameters
optionaluid: string
The uid of the state manager. If omitted it is autogenerated.
Returns FrameOfReferenceSpecificAnnotationManager
publicreadonlyuid
_imageVolumeModifiedHandler
When a volume is modified we invalidate all of the
annotations
on the volume’sFrameOfReferenceUID
. This is mainly to update statistics calculations when an annotation is drawn whilst data is still loading.Parameters
evt: ImageVolumeModifiedEvent
The IMAGE_VOLUME_MODIFIED rendering event.
Returns void
addAnnotation
Adds an instance of
Annotation
to theannotations
.Parameters
annotation: Annotation
The annotation to add.
optionalgroupKey: string
The annotation group key to add the annotation to (in default manager it is FrameOfReferenceUID).
Returns void
getAnnotation
Given the unique identified for the some
annotation
, returns theannotation
from theannotations
. Eachannotation
has a unique identifier.Parameters
annotationUID: string
The unique identifier of the
annotation
.
Returns Annotation
The retrieved
annotation
.
getAnnotations
Returns the annotations associated with the specified frameOfReference and tool, or all annotations for the group if the tool name is not provided.
Parameters
groupKey: string
The annotation group key to retrieve annotations for (in default manager it is FrameOfReferenceUID).
optionaltoolName: string
Optional. The name of the tool to retrieve annotations for.
Returns Annotations | GroupSpecificAnnotations
The annotations associated with the specified group (default FrameOfReferenceUID) and tool, or all annotations for the group (FrameOfReferenceUID) if the tool name is not provided.
getFramesOfReference
Returns all the available frameOfReferences inside the state manager
Returns string[]
- All the added frames of references inside the manager
getGroupKey
Default annotation manager works with FrameOfReferenceUID as the key. The manager adds them under the FrameOfReferenceUID for the element being annotated.
Parameters
annotationGroupSelector: AnnotationGroupSelector
element or a string that is provided to the annotation manager to get the key.
Returns string
- The annotation state key for the element.
getNumberOfAllAnnotations
A function that returns the number of all annotations in the annotation state
Returns number
The number of all annotations in the state
getNumberOfAnnotations
A function that returns the number of annotations for a given tool in the specific group (default FrameOfReferenceUID) IF no groupKey (FrameOfReferenceUID) is provided, it will return the number of annotations for the tool in all groups (FrameOfReferenceUIDs)
Parameters
groupKey: string
The annotation group key to retrieve annotations for (in default manager it is FrameOfReferenceUID).
optionaltoolName: string
The name of the tool to retrieve data for.
Returns number
The number of annotations for a given tool in the state
removeAllAnnotations
Removes all annotations in the annotation state.
Returns void
removeAnnotation
Given the unique identified for the some
annotation
, removes theannotation
from theannotations
.Parameters
annotationUID: string
The unique identifier of the
annotation
to remove.
Returns void
removeAnnotations
Removes all annotations associated with the specified group (FrameOfReferenceUID) and tool, or all annotations for the group (FrameOfReferenceUID) if the tool name is not provided.
Parameters
groupKey: string
The group key to remove annotations for (in default manager it is FrameOfReferenceUID).
optionaltoolName: string
Optional. The name of the tool to remove annotations for.
Returns void
restoreAnnotations
Restores a section of the
annotations
. Useful for loading in serialized data.- If no arguments are given, the entire
AnnotationState
instance is restored. - If the
FrameOfReferenceUID
is given, the correspondingFrameOfReferenceSpecificAnnotations
instance is restored. - If both the
FrameOfReferenceUID
and thetoolName
are are given, the correspondingAnnotations
instance is restored.
Parameters
state: Annotations | GroupSpecificAnnotations | AnnotationState
optionalgroupKey: string
A filter string for restoring only the
annotations
of a specific frame of reference.optionaltoolName: string
A filter string for restoring
annotation
for a specific tool on a specific frame of reference.
Returns void
- If no arguments are given, the entire
saveAnnotations
Returns a section of the annotations. Useful for serialization. If both groupKey (default manager is FrameOfReferenceUID) and toolName are provided, returns the corresponding Annotations instance for that groupKey (FrameOfReferenceUID) and toolName. If only groupKey is provided, returns the corresponding FrameOfReferenceSpecificAnnotations instance for that groupKey. If neither groupKey nor toolName is provided, returns the entire AnnotationState object.
Parameters
optionalgroupKey: string
Optional. The group key (e.g. FrameOfReferenceUID) to retrieve annotations for.
optionaltoolName: string
Optional. The name of the tool to retrieve annotations for.
Returns Annotations | GroupSpecificAnnotations | AnnotationState
A section of the annotations.
getFont - Returns a font string of the form “{fontSize}px fontName” used by
canvas
.