SelectionManager

class Communicator.SelectionManager()

This class provides the main interface into the selection functionality of the viewer. The class manages a list of selection items that are optionally highlighted as the user selects objects in the scene.

Properties

Methods


Properties

SelectionManager.ifcSelectionFilter
Type

function

SelectionManager.ifcSelectionFilter(nodeId, model)
Arguments
  • nodeId (number()) –

  • model (Model()) –

Return type

number | null

Methods

add

SelectionManager.add(itemOrItems[, suppressCallback])

Manually adds an item or array of items to the selection set. Triggers a selection event.

Arguments
  • itemOrItems (NodeSelectionItem() | [NodeSelectionItem()] | null) – A selectionItem or selectionItem array that will be added to the current selection set.

  • suppressCallback (boolean()) – optional Optional boolean param to suppress the selectionArray callbacks calls to this generate.

Return type

void

advanceIncrementalSelection

SelectionManager.advanceIncrementalSelection(handle[, predicate])

Adds the next batch of instances selected by the supplied selection context to the selection set.

Arguments
  • handle (IncrementalSelectionId()) – The handle to an active area selection context.

  • predicate (function | null()) – optional An optional function that returns true if a given NodeSelectionItem should be added to the selection set. If false is returned, the item will not be added.

Return type

Promise <boolean>

Returns

true if there are possibly more items to select and false if not.

SelectionManager.predicate(item)
Arguments
Return type

Promise <boolean>

advanceVolumeSelection

SelectionManager.advanceVolumeSelection(handle[, predicate])
Deprecated

Use advanceIncrementalSelection instead.

Arguments
Return type

Promise <boolean>

SelectionManager.predicate(item)
Arguments
Return type

Promise <boolean>

beginConvexPolyhedronSelection

SelectionManager.beginConvexPolyhedronSelection(volumePlanes, heuristicOrigin, config)

Creates a new and active selection context for the provided selection volume. The selection volume is a convex polyhedron defined by the bounded intersection of its half-spaces.

Arguments
  • volumePlanes ([Plane()]) – The planes used to define volume. A point p is inside the volume if and only if (plane.determineSide(p) == true) for all supplied planes.

  • heuristicOrigin (Point3()) – A point used to compute distances against for ordering returned results. This is typically (but not necessarily) the center of the volume.

  • config (IncrementalPickConfig()) – The configuration object used for this selection operation.

Return type

Promise <IncrementalSelectionId()>

Returns

The handle for the selection context.

beginRayDrillSelection

SelectionManager.beginRayDrillSelection(rayCssOrigin, rayCssBoxRadius, config)

Creates a new and active selection context for the provided selection ray. The ray is created at the supplied ray origin and is cast into the scene. Faces are selected if they lie along the ray. Lines and points are selected if they lie within the ray’s box radius.

Note: Somewhat confusingly ray drill selection is actually a selection by volume. The provided ray origin and radius are used to create a frustum to preform the selection. This has some consequences. For example, the SelectionResults returned by advancing a ray drill selection will not have selection positions, since they were not selected at a single point.

Arguments
  • rayCssOrigin (Point2()) – The coordinate in css pixel space for the selection ray’s origin.

  • rayCssBoxRadius (number()) – The radius around the ray in css pixel space used for line and point selection proximity.

  • config (IncrementalPickConfig()) – The configuration object used for this selection operation.

Return type

Promise <IncrementalSelectionId()>

Returns

The handle for the selection context.

Note: Somewhat confusingly ray drill selection is actually a selection by volume. The provided ray origin and radius are used to create a frustum to preform the selection. This has some consequences. For example, the SelectionResults returned by advancing a ray drill selection will not have selection positions, since they were not selected at a single point.

beginScreenSelectByArea

SelectionManager.beginScreenSelectByArea(areaCssMin, areaCssMax, config)

Creates a new and active selection context for the provided selection window.

Arguments
  • areaCssMin (Point2()) – The minimum coordinate in css pixel space for the selection window.

  • areaCssMax (Point2()) – The maximum coordinate in css pixel space for the selection window.

  • config (IncrementalPickConfig()) – The configuration object used for this selection operation.

Return type

Promise <IncrementalSelectionId()>

Returns

The handle for the selection context.

beginSphereSelection

