DWVv0.37.0

ViewController

Source: viewController.js:34

View controller.


Constructor

new ViewController(view: View): ViewController

Parameters

  • view (View) — The associated view.

Instance Methods

getPlaneHelper(): PlaneHelper

Get the plane helper.

Returns

updatePlaneHelper()

Update the plane helper if there is a change in the image geometry.

isMask(): boolean

Check is the associated image is a mask.

Returns

  • boolean — True if the associated image is a mask.

initialise()

Initialise the controller.

resetWindowLevel()

Reset the window level.

resetPosition()

Reset the position.

getModality(): string

Get the image modality.

Returns

  • string — The modality.

getSopClassUid(): string | undefined

Get the image SOP class UID.

Returns

  • string | undefined — The uid.

getWindowLevelPresetsNames(): Array.<string>

Get the window/level presets names.

Returns

  • Array.<string> — The presets names.

addWindowLevelPresets( presets: Record.<string, WindowPreset>, ): object

Add window/level presets to the view.

Parameters

  • presets (Record.<string, WindowPreset>) — A preset object.

Returns

  • object — The list of presets.

setWindowLevelPreset(name: string)

Set the window level to the preset with the input name.

Parameters

  • name (string) — The name of the preset to activate.

setWindowLevelPresetById(id: number)

Set the window level to the preset with the input id.

Parameters

  • id (number) — The id of the preset to activate.

isPlaying(): boolean

Check if the controller is playing.

Returns

  • boolean — True if the controler is playing.

getPositionHelper(): PositionHelper

Get a position helper: returns a new helper based on the current view.

Returns

getCurrentPosition(): Point

Get the current position.

Returns

  • Point — The position.

getCurrentIndex(): Index

Get the current index.

Returns

  • Index — The current index.

canSyncVolume( viewController: ViewController, value: number, ): boolean

Check if the volume of this view can follow the one of another view.

Parameters

  • viewController (ViewController) — The view controller to follow.
  • value (number) — The volume id value to follow.

Returns

  • boolean — True if the volume can follow.

getCurrentImageUid(): string

Get the SOP image UID of the current image.

Returns

  • string — The UID.

getOriginForImageUid(uid: string): Point3D | undefined

Get the image origin for a image UID.

Parameters

  • uid (string) — The UID.

Returns

  • Point3D | undefined — The origin.

includesImageUid(uid: string): boolean

Check if the image includes an UID.

Parameters

  • uid (string) — The UID.

Returns

  • boolean — True if present.

getCurrentOrientedIndex(): Index

Get the current oriented index.

Returns

getScrollDimIndex(): number

Get the scroll dimension index.

Returns

  • number — The index.

getCurrentIndexScrollValue(): number

Get the current index scroll value.

Returns

  • number — The value.

getOrigin(position?: Point): Point3D

Get the first origin or at a given position.

Parameters

  • position (Point, optional) — Optional position.

Returns

isAquisitionOrientation(): boolean

Is this view in the same orientation as the image aquisition.

Returns

  • boolean — True if in aquisition plane.

getPlanePoints(position: Point): Array.<Point3D>

Get a list of points that define the plane at input position, given this classes orientation.

Parameters

  • position (Point) — The position.

Returns

  • Array.<Point3D> — An origin and 2 cosines vectors.

getCurrentScrollPosition(): number

Get the current scroll position value.

Returns

  • number — The value.

generateImageData(array: ImageData, index?: Index)

Generate display image data to be given to a canvas.

Parameters

  • array (ImageData) — The array to fill in.
  • index (Index, optional) — Optional index at which to generate, otherwise generates at current index.

setImage(img: Image)

Set the associated image.

Parameters

  • img (Image) — The associated image.

get2DSpacing(): Scalar2D

Get the current view (2D) spacing.

Returns

  • Scalar2D — The spacing as a 2D array.

getRescaledImageValue(position: Point): number | undefined

Get the image rescaled value at the input position.

Parameters

  • position (Point) — The input position.

Returns

  • number | undefined — The image value or undefined if out of bounds or no quantifiable (for ex RGB).

getSegmentNumbersAtPosition(position: Point): Array.<number>

Get the numbers of the mask segments at the input position.

Parameters

  • position (Point) — The input position.

Returns

  • Array.<number> — The list of segment numbers, empty if the image is not a mask, for background or if out of bounds.

getPixelUnit(): string

Get the image pixel unit.

Returns

  • string — The unit.

getLengthUnit(): string

Get the image length unit.

Returns

  • string — The unit.

getImageRegionValues( min: Point2D, max: Point2D, index: Index, ): Array

Get some values from the associated image in a region.

Parameters

  • min (Point2D) — Minimum point.
  • max (Point2D) — Maximum point.
  • index (Index) — The index at which to get the image values (combined with min/max).

Returns

  • Array — A list of values.

getImageVariableRegionValues( regions: Array.<Array.<Array.<number>>>, index: Index, ): Array

Get some values from the associated image in variable regions.

Parameters

  • regions (Array.<Array.<Array.<number>>>) — A list of [x, y] pairs (min, max).
  • index (Index) — The index at which to get the image values (combined with regions min/max).

Returns

  • Array — A list of values.

canQuantifyImage(): boolean

Can the image values be quantified?

Returns

  • boolean — True if possible.

canWindowLevel(): boolean

Can window and level be applied to the data?

Since v0.33, please use isMonochrome instead.

