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
bindImage()
Bind this layer to the view image.
- 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(point2D) → {Point2D}
Get a main plane position from a display position.
Name | Type | Description |
---|---|---|
point2D | Point2D | The input point. |
- Source
The main plane position.
- Type:
- Point2D
displayToPlaneIndex(point2D) → {Index}
Transform a display position to a 2D index.
Name | Type | Description |
---|---|---|
point2D | Point2D | The input point. |
- Source
The equivalent 2D index.
- Type:
- Index
displayToPlanePos(point2D) → {Point2D}
Get a plane position from a display position.
Name | Type | Description |
---|---|---|
point2D | Point2D | The input point. |
- Source
The plane position.
- Type:
- Point2D
displayToPlaneScale(point2D) → {Point2D}
Remove scale from a display position.
Name | Type | Description |
---|---|---|
point2D | Point2D | The input point. |
- Source
The de-scaled point.
- Type:
- Point2D
draw()
Draw the content (imageData) of the layer. The imageData variable needs to be set.
- Source
fitToContainer(containerSize, divToWorldSizeRatio, fitOffset)
Fit the layer to its parent container.
Name | Type | Description |
---|---|---|
containerSize | Scalar2D | The fit size as {x,y}. |
divToWorldSizeRatio | number | The div to world size ratio. |
fitOffset | Scalar2D | The fit offset as {x,y}. |
- Source
flipScaleX()
Flip the scale along the layer X axis.
- Source
flipScaleY()
Flip the scale along the layer Y axis.
- Source
flipScaleZ()
Flip the scale along the layer Z axis.
- Source
getAbsoluteZoomOffset() → {Scalar2D}
Get the layer zoom offset without the fit scale.
- Source
The offset as {x,y}.
- Type:
- Scalar2D
getBaseSize() → {Scalar2D}
Get the layer base size (without scale).
- Source
The size as {x,y}.
- Type:
- Scalar2D
getDataId() → {string}
Get the associated data id.
- Source
The data id.
- Type:
- string
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() → {Scalar2D}
Get the image world (mm) 2D size.
- Source
The 2D size as {x,y}.
- Type:
- Scalar2D
getOpacity() → {number}
Get the layer opacity.
- Source
The opacity ([0:1] range).
- Type:
- number
getScale() → {Scalar2D}
Get the layer scale.
- Source
The scale as {x,y}.
- Type:
- Scalar2D
getViewController() → {ViewController}
Get the view controller.
- Source
The controller.
- Type:
- ViewController
initScale(newScale, absoluteZoomOffset)
Initialise the layer scale.
Name | Type | Description |
---|---|---|
newScale | Scalar3D | The scale as {x,y,z}. |
absoluteZoomOffset | Scalar2D | The zoom offset as {x,y} without the fit scale (as provided by getAbsoluteZoomOffset). |
- Source
initialise(size, spacing, alpha)
Initialise the layer: set the canvas and context.
Name | Type | Description |
---|---|---|
size | Scalar2D | The image size as {x,y}. |
spacing | Scalar2D | 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
onimagecontentchange(event)
Handle an image content change event.
Name | Type | Description |
---|---|---|
event | object | The event. |
- Source
onimagegeometrychange(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(point2D) → {Point2D}
Get a display position from a plane position.
Name | Type | Description |
---|---|---|
point2D | Point2D | The input point. |
- Source
The display position, can be individually undefined if out of bounds.
- Type:
- Point2D
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
removeFromDOM()
Remove the HTML element from the DOM.
- Source
setBaseOffset(scrollOffset, planeOffset, layerGroupOriginopt, layerGroupOrigin0opt) → {boolean}
Set the base layer offset. Updates the layer offset.
Name | Type | Attributes | Description |
---|---|---|---|
scrollOffset | Vector3D | The scroll offset vector. | |
planeOffset | Vector3D | The plane offset vector. | |
layerGroupOrigin | Point3D | <optional> | The layer group origin. |
layerGroupOrigin0 | Point3D | <optional> | The layer group first origin. |
- 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
setImageSmoothing(flag)
Set the imageSmoothing flag value.
Name | Type | Description |
---|---|---|
flag | boolean | True to enable smoothing. |
- Source
setOffset(newOffset)
Set the layer offset.
Name | Type | Description |
---|---|---|
newOffset | Scalar3D | The offset as {x,y,z}. |
- 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 | Scalar3D | The scale as {x,y,z}. | |
center | Point3D | <optional> | The scale center. |
- Source
setView(view, dataId)
Set the associated view.
Name | Type | Description |
---|---|---|
view | object | The view. |
dataId | string | The associated data id. |
- Source
unbindImage()
Unbind this layer to the view image.
- Source
unbindInteraction()
Disable and stop listening to container interaction events.
- Source