ViewLayer

dwv.gui. ViewLayer

new ViewLayer(containerDiv)

Source:

View layer.

Parameters:
Name Type Description
containerDiv object

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

Methods

addEventListener(type, callback)

Source:

Add an event listener to this class.

Parameters:
Name Type Description
type string

The event type.

callback object

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

align(rhs)

Source:

Align on another layer.

Parameters:
Name Type Description
rhs dwv.gui.ViewLayer

The layer to align on.

bindInteraction()

Source:

Enable and listen to container interaction events.

clear()

Source:

Clear the context and reset the image data.

display(flag)

Source:

Display the layer.

Parameters:
Name Type Description
flag boolean

Whether to display the layer or not.

displayToPlaneIndex(x, y) → {dwv.math.Index}

Source:

Transform a display position to an index.

Parameters:
Name Type Description
x number

The X position.

y number

The Y position.

Returns:

The equivalent index.

Type
dwv.math.Index

draw()

Source:

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

Fires:

fitToContainer(fitScale1D)

Source:

Fit the layer to its parent container.

Parameters:
Name Type Description
fitScale1D number

The 1D fit scale.

getBaseSize() → {object}

Source:

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type
object

getDataIndex() → {number}

Source:

Get the associated data index.

Returns:

The index.

Type
number

getFullSize() → {object}

Source:

Get the data full size, ie size * spacing.

Returns:

The full size as {x,y}.

Type
object

getId() → {string}

Source:

Get the id of the layer.

Returns:

The string id.

Type
string

getImageData() → {object}

Source:

Get the canvas image data.

Returns:

The image data.

Type
object

getOpacity() → {number}

Source:

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type
number

getViewController() → {object}

Source:

Get the view controller.

Returns:

The controller.

Type
object

initialise(size, spacing, index)

Source:

Initialise the layer: set the canvas and context

Parameters:
Name Type Description
size object

The image size as {x,y}.

spacing object

The image spacing as {x,y}.

index number

The associated data index.

isVisible() → {boolean}

Source:

Check if the layer is visible.

Returns:

True if the layer is visible.

Type
boolean

onimagechange(event)

Source:

Handle an image change event.

Parameters:
Name Type Description
event object

The event.

removeEventListener(type, callback)

Source:

Remove an event listener from this class.

Parameters:
Name Type Description
type string

The event type.

callback object

The method associated with the provided event type.

setBaseOffset(off)

Source:

Set the base layer offset. Resets the layer offset.

Parameters:
Name Type Description
off object

The offset as {x,y}.

setCurrentPosition(position, _index)

Source:

Set the current position.

Parameters:
Name Type Description
position dwv.math.Point

The new position.

_index dwv.math.Index

The new index.

setOffset(newOffset)

Source:

Set the layer offset.

Parameters:
Name Type Description
newOffset object

The offset as {x,y}.

setOpacity(alpha)

Source:

Set the layer opacity.

Parameters:
Name Type Description
alpha number

The opacity ([0:1] range).

setScale(newScale)

Source:

Set the layer scale.

Parameters:
Name Type Description
newScale object

The scale as {x,y}.

setView(view)

Source:

Set the associated view.

Parameters:
Name Type Description
view object

The view.

unbindInteraction()

Source:

Disable and stop listening to container interaction events.

(inner) updateImageData()

Source:

Update the canvas image data.