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


    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

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.


    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

  • addAnnotation(element: HTMLDivElement, annotation: Annotation): string
  • Add the annotation to the annotations for the FrameOfReference of the Viewport being viewed by the cornerstone3D enabled element.


    Parameters

    • element: HTMLDivElement

      HTMLDivElement

    • annotation: Annotation

      The annotation that is being added to the annotations manager.

    Returns string

getAnnotation

  • getAnnotation(annotationUID: string, element?: HTMLDivElement): Annotation
  • 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

  • getAnnotations(element: HTMLDivElement, toolName: string): Annotations
  • Returns the annotations for the FrameOfReference of the Viewport being viewed by the cornerstone3D enabled element.


    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

  • getDefaultAnnotationManager(): default
  • It returns the default annotations manager.


    Returns default

    the singleton default annotations manager.

getNumberOfAnnotations

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

  • removeAllAnnotations(element?: HTMLDivElement): void
  • 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

  • removeAnnotation(annotationUID: string, element?: HTMLDivElement): void
  • Remove the annotation by UID of the annotation.


    Parameters

    • annotationUID: string

      The unique identifier for the annotation.

    • optionalelement: HTMLDivElement

      HTMLDivElement

    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

FrameOfReferenceSpecificAnnotationManager

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

  • new FrameOfReferenceSpecificAnnotationManager(uid?: string): default
  • Parameters

    • optionaluid: string

      The uid of the state manager. If omitted it is autogenerated.

    Returns default

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

  • Adds an instance of Annotation to the annotations.


    Parameters

    Returns void

get

  • get(FrameOfReferenceUID: string, toolName: string): Annotations
  • Get Annotations from the the manager given the FrameOfReferenceUID and toolName.


    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

  • getAnnotation(annotationUID: string, filter?: FilterInterface): Annotation
  • Given the unique identified for the some annotation, returns the annotation from the annotations. Searches are more efficient if either/both of the FrameOfReferenceUID and the toolName are given by the filter.


    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 FrameOfReference


    Parameters

    • FrameOfReferenceUID: string

      The UID of the FrameOfReference to retrieve data for.

    Returns FrameOfReferenceSpecificAnnotations

    FrameOfReferenceSpecificAnnotations

getFramesOfReference

  • getFramesOfReference(): string[]
  • Returns all the available frameOfReferences inside the state manager


    Returns string[]

    • All the registered frame of references inside the manager

getNumberOfAnnotations

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

  • getNumberOfAnnotationsInFrameOfReference(toolName: string, frameOfReferenceUID: string): number
  • Parameters

    • toolName: string
    • frameOfReferenceUID: string

    Returns number

removeAllAnnotations

  • removeAllAnnotations(): void
  • Returns void

removeAnnotation

  • removeAnnotation(annotationUID: string, filter?: FilterInterface): void
  • Given the unique identified for the some annotation, removes the annotation from the annotations. Searches are more efficient if either/both of the FrameOfReferenceUID and the toolName are given by the filter.


    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 corresponding FrameOfReferenceSpecificAnnotations instance is restored.
    • If both the FrameOfReferenceUID and the toolName are are given, the corresponding Annotations 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

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 corresponding FrameOfReferenceSpecificAnnotations instance is returned.
    • If both the FrameOfReferenceUID and the toolName are are given, the corresponding Annotations 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.