DrawLayer

Draw layer.

Constructor

new DrawLayer(containerDiv)

Parameters:
NameTypeDescription
containerDivHTMLDivElement

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

Classes

DrawLayer

Methods

activateCurrentPositionShapes(flag)

Activate shapes at current position.

Parameters:
NameTypeDescription
flagboolean

The flag to activate or not.

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.

deleteDraw(_id, _exeCallback)

Delete a Draw from the stage.

Parameters:
NameTypeDescription
_idstring

The id of the group to delete.

_exeCallbackfunction

The callback to call once the DeleteCommand has been executed.

Deprecated
  • Since v0.34, please switch to `annotationGroup.remove`.

deleteDraws(_exeCallback)

Delete all Draws from the stage.

Parameters:
NameTypeDescription
_exeCallbackfunction

The callback to call once the DeleteCommand has been executed.

Deprecated
  • Since v0.34, please switch to `annotationGroup.remove`.

display(flag)

Display the layer.

Parameters:
NameTypeDescription
flagboolean

Whether to display the layer or not.

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 container 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.

getBaseSize() → {Scalar2D}

Get the layer base size (without scale).

Returns:

The size as {x,y}.

Type: 
Scalar2D

getCurrentPosGroup() → {Konva.Group|undefined}

Get the current position group.

Returns:

The Konva.Group.

Type: 
Konva.Group | undefined

getDataId() → {string}

Get the associated data id.

Returns:

The id.

Type: 
string

getDrawController() → {DrawController}

Get the draw controller.

Returns:

The controller.

Type: 
DrawController

getGroup(id) → {object|undefined}

Get a Konva group using its id.

Parameters:
NameTypeDescription
idstring

The group id.

Returns:

The Konva group.

Type: 
object | undefined

getId() → {string}

Get the id of the layer.

Returns:

The string id.

Type: 
string

getKonvaLayer() → {Konva.Layer}

Get the Konva layer.

Returns:

The layer.

Type: 
Konva.Layer

getKonvaStage() → {Konva.Stage}

Get the Konva stage.

Returns:

The stage.

Type: 
Konva.Stage

getNumberOfDraws() → {number|undefined}

Get the total number of draws of this layer (at all positions).

Returns:

The total number of draws.

Type: 
number | undefined

getOpacity() → {number}

Get the layer opacity.

Returns:

The opacity ([0:1] range).

Type: 
number

getReferenceLayerId() → {string}

Get the reference data id.

Returns:

The id.

Type: 
string

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, refLayerId)

Initialise the layer: set the canvas and context.

Parameters:
NameTypeDescription
sizeScalar2D

The image size as {x,y}.

spacingScalar2D

The image spacing as {x,y}.

refLayerIdstring

The reference image dataId.

isAnnotationVisible(id) → {boolean}

Check the visibility of an annotation.

Parameters:
NameTypeDescription
idstring

The id of the annotation.

Returns:

True if the annotation is visible.

Type: 
boolean

isVisible() → {boolean}

Check if the layer is visible.

Returns:

True if the layer is visible.

Type: 
boolean

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.

setAnnotationGroup(annotationGroup, dataId, exeCallback)

Set the annotation group.

Parameters:
NameTypeDescription
annotationGroupAnnotationGroup

The annotation group.

dataIdstring

The associated data id.

exeCallbackobject

The undo stack callback.

setAnnotationVisibility(id, visibleopt) → {boolean}

Set the visibility of an annotation.

Parameters:
NameTypeAttributesDescription
idstring

The id of the annotation.

visibleboolean<optional>

True to set to visible, will toggle visibility if not defined.

Returns:

False if the annotation shape cannot be found.

Type: 
boolean

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, indexopt) → {boolean}

Set the current position.

Parameters:
NameTypeAttributesDescription
positionPoint

The new position.

indexIndex<optional>

Optional coresponding index.

Returns:

True if the position was updated.

Type: 
boolean

setLabelVisibility(shapeGroup)

Set a shape group label visibility according to this layer setting.

Parameters:
NameTypeDescription
shapeGroupKonva.Group

The shape group.

setLabelsVisibility(visibleopt)

Set the visibility of all labels.

Parameters:
NameTypeAttributesDescription
visibleboolean<optional>

True to set to visible, will toggle visibility if not defined.

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).

setPlaneHelper(helper)

Set the plane helper.

Parameters:
NameTypeDescription
helperPlaneHelper

The helper.

setScale(newScale, centeropt)

Set the layer scale.

Parameters:
NameTypeAttributesDescription
newScaleScalar3D

The scale as {x,y,z}.

centerPoint3D<optional>

The scale center.

setShapeHandler(handler)

Set the draw shape handler.

Parameters:
NameTypeDescription
handlerDrawShapeHandler | undefined

The shape handler.

unbindInteraction()

Disable and stop listening to container interaction events.