Class: SelectionHandler

BIM.Path. SelectionHandler

Handles the interactive selection of paths within the model.

This handler adds the following selection types when created:

  • PD.SELECTION.PATH
  • PD.SELECTION.JUNCTION
  • PD.SELECTION.SEGMENT
  • PD.SELECTION.APERTURE
  • PD.SELECTION.NODE

new SelectionHandler(selectionManager)

Creates a new path selection handler instance.

Parameters:
Name Type Description
selectionManager PD.SelectionManager

The selection manager to connect to.

Author:
  • drajmarsh

Extends

Members


:PD.SelectionSet

_selectionSet

Stores the selected items.

This property is set by the PD.SelectionHandler#connectTo method, and is a direct reference to the PD.SelectionManager#selectionSet property you are using. It is used to store one or more selected items and the sub-items currently selected within them.

Type
Inherited From:
Overrides:

:BIM.Aperture|null

currentAperture

Stores the currently selected aperture.

Whilst there can be multiple selected openings stored in the selectionSet map, this represents the first and closest to the initial selection click. It is used mainly when dragging and to set the direction vector of the opening cursor.

Type

:number

currentApertureIndex

Stores the index of the current aperture in the selected line segment.

Type
  • number

:Array|null

currentContour

Stores the currently selected contour array.

Type
  • Array | null

:number

currentContourIndex

Stores the index of the currently selected contour array.

Type
  • number

:BIM.Element|null

currentElement

Stores the currently selected model element.

Whilst there can be multiple selected elements stored in the selectionSet map, this represents the primary selection (usually closest to the initial selection ray or first in a region-based selection) and is the one that subsequent actions/selections are always based on.

Type

:BIM.Element|null

currentHierarchy

Stores the currently selected hierarchy.

This is used by the UI when dynamically switching between tabs showing different selection levels. It needs to be part of the selection manager so that it can be updated when the selection set changes, but independent of tab settings.

Type

:BIM.Junction|null

currentJunction

Stores the actual currently selected contour point.

Type

:number

currentJunctionIndex

Stores the index of the currently selected contour point.

Type
  • number

:BIM.Aperture|null

currentNode

Stores the currently selected junction node.

Whilst there can be multiple selected noed stored in the selectionSet map, this represents the first and closest to the initial selection click. It is used mainly when dragging and editing to set the cursor.

Type

:number

currentNodeIndex

Stores the index of the current node in the selected junction.

Type
  • number

:BIM.Path|null

currentPath

Stores the currently selected path in model element.

Whilst there can be multiple selected paths stored in the selectionSet map, this represents the primary selection (usually closest to the initial selection ray or first in a region-based selection) and is the one that subsequent actions/selections are always based on.

Type

:BIM.Junction

currentSegment

Stores the start junction of the currently selected path segment.

Whilst there can be multiple selected segments stored in the selectionSet map, this represents the first and closest to the initial selection click. It is used mainly when dragging and to set the direction vector of the 1D cursor. It is also the one that will be deleted or inserted into.

Type

:number

currentSegmentIndex

Stores the index of the segment in the selected path.

Type
  • number

:boolean

isSelectionHandler <readonly>

A flag identifying this object as a selection handler.

Type
  • boolean
Inherited From:
Overrides:

:object

nodeSelection

Stores information for selecting and editing curve control nodes.

Selecting and editing a curve control node should not affect the current selection set, unless the user clicks away. Thus, control nodes can only be selected when displayed as part of an existing selection, and the switch between node and previous selection should be seamless.

Type
  • object

:PD.SelectionManager

selectionManager

Stores the selection manager using this handler.

This property is set by the PD.SelectionHandler#connectTo method, called with the application-wide PD.SelectionManager instance.

Type
Inherited From:
Overrides:

:PD.SelectionSet

selectionSet <readonly>

Stores the current selection set.

This property is set by the PD.SelectionHandler#connectTo method, and is a direct reference to the PD.SelectionManager#selectionSet property you are using. It is used to store one or more selected items and the sub-items currently selected within them.

Type
Inherited From:
Overrides:

Methods


addAperture(path, aperture)

Adds the given aperture to the selection set.

If the current type is not set to PD.SELECTION.APERTURE, the aperture will not be added.

Parameters:
Name Type Description
path BIM.Path

The path containing the aperture.

aperture BIM.Aperture

The aperture to add to selection set.

Returns:

Returns true if the path aperture was added.

Type
boolean

addApertures(path, apertures [, selectionSet])

Adds the given path apertures to the selection set.

