All files / tools/src/types AnnotationTypes.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149                                                                                                                                                                                                                                                                                                         
import type { Types } from '@cornerstonejs/core';
 
export type AnnotationMetadata = Types.ViewReference & {
  /**
   * The registered name of the tool
   */
  toolName: string;
  /**
   * The position of the camera in world space.
   */
  cameraPosition?: Types.Point3;
  /**
   * The viewUp for the view position
   */
  viewUp?: Types.Point3;
 
  /** The color of the segmentation - really this is annotation data */
  segmentColor?;
 
  /** The enable element of the annotation */
  enabledElement?: Types.IEnabledElement;
};
 
export type AnnotationData = {
  /**
   * Annotation handles that are grabbable for manipulation
   */
  handles?: Handles;
  /**
   * Cached Annotation statistics which is specific to the tool
   */
  cachedStats?: Record<string, unknown>;
  /**
   * Label of an annotation
   */
  label?: string;
  /**
   * contour data
   */
  contour?: Contour;
 
  /**
   * Other data/keys
   */
  [key: string]: unknown;
};
 
/**
 * Defines the basic annotation type.  This SHOULD be an interface, but
 * typescript doesn't properly handle extending interfaces.
 */
export type Annotation = {
  /** A unique identifier for this annotation */
  annotationUID?: string;
  /**
   * Parent annotation UID
   *
   * An annotation may have a parent annotation when it is, for example, a
   * hole inside a contour.
   */
  parentAnnotationUID?: string;
  /**
   * The interpolationUID, to match up annotations getting interpolated
   */
  interpolationUID?: string;
  /**
   * Array that contains all child annotation UID
   *
   * An annotation may have one or more child annotations when it is contour
   * and have some holes in it.
   */
  childAnnotationUIDs?: string[];
  /** If the annotation is being hovered over and is highlighted */
  highlighted?: boolean;
  /** If the annotation is locked for manipulation */
  isLocked?: boolean;
  /** If the annotation is visible for manipulation */
  isVisible?: boolean;
  /** Has annotation data been invalidated (e.g., as a result of mouse interactions) */
  invalidated?: boolean;
  /** If the annotation is selected */
  isSelected?: boolean;
  /** If the annotation is auto generated from other annotations*/
  autoGenerated?: boolean;
  /** Metadata for annotation.  Optional for any type, but required for measurements */
  metadata?: AnnotationMetadata;
  /**
   * Data for annotation, Derivatives need to define their own data types.
   */
  data: AnnotationData;
};
 
export type Contour = {
  /** world location of the polyline in the space */
  polyline?: Types.Point3[];
  /** PointsManager */
  pointsManager?: Types.IPointsManager<Types.Point3>;
  /** boolean indicating if the contour is closed */
  closed?: boolean;
};
 
/** Array of annotations */
export type Annotations = Array<Annotation>;
 
export type GroupSpecificAnnotations = {
  /** Each tool annotations */
  [toolName: string]: Annotations;
};
 
/**
 * All frame of reference specific annotations for all tools.
 */
export type AnnotationState = {
  /**
   * A string representing the key that can be used
   * to retrieve the key-specific annotations. For instance, our default
   * annotation state key is the FrameOfReferenceUID which is for our default
   * frameOfReferenceAnnotationManager. You can write your own annotation manager
   * that works for a different use case and use a different key.
   */
  [key: string]: GroupSpecificAnnotations;
};
 
export type Handles = {
  /** world location of the handles in the space */
  points?: Types.Point3[];
  /** index of the active handle being manipulated */
  activeHandleIndex?: number | null;
  /** annotation text box information */
  textBox?: {
    /** whether the text box has moved */
    hasMoved?: boolean;
    /** the world location of the text box */
    worldPosition?: Types.Point3;
    /** text box bounding box information */
    worldBoundingBox?: {
      /** Top left location of the text box in the world space */
      topLeft: Types.Point3;
      /** Top right location of the text box in the world space */
      topRight: Types.Point3;
      /** Bottom left location of the text box in the world space */
      bottomLeft: Types.Point3;
      /** Bottom right location of the text box in the world space */
      bottomRight: Types.Point3;
    };
  };
  [key: string]: unknown;
};