SelectionManager.beginSphereSelection(sphereCenter, sphereRadius, config)

Creates a new and active selection context for the provided selection sphere.

Arguments
  • sphereCenter (Point3()) – The center of the selection sphere.

  • sphereRadius (number()) – The radius of the selection sphere.

  • config (IncrementalPickConfig()) – The configuration object used for this selection operation.

Return type

Promise <IncrementalSelectionId()>

Returns

The handle for the selection context.

clear

SelectionManager.clear([triggerCallback])

Removes all items from the selection set.

Arguments
  • triggerCallback (boolean()) – optional triggers a null selection callback when true.

Return type

void

contains

SelectionManager.contains(item)
Arguments
Return type

boolean

containsParent

SelectionManager.containsParent(item)

Checks if the parent of a selection item is in the selection set.

Arguments
Return type

NodeSelectionItem() | null

Returns

parent selection item, or null if not found

each

SelectionManager.each(func)

Iterates over all selection items. The function passed in will be called once for every selection item and will receive the item as its parameter.

Arguments
  • func (function()) – a function to be called for every selection item.

Return type

void

SelectionManager.func(s)
Arguments
Return type

void

endIncrementalSelection

SelectionManager.endIncrementalSelection(handle)

Deactivates and destroys the provided selection context.

Arguments
Return type

DeprecatedPromise()

endVolumeSelection

SelectionManager.endVolumeSelection(handle)
Deprecated

Use endIncrementalSelection instead.

Arguments
Return type

DeprecatedPromise()

exportSelectionData

SelectionManager.exportSelectionData()

Exports selection objects so that they may be loaded back into the the system at a later time using loadSelectionData.

Return type

[Object]

Returns

exported selection data.

getFirst

SelectionManager.getFirst()

Gets the least recent selection item.

Return type

NodeSelectionItem() | null

Returns

the least recently selected item (if any).

getHighlightFaceElementSelection

SelectionManager.getHighlightFaceElementSelection()

Gets whether face elements will be highlighted on selection.

Return type

boolean

Returns

boolean the current value for face element selection highlighting.

getHighlightLineElementSelection

SelectionManager.getHighlightLineElementSelection()

Gets whether line elements will be highlighted on selection.

Return type

boolean

Returns

boolean the current value for line element selection highlighting.

getHighlightNodeSelection

SelectionManager.getHighlightNodeSelection()

Gets whether nodes will be highlighted on selection.

Return type

boolean

Returns

the current value for node selection highlighting.

getHighlightPointElementSelection

SelectionManager.getHighlightPointElementSelection()

Gets whether point elements will be highlighted on selection.

Return type

boolean

Returns

boolean the current value for point element selection highlighting.

getIgnoreEntityWhenTogglingChildSelection

SelectionManager.getIgnoreEntityWhenTogglingChildSelection()

Gets whether ignore entity when toggling child selection mode is enabled. See also: setIgnoreEntityWhenTogglingChildSelection

Return type

boolean

getLast

SelectionManager.getLast()

Gets the most recent selection item.

Return type

NodeSelectionItem() | null

Returns

the most recently selected item (if any).

getNodeElementSelectionColor

SelectionManager.getNodeElementSelectionColor()

Gets the color to use for face and line selection.

Return type

Color()

Returns

the color used for face and line selection.

getNodeElementSelectionHighlightMode

SelectionManager.getNodeElementSelectionHighlightMode()
Return type

SelectionHighlightMode

getNodeElementSelectionOutlineColor

SelectionManager.getNodeElementSelectionOutlineColor()

Gets the color to use for outlining face and line selection.

Return type

Color()

Returns

color the color used for outlining face and line selection.

getNodeSelectionColor

SelectionManager.getNodeSelectionColor()

Gets the color to be used when selecting nodes.

Return type

Color()

Returns

the color that is applied to a selected node.

getNodeSelectionHighlightMode

SelectionManager.getNodeSelectionHighlightMode()

Gets the highlighting mode for selected nodes.

Return type

SelectionHighlightMode

Returns

the current

getNodeSelectionOutlineColor

SelectionManager.getNodeSelectionOutlineColor()

Gets the color to be used for outlining the node selection.

Return type

Color()

Returns

the color for node selection outline.

getPickTolerance

SelectionManager.getPickTolerance()

Gets the pick tolerance in pixels for line and point picking.

