dwv.tool. Draw

new Draw(app)

Drawing tool.

This tool is responsible for the draw layer group structure. The layout is:

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
Parameters:
NameTypeDescription
appdwv.App

The associated application.

Members

shapeFactoryList :object

Shape factory list

Type:
  • object

shapeName :string

Shape name.

Type:
  • string

style :dwv.gui.Style

Drawing style.

(inner) scrollWhell :dwv.tool.ScrollWheel

Scroll wheel handler.

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.

listenerobject

The method associated with the provided event type.

dblclick(event)

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

Parameters:
NameTypeDescription
eventobject

The double click event.

getEventNames() → {Array}

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

Returns:

The list of event names.

Type: 
Array

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.

keydown(event)

Handle key down event.

Parameters:
NameTypeDescription
eventobject

The key down event.

mousedown(event)

Handle mouse down event.

Parameters:
NameTypeDescription
eventobject

The mouse down event.

mousemove(event)

Handle mouse move event.

Parameters:
NameTypeDescription
eventobject

The mouse move event.

mouseout(event)

Handle mouse out event.

Parameters:
NameTypeDescription
eventobject

The mouse out event.

mouseup(event)

Handle mouse up event.

Parameters:
NameTypeDescription
eventobject

The mouse up event.

removeEventListener(type, listener)

Remove an event listener from the app.

Parameters:
NameTypeDescription
typestring

The event type.

listenerobject

The method 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.

setShapeOn(shapeGroup, layerGroup)

Set shape group on properties.

Parameters:
NameTypeDescription
shapeGroupobject

The shape group to set on.

layerGroupdwv.gui.LayerGroup

The origin layer group.

touchend(event)

Handle touch end event.

Parameters:
NameTypeDescription
eventobject

The touch end event.

touchmove(event)

Handle touch move event.

Parameters:
NameTypeDescription
eventobject

The touch move event.

touchstart(event)

Handle touch start event.

Parameters:
NameTypeDescription
eventobject

The touch start event.

wheel(event)

Handle mouse wheel event.

Parameters:
NameTypeDescription
eventobject

The mouse wheel event.

(inner) activateCurrentPositionShapes(visible, layerGroup)

Activate shapes at current position.

Parameters:
NameTypeDescription
visibleboolean

Set the draw layer visible or not.

layerGroupdwv.gui.LayerGroup

The origin layer group.

(inner) onFinalPoints(finalPoints, layerGroup)

Create the final shape from a point list.

Parameters:
NameTypeDescription
finalPointsArray

The array of points.

layerGroupdwv.gui.LayerGroup

The origin layer group.

(inner) onNewPoints(tmpPoints, layerGroup)

Update the current draw with new points.

Parameters:
NameTypeDescription
tmpPointsArray

The array of new points.

layerGroupdwv.gui.LayerGroup

The origin layer group.

(inner) resetActiveShapeGroup()

Reset the active shape group and mouse cursor to their original state.

(inner) setShapeOff(shapeGroup)

Set shape group off properties.

Parameters:
NameTypeDescription
shapeGroupobject

The shape group to set off.

(inner) updateDrawLayer(layerGroup)

Update the draw layer.

Parameters:
NameTypeDescription
layerGroupdwv.gui.LayerGroup

The origin layer group.