Skip to main content

annotation

Index

Namespaces

config

config:

conststyle

style: ToolStyle = ...

getFont

  • getFont - Returns a font string of the form “{fontSize}px fontName” used by canvas.


    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. The ordering of states is:

    • Highlighted
    • Selected
    • Locked
    • Autogenerated
    • Default So the first one that applies will be returned. For the autogenerated state, it depends on the autoGenerated flag on the annotation, so once that is gone/false, the annotation will go to default.

    Parameters

    • optionalannotation: Annotation

      The annotation that we want to style.

    Returns AnnotationStyleStates

    The state of the annotation whether it is Default, Highlighted, Locked, Selected, or AutoGenerated.

locking

locking:

checkAndDefineIsLockedProperty

  • checkAndDefineIsLockedProperty(annotation: Annotation): void
  • 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

  • getAnnotationsLockedCount(): number
  • Get the number of locked annotation objects in the global set of locked annotation objects.


    Returns number

    The number of locked annotation objects.

isAnnotationLocked

  • isAnnotationLocked(annotation: Annotation): boolean
  • Given a Annotation object, return true if it is locked.


    Parameters

    Returns boolean

    A boolean value.

setAnnotationLocked

  • setAnnotationLocked(annotation: Annotation, locked?: boolean): void
  • Set the “Locked” state of a given annotation instance.

    @triggers

    ANNOTATION_LOCK_CHANGE


    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

  • unlockAllAnnotations(): void
  • Clears all the locked annotation


    Returns void

selection

selection:

deselectAnnotation

  • deselectAnnotation(annotationUID?: string): void
  • 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

  • getAnnotationsSelected(): string[]
  • Return an array of ALL the selected annotationUIDs


    Returns string[]

    An array of Annotation UIDs

getAnnotationsSelectedByToolName

  • getAnnotationsSelectedByToolName(toolName: string): string[]
  • 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

  • getAnnotationsSelectedCount(): number
  • Return the number of the selected annotation


    Returns number

    The size of the selected annotation set

isAnnotationSelected

  • isAnnotationSelected(annotationUID: string): boolean
  • Given an annotationUID, return true if it is selected, false otherwise.


    Parameters

    • annotationUID: string

      Annotation UID

    Returns boolean

    A boolean value.

setAnnotationSelected

  • setAnnotationSelected(annotationUID: string, selected?: boolean, preserveSelected?: boolean): void
  • 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

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

addChildAnnotation

  • Creates a parent/child association between annotations. A annotation may have only one parent and multiple children (eg: a contour may have multiple holes in it).


    Parameters

    Returns void

clearParentAnnotation

  • clearParentAnnotation(annotation: Annotation): void
  • Removes the association between the annotation passed as parameter and its parent in case it has one (eg: contour holes).


    Parameters

    Returns void

getAllAnnotations

getAnnotation

  • Get the Annotation object by its UID


    Parameters

    • annotationUID: string

      The unique identifier of the annotation.

    Returns Annotation

getAnnotationManager

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.

getChildAnnotations

  • Returns all children annotation of a given one since annotations can be associated in a parent/child way (eg: polyline holes)


    Parameters

    Returns Annotation[]

    Child annotations

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

getParentAnnotation

  • Returns the parent annotation of a given one since annotations can be associated in a parent/child way (eg: polyline holes)


    Parameters

    Returns Annotation

    Parent annotation

invalidateAnnotation

  • invalidateAnnotation(annotation: Annotation): void
  • Invalidate current and all parent annotations (eg: contour holes)


    Parameters

    Returns void

removeAllAnnotations

  • removeAllAnnotations(): void
  • It removes all annotations from the default annotation manager


    Returns void

removeAnnotation

  • removeAnnotation(annotationUID: string): void
  • Remove the annotation by UID of the annotation.


    Parameters

    • annotationUID: string

      The unique identifier for the annotation.

    Returns void

resetAnnotationManager

  • resetAnnotationManager(): void
  • Returns void

