Click or drag to resize
SoSelection Class

Manages a list of selected objects.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.2.2.0 (10.16.2.0)
Syntax
public class SoSelection : SoSeparator

The SoSelection type exposes the following members.

Constructors
  NameDescription
Public methodSoSelection

Creates a selection node with the default settings.

Public methodSoSelection(Int32)

Constructor that specifies the approximate number of children.

Top
Methods
  NameDescription
Public methodAddChild

Adds a child as last one in group.

(Inherited from SoGroup.)
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoSeparator.)
Public methodCallback
(Inherited from SoSeparator.)
Public methodClearCacheList
(Inherited from SoSeparator.)
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDeselect(Int32)

Deselects a path by removing it from the selection list.

Public methodDeselect(SoNode)

Deselects the passed node by creating a path to it, and removing the node from the selection list by calling deselect(path) .

Public methodDeselect(SoPath)

Deselects the passed path by removing it from the selection list.

Public methodDeselectAll

Deselects all paths in the selection list, that is, clear the list.

Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
(Inherited from SoSeparator.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodFindChild

Finds index of given child within group.

(Inherited from SoGroup.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoSeparator.)
Public methodGetChild

Returns pointer the child node with the given index.

(Inherited from SoGroup.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetList

Returns the list of selected paths.

Public methodGetMatrix
(Inherited from SoSeparator.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetNumChildren

Returns number of children.

(Inherited from SoGroup.)
Public methodGetNumSelected

Returns the number of paths in the selection list.

Public methodGetPath

Returns the ith path in the selection list.

Public methodGetPickRadius

Returns the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.

Public methodGetPrimitiveCount
(Inherited from SoSeparator.)
Public methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
(Inherited from SoSeparator.)
Public methodGLRenderBelowPath
(Inherited from SoSeparator.)
Public methodGLRenderInPath
(Inherited from SoSeparator.)
Public methodGLRenderOffPath
(Inherited from SoSeparator.)
Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodInsertChild

Adds a child so that it becomes the one with the given index.

(Inherited from SoGroup.)
Public methodIsBoundingBoxIgnoring

Used by BoundingBoxAction to known if bounding box computation should be ignored or not.

(Inherited from SoGroup.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override flag.

(Inherited from SoNode.)
Public methodIsPickMatching

Returns pick matching flag.

Public methodIsSelected(SoNode)

Returns true if the passed node is selected by creating a path to it, then calling OIV.Inventor.Nodes.SoSelection.IsSelected(OIV.Inventor.SoPath).

Public methodIsSelected(SoPath)

Returns true if the passed path is selected, that is, if it is in the selection list.

Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoGroup.)
Public methodRayPick
(Inherited from SoSeparator.)
Public methodRemoveAllChildren

Removes all children from group.

(Inherited from SoGroup.)
Public methodRemoveChild(Int32)

Removes child with given index from group.

(Inherited from SoGroup.)
Public methodRemoveChild(SoNode)

Removes first instance of given child from group.

(Inherited from SoGroup.)
Public methodReplaceChild(Int32, SoNode)

Replaces child with given index with new child.

(Inherited from SoGroup.)
Public methodReplaceChild(SoNode, SoNode)

Replaces first instance of given child with new child.

(Inherited from SoGroup.)
Public methodSearch
(Inherited from SoSeparator.)
Public methodSelect(SoNode)

Selects the passed node by creating a path to it, and adding the path to the selection list by calling select(path) .

Public methodSelect(SoPath)

Selects the passed path by adding it to the selection list.

Public methodSet

Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.

(Inherited from SoFieldContainer.)
Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Turns the override flag on or off.

(Inherited from SoNode.)
Public methodSetPickFilterCallback(SoSelectionPickCB)
Calls SetPickFilterCallback(f, true).
Public methodSetPickFilterCallback(SoSelectionPickCB, Boolean)

The pick filter callback is invoked when a pick has occurred and the selection node is about to change the selection list.

Public methodSetPickMatching

OIV.Inventor.Nodes.SoSelection will pick once on mouse down and once on mouse up, and make sure the picks match before changing the selection list.

Public methodSetPickRadius

Sets the radius (in pixels) around the viewport-space point through which the ray passes when doing ray picking.

Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToggle(SoNode)

Toggles the selection status of the passed node by creating a path to it, then calling toggle(path) .

Public methodToggle(SoPath)

Toggles the selection status of the passed path - if the path is in the selection list, it is removed; if not in the list, it is added.

Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoGroup.)
Top
Properties
  NameDescription
Public propertyboundingBoxCaching
(Inherited from SoSeparator.)
Public propertyboundingBoxIgnoring

Whether to ignore this node during bounding box traversal.

(Inherited from SoGroup.)
Public propertyfastEditing

Specifies the fast edit mode of the separator node.

(Inherited from SoSeparator.)
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyItem

Returns the ith path in the selection list.

Public propertypickCulling

Whether to cull during picking traversal.

(Inherited from SoSeparator.)
Public propertypolicy

Selection policy that is followed in response to user interaction.

Public propertyrenderCaching Obsolete.

Whether to cache during rendering traversal.

(Inherited from SoSeparator.)
Public propertyrenderCulling

Whether to cull during rendering traversal.

(Inherited from SoSeparator.)
Public propertyrenderUnitId

Used during the ScaleViz depth compositing process, this field specifies which render unit (OIRU) will render the sub scene graph below this separator.

(Inherited from SoSeparator.)
Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Events
Remarks

OIV.Inventor.Nodes.SoSelection defines a node which can be inserted into a scene graph and will generate and manage a selection list from picks on any node in the subgraph below it. Nodes are selected based on a current selection policy. Delegate functions report back to the application when a path has been selected or deselected. The selection list can also be managed programmatically.

OIV.Inventor.Nodes.SoSelection is convenient when the application just needs to know the path (OIV.Inventor.SoPath) to the objects that were selected (or deselected). OIV.Inventor.Nodes.SoSelection automatically does picking (applies an OIV.Inventor.Actions.SoRayPickAction), but it does not provide information about the picked point or pick details. For that see OIV.Inventor.Actions.SoRayPickAction, OIV.Inventor.Nodes.SoEventCallback and OIV.Inventor.Details.SoDetail. OIV.Inventor.Nodes.SoSelection does picking based on a single coordinate (the cursor position). The OIV.Inventor.Nodes.SoExtSelection node can do selection based on a lasso or rectangle drawn on the screen.

The selection callbacks are invoked every time an object is selected, whether from user interaction or from a method call. The callbacks are invoked after the object has been added to the selection list.

When handling events, by default OIV.Inventor.Nodes.SoSelection makes sure that the mouse release event was over the same object as the mouse press event before changing the list of selected objects. This allows users to mouse down on an object, change their mind and move the cursor off the object, then release the mouse button without altering the selection. See the OIV.Inventor.Nodes.SoSelection.SetPickMatching(System.Boolean) method.

The selection can be highlighted automatically by replacing the render area's render action with one of the specialized highlighting render actions, for example OIV.Inventor.Actions.SoHaloHighlightRenderAction. See the code example below. The application can also create a custom highlight action. See the chapter "Creating a Selection Highlight Style" in the Inventor Toolmaker Volume 1.

It is possible to use multiple OIV.Inventor.Nodes.SoSelection nodes in a scene graph, but there are a few things to keep in mind:

  • If two selection nodes could potentially select the same geometry, the geometry will be selected by the selection node lowest in the scene graph (the closest ancestor of the geometry).

  • The automatic viewer redraw on selection change (renderArea's redrawOnSelectionChange method) feature currently only works for a single selection node. You can work around this by calling renderArea's scheduleRedraw() method in a selection delegate.

  • The box and line highlighting render actions currently search for the first selection node in the scene graph and only highlight geometry selected by that selection node. You can work around this by creating a custom highlight action.

Instancing: When instance nodes of a OIV.Inventor.Nodes.SoMultipleInstance or a OIV.Inventor.Nodes.SoMultipleCopy group are selected, the application can get the instance identifier using the OIV.Inventor.SoPath method getInstanceIndex().

Hidden references:

OIV.Inventor.Nodes.SoSelection creates an OIV.Inventor.SoPath when an object is added to the selection list. The OIV.Inventor.SoPath references each node in the path, including the OIV.Inventor.Nodes.SoSelection node. This reference will prevent those nodes, including the OIV.Inventor.Nodes.SoSelection, from being reclaimed for as long as the OIV.Inventor.SoPath exists. The OIV.Inventor.SoPath exists until the object is deselected or the selection list is cleared. In general, the OIV.Inventor.Nodes.SoSelection.DeselectAll() method should be called when the OIV.Inventor.Nodes.SoSelection is no longer needed.

EXAMPLE

Create an OIV.Inventor.Nodes.SoSelection node, set a selection callback and add children.

SoSelection selectionNode = new SoSelection();
selectionNode.Selection   += selectionCB;
selectionNode.Deselection += deselectionCB;
selectionNode.AddChild(scene);

Enable automatic highlighting.

viewer.SetSceneGraph( selectionNode );
viewer.RedrawOnSelectionChange( selectionNode );
viewer.SetGLRenderAction( new SoHaloHighlightRenderAction() );

Implement the selection and deselection callbacks.

public void selectionCB(SoPath path)
{
   SoNode node = path.GetTail();
   Console.WriteLine("Selected {0}", node.GetType().Name);
}

public void deselectionCB(SoPath path)
{
   SoNode node = path.GetTail();
   Console.WriteLine("De-selected {0}", node.GetType().Name);
}

FILE FORMAT/DEFAULT

Selection {
boundingBoxCaching AUTO
renderCulling AUTO
pickCulling AUTO
policy SHIFT
fastEditing DISABLE
}

See Also