Class: SelectionHandler

PD. SelectionHandler

The base class for all selection handlers which defines an interface that they must all implement.

Selection handler instances are associated with a PD.SELECTION type using the handler property of the associated type. The selection types for with each handler must be added within their constructor.


new SelectionHandler(selectionManager)

Creates a new selection handler instance.

Parameters:
Name Type Description
selectionManager PD.SelectionManager

The selection manager to connect to.

Author:
  • drajmarsh

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

:boolean

isSelectionHandler <readonly>

A flag identifying this object as a selection handler.

Type
  • boolean

: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

: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

Methods


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.

Returns:

Returns true if the selection set changed.

Type
boolean

checkForExtendedSelection(mode, type, selection)

Determines whether newly 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
mode PD.SELECT_ACTION

The extended selection mode.

type PD.SELECTION

The selection type.

selection PD.Selection

The interactive selection accumulator.

Returns:

Returns true if the extended selection set was changed.

Type
boolean

clear()

Clears and empties the selection set.


connectTo(selectionManager)

Initialises this instance for use with a selection manager.

Call this method to connect this instance to a selection set that is shared by the selection manager. The connected 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.


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.

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.

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.

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.

Returns:

Returns true if the selection set changed.

Type
boolean

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.


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.


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.


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.

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.

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.


moveByVector3(vector)

Move the selection by a relative vector.

Parameters:
Name Type Description
vector THREE.Vector3

The relative movement vector.


setSelection(selection)

Sets the current selection from the given accumulated selection data.

Parameters:
Name Type Description
selection PD.Selection

The interactive selection accumulator.

Returns:

Returns true if currently selected item(s) changed.

Type
boolean

isSelectionHandlerClass() <static>

Indicates that this is an selection handler class rather than instance.