SoSelection Class Reference
[Groups]

Manages a list of selected objects. More...

#include <Inventor/nodes/SoSelection.h>

Inheritance diagram for SoSelection:
SoSeparator SoGroup SoNode SoFieldContainer SoBase SoRefCounter SoTypedObject SoExtSelection

List of all members.

Public Types

enum  Policy {
  SINGLE,
  TOGGLE,
  SHIFT,
  DISABLE
}

Public Member Functions

virtual SoType getTypeId () const
 SoSelection ()
 SoSelection (int nChildren)
void select (const SoPath *path)
void select (SoNode *node)
void deselect (const SoPath *path)
void deselect (int which)
void deselect (SoNode *node)
void toggle (const SoPath *path)
void toggle (SoNode *node)
SbBool isSelected (const SoPath *path) const
SbBool isSelected (SoNode *node) const
SbBool isSelected (const SoNode *node) const
void deselectAll ()
int getNumSelected () const
const SoPathListgetList () const
SoPathgetPath (int index) const
SoPathoperator[] (int i) const
void setPickRadius (float radiusInPixels)
float getPickRadius () const
void addSelectionCallback (SoSelectionPathCB *f, void *userData=NULL)
void removeSelectionCallback (SoSelectionPathCB *f, void *userData=NULL)
void addDeselectionCallback (SoSelectionPathCB *f, void *userData=NULL)
void removeDeselectionCallback (SoSelectionPathCB *f, void *userData=NULL)
void addStartCallback (SoSelectionClassCB *f, void *userData=NULL)
void removeStartCallback (SoSelectionClassCB *f, void *userData=NULL)
void addFinishCallback (SoSelectionClassCB *f, void *userData=NULL)
void removeFinishCallback (SoSelectionClassCB *f, void *userData=NULL)
void setPickFilterCallback (SoSelectionPickCB *f, void *userData=NULL, SbBool callOnlyIfSelectable=TRUE)
void setPickMatching (SbBool pickTwice)
SbBool isPickMatching () const

Static Public Member Functions

static SoType getClassTypeId ()

Public Attributes

SoSFEnum policy

Detailed Description

Manages a list of selected objects.

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. Callbacks report back to the application when a path has been selected or deselected. The selection list can also be managed programmatically.

SoSelection is convenient when the application just needs to know the path (SoPath) to the objects that were selected (or deselected). SoSelection automatically does picking (applies an SoRayPickAction), but it does not provide information about the picked point or pick details. For that see SoRayPickAction, SoEventCallback and SoDetail. SoSelection does picking based on a single coordinate (the cursor position). The 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 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 setPickMatching 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 SoBoxHighlightRenderAction. 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 SoSelection nodes in a scene graph, but there are a few things to keep in mind:

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

Hidden references:

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

EXAMPLE

FILE FORMAT/DEFAULT

SEE ALSO

SoEventCallback, SoWinRenderArea, SoBoxHighlightRenderAction, SoLineHighlightRenderAction


Member Enumeration Documentation

Enumerator:
SINGLE 

Picking an object object clears current selection, then selects object.

Picking on nothing clears current selection. Only one object may be selected at a time.

TOGGLE 

Picking an object toggles its selection status.

Picking on nothing does nothing. Multiple objects may be selected.

SHIFT 

When shift key is down, selection policy is TOGGLE.

When shift key is up, selection policy is SINGLE. Multiple objects may be selected.

DISABLE 

Disable selection (behave like a normal SoSeparator).


Constructor & Destructor Documentation

SoSelection::SoSelection (  ) 

Creates a selection node with the default settings.

SoSelection::SoSelection ( int  nChildren  ) 

Constructor that specifies the approximate number of children.


Member Function Documentation

void SoSelection::addDeselectionCallback ( SoSelectionPathCB f,
void *  userData = NULL 
)

Adds deselection callback.

The deselection callbacks are invoked every time an object is deselected, whether it be from user interaction or from method call. This is invoked after the object has been removed from the selection list.

void SoSelection::addFinishCallback ( SoSelectionClassCB f,
void *  userData = NULL 
)

Adds finish callback.

The finish callbacks are invoked when the user has finished interactively changing the selection list (by picking objects). This was preceded by an invocation of each start callback, and invocations of the select and/or deselect callbacks. The finish callbacks are not called when the selection list is changed programmatically.

void SoSelection::addSelectionCallback ( SoSelectionPathCB f,
void *  userData = NULL 
)

Adds selection callback.

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

void SoSelection::addStartCallback ( SoSelectionClassCB f,
void *  userData = NULL 
)

Adds start callback.

The start callbacks are invoked when the user has initiated an interactive change to the selection list (by picking objects). This will be followed by invocations of the select and/or deselect callbacks, finally followed by each finish callback. A start callback can be used, for instance, to save the current selection for later restoration (e.g. undo/redo). The start callbacks are not called when the selection list is changed programmatically.

void SoSelection::deselect ( SoNode node  ) 

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

If there is more than one instance of node beneath the selection node, the created path will be the first instance found.

void SoSelection::deselect ( int  which  ) 

Deselects a path by removing it from the selection list.

The argument which specifies which path in the list to be removed.

void SoSelection::deselect ( const SoPath path  ) 

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