Returns

  • boolean — True if possible.

isMonochrome(): boolean

Is the data monochrome.

Returns

  • boolean — True if the data is monochrome.

canScroll(): boolean

Can the data be scrolled?

Returns

  • boolean — True if the data has either the third dimension or above greater than one.

getImageSize(): Size

Get the oriented image size.

Returns

  • Size — The size.

getImageSpacing(): Spacing

Get the oriented image spacing.

Returns

moreThanOne(dim: number): boolean

Is the data size larger than one in the given dimension?

Parameters

  • dim (number) — The dimension.

Returns

  • boolean — True if the image size is larger than one in the given dimension.

getImageWorldSize(): Scalar2D

Get the image world (mm) 2D size.

Returns

getImageRescaledDataRange(): object

Get the image rescaled data range.

Returns

  • object — The range as {min, max}.

equalImageMeta(meta: object): boolean

Compare the input meta data to the associated image one.

Parameters

  • meta (object) — The meta data.

Returns

  • boolean — True if the associated image has equal meta data.

isPositionInBounds(position?: Point): boolean

Check if the current position (default) or the provided position is in bounds.

Parameters

  • position (Point, optional) — Optional position.

Returns

  • boolean — True is the position is in bounds.

setCurrentPosition(pos: Point, silent?: boolean): boolean

Set the current position.

Parameters

  • pos (Point) — The position.
  • silent (boolean, optional) — If true, does not fire a positionchange event.

Returns

  • boolean — False if not in bounds.

getPositionFromPlanePoint(point2D: Point2D, k?: number): Point

Get a world position from a 2D plane position.

Parameters

  • point2D (Point2D) — The input point.
  • k (number, optional) — Optional slice index, if undefined, uses the current one.

Returns

  • Point — The associated position.

validatePlanePoint(point2D: Point2D): boolean

Check if an input plane point is in the geometrys' bounds.

Parameters

  • point2D (Point2D) — The point to check.

Returns

  • boolean — True if in bounds.

getPlanePositionFromPosition(point: Point): Point2D

Get a 2D plane position from a world position.

Parameters

  • point (Point) — The 3D position.

Returns

getIndexFromPosition(point: Point): Index

Get the index of a world position.

Parameters

  • point (Point) — The 3D position.

Returns

getPositionFromIndex(index: Index): Point

Get the world position of an index.

Parameters

  • index (Index) — The index.

Returns

  • Point — The position.

setCurrentIndex(index: Index, silent?: boolean): boolean

Set the current index.

Parameters

  • index (Index) — The index.
  • silent (boolean, optional) — If true, does not fire a positionchange event.

Returns

  • boolean — False if not in bounds.

getPlanePositionFromPlanePoint(point2D: Point2D): Point3D

Get a plane 3D position from a plane 2D position: does not compensate for the image origin. Needed for setting the scale center...

Parameters

  • point2D (Point2D) — The 2D position.

Returns

getOffset3DFromPlaneOffset(offset2D: Scalar2D): Vector3D

Get a 3D offset from a plane one.

Parameters

  • offset2D (Scalar2D) — The plane offset as {x,y}.

Returns

play()

Scroll play: loop through all slices.

stop()

Stop scroll playing.

getWindowLevel(): WindowLevel

Get the window/level.

Returns

getCurrentWindowPresetName(): string

Get the current window level preset name.

Returns

  • string — The preset name.

setWindowLevel(wl: WindowLevel)

Set the window and level.

Parameters

getColourMap(): string

Get the colour map.

Returns

  • string — The colour map name.

setColourMap(name: string)

Set the colour map.

Parameters

  • name (string) — The colour map name.

setViewAlphaFunction(func: alphaFn)

Set the view per value alpha function.

Parameters

setMaskViewHelper(helper: MaskSegmentViewHelper)

Set the mask segment view helper to handle hidden segments.

Parameters

getSegmentHighlight(): Object | undefined

Get the segment highlight.

Returns

  • Object | undefined — The highlighted segment number and its opacity factor.

setSegmentHighlight(segmentNumber?: number, opacity?: number)

Set the segment highlight: the opacity of the given segment is multiplied by the input factor. Only one segment can be highlighted at a time. This only has an effect on segmentation views.

Parameters

  • segmentNumber (number, optional) — The segment number, undefined to remove the highlight.
  • opacity (number, optional) — The opacity factor (between 0 and 1), defaults to 1.

getFillOpacity(): number

Get the fill opacity relative to the global opacity.

Returns

  • number — The fill opacity (between 0 and 1).

setFillOpacity(opacity: number)

Set the fill opacity relative to the global opacity. This only has an effect on segmentation views, or any other alpha function that makes use of it.

Parameters

  • opacity (number) — The fill opacity (between 0 and 1).

getContourThickness(): number

Get the thickness of the contour in pixels.

Returns

  • number — The contour thickness (integer >= 1).

setContourThickness(thickness: number)

Set the thickness of the contour in pixels. This only has an effect on segmentation views, or any other alpha function that makes use of it.

Parameters

  • thickness (number) — The contour thickness (integer >= 1).

bindImageAndLayer(viewLayer: ViewLayer)

Bind the view image to the provided layer.

Parameters

  • viewLayer (ViewLayer) — The layer to bind.

unbindImageAndLayer(viewLayer: ViewLayer)

Unbind the view image to the provided layer.

Parameters

  • viewLayer (ViewLayer) — The layer to bind.