Class: Add

BIM.UserModeHandler. Add

Handles the interactive creation of elements by path within the model.

This is the default handler for the PD.MODE.ADD mode and allows for the interactive creation of model elements using large 3D touch-friendly cursor manipulators.


new Add()

Creates a new edit mode handler.

Author:
  • drajmarsh

Extends

Members


:boolean

isUserModeHandler <readonly>

A flag identifying this object as an edit mode handler.

Type
  • boolean
Inherited From:
Overrides:

Methods


appendNewJunction(host, cursor [, displace])

Appends a new vertex to the current path contour.

If the optional displace parameter is true, or if automatic progression is disabled, the new junction will be displaced relative to the outgoing vector of the previous junction to highlight the addition of the new junction and allow the user to drag it to a new position.

Parameters:
Name Type Argument Default Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that was dragged.

displace boolean <optional>
false

Whether or not to displace next junction, defaults to false.


cancel(host)

Cancels this edit mode.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:

checkToCloseElement(element, contour)

Check whether the user joined the last point to the first.

If the user drags the last junction to be exactly coincident with the first, this is taken as an indication that they wish to close an open path. This method checks whether this is okay for the element being created and, if so, closes it.

Parameters:
Name Type Description
element BIM.Element

The element being edited.

contour Array

The contour being edited.

Returns:

Returns true if the ending vertex is coincident with the first.

Type
boolean

complete(host)

Completes any pending modal action(s) in this edit mode.

This method checks that there are sufficient junctions to form a valid path for the new element and, if so, creates it.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:
Returns:

Returns true is a pending action was completed.

Type
boolean

cursorUpdateInfo(host, count)

Updates the cursor information string.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

count number

The vertex count to show.


displayDimensions(host, mesh)

Regenerates dimension lines for the current element being added.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

mesh PD.PolyMesh

The mesh to add the dimension(s) to.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was dimensioned and the mesh should be visible, otherwise false.

Type
boolean

handleClickSelect(host, raycaster, event)

Called when the user clicks/taps in the canvas away from the 3D cursor.

The calling of this method signifies that the user has completed the interactive input of path segments and wishes the new element to be added to the model.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

raycaster THREE.Raycaster

The ray cast into the current scene.

event object

The DOM event that triggered this selection.

Inherited From:
Overrides:
Returns:

Returns true if the new element was added to the model and a redraw is required, otherwise false.

Type
boolean

handleDragEnd(host, cursor, event)

Completes the move after a drag has finished.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that just finished moving.

event object

The DOM event that triggered the end of the move.

Inherited From:
Overrides:
Returns:

Returns true if the move was finalised.

Type
boolean

handleDragMove(host, newPos, cursor, event)

Moves the newly inserted point as the cursor is dragged.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

newPos THREE.Vector3

The proposed new position of the cursor.

cursor PD.Cursor

The cursor that moved.

event object

The DOM event that triggered this move.

Inherited From:
Overrides:
Returns:

Returns true if the move was applied.

Type
boolean

handleDragStart(host, cursor, event)

Prepare the selection just prior to a drag event.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that is about to move.

event object

The DOM event that triggered this move.

Inherited From:
Overrides:
Returns:

Returns true if the move is allowed.

Type
boolean

handlePreSelect(host, raycaster, event)

Handles interactive pre-selection events.

This allows the user to click anywhere in the model to position and drag the very first junction in the path. After that, clicking away from the 3D model cursor completes the add element action.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

raycaster THREE.Raycaster

The ray cast into the current scene.

event object

The DOM event that triggered this callback.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was pre-selected and geometry was added to the mesh, otherwise false.

Type
boolean

hasEnoughJunctionsInPath(host, element)

Determines if there are enough junctions to create the element.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

element BIM.Element

The element path top check.

Returns:

Returns true if there are enough junctions to create element.

Type
boolean

initialise(host)

Called each time this edit mode is entered.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:

progressToNextStage(host [, stage])

Increments the staged process of adding an element.

This method adds a new junction at the cursor position and checks to ensure that they are not coincident with previous junctions.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

stage number <optional>

An optional stage in the progress.

Inherited From:
Overrides:

setCursorPosition(host, pos [, event])

Manually sets the cursor position during an action.

This method is called when the user manually edits the cursor position using the keyboard or other numeric input within the UI, as opposed to dragging the cursor. It is not called when the cursor is moved interactively using the manipulators and a pointer.

This method should undertake whatever action dragging the cursor would have at the current progress stage.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

pos Object | Array

The new position to move the cursor to.

event Event <optional>

The event that invoked this method.

Inherited From:
Overrides:

setDrawingSurface(element, junction, cursor)

Initialises surface drawing.

Parameters:
Name Type Description
element BIM.Element

The element that owns the drawing surface.

junction BIM.Junction

The junction that defines the drawing surface.

cursor PD.Cursor

The cursor to follow the drawing surface.

Returns:

Returns true drawing is restricted to element/junction surface.

Type
boolean

updateAfterUndoRedo(host)

Selects the last junction in the element path.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.