DrawController

Draw controller.

Constructor

new DrawController(konvaLayer)

Parameters:
NameTypeDescription
konvaLayerKonva.Layer

The draw layer.

Classes

DrawController

Methods

activateDrawLayer(index, scrollIndex)

Activate the current draw layer.

Parameters:
NameTypeDescription
indexIndex

The current position.

scrollIndexnumber

The scroll index.

deleteDraw(id, cmdCallback, exeCallback) → {boolean}

Delete a Draw from the stage.

Parameters:
NameTypeDescription
idstring

The id of the group to delete.

cmdCallbackfunction

The DeleteCommand callback.

exeCallbackfunction

The callback to call once the DeleteCommand has been executed.

Returns:

False if the group cannot be found.

Type: 
boolean

deleteDrawGroup(group, cmdCallback, exeCallback)

Delete a Draw from the stage.

Parameters:
NameTypeDescription
groupobject

The group to delete.

cmdCallbackobject

The DeleteCommand callback.

exeCallbackobject

The callback to call once the DeleteCommand has been executed.

deleteDraws(cmdCallback, exeCallback)

Delete all Draws from the stage.

Parameters:
NameTypeDescription
cmdCallbackfunction

The DeleteCommand callback.

exeCallbackfunction

The callback to call once the DeleteCommand has been executed.

getCurrentPosGroup() → {object}

Get the current position group.

Returns:

The Konva.Group.

Type: 
object

getDrawDisplayDetails() → {Array}

Get a list of drawing display details.

Returns:

A list of draw details as {id, position, type, color, meta}

Type: 
Array

getDrawStoreDetails() → {object}

Get a list of drawing store details. Used in state.

Returns:

A list of draw details including id, text, quant... TODO Unify with getDrawDisplayDetails?

Type: 
object

getGroup(id) → {object|undefined}

Get a Konva group using its id.

Parameters:
NameTypeDescription
idstring

The group id.

Returns:

The Konva group.

Type: 
object | undefined

reset()

Reset: clear the layers array.

setDrawings(drawings, drawingsDetails, cmdCallback, exeCallback)

Set the drawings on the current stage.

Parameters:
NameTypeDescription
drawingsArray

An array of drawings.

drawingsDetailsArray

An array of drawings details.

cmdCallbackobject

The DrawCommand callback.

exeCallbackobject

The callback to call once the DrawCommand has been executed.

updateDraw(drawDetails)

Update a drawing from its details.

Parameters:
NameTypeDescription
drawDetailsobject

Details of the drawing to update.