Class: SelectionHandler

PD.BRep. SelectionHandler

Handles the interactive selection of BReps within the model.

This handler adds the following selection types when created:

  • PD.SELECTION.BREP
  • PD.SELECTION.BREP_FACE
  • PD.SELECTION.BREP_EDGE
  • PD.SELECTION.BREP_VERTEX

new SelectionHandler(selectionManager)

Creates a new BRep 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:

:PD.BRep|null

currentBRep

The currently selected BRep within the model.

The currently selected BRep is one of the BReps within the selectionSet array that the user is currently primarily on. It is also the surface that owns the currentFace, the currentEdge and the currentVertex, if any.

Type

:Array.<PD.Point>|null

currentEdge

The currently selected edge within the current BRep.

The currently selected edge is the one the user is primarily focused on and is the basis for cursor manipulation. Any interactive manipulation of this edge is also applied to all other selected edges.

If there are any selected edges, this value must always reference one of them. It will only be null when there are no edges currently selected.

Type

:PD.BRep.Face|null

currentFace

The currently selected face within the current BRep.

The currently selected face is the one the user is primarily focused on and is the basis for cursor manipulation. Any interactive manipulation of this face is also applied to all other selected faces.

If there are any selected faces, this value must always reference one of them. It will only be null when there are no faces currently selected.

Type

:PD.Point|null

currentVertex

The currently selected vertex within the current BRep.

The currently selected vertex is the one the user is primarily focused on and is the basis for cursor manipulation. Any interactive manipulation of this vertex is also applied to all other selected vertices.

If there are any selected vertices, this value must always reference one of them. It will only be null when there are no edges currently selected.

Type

:boolean

isSelectionHandler <readonly>

A flag identifying this object as a selection handler.

Type
  • boolean
Inherited From:
Overrides:

: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


addBRep(brep)

Adds the given BRep to the selection set.

If the selection set is empty, the BRep 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.BREP, then the BRep will not be added and the selection set will remain unchanged.

Parameters:
Name Type Description
brep PD.BRep

The BRep to add to selection set.

Returns:

Returns true if BRep was added.

Type
boolean

addBReps(breps [, selectionSet])

Adds the given BRep faces to the selection set.

If the selection set type is not PD.SELECTION.BREP_FACE, 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 faces, they will not be added.

Parameters:
Name Type Argument Description
breps Array.<PD.BRep>

The array of BReps 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 BReps were added.

Type
boolean

addEdge(brep, edge)

Adds the given edge to the selection set.

If the current type is not set to PD.SELECTION.BREP_EDGE, the edge will not be added.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the edge.

edge Array.<PD.Point>

The edge to add to selection set.

Returns:

Returns true if the BRep edge was added.

Type
boolean

addEdges(brep, edges [, selectionSet])

Adds the given BRep edges to the selection set.

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

Parameters:
Name Type Argument Description
brep PD.BRep

The BRep containing the edges.

edges Array.<PD.Point>

The array of edges 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 BRep edges were added.

Type
boolean

addFace(brep, face)

Adds the given face to the selection set.

If the current type is not set to PD.SELECTION.BREP_FACE, the face will not be added.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the face.

face PD.BRep.Face

The face to add to selection set.

Returns:

Returns true if the BRep face was added.

Type
boolean

addFaces(brep, faces [, selectionSet])

Adds the given BRep faces to the selection set.

If the selection set type is not PD.SELECTION.BREP_FACE, 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 faces, they will not be added.

Parameters:
Name Type Argument Description
brep PD.BRep

The BRep containing the faces.

faces Array.<PD.BRep.Face>

The array of faces 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 BRep faces were added.

Type
boolean

addFoundItemsToSelection(mode, selection)

Search the selection.foundItems selection set and adds, removes or toggles 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

addVertex(brep, vertex)

Adds the given vertex to the selection set.

If the current type is not set to PD.SELECTION.BREP_VERTEX, the vertex will not be added.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the vertex.

