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 annotations for the
FrameOfReference
of theViewport
being viewed by the cornerstone3D enabledelement
.Parameters
element: HTMLDivElement
HTMLDivElement
annotation: Annotation
The annotation that is being added to the annotations manager.
Returns string
getAnnotation
Get the Annotation object by its UID
Parameters
annotationUID: string
The unique identifier of the annotation.
optionalelement: HTMLDivElement
The element that the tool is being used on.
Returns Annotation
A Annotation object
getAnnotations
Returns the annotations for the
FrameOfReference
of theViewport
being viewed by the cornerstone3D enabledelement
.Parameters
element: HTMLDivElement
The HTML element.
toolName: string
The name of the tool.
Returns Annotations
The annotations corresponding to the Frame of Reference and the toolName.
getDefaultAnnotationManager
It returns the default annotations manager.
Returns default
the singleton default annotations manager.
getNumberOfAnnotations
Get the number of annotations for a given tool in the specified frame of reference. If no frame of reference is specified, it will return the number of annotations for all frames of reference.
Parameters
toolName: string
The name of the tool
optionalframeOfReferenceUID: string
The frame of reference UID
Returns number
The number of annotations for a given frame of reference and tool name.
getViewportSpecificAnnotationManager
Given an element, return the FrameOfReferenceSpecificStateManager for that element
Parameters
optionalelement: HTMLDivElement | IEnabledElement
The element that the state manager is managing the state of.
Returns default
The default state manager
removeAllAnnotations
It removes all annotations from the default annotation manager
Parameters
optionalelement: HTMLDivElement
Optional element to get the annotation manager from, if not specified it will use the default annotation manager.
Returns void
removeAnnotation
Remove the annotation by UID of the annotation.
Parameters
annotationUID: string
The unique identifier for the annotation.
optionalelement: HTMLDivElement
HTMLDivElement
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 class stores annotations in per FrameOfReference. Tool coordinates are in the world coordinates for the viewports, which is the patient coordinate system for DICOM.
Each FrameOfReferenceSpecificAnnotationManager is separate, so it is be possible to render different annotations of the same tool on different viewports that share the same FrameOfReferenceUID, however no core tool in this library currently does this. This could be useful for e.g. viewing two different reads of the same data side-by-side.
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 default
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.
Returns void
get
Get
Annotations
from the the manager given theFrameOfReferenceUID
andtoolName
.Parameters
FrameOfReferenceUID: string
The UID of the FrameOfReference to retrieve data for.
toolName: string
The name of the tool to retrieve data for.
Returns Annotations
getAnnotation
Given the unique identified for the some
annotation
, returns theannotation
from theannotations
. Searches are more efficient if either/both of theFrameOfReferenceUID
and thetoolName
are given by thefilter
.Parameters
annotationUID: string
The unique identifier of the
annotation
.filter: FilterInterface = {}
A
filter
which reduces the scope of the search.
Returns Annotation
The retrieved
annotation
.
getFrameOfReferenceAnnotations
get all tools
Annotations
for the provided FrameOfReferenceParameters
FrameOfReferenceUID: string
The UID of the FrameOfReference to retrieve data for.
Returns FrameOfReferenceSpecificAnnotations
FrameOfReferenceSpecificAnnotations
getFramesOfReference
Returns all the available frameOfReferences inside the state manager
Returns string[]
- All the registered frame of references inside the manager
getNumberOfAnnotations
A function that returns the number of annotations for a given tool in the specific frame of reference. IF no frame of reference is provided, it will return the number of annotations for the tool in all frames of references
Parameters
toolName: string
The name of the tool to retrieve data for.
optionalframeOfReferenceUID: string
The UID of the FrameOfReference to retrieve data for.
Returns number
The number of annotations for a given tool in the state
getNumberOfAnnotationsInFrameOfReference
Parameters
toolName: string
frameOfReferenceUID: string
Returns number
removeAllAnnotations
Returns void
removeAnnotation
Given the unique identified for the some
annotation
, removes theannotation
from theannotations
. Searches are more efficient if either/both of theFrameOfReferenceUID
and thetoolName
are given by thefilter
.Parameters
annotationUID: string
The unique identifier of the
annotation
to remove.filter: FilterInterface = {}
A
filter
which reduces the scope of the search.
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 | FrameOfReferenceSpecificAnnotations | AnnotationState
optionalFrameOfReferenceUID: 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 no arguments are given, the entire
AnnotationState
instance is returned. - If the
FrameOfReferenceUID
is given, the correspondingFrameOfReferenceSpecificAnnotations
instance is returned. - If both the
FrameOfReferenceUID
and thetoolName
are are given, the correspondingAnnotations
instance is returned.
Parameters
optionalFrameOfReferenceUID: string
A filter string for returning the
annotations
of a specific frame of reference.optionaltoolName: string
A filter string for returning
annotations
for a specific tool on a specific frame of reference.
Returns Annotations | FrameOfReferenceSpecificAnnotations | AnnotationState
The retrieved
annotation
.- If no arguments are given, the entire
getFont - Returns a font string of the form “{fontSize}px fontName” used by
canvas
.