If the selection set type is not PD.SELECTION.APERTURE, this method will clear any existing selection and set that type before adding the apertures. If any of the items in the array are not valid apertures, they will not be added.

When using this method, you must ensure that you also set one of the apertures as the current selection using the BIM.Path.Selection.selectAperture method.

Parameters:
Name Type Argument Description
path BIM.Path

The path containing the apertures.

apertures Array.<BIM.Aperture>

The array of apertures to add to selection set.

selectionSet PD.SelectionSet <optional>

The selection set to add to, defaults to host selection manager's set.

Returns:

Returns true if any path apertures were added.

Type
boolean

addFoundItemsToSelection(mode, selection)

Search the selection.foundItems selection set and add, remove or toggle items as per the select action mode.

Parameters:
Name Type Description
mode PD.SELECT_ACTION

The extended selection mode.

selection PD.Selection

The interactive selection accumulator.

Inherited From:
Overrides:
Returns:

Returns true if the selection set changed.

Type
boolean

addJunction(path, junction)

Adds the given junction to the selection set.

If the current type is not set to PD.SELECTION.JUNCTION, the junction will not be added.

Parameters:
Name Type Description
path BIM.Path

The path containing the junction.

junction BIM.Junction

The junction to add to selection set.

Returns:

Returns true if the path junction was added.

Type
boolean

addJunctions(path, junctions [, selectionSet])

Adds the given path junctions to the selection set.

If the selection set type is not PD.SELECTION.JUNCTION, this method will clear any existing selection and set that type before adding the junctions. If any of the items in the array are not valid junctions, they will not be added.

When using this method, you must ensure that you also set one of the junctions as the current selection using the BIM.Path.Selection.selectJunction method.

Parameters:
Name Type Argument Description
path BIM.Path

The path containing the junctions.

junctions Array.<BIM.Junction>

The array of junctions to add to selection set.

selectionSet PD.SelectionSet <optional>

The selection set to add to, defaults to host selection manager's set.

Returns:

Returns true if any path junctions were added.

Type
boolean

addNode(path, junction, node)

Adds the given node to the selection set.

If the current type is not set to PD.SELECTION.NODE, the node will not be added.

Parameters:
Name Type Description
path BIM.Path

The path containing the node.

junction BIM.Junction

The junction the node belongs to.

node PD.Point

The node to select and make current.

Returns:

Returns true if the path node was added.

Type
boolean

addNodes(path, junction, nodes [, selectionSet])

Adds the given path nodes to the selection set.

If the selection set type is not PD.SELECTION.NODE, this method will clear any existing selection and set that type before adding the nodes. If any of the items in the array are not valid nodes, they will not be added.

When using this method, you must ensure that you also set one of the nodes as the current selection using the BIM.Path.Selection.selectNode method.

Parameters:
Name Type Argument Description
path BIM.Path

The path containing the nodes.

junction BIM.Junction

The junction the node belongs to.

nodes Array.<PD.Point>

The array of nodes to add to selection set.

selectionSet PD.SelectionSet <optional>

The selection set to add to, defaults to host selection manager's set.

Returns:

Returns true if any path nodes were added.

Type
boolean

addPath(path)

Adds the given path to the selection set.

If the selection set is empty, the path will be added and also made the current selection.

If the selection set is not empty and the current type is not set to PD.SELECTION.PATH, then the path will not be added and the selection set will remain unchanged.

Parameters:
Name Type Description
path BIM.Path

The path to add to selection set.

Returns:

Returns true if path was added.

Type
boolean

addPaths(paths [, selectionSet])

Adds the given path faces to the selection set.

If the selection set type is not PD.SELECTION.PATH, this method will clear any existing selection and set that type before adding the faces. If any of the items in the array are not valid paths, they will not be added.

Parameters:
Name Type Argument Description
paths Array.<BIM.Path>

The array of paths to add to selection set.

selectionSet PD.SelectionSet <optional>

The selection set to add to, defaults to host selection manager's set.

Returns:

Returns true if any paths were added.

Type
boolean

addSegment(path, segment)

Adds the given segment to the selection set.

If the current type is not set to PD.SELECTION.SEGMENT, the segment will not be added.

Parameters:
Name Type Description
path BIM.Path

The path containing the segment.

segment BIM.Junction

The segment to add to selection set.

Returns:

Returns true if the path segment was added.

Type
boolean

addSegments(path, segments [, selectionSet])

Adds the given path segments to the selection set.