void SoSelection::deselectAll (  ) 

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

static SoType SoSelection::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoSeparator.

Reimplemented in SoExtSelection.

const SoPathList* SoSelection::getList (  )  const [inline]

Returns the list of selected paths.

int SoSelection::getNumSelected (  )  const [inline]

Returns the number of paths in the selection list.

SoPath* SoSelection::getPath ( int  index  )  const

Returns the ith path in the selection list.

float SoSelection::getPickRadius (  )  const [inline]

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

virtual SoType SoSelection::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Reimplemented from SoSeparator.

Reimplemented in SoExtSelection.

SbBool SoSelection::isPickMatching (  )  const [inline]

Returns pick matching flag.

SbBool SoSelection::isSelected ( const SoNode node  )  const

Returns TRUE if the passed node is selected by creating a path to it, then calling isSelected().

If there is more than one instance of node beneath the selection node, the created path will be the first instance found.

SbBool SoSelection::isSelected ( SoNode node  )  const

Returns TRUE if the passed node is selected by creating a path to it, then calling isSelected().

If there is more than one instance of node beneath the selection node, the created path will be the first instance found.

SbBool SoSelection::isSelected ( const SoPath path  )  const

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

SoPath* SoSelection::operator[] ( int  i  )  const [inline]

Returns the ith path in the selection list.

void SoSelection::removeDeselectionCallback ( SoSelectionPathCB f,
void *  userData = NULL 
)

Removes deselection callback.

The deselection callbacks are invoked every time an object is deselected, whether it be from user interaction or from method call. This is invoked after the object has been removed from the selection list.

void SoSelection::removeFinishCallback ( SoSelectionClassCB f,
void *  userData = NULL 
)

Removes finish callback.

The finish callbacks are invoked when the user has finished interactively changing the selection list (by picking objects). This was preceded by an invocation of each start callback, and invocations of the select and/or deselect callbacks. The finish callbacks are not called when the selection list is changed programmatically.

void SoSelection::removeSelectionCallback ( SoSelectionPathCB f,
void *  userData = NULL 
)

Removes selection callback.

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

void SoSelection::removeStartCallback ( SoSelectionClassCB f,
void *  userData = NULL 
)

Removes start callback.

The start callbacks are invoked when the user has initiated an interactive change to the selection list (by picking objects). This will be followed by invocations of the select and/or deselect callbacks, finally followed by each finish callback. A start callback can be used, for instance, to save the current selection for later restoration (e.g. undo/redo). The start callbacks are not called when the selection list is changed programmatically.

void SoSelection::select ( SoNode node  ) 

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

If there is more than one instance of node beneath the selection node, the created path will be the first instance found.

void SoSelection::select ( const SoPath path  ) 

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

The selection node must lie in the path. The path is copied and truncated such that the selection node is the head of the path. If the selection node does not lie in the path, the selection list remains unchanged. This method ignores the current selection policy.

void SoSelection::setPickFilterCallback ( SoSelectionPickCB f,
void *  userData = NULL,
SbBool  callOnlyIfSelectable = TRUE 
)

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

The callback function returns the path that the selection node should use when selecting and deselecting. If no pick callback is registered (the default), the selection node will use the path returned by SoPickedPoint::getPath() on the picked point associated with the event being processed. The returned path should not be ref'd - selection will ref() and unref() it. (See SoPath::unrefNoDelete().)

Note that a picked object may or may not be a child of the selection node. A selection node will only select paths that pass through it. Possible return values from the callback:

[a] NULL - selection behaves as if nothing was picked (i.e. for SINGLE and SHIFT policies, this clears the selection list). Handle event action traversal halts.

[b] Path - this path will be selected/deselected according to the selection policy (it must lie under the selection node). Handle event action traversal halts.

[c] Path containing only the selection node - apply the selection policy as if nothing was picked. Handle event action traversal continues.

[d] Path not passing through the selection node - selection ignores this pick event and no change is made to the selection list. Handle event action traversal continues.

A simple way to tell selection to ignore the pick is to return an SoPath with no nodes in it. (i.e. return new SoPath; ) Selection will always ref the path returned by the callback, make a copy of the path, then unref the path.

The callOnlyIfSelectable argument, when set to TRUE, means the pick callback function will only be invoked on picks which pass through the selection node. When FALSE, all picks will be passed to the callback whether they pass through the selection or not.

void SoSelection::setPickMatching ( SbBool  pickTwice  )  [inline]

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

This allows the user to pick down on an object, change their mind and drag off the object, release the mouse button and not affect the selection. Pass TRUE to enable this behavior. Pass FALSE to disable this, meaning whatever is picked on a mouse release is added to/removed from the selection list. Default is pick-matching on.

void SoSelection::setPickRadius ( float  radiusInPixels  )  [inline]

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

Ray picking is performed when getPickedPoint() is called. The pick radius set here is only used when testing the ray against lines and points.

void SoSelection::toggle ( SoNode node  ) 

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

If there is more than one instance of node beneath the selection node, the created path will be the first instance found.

void SoSelection::toggle ( const SoPath path  ) 

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.


Member Data Documentation

Selection policy that is followed in response to user interaction.

Use enum Policy. Default is SHIFT.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 12 Feb 2024
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/