ViewLayer

View layer.

Constructor

new ViewLayer(containerDiv)

Parameters:
NameTypeDescription
containerDivHTMLElement

The layer div, its id will be used as this layer id.

Classes

ViewLayer

Methods

addEventListener(type, callback)

Add an event listener to this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type, will be called with the fired event.

addFlipOffsetX()

Add a flip offset along the layer X axis.

addFlipOffsetY()

Add a flip offset along the layer Y axis.

bindImage()

Bind this layer to the view image.

bindInteraction()

Enable and listen to container interaction events.

clear()

Clear the context.

display(flag)

Display the layer.

Parameters:
NameTypeDescription
flagboolean

Whether to display the layer or not.

displayToMainPlanePos(point2D) → {Point2D}

Get a main plane position from a display position.

Parameters:
NameTypeDescription
point2DPoint2D

The input point.

Returns:

The main plane position.

Type: 
Point2D

displayToPlaneIndex(point2D) → {Index}

Transform a display position to a 2D index.

Parameters:
NameTypeDescription
point2DPoint2D

The input point.

Returns:

The equivalent 2D index.

Type: 
Index

displayToPlanePos(point2D) → {Point2D}

Get a plane position from a display position.

Parameters:
NameTypeDescription
point2DPoint2D

The input point.

Returns:

The plane position.

Type: 
Point2D

displayToPlaneScale(point2D) → {Point2D}

Remove scale from a display position.

Parameters:
NameTypeDescription
point2DPoint2D

The input point.

Returns:

The de-scaled point.

Type: 
Point2D

draw()

Draw the content (imageData) of the layer. The imageData variable needs to be set.

fitToContainer(containerSize, divToWorldSizeRatio, fitOffset)

Fit the layer to its parent container.

Parameters:
NameTypeDescription
containerSizeScalar2D

The fit size as {x,y}.

divToWorldSizeRationumber

The div to world size ratio.

fitOffsetScalar2D

The fit offset as {x,y}.

flipScaleX()

Flip the scale along the layer X axis.

flipScaleY()

Flip the scale along the layer Y axis.

flipScaleZ()

Flip the scale along the layer Z axis.

getAbsoluteZoomOffset() → {Scalar2D}

Get the layer zoom offset without the fit scale.

Returns:

The offset as {x,y}.

Type: 
Scalar2D

getBaseSize() → {Scalar2D}

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type: 
Scalar2D

getDataId() → {string}

Get the associated data id.

Returns:

The data id.

Type: 
string

getId() → {string}

Get the id of the layer.

Returns:

The string id.

Type: 
string

getImageData() → {object}

Get the canvas image data.

Returns:

The image data.

Type: 
object

getImageWorldSize() → {Scalar2D}

Get the image world (mm) 2D size.

Returns:

The 2D size as {x,y}.

Type: 
Scalar2D

getOpacity() → {number}

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type: 
number

getScale() → {Scalar2D}

Get the layer scale.

Returns:

The scale as {x,y}.

Type: 
Scalar2D

getViewController() → {ViewController}

Get the view controller.

Returns:

The controller.

Type: 
ViewController

initScale(newScale, absoluteZoomOffset)

Initialise the layer scale.

Parameters:
NameTypeDescription
newScaleScalar3D

The scale as {x,y,z}.

absoluteZoomOffsetScalar2D

The zoom offset as {x,y} without the fit scale (as provided by getAbsoluteZoomOffset).

initialise(size, spacing, alpha)

Initialise the layer: set the canvas and context.

Parameters:
NameTypeDescription
sizeScalar2D

The image size as {x,y}.

spacingScalar2D

The image spacing as {x,y}.

alphanumber

The initial data opacity.

isVisible() → {boolean}

Check if the layer is visible.

Returns:

True if the layer is visible.

Type: 
boolean

onimagecontentchange(event)

Handle an image content change event.

Parameters:
NameTypeDescription
eventobject

The event.

onimagegeometrychange(event)

Handle an image change event.

Parameters:
NameTypeDescription
eventobject

The event.

onimageset(event)

Handle an image set event.

Parameters:
NameTypeDescription
eventobject

The event.

planePosToDisplay(point2D) → {Point2D}

Get a display position from a plane position.

Parameters:
NameTypeDescription
point2DPoint2D

The input point.

Returns:

The display position, can be individually undefined if out of bounds.

Type: 
Point2D

removeEventListener(type, callback)

Remove an event listener from this class.

Parameters:
NameTypeDescription
typestring

The event type.

callbackfunction

The function associated with the provided event type.

removeFromDOM()

Remove the HTML element from the DOM.

setBaseOffset(scrollOffset, planeOffset, layerGroupOriginopt, layerGroupOrigin0opt) → {boolean}

Set the base layer offset. Updates the layer offset.

Parameters:
NameTypeAttributesDescription
scrollOffsetVector3D

The scroll offset vector.

planeOffsetVector3D

The plane offset vector.

layerGroupOriginPoint3D<optional>

The layer group origin.

layerGroupOrigin0Point3D<optional>

The layer group first origin.

Returns:

True if the offset was updated.

Type: 
boolean

setCurrentPosition(position, _index) → {boolean}

Set the current position.

Parameters:
NameTypeDescription
positionPoint

The new position.

_indexIndex

The new index.

Returns:

True if the position was updated.

Type: 
boolean

setImageSmoothing(flag)

Set the imageSmoothing flag value.

Parameters:
NameTypeDescription
flagboolean

True to enable smoothing.

setOffset(newOffset)

Set the layer offset.

Parameters:
NameTypeDescription
newOffsetScalar3D

The offset as {x,y,z}.

setOpacity(alpha)

Set the layer opacity.

Parameters:
NameTypeDescription
alphanumber

The opacity ([0:1] range).

setScale(newScale, centeropt)

Set the layer scale.

Parameters:
NameTypeAttributesDescription
newScaleScalar3D

The scale as {x,y,z}.

centerPoint3D<optional>

The scale center.

setView(view, dataId)

Set the associated view.

Parameters:
NameTypeDescription
viewobject

The view.

dataIdstring

The associated data id.

unbindImage()

Unbind this layer to the view image.

unbindInteraction()

Disable and stop listening to container interaction events.