If the selection set type is not PD.SELECTION.SEGMENT, this method will clear any existing selection and set that type before adding the segments. If any of the items in the array are not valid segments, they will not be added.

When using this method, you must ensure that you also set one of the segments as the current selection using the BIM.Path.Selection.selectSegment method.

Parameters:
Name Type Argument Description
path BIM.Path

The path containing the segments.

segments Array.<BIM.Junction>

The array of segments to add to selection set.

selectionSet PD.SelectionSet <optional>

The selection set to add to, defaults to host selection manager's set.

Returns:

Returns true if any path segments were added.

Type
boolean

checkForExtendedSelection(action, type, selection)

Determines whether selected items are added to, removed from or toggled within the current selection set.

This method is called by the PD.SelectionManager.checkForExtendedSelection method when the selection mode is not PD.SELECT_ACTION.REPLACE.

Parameters:
Name Type Description
action PD.SELECT_ACTION

The extended selection action.

type PD.SELECTION

The path selection type.

selection PD.Selection

The interactive selection accumulator.

Inherited From:
Overrides:
Returns:

Returns true if the extended selection set was changed.

Type
boolean

clear()

Clears and empties the selection set.

Inherited From:
Overrides:

clearClosestSelection(selection)

Clear any closest items from the selection.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.


clearCurrentSelection()

Clears the current selection set.


connectTo(selectionManager)

Initialises this instance for use with a selection manager.

Call this method to connect this instance to the application-wide selection manager. The connected selection manager's selection set is used to store one or more paths and the junctions, apertures or nodes currently selected within them.

Parameters:
Name Type Description
selectionManager PD.SelectionManager

The selection manager for this handler.

Inherited From:
Overrides:

expandSelection(type [, path])

Selects all junctions in each path or all apertures in each junction.

Parameters:
Name Type Argument Description
type PD.SELECTION

The current selection type.

path BIM.Path <optional>

An optional path to expand, defaults to all selected paths.

Inherited From:
Overrides:
Returns:

Returns true if the selection changed, otherwise false.

Type
boolean

extendSelectionByRay(type, selection)

Searches for the closest item based on the given type.

If something is found. this method fills out the selection object with information on the closest item.

Parameters:
Name Type Description
type PD.SELECTION

The current selection type.

selection PD.Selection

The interactive selection accumulator.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was found and the selection set updated, otherwise false.

Type
boolean

findInExtendedSelectionByRay(selection)

Checks if the user's intent is to select an already selected item.

This method is used to determine if the user is selecting an existing item in the extended selection set, or choosing something new. It is called during pre-selection and first checks for proximity to items in the current selection set, but only when the selection set has multiple items.

The PD.SelectionManager#makeExtendedSelectionItemCurrent method is then called when the selection pointer/touch is released to process the selection and detect a re-selection.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

Overrides:
Returns:

Returns true if an already selected item was re-selected, otherwise false.

Type
boolean

findItemsByFrustum(selection, type [, event])

Finds items inside or touching the selection frustum and adds them to the selection.foundItems selection set.

This find-and-collect phase is separate from actual selection as we first need to find all the items, and then in the next phase work out if we should add, remove or toggle them. This is done in the PD.SelectionHandler#handleExtendedSelection method.

Parameters:
Name Type Argument Description
selection PD.Selection

The interactive selection accumulator.

type PD.SELECTION

The current selection type.

event Event <optional>

The DOM event that triggered this action.

Inherited From:
Overrides:
Returns:

Returns true if the selection set changed.

Type
boolean

foundPath(selection, element, path, forceSelect)

Check to assign a path as selected.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

element BIM.Element | null

The element containing the path, if any.

path PD.Path

The path to select.

forceSelect boolean

When true, ignores depth tests and forces selection.

Throws:

Throws an error if path is invalid.

Type
Error
Returns:

Returns true if this is the closest intersection to eye position.

Type
boolean

getSelectedApertures(path)

Retrieves an array of selected apertures in the given path.

Parameters:
Name Type Description
path BIM.Path

The path to obtain selection data for.

Returns:

Returns an array of selected apertures in this path.

Type
Array.<BIM.Aperture>

getSelectedJunctions(path)

Retrieves an array of selected junctions in the given path.

Parameters:
Name Type Description
path BIM.Path

The path to obtain selection data for.

Returns:

Returns an array of selected junctions in this path.

Type
Array.<BIM.Junction>

getSelectedNodes(path)

Retrieves an array of selected nodes in the given path.

Parameters:
Name Type Description
path BIM.Path

The path to obtain selection data for.