The default value is 20.

Return type

number

Returns

number Pick tolerance value in pixels

The default value is 20.

getPruneSelectionDescendants

SelectionManager.getPruneSelectionDescendants()

Gets whether descendant pruning is enabled. See also: setPruneSelectionDescendants

Return type

boolean

getResult

SelectionManager.getResult(index)

Gets a selection at the specified index. The first selected item will be at index 0.

Arguments
  • index (number()) – index of selection item to get

Return type

NodeSelectionItem() | null

Returns

the selection result at the given index.

getResults

SelectionManager.getResults()

Gets all current selection items.

Return type

[NodeSelectionItem()]

Returns

array of all selection items.

getSelectParentIfSelected

SelectionManager.getSelectParentIfSelected()

Gets whether automatic parent selection is enabled. See also: setSelectParentIfSelected

Return type

boolean

getSelectedLayers

SelectionManager.getSelectedLayers()

Gets all selected layers.

Return type

[LayerName]

getSelectedTypes

SelectionManager.getSelectedTypes()

Gets all selected IFC types.

Return type

[GenericType]

getSelectionFilter

SelectionManager.getSelectionFilter()
Return type

SelectionFilter | null

Returns

SelectionFilter function or null if none is set.

getSingleEntityToggleModeEnabled

SelectionManager.getSingleEntityToggleModeEnabled()

Gets whether single entity toggle mode is enabled. See also: setSingleEntityToggleModeEnabled

Return type

boolean

getSuppressImplicitRemovalCallback

SelectionManager.getSuppressImplicitRemovalCallback()

Gets whether implicit removal callbacks are being suppressed See also: setSuppressImplicitRemovalCallback

Return type

boolean

isNodeSelected

SelectionManager.isNodeSelected(nodeId)

Checks whether a node, or its parents, appear in the selection set or not. Note: for the purposes of this function element selections on a node are considered the same as node selection.

Arguments
  • nodeId (NodeId) – Node to check for

Return type

boolean

Returns

true if the node or its parents appear in the selection set. false otherwise

isSelected

SelectionManager.isSelected(item)
Arguments
Return type

boolean

loadSelectionData

SelectionManager.loadSelectionData(datas)

Loads serialized selection items exported using exportSelectionData back into the SelectionManager The current selection will be cleared. A selection event will be triggered for each loaded item. This method should not be called before the CallbackMap.modelStructureReady callback has been triggered.

Arguments
  • datas ([Object] | string()) –

Return type

void

remove

SelectionManager.remove(itemOrItems[, suppressCallback])

Manually removes an item or an array of items from the selection set. Triggers a selection event.

Arguments
  • itemOrItems (NodeSelectionItem() | [NodeSelectionItem()]) – A selectionItem or an array of selection items that will be removed from the current selection set.

  • suppressCallback (boolean()) – optional Optional boolean param to suppress the selectionArray callbacks calls to this generate.

Return type

void

selectAllFromPoint

SelectionManager.selectAllFromPoint(point, config[, selectionMode])

Performs a selection operation from the given position on the canvas. All candidate entities are selected. This method triggers a selection event.

Arguments
  • point (Point2()) – The canvas position to select from.

  • config (PickConfig()) – The configuration object used for this picking operation.

  • selectionMode (SelectionMode) – optional The mode to use for this selection.

Return type

Promise <void>

Returns

Promise that resolves when this operation has completed.

selectAllFromRay

SelectionManager.selectAllFromRay(ray, config[, selectionMode])

Performs a selection operation from the given world-space ray. All candidate entities are selected. This method triggers a selection event.

Arguments
  • ray (Ray()) – The world-space ray to perform the selection with.

  • config (PickConfig()) – The configuration object used for this picking operation.

  • selectionMode (SelectionMode) – optional The mode to use for this selection.

Return type

Promise <void>

Returns

Promise that resolves when this operation has completed.

selectFromPoint

SelectionManager.selectFromPoint(point, config[, selectionMode])

Performs a selection operation from the given position on the canvas. The best candidate entity is selected. This method triggers a selection event.

Arguments
  • point (Point2()) – The canvas position to select from.

  • config (PickConfig()) – The configuration object used for this picking operation.

  • selectionMode (SelectionMode) – optional The mode to use for this selection.

