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.

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(x, y) → {object}

Get a main plane position from a display position.

Parameters:
NameTypeDescription
xnumber

The X position.

ynumber

The Y position.

Returns:

The main plane position as {x,y}.

Type: 
object

displayToPlaneIndex(x, y) → {Index}

Transform a display position to an index.

Parameters:
NameTypeDescription
xnumber

The X position.

ynumber

The Y position.

Returns:

The equivalent index.

Type: 
Index

displayToPlanePos(x, y) → {object}

Get a plane position from a display position.

Parameters:
NameTypeDescription
xnumber

The X position.

ynumber

The Y position.

Returns:

The plane position as {x,y}.

Type: 
object

displayToPlaneScale(x, y) → {object}

Remove scale from a display position.

Parameters:
NameTypeDescription
xnumber

The X position.

ynumber

The Y position.

Returns:

The de-scaled position as {x,y}.

Type: 
object

draw()

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

enableImageSmoothing(flag)

Set the imageSmoothingEnabled flag value.

Parameters:
NameTypeDescription
flagboolean

True to enable smoothing.

fitToContainer(fitScale1D, fitSize, fitOffset)

Fit the layer to its parent container.

Parameters:
NameTypeDescription
fitScale1Dnumber

The 1D fit scale.

fitSizeobject

The fit size as {x,y}.

fitOffsetobject

The fit offset as {x,y}.

getBaseSize() → {object}

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type: 
object

getDataIndex() → {number}

Get the associated data index.

Returns:

The index.

Type: 
number

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() → {object}

Get the image world (mm) 2D size.

Returns:

The 2D size as {x,y}.

Type: 
object

getOpacity() → {number}

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type: 
number

getViewController() → {ViewController}

Get the view controller.

Returns:

The controller.

Type: 
ViewController

initialise(size, spacing, alpha)

Initialise the layer: set the canvas and context

Parameters:
NameTypeDescription
sizeobject

The image size as {x,y}.

spacingobject

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

onimagechange(event)

Handle an image change event.

Parameters:
NameTypeDescription
eventobject

The event.

onimageset(event)

Handle an image set event.

Parameters:
NameTypeDescription
eventobject

The event.

planePosToDisplay(x, y) → {object}

Get a display position from a plane position.

Parameters:
NameTypeDescription
xnumber

The X position.

ynumber

The Y position.

Returns:

The display position as {x,y}.

Type: 
object

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.

setBaseOffset(scrollOffset, planeOffset) → {boolean}

Set the base layer offset. Updates the layer offset.

Parameters:
NameTypeDescription
scrollOffsetVector3D

The scroll offset vector.

planeOffsetVector3D

The plane offset vector.

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

setOffset(newOffset)

Set the layer offset.

Parameters:
NameTypeDescription
newOffsetobject

The offset as {x,y}.

setOpacity(alpha)

Set the layer opacity.

Parameters:
NameTypeDescription
alphanumber

The opacity ([0:1] range).

setScale(newScale, centeropt)

Set the layer scale.

Parameters:
NameTypeAttributesDescription
newScaleobject

The scale as {x,y}.

centerPoint3D<optional>

The scale center.

setView(view, index)

Set the associated view.

Parameters:
NameTypeDescription
viewobject

The view.

indexnumber

The associated data index.

unbindInteraction()

Disable and stop listening to container interaction events.