Returns:

Returns an array of selected nodes in this path.

Type
Array.<PD.Point>

getSelectedPaths()

Retrieves an array of the currently selected paths.

Returns:

Returns an array of selected paths.

Type
Array.<BIM.Path>

getSelectedSegments(path)

Retrieves an array of selected segments in the given path.

Parameters:
Name Type Description
path BIM.Path

The path to obtain selection data for.

Returns:

Returns an array of selected segments in this path.

Type
Array.<BIM.Junction>

hasAperture(path, aperture)

Checks if the selection set contains the given aperture.

Parameters:
Name Type Description
path BIM.Path

The path containing the aperture.

aperture BIM.Aperture

The aperture to check for in selection set.

Returns:

Returns true if selection set contains the aperture.

Type
boolean

hasJunction(path, junction)

Checks if the selection set contains the given junction.

Parameters:
Name Type Description
path BIM.Path

The path containing the junction.

junction BIM.Junction

The junction to check for in selection set.

Returns:

Returns true if selection set contains the junction.

Type
boolean

hasNode(path, node)

Checks if the selection set contains the given node.

Parameters:
Name Type Description
path BIM.Path

The path containing the node.

node PD.Point

The node to check for in selection set.

Returns:

Returns true if selection set contains the node.

Type
boolean

hasPath(path)

Checks if the selection set contains the given path.

Parameters:
Name Type Description
path BIM.Path

The path to check for.

Returns:

Returns true if selection set contains the path.

Type
boolean

hasSegment(path, segment)

Checks if the selection set contains the given segment.

Parameters:
Name Type Description
path BIM.Path

The path containing the segment.

segment BIM.Junction

The segment to check for in selection set.

Returns:

Returns true if selection set contains the segment.

Type
boolean

highlightAperture(mesh_outline, mesh_surface, aperture, size)

Adds the facets of an aperture to the given mesh.

Parameters:
Name Type Description
mesh_outline PD.PolyMesh

The mesh to receive highlight lines.

mesh_surface PD.PolyMesh

The mesh to receive highlight surfaces.

aperture BIM.Aperture

The aperture to highlight.

size number

The indicator size in model units.


highlightCurrentSelection(renderData, type)

Renders the current selection as highlighted with the given mesh.

Parameters:
Name Type Description
renderData object

An object containing meshes and view-specific data.

Properties of renderData:
Name Type Description
meshSurface PD.PolyMesh

The mesh to render triangulated surfaces to.

meshOutline PD.PolyMesh

The mesh to render edges and outlines to.

pointSize number

A reference point size based on the current model size and view.

dashSize object

A size for dashed lines based on the current model size and view.

nodeSize object

A size for selectable nodes in the current model size and view.

type PD.SELECTION

The current selection type.

Inherited From:
Overrides:

highlightExtendedSelection(renderData, type)

Renders the extended selection set as highlighted with the given mesh.

Parameters:
Name Type Description
renderData object

An object containing meshes and view-specific data.

Properties of renderData:
Name Type Description
meshSurface PD.PolyMesh

The mesh to render triangulated surfaces to.

meshOutline PD.PolyMesh

The mesh to render edges and outlines to.

pointSize number

A reference point size based on the current model size and view.

dashSize object

A size for dashed lines based on the current model size and view.

nodeSize object

A size for selectable nodes in the current model size and view.

type PD.SELECTION

The current selection type.

Inherited From:
Overrides:

highlightJunction(mesh, junction, size)

Adds a highlighted path vertex/junction to the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

junction BIM.Junction

The path junction to highlight.

size number

The indicator size in model units.


highlightJunctionFacets(mesh, path [, junction])

Adds the facets that belong to a junction to the given mesh.

Parameters:
Name Type Argument Default Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

path PD.Polyline

The polyline with the contour outline to highlight.

junction BIM.Junction <optional>
null

An optional junction containing facets.


highlightNode(mesh, node, size)

Renders the given path as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

node PD.Point

The path node to render as highlighted.

size number

The size to render features at.


highlightPath(mesh, path)

Renders the given path as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

path BIM.Path

The path to render as highlighted.


highlightPathContour(mesh, path, size [, contour])

Adds a highlighted path/polyline outline to the given mesh.

Parameters:
Name Type Argument Default Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

path PD.Polyline

The polyline with the contour outline to highlight.

size number

The indicator size in model units.

contour Array.<PD.Point> <optional>
null

The contour to highlight, defaults to first in poly.


highlightSegment(mesh, segment, size)

Adds a highlighted path segment to the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