setAnnotationManager

  • setAnnotationManager(annotationManager: any): void
  • Set the annotation manager to be used for rendering, adding, removing, etc.


    Parameters

    • annotationManager: any

      The annotation manager to be used

    Returns void

visibility

visibility:

checkAndDefineIsVisibleProperty

  • checkAndDefineIsVisibleProperty(annotation: Annotation): void
  • 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

  • isAnnotationVisible(annotationUID: string): boolean | undefined
  • 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

  • showAllAnnotations(): void
  • Clears all the hidden annotations.


    Returns void

setAnnotationVisibility

  • setAnnotationVisibility(annotationUID: string, visible?: boolean): void
  • 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

AnnotationGroup

AnnotationGroup:

An annotation group

constructor

publicvisibleFilter

visibleFilter: (uid: string) => boolean

Type declaration

    • (uid: string): boolean
    • Parameters

      • uid: string

      Returns boolean

publicisVisible

  • get isVisible(): boolean
  • Returns boolean

publicadd

  • add(...annotationUIDs: string[]): void
  • Adds the annotation to the group Does NOT change the visibility status of the annotation.


    Parameters

    • rest...annotationUIDs: string[]

    Returns void

publicclear

  • clear(): void
  • Removes everything from the group.


    Returns void

publicfindNearby

  • findNearby(uid: string, direction: 1): string
  • Finds the nearby/next annotation in the given direction


    Parameters

    • uid: string
    • direction: 1

    Returns string

publichas

  • has(uid: string): boolean
  • Parameters

    • uid: string

    Returns boolean

publicremove

  • remove(...annotationUIDs: string[]): void
  • Removes the annotation from the group. Does not affect the visibility status of the annotation.


    Parameters

    • rest...annotationUIDs: string[]

    Returns void

publicsetVisible

  • setVisible(isVisible?: boolean, baseEvent: BaseEventDetail, filter?: (annotationUID: string) => boolean): void
  • Sets whether annotations belonging to this group are visible or not. If there are multiple groups, then the set visible false should be called before before re-enabling the other groups with setVisible true.


    Parameters

    • isVisible: boolean = true
    • baseEvent: BaseEventDetail
    • optionalfilter: (annotationUID: string) => boolean

    Returns void

FrameOfReferenceSpecificAnnotationManager

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

publicreadonlyuid

uid: string

_imageVolumeModifiedHandler

  • _imageVolumeModifiedHandler(evt: ImageVolumeModifiedEvent): void
  • When a volume is modified we invalidate all of the annotations on the volume’s FrameOfReferenceUID. 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

  • addAnnotation(annotation: Annotation, groupKey?: string): void
  • Adds an instance of Annotation to the annotations.


    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

getAllAnnotations

  • return all annotations as a single array


    Returns Annotations

getAnnotation

  • Given the unique identified for the some annotation, returns the annotation from the annotations. Each annotation 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. WARNING: The list returned here is internal tool data, not a copy, so do NOT modify it.

getFramesOfReference

  • getFramesOfReference(): string[]
  • 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

  • getNumberOfAllAnnotations(): number
  • A function that returns the number of all annotations in the annotation state


    Returns number

    The number of all annotations in the state

getNumberOfAnnotations

  • getNumberOfAnnotations(groupKey: string, toolName?: string): number
  • 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

  • removeAllAnnotations(): void
  • Removes all annotations in the annotation state.


    Returns void

removeAnnotation

  • removeAnnotation(annotationUID: string): void
  • Given the unique identified for the some annotation, removes the annotation from the annotations.


    Parameters

    • annotationUID: string

      The unique identifier of the annotation to remove.

    Returns void

removeAnnotations

  • removeAnnotations(groupKey: string, toolName?: string): void
  • 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 corresponding FrameOfReferenceSpecificAnnotations instance is restored.
    • If both the FrameOfReferenceUID and the toolName are are given, the corresponding Annotations 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

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.