vertex PD.Point

The vertex to add to selection set.

Returns:

Returns true if the BRep vertex was added.

Type
boolean

addVertices(brep, vertices [, selectionSet])

Adds the given BRep vertices to the selection set.

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

Parameters:
Name Type Argument Description
brep PD.BRep

The BRep containing the vertices.

vertices Array.<PD.Point>

The array of vertices 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 BRep vertices 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 BRep 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:

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 BReps and the faces, edges or vertices currently selected within them.

Parameters:
Name Type Description
selectionManager PD.SelectionManager

The selection manager for this handler.

Inherited From:
Overrides:

expandSelection(type [, item])

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

Parameters:
Name Type Argument Description
type PD.SELECTION

The current selection type.

item any <optional>

An optional item to expand, defaults to all selected items.

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.

Overrides:
Returns:

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

Type
boolean

findInExtendedSelectionByRay(selection, type [, event])

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 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 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.Brep.Selection#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

foundBRep(selection, element, brep, forceSelect)

Check to assign a BRep as selected.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

element BIM.Element | null

The element containing the BRep, if any.

brep PD.BRep

The BRep to select.

forceSelect boolean

When true, ignores depth tests and forces selection.

Throws:

Throws an error if BRep is invalid.

Type
Error
Returns:

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

Type
boolean

foundBRepEdge(selection, element, brep, edge, forceSelect)

Check to assign a BRep edge as selected.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

element BIM.Element | null

The element containing the BRep, if any.

brep PD.BRep

The BRep that the edge belongs to.

edge Array.<PD.Point>

The selected edge within the BRep.

forceSelect boolean

When true, ignores depth tests and forces selection.

Throws:

Throws an error if BRep is invalid or the selected edge not found within it.

Type
Error
Returns:

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

Type
boolean

foundBRepFace(selection, element, brep, face, forceSelect)

Check to assign a BRep face as selected.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

element BIM.Element | null

The element containing the BRep, if any.

brep PD.BRep

The BRep that the face belongs to.

face PD.BRep.Face

The selected face within the BRep.

forceSelect boolean

When true, ignores depth tests and forces selection.

Throws:

Throws an error if BRep is invalid or the selected face not found within it.

Type
Error
Returns:

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

Type
boolean

foundBRepVertex(selection, element, brep, vertex, forceSelect)

Check to assign a BRep vertex as selected.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

element BIM.Element | null

The element containing the BRep, if any.

brep PD.BRep

The BRep that the vertex belongs to.

vertex PD.Point

The selected vertex within the BRep.

forceSelect boolean

When true, ignores depth tests and forces selection.

Throws:

Throws an error if BRep is invalid or the selected vertex not found within it.

Type
Error
Returns:

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

Type
boolean

getSelectedBReps()

Retrieves an array of the currently selected BReps.

Returns:

Returns an array of selected BReps.

Type
Array.<PD.BRep>

getSelectedEdges(brep)

Retrieves an array of selected edges in the given BRep.

Parameters:
Name Type Description
brep PD.BRep

The BRep to obtain selection data for.

Returns:

Returns an array of selected edges in this BRep.

Type
Array.<PD.Point>

getSelectedFaces(brep)

Retrieves an array of selected faces in the given BRep.

Parameters:
Name Type Description
brep PD.BRep

The BRep to obtain selection data for.

Returns:

Returns an array of selected faces in this BRep.

Type
Array.<PD.BRep.Face>

getSelectedVertices(brep)

Retrieves an array of selected vertices in the given BRep.

Parameters:
Name Type Description
brep PD.BRep

The BRep to obtain selection data for.

Returns:

Returns an array of selected vertices in this BRep.

Type
Array.<PD.Point>

hasBRep(brep)

Checks if the selection set contains the given BRep.

Parameters:
Name Type Description
brep PD.BRep

The BRep to check for.

Returns:

Returns true if selection set contains the BRep.