segment BIM.Junction

The junction segment highlight.

size number

The indicator size in model units.


highlightSelection(mesh, selection, size)

Renders the given selection as highlighted with the given mesh.

This method is called by the PD.SelectionManager.updatePreSelection method to populate the pre-selection mesh when the user first makes a selection action within the canvas.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

selection PD.Selection

The interactive selection accumulator.

size number

The size to render features at.

Inherited From:
Overrides:

initialiseExtendedSelection(type)

Initialises the selection set with the current selection.

This method is called AFTER the current selection is updated and should simply copy the current selection into the extended selection set.

Parameters:
Name Type Description
type PD.SELECTION

The selection type.

Inherited From:
Overrides:
Returns:

Returns true if currently selected item(s) changed.

Type
boolean

makeExtendedSelectionItemCurrent(selection)

Checks the selection data to see if item is already in the selection set.

This method checks if the selected item is already in the extended selection set and, if so, it should be made current and the rest of the selection left unchanged.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

Overrides:
Returns:

Returns true if currently selected item changed.

Type
boolean

moveByMatrix4(matrix)

Transforms the selection by applying the matrix to it.

Parameters:
Name Type Description
matrix THREE.Matrix4

The transform matrix to apply to the element.

Inherited From:
Overrides:

moveByVector3(vector)

Move the selection by a relative vector.

Parameters:
Name Type Description
vector THREE.Vector3

The relative movement vector.

Inherited From:
Overrides:

removeApertures(path, apertures)

Removes the given apertures from the selection set.

Parameters:
Name Type Description
path BIM.Path

The path containing the apertures.

apertures Array.<BIM.Aperture>

The array of apertures to remove from selection set.

Returns:

Returns true if any apertures were removed.

Type
boolean

removeJunctions(path, junctions)

Removes the given junctions from the selection set.

Parameters:
Name Type Description
path BIM.Path

The path containing the junctions.

junctions Array.<BIM.Junction>

The array of junctions to remove from selection set.

Returns:

Returns true if any junctions were removed.

Type
boolean

removeNodes(path, nodes)

Removes the given nodes from the selection set.

Parameters:
Name Type Description
path BIM.Path

The path containing the nodes.

nodes Array.<Array.<PD.Point>>

The array of nodes to remove from selection set.

Returns:

Returns true if any paths were removed.

Type
boolean

removePaths(paths)

Removes the given paths from the selection set.

Parameters:
Name Type Description
paths Array.<BIM.Path>

The array of paths to remove from selection set.

Returns:

Returns true if any paths were removed.

Type
boolean

removeSegments(path, segments)

Removes the given segments from the selection set.

Parameters:
Name Type Description
path BIM.Path

The path containing the segments.

segments Array.<BIM.Junction>

The array of segments to remove from selection set.

Returns:

Returns true if any paths were removed.

Type
boolean

selectAperture(path, aperture)

Sets the given aperture as the currently selected aperture.

If this aperture does not already exist within the selection set, the selection set will be cleared before setting it.

Parameters:
Name Type Description
path BIM.Path

The path containing the aperture.

aperture BIM.Aperture

The aperture to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

selectJunction(path, junction)

Sets the given junction as the currently selected junction.

If this junction does not already exist within the selection set, the selection set will be cleared before setting it.

Parameters:
Name Type Description
path BIM.Path

The path containing the junction.

junction BIM.Junction

The junction to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

selectNode(path, junction, node)

Sets the given node as the primary selected node.

If this node does not already exist within the selection set, the selection set will be cleared before setting it.

Parameters:
Name Type Description
path BIM.Path

The path containing the node.

junction BIM.Junction

The junction the node belongs to.

node PD.Point

The node to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

selectPath(path [, contourIndex])

Sets the given path as the primary selected path.

If this path does not already exist within the selection set, the selection set will be cleared before setting it.

Parameters:
Name Type Argument Description
path BIM.Path

The path containing the face.

contourIndex number <optional>

The contour to edit within the path, defaults to 0.

Returns:

Returns true if the current selection changed.

Type
boolean

selectSegment(path, segment)

Sets the given segment as the primary selected segment.

If this segment does not already exist within the selection set, the selection set will be cleared before setting it.

Parameters:
Name Type Description
path BIM.Path

The path containing the segment.

segment BIM.Junction

The segment to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

setSelection(selection)

Sets the current selection from the given accumulated selection data.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

Inherited From:
Overrides:
Returns:

Returns true if currently selected item(s) changed.

Type
boolean