Return type

Promise <void>

Returns

Promise that resolves when this operation has completed.

selectFromRay

SelectionManager.selectFromRay(ray, config[, selectionMode])

Performs a selection operation from the given world-space ray. The best candidate entity is selected. This method triggers a selection event.

Arguments
  • ray (Ray()) – The world-space ray to perform the selection with.

  • config (PickConfig()) – The configuration object used for this picking operation.

  • selectionMode (SelectionMode) – optional The mode to use for this selection.

Return type

Promise <void>

Returns

Promise that resolves when this operation has completed.

selectLayer

SelectionManager.selectLayer(layerName, selectionMode)

Adds all items in a layer to the selection set.

Arguments
Return type

void

selectNode

SelectionManager.selectNode(nodeId[, selectionMode])

Selects a node with the given Id.

Arguments
  • nodeId (NodeId | null) – nodeId of the node to select. Pass null to clear the selection.

  • selectionMode (SelectionMode) – optional

Return type

SelectionType

Returns

the selection type of this operation.

selectType

SelectionManager.selectType(genericType, selectionMode)

Adds all items with an IFC type to the selection set.

Arguments
Return type

void

set

SelectionManager.set(selection)

Manually removes all currently selected items (if any) from the selection set and adds the supplied item. Triggers a selection event.

Arguments
Return type

void

setHighlightFaceElementSelection

SelectionManager.setHighlightFaceElementSelection(highlightFaceElementSelection)

Sets whether face elements should be highlighted when a selection occurs. By default the system will automatically highlight face elements associated with a selection item.

Arguments
  • highlightFaceElementSelection (boolean()) – value indicating whether selected face elements should be highlighted.

Return type

DeprecatedPromise()

setHighlightLineElementSelection

SelectionManager.setHighlightLineElementSelection(highlightLineElementSelection)

Sets whether line elements should be highlighted when a selection occurs. By default the system will automatically highlight line elements associated with a selection item.

Arguments
  • highlightLineElementSelection (boolean()) – value indicating whether selected line elements should be highlighted.

Return type

DeprecatedPromise()

setHighlightNodeSelection

SelectionManager.setHighlightNodeSelection(highlightSelection)

Sets whether nodes should be highlighted when a selection occurs. By default, the system will automatically highlight the node associated with a selection item.

Arguments
  • highlightSelection (boolean()) –

Return type

DeprecatedPromise()

setHighlightPointElementSelection

SelectionManager.setHighlightPointElementSelection(highlightPointElementSelection)

Sets whether point elements should be highlighted when a selection occurs. By default the system will automatically highlight point elements associated with a selection item.

Arguments
  • highlightPointElementSelection (boolean()) – value indicating whether selected point elements should be highlighted.

Return type

DeprecatedPromise()

setIgnoreEntityWhenTogglingChildSelection

SelectionManager.setIgnoreEntityWhenTogglingChildSelection(strictMode)

Enables / disables ignore entity when toggling child selection mode.

When enabled, a Selection.NodeSelectionItem that has a selected ancestor may only be toggled if it does not contain an entity selection. A selection item without an entity selection is usually generated from selecting a node via a model tree control. A selection item containing an entity selection is usually generated as a result of a viewport picking operation.

This behavior is enabled by default. See Also: toggle

Arguments
  • strictMode (boolean()) –

Return type

void

When enabled, a Selection.NodeSelectionItem that has a selected ancestor may only be toggled if it does not contain an entity selection. A selection item without an entity selection is usually generated from selecting a node via a model tree control. A selection item containing an entity selection is usually generated as a result of a viewport picking operation.

This behavior is enabled by default. See Also: toggle

setNodeElementSelectionColor

SelectionManager.setNodeElementSelectionColor(color)

Sets the color to use for node element selection. This method should not be called before the sceneReady callback has been triggered.

Arguments
  • color (Color()) – the color to apply to selected node elements.

Return type

DeprecatedPromise()

setNodeElementSelectionHighlightMode

SelectionManager.setNodeElementSelectionHighlightMode(highlightMode)

Sets the highlighting mode for selected node elements. The default behavior is to highlight the node element and render an overlay outline. This method should not be called before the sceneReady callback has been triggered.

Arguments
Return type

DeprecatedPromise()

setNodeElementSelectionOutlineColor