Type
boolean

hasEdge(brep, edge)

Checks if the selection set contains the given edge.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the edge.

edge Array.<PD.Point>

The edge to check for in selection set.

Returns:

Returns true if selection set contains the edge.

Type
boolean

hasFace(brep, face)

Checks if the selection set contains the given face.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the face.

face PD.BRep.Face

The face to check for in selection set.

Returns:

Returns true if selection set contains the face.

Type
boolean

hasVertex(brep, vertex)

Checks if the selection set contains the given vertex.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the vertex.

vertex PD.Point

The vertex to check for in selection set.

Returns:

Returns true if selection set contains the vertex.

Type
boolean

highlightBRep(mesh, brep)

Renders the given BRep as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

he mesh to receive the highlight geometry.

brep PD.BRep

The BRep to render as highlighted.


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:

highlightEdge(mesh, edge, size)

Renders the given BRep as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

edge Array.<PD.Point>

The BRep edge to render as highlighted.

size number

The size to render features at.


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:

highlightFace(mesh, face)

Renders the given BRep as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

face PD.BRep.Face

The BRep face to render as highlighted.


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:

highlightVertex(mesh, vertex, size)

Renders the given BRep as highlighted using the given mesh.

Parameters:
Name Type Description
mesh PD.PolyMesh

The mesh to receive the highlight geometry.

vertex PD.Point

The BRep vertex to render as highlighted.

size number

The size to render features at.


initialiseExtendedSelection(type)

Initialises the selection set with the current selection.

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

Parameters:
Name Type Description
type PD.SELECTION

The selection type.

Overrides:
Returns:

Returns true if currently selected item(s) changed.

Type
boolean

makeExtendedSelectionItemCurrent(selection, type)

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 will be made current and the rest of the selection left unchanged.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

type PD.SELECTION

The current selection type.

Inherited From:
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:

removeBReps(breps)

Removes the given BReps from the selection set.

Parameters:
Name Type Description
breps Array.<PD.BRep>

The array of BReps to remove from selection set.

Returns:

returns true if any BReps were removed.

Type
boolean

removeEdges(brep, edges [, selectionSet])

Removes the given edges from the selection set.

Parameters:
Name Type Argument Description
brep PD.BRep

The BRep containing the edges.

edges Array.<PD.Point>

The array of edges to remove from selection set.

selectionSet PD.SelectionSet <optional>

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

Returns:

Returns true if any BReps were removed.

Type
boolean

removeFaces(brep, faces)

Removes the given faces from the selection set.

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the faces.

faces Array.<PD.BRep.Face>

The array of faces to remove from selection set.

Returns:

Returns true if any faces were removed.

Type
boolean

removeVertices(brep, vertices [, selectionSet])

Removes the given vertices from the selection set.

Parameters:
Name Type Argument Description
brep PD.BRep

The BRep containing the vertices.

vertices Array.<PD.Point>

The array of vertices to remove from selection set.

selectionSet PD.SelectionSet <optional>

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

Returns:

Returns true if any BRep vertices were removed.

Type
boolean

selectBRep(brep)

Sets the given BRep as the primary selected BRep.

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

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the face.

Returns:

Returns true if the current selection changed.

Type
boolean

selectEdge(brep, edge)

Sets the given edge as the primary selected edge.

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

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the edge.

edge Array.<PD.Point>

The edge to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

selectFace(brep, face)

Sets the given face as the currently selected face.

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

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the face.

face PD.BRep.Face

The face to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

selectVertex(brep, vertex)

Sets the given vertex as the primary selected vertex.

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

Parameters:
Name Type Description
brep PD.BRep

The BRep containing the vertex.

vertex PD.Point

The vertex to select and make current.

Returns:

Returns true if the current selection changed.

Type
boolean

setSelection(selection)

Sets the current selection from the given selection data.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

Overrides:
Returns:

Returns true if currently selected item(s) changed.

Type
boolean