Draw

Drawing tool.

This tool is responsible for the draw of layer group structure.

drawLayer
|_ positionGroup: {name="position-group", id="#2-0#_#3-1"}
   |_ shapeGroup: {name="{shape name}-group", id="#"}
      |_ shape: {name="shape"},
      |_ label: {name="label"},
      |_ extra: line tick, protractor arc...

Discussion:

  • posGroup > shapeGroup: (pro) slice/frame display: 1 loop - (cons) multi-slice shape splitted in positionGroups.
  • shapeGroup > posGroup: (pros) more logical - (cons) slice/frame display: 2 loops.

Constructor

new Draw(app)

Parameters:
NameTypeDescription
appApp

The associated application.

Classes

Draw

Members

dblclick

Handle double click event: some tools use it to finish interaction.

keydown

Handle key down event.

mousedown

Handle mouse down event.

mousemove

Handle mouse move event.

mouseout

Handle mouse out event.

mouseup

Handle mouse up event.

touchend

Handle touch end event.

touchmove

Handle touch move event.

touchstart

Handle touch start event.

wheel

Handle mouse wheel event.

Methods

activate(flag)

Activate the tool.

Parameters:
NameTypeDescription
flagboolean

The flag to activate or not.

addEventListener(type, listener)

Add an event listener on the app.

Parameters:
NameTypeDescription
typestring

The event type.

listenerfunction

The function associated with the provided event type.

getEventNames() → {Array.<string>}

Get the list of event names that this tool can fire.

Returns:

The list of event names.

Type: 
Array.<string>

getOptionsType() → {string}

Get the type of tool options: here 'factory' since the shape list contains factories to create each possible shape.

Returns:

The type.

Type: 
string

hasShape(name) → {boolean}

Check if the shape is in the shape list.

Parameters:
NameTypeDescription
namestring

The name of the shape.

Returns:

True if there is a factory for the shape.

Type: 
boolean

init()

Initialise the tool.

removeEventListener(type, listener)

Remove an event listener from the app.

Parameters:
NameTypeDescription
typestring

The event type.

listenerfunction

The function associated with the provided event type.

setFeatures(features)

Set the tool live features: shape colour and shape name.

Parameters:
NameTypeDescription
featuresobject

The list of features.

setOptions(options)

Set the tool configuration options.

Parameters:
NameTypeDescription
optionsobject

The list of shape names amd classes.

Events

annotationselect

Annotation select event.

Type:
  • object
Properties
NameTypeDescription
typestring

The event type.

annotationidstring

The annotation id.

dataidstring

The data id.

warn

Warn event.

Type:
  • object
Properties
NameTypeDescription
typestring

The event type.

messagestring

The warning message.