Constructor
new ViewLayer(containerDiv)
Name | Type | Description |
---|---|---|
containerDiv | HTMLElement | The layer div, its id will be used as this layer id. |
- Source
Classes
Methods
addEventListener(type, callback)
Add an event listener to this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type, will be called with the fired event. |
- Source
addFlipOffsetX()
Add a flip offset along the layer X axis.
- Source
addFlipOffsetY()
Add a flip offset along the layer Y axis.
- Source
bindInteraction()
Enable and listen to container interaction events.
- Source
clear()
Clear the context.
- Source
display(flag)
Display the layer.
Name | Type | Description |
---|---|---|
flag | boolean | Whether to display the layer or not. |
- Source
displayToMainPlanePos(x, y) → {object}
Get a main plane position from a display position.
Name | Type | Description |
---|---|---|
x | number | The X position. |
y | number | The Y position. |
- Source
The main plane position as {x,y}.
- Type:
- object
displayToPlaneIndex(x, y) → {Index}
Transform a display position to an index.
Name | Type | Description |
---|---|---|
x | number | The X position. |
y | number | The Y position. |
- Source
The equivalent index.
- Type:
- Index
displayToPlanePos(x, y) → {object}
Get a plane position from a display position.
Name | Type | Description |
---|---|---|
x | number | The X position. |
y | number | The Y position. |
- Source
The plane position as {x,y}.
- Type:
- object
displayToPlaneScale(x, y) → {object}
Remove scale from a display position.
Name | Type | Description |
---|---|---|
x | number | The X position. |
y | number | The Y position. |
- Source
The de-scaled position as {x,y}.
- Type:
- object
draw()
Draw the content (imageData) of the layer. The imageData variable needs to be set
- Source
enableImageSmoothing(flag)
Set the imageSmoothingEnabled flag value.
Name | Type | Description |
---|---|---|
flag | boolean | True to enable smoothing. |
- Source
fitToContainer(fitScale1D, fitSize, fitOffset)
Fit the layer to its parent container.
Name | Type | Description |
---|---|---|
fitScale1D | number | The 1D fit scale. |
fitSize | object | The fit size as {x,y}. |
fitOffset | object | The fit offset as {x,y}. |
- Source
getBaseSize() → {object}
Get the layer base size (without scale).
- Source
The size as {x,y}.
- Type:
- object
getDataIndex() → {number}
Get the associated data index.
- Source
The index.
- Type:
- number
getId() → {string}
Get the id of the layer.
- Source
The string id.
- Type:
- string
getImageData() → {object}
Get the canvas image data.
- Source
The image data.
- Type:
- object
getImageWorldSize() → {object}
Get the image world (mm) 2D size.
- Source
The 2D size as {x,y}.
- Type:
- object
getOpacity() → {number}
Get the layer opacity.
- Source
The opacity ([0:1] range).
- Type:
- number
getViewController() → {ViewController}
Get the view controller.
- Source
The controller.
- Type:
- ViewController
initialise(size, spacing, alpha)
Initialise the layer: set the canvas and context
Name | Type | Description |
---|---|---|
size | object | The image size as {x,y}. |
spacing | object | The image spacing as {x,y}. |
alpha | number | The initial data opacity. |
- Source
isVisible() → {boolean}
Check if the layer is visible.
- Source
True if the layer is visible.
- Type:
- boolean
onimagechange(event)
Handle an image change event.
Name | Type | Description |
---|---|---|
event | object | The event. |
- Source
onimageset(event)
Handle an image set event.
Name | Type | Description |
---|---|---|
event | object | The event. |
- Source
planePosToDisplay(x, y) → {object}
Get a display position from a plane position.
Name | Type | Description |
---|---|---|
x | number | The X position. |
y | number | The Y position. |
- Source
The display position as {x,y}.
- Type:
- object
removeEventListener(type, callback)
Remove an event listener from this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type. |
- Source
setBaseOffset(scrollOffset, planeOffset) → {boolean}
Set the base layer offset. Updates the layer offset.
Name | Type | Description |
---|---|---|
scrollOffset | Vector3D | The scroll offset vector. |
planeOffset | Vector3D | The plane offset vector. |
- Source
True if the offset was updated.
- Type:
- boolean
setCurrentPosition(position, _index) → {boolean}
Set the current position.
- Source
True if the position was updated.
- Type:
- boolean
setOffset(newOffset)
Set the layer offset.
Name | Type | Description |
---|---|---|
newOffset | object | The offset as {x,y}. |
- Source
setOpacity(alpha)
Set the layer opacity.
Name | Type | Description |
---|---|---|
alpha | number | The opacity ([0:1] range). |
- Source
setScale(newScale, centeropt)
Set the layer scale.
Name | Type | Attributes | Description |
---|---|---|---|
newScale | object | The scale as {x,y}. | |
center | Point3D | <optional> | The scale center. |
- Source
setView(view, index)
Set the associated view.
Name | Type | Description |
---|---|---|
view | object | The view. |
index | number | The associated data index. |
- Source
unbindInteraction()
Disable and stop listening to container interaction events.
- Source