SelectionManager.setNodeElementSelectionOutlineColor(color)

Gets the color to use for outlining node element selection. This method should not be called before the sceneReady callback has been triggered.

Arguments
  • color (Color()) – the color used for outlining face and line selection.

Return type

DeprecatedPromise()

setNodeSelectionColor

SelectionManager.setNodeSelectionColor(color)

Sets the color to be used when selecting nodes. This method should not be called before the sceneReady callback has been triggered.

Arguments
  • color (Color()) – the color to apply to the selected node.

Return type

DeprecatedPromise()

setNodeSelectionHighlightMode

SelectionManager.setNodeSelectionHighlightMode(highlightMode)

Sets the highlighting mode for selected nodes. The default behavior is to highlight the node and render an overlay outline. This method should not be called before the sceneReady callback has been triggered.

Arguments
Return type

DeprecatedPromise()

setNodeSelectionOutlineColor

SelectionManager.setNodeSelectionOutlineColor(color)

Sets color for the node selection outline. This method should not be called before the sceneReady callback has been triggered.

Arguments
  • color (Color()) – the color to apply to the node selection outline.

Return type

DeprecatedPromise()

setPickTolerance

SelectionManager.setPickTolerance(tolerance)

Sets the pick tolerance in pixels for line and point picking. If a line or point is within this pixel tolerance of the click point, it will be prioritized over the face at the click position.

The default value is 20.

Arguments
  • tolerance (number()) –

Return type

void

The default value is 20.

setPruneSelectionDescendants

SelectionManager.setPruneSelectionDescendants(pruneSelectionDescendants)

Enables / disables descendant pruning and clears the current selection set. When enabled, a parent and child will not be present in the same selection set. This behavior is enabled by default.

Arguments
  • pruneSelectionDescendants (boolean()) –

Return type

void

setSelectParentIfSelected

SelectionManager.setSelectParentIfSelected(selectParent)

Enables / disables automatic parent selection. When enabled, if a selected part is selected again, its parent will be selected. This behavior is enabled by default.

Arguments
  • selectParent (boolean()) –

Return type

void

setSelectionFilter

SelectionManager.setSelectionFilter(selectionFilter)

This allows manipulating the selected NodeId. To reset the filter, set it to null.

Arguments
  • selectionFilter (SelectionFilter | null) – function that manipulates the selected NodeId.

Return type

void

setSingleEntityToggleModeEnabled

SelectionManager.setSingleEntityToggleModeEnabled(enabled)

Enables / disables single entity toggle mode.

When enabled, limits the selection set to containing only one entity selection for each node id. Toggling with an entity selection that has the same node id as a Selection.NodeSelectionItem already in the selection set will remove that item from the selection set.

This behavior is disabled by default. See Also: toggle

Arguments
  • enabled (boolean()) –

Return type

void

When enabled, limits the selection set to containing only one entity selection for each node id. Toggling with an entity selection that has the same node id as a Selection.NodeSelectionItem already in the selection set will remove that item from the selection set.

This behavior is disabled by default. See Also: toggle

setSuppressImplicitRemovalCallback

SelectionManager.setSuppressImplicitRemovalCallback(suppress)

Sets whether to generate selectionArray callbacks with implicitly removed nodes.

For example, consider the case where you have a parent node that has a multiple child nodes. Normally, if the parent begins selected and then a child is removed from the selection set there will be two selectionArray callbacks generated. The first will for the removal of the parent node. The second wil be for the addition of all of it’s children except the one that was initially removed.

When this behavior is enabled only a single selectionArray callback will be generated for the child node that was removed.

This behavior is disabled by default.

Arguments
  • suppress (boolean()) –

Return type

void

For example, consider the case where you have a parent node that has a multiple child nodes. Normally, if the parent begins selected and then a child is removed from the selection set there will be two selectionArray callbacks generated. The first will for the removal of the parent node. The second wil be for the addition of all of it’s children except the one that was initially removed.

When this behavior is enabled only a single selectionArray callback will be generated for the child node that was removed.

This behavior is disabled by default.

size

SelectionManager.size()

Gets the number of selection items.

Return type

number

Returns

the number of selected items.

toggle

SelectionManager.toggle(item)

Manually adds or removes an item from the selection set. Triggers a selection event.

Arguments
Return type

void