Open Inventor Reference
|
Manages a list of selected objects. More...
#include <Inventor/nodes/SoSelection.h>
Public Types | |
enum | Policy { SINGLE, TOGGLE, SHIFT } |
Selection policy. More... | |
Public Member Functions | |
SoSelection () | |
Creates a selection node with the default settings. | |
SoSelection (int nChildren) | |
Constructor that specifies the approximate number of children. | |
void | select (const SoPath *path) |
Select the passed path by adding it to the selection list. | |
void | select (SoNode *node) |
Select the passed node by creating a path to it, and adding the path to the selection list by calling select(path). | |
void | deselect (const SoPath *path) |
Deselect the passed path by removing it from the selection list. | |
void | deselect (int which) |
Deselect a path by removing it from the selection list. | |
void | deselect (SoNode *node) |
Deselect the passed node by creating a path to it, and removing the node from the selection list by calling deselect(path). | |
void | toggle (const SoPath *path) |
Toggle the selection status of the passed path em if the path is in the selection list, it is removed; if not in the list, it is added. | |
void | toggle (SoNode *node) |
Toggle the selection status of the passed node by creating a path to it, then calling toggle(path). | |
SbBool | isSelected (const SoPath *path) const |
returns TRUE if the path is selected | |
SbBool | isSelected (SoNode *node) const |
This convenience version of deselect will search for the first instance of the passed node under this selection node, and return whether that path is selected. | |
void | deselectAll () |
Deselect all paths in the selection list, that is, clear the list. | |
int | getNumSelected () const |
Return the number of paths in the selection list. | |
const SoPathList * | getList () const |
Return the list of selected paths. | |
SoPath * | getPath (int index) const |
Return the ith path in the selection list. | |
SoPath * | operator[] (int i) const |
[] indexes into the selection list | |
void | addSelectionCallback (SoSelectionPathCB *f, void *userData=NULL) |
The selection callbacks are invoked every time an object is selected, whether it be from user interaction or from method call. | |
void | removeSelectionCallback (SoSelectionPathCB *f, void *userData=NULL) |
Remove selection callback. | |
void | addDeselectionCallback (SoSelectionPathCB *f, void *userData=NULL) |
The deselection callbacks are invoked every time an object is deselected, whether it be from user interaction or from method call. | |
void | removeDeselectionCallback (SoSelectionPathCB *f, void *userData=NULL) |
Remove deselection callback. | |
void | addStartCallback (SoSelectionClassCB *f, void *userData=NULL) |
The start callbacks are invoked when the user has initiated an interactive change to the selection list (by picking objects). | |
void | removeStartCallback (SoSelectionClassCB *f, void *userData=NULL) |
Remove the start callback. | |
void | addFinishCallback (SoSelectionClassCB *f, void *userData=NULL) |
The finish callbacks are invoked when the user has finished interactively changing the selection list (by picking objects). | |
void | removeFinishCallback (SoSelectionClassCB *f, void *userData=NULL) |
Remove finish callback. | |
void | 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. | |
void | setPickMatching (SbBool pickTwice) |
SoSelection will pick once on mouse down and once on mouse up, and make sure the picks match before changing the selection list. | |
SbBool | isPickMatching () const |
Returns if pick matching is on. | |
SbBool | getPickMatching () const |
Returns if pick matching is on. | |
void | addChangeCallback (SoSelectionClassCB *f, void *userData=NULL) |
Selection notify callbacks - invoked whenever the selection changes. | |
void | removeChangeCallback (SoSelectionClassCB *f, void *userData=NULL) |
Static Public Member Functions | |
static void | initClass () |
Internal: | |
Public Attributes | |
Fields | |
SoSFEnum | policy |
Selection policy that is followed in response to user interaction. | |
Protected Member Functions | |
void | invokeSelectionPolicy (SoPath *path, SbBool shiftDown) |
Selection policies (shiftSelection is a combination of these) invokeSelectionPolicy() is called from handleEvent() - for a customized selection policy, either derive a class and write a new handleEvent() method, or use an SoEventCallback node placed such that it receives events before the selection node. | |
void | performSingleSelection (SoPath *path) |
void | performToggleSelection (SoPath *path) |
SoPath * | copyFromThis (const SoPath *path) const |
This copies the path so the copy is rooted by 'this'. | |
void | addPath (SoPath *path) |
addPath() assumes the path is rooted by 'this' | |
void | removePath (int which) |
int | findPath (const SoPath *path) const |
This locates path in the selection list. | |
virtual void | handleEvent (SoHandleEventAction *action) |
Traversal routine for SoHandleEventAction - this will call action->setHandled() if the event is handled. | |
~SoSelection () | |
Destructor removes everything from the list. | |
Protected Attributes | |
SoPathList | selectionList |
List of paths of selected objects. | |
SoCallbackList * | selCBList |
Selection callback lists. | |
SoCallbackList * | deselCBList |
SoCallbackList * | startCBList |
SoCallbackList * | finishCBList |
SoSelectionPickCB * | pickCBFunc |
Pick filter is a single callback function, not a list. | |
void * | pickCBData |
SbBool | callPickCBOnlyIfSelectable |
SoCallbackList * | changeCBList |
Change callbacks. | |
SoPath * | mouseDownPickPath |
Mouse down picked path. | |
SbBool | pickMatching |
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. Callback functions report back to the application when a path has been selected or deselected. The selection list can also be managed programmatically.
When handling events, 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.
The selection can be highlighted automatically through the SoQtRenderArea, or the application can provide custom highlights. Please see the chapter "Creating a Selection Highlight Style" in the Inventor Toolmaker.
Selection { renderCaching AUTO boundingBoxCaching AUTO renderCulling AUTO pickCulling AUTO policy SHIFT }
Definition at line 125 of file SoSelection.h.
enum SoSelection::Policy |
---------------- Default selection policy is SoSelection::SHIFT.
Definition at line 142 of file SoSelection.h.
SoSelection::SoSelection | ( | ) |
SoSelection::SoSelection | ( | int | nChildren | ) |
SoSelection::~SoSelection | ( | ) | [protected] |
void SoSelection::addChangeCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
Used by the render area to redraw for selection highlighting.
void SoSelection::addDeselectionCallback | ( | SoSelectionPathCB * | f, |
void * | userData = NULL |
||
) |
This is invoked after the object has been removed from the selection list.
void SoSelection::addFinishCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
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::addPath | ( | SoPath * | path | ) | [protected] |
void SoSelection::addSelectionCallback | ( | SoSelectionPathCB * | f, |
void * | userData = NULL |
||
) |
The callbacks are invoked after the object has been added to the selection list.
void SoSelection::addStartCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
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.
Returns NULL if 'this' not found in the passed path.
void SoSelection::deselect | ( | int | which | ) |
The argument which
specifies which path in the list to be removed.
void SoSelection::deselect | ( | SoNode * | node | ) |
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 | ( | const SoPath * | path | ) |
void SoSelection::deselectAll | ( | ) |
int SoSelection::findPath | ( | const SoPath * | path | ) | const [protected] |
The head of this path does not necessarily have to be 'this'.
const SoPathList* SoSelection::getList | ( | ) | const [inline] |
Definition at line 221 of file SoSelection.h.
int SoSelection::getNumSelected | ( | ) | const [inline] |
Definition at line 219 of file SoSelection.h.
SoPath* SoSelection::getPath | ( | int | index | ) | const |
SbBool SoSelection::getPickMatching | ( | ) | const [inline] |
Definition at line 331 of file SoSelection.h.
virtual void SoSelection::handleEvent | ( | SoHandleEventAction * | action | ) | [protected, virtual] |
Reimplemented from SoSeparator.
static void SoSelection::initClass | ( | ) | [static] |
Reimplemented from SoSeparator.
SbBool SoSelection::isPickMatching | ( | ) | const [inline] |
Definition at line 329 of file SoSelection.h.
SoPath* SoSelection::operator[] | ( | int | i | ) | const [inline] |
Definition at line 226 of file SoSelection.h.
void SoSelection::performSingleSelection | ( | SoPath * | path | ) | [protected] |
void SoSelection::performToggleSelection | ( | SoPath * | path | ) | [protected] |
void SoSelection::removeChangeCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
void SoSelection::removeDeselectionCallback | ( | SoSelectionPathCB * | f, |
void * | userData = NULL |
||
) |
void SoSelection::removeFinishCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
void SoSelection::removePath | ( | int | which | ) | [protected] |
void SoSelection::removeSelectionCallback | ( | SoSelectionPathCB * | f, |
void * | userData = NULL |
||
) |
void SoSelection::removeStartCallback | ( | SoSelectionClassCB * | f, |
void * | userData = NULL |
||
) |
void SoSelection::select | ( | SoNode * | node | ) |
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 | ) |
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 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 em 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 em 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 em apply the selection policy as if nothing was picked. Handle event action traversal continues.
[d] Path not passing through the selection node em 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] |
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.
Definition at line 327 of file SoSelection.h.
void SoSelection::toggle | ( | const SoPath * | path | ) |
void SoSelection::toggle | ( | SoNode * | node | ) |
If there is more than one instance of node
beneath the selection node, the created path will be the first instance found.
SbBool SoSelection::callPickCBOnlyIfSelectable [protected] |
Definition at line 355 of file SoSelection.h.
SoCallbackList* SoSelection::changeCBList [protected] |
Definition at line 358 of file SoSelection.h.
SoCallbackList* SoSelection::deselCBList [protected] |
Definition at line 348 of file SoSelection.h.
SoCallbackList* SoSelection::finishCBList [protected] |
Definition at line 350 of file SoSelection.h.
SoPath* SoSelection::mouseDownPickPath [protected] |
Definition at line 361 of file SoSelection.h.
void* SoSelection::pickCBData [protected] |
Definition at line 354 of file SoSelection.h.
SoSelectionPickCB* SoSelection::pickCBFunc [protected] |
Definition at line 353 of file SoSelection.h.
SbBool SoSelection::pickMatching [protected] |
Definition at line 362 of file SoSelection.h.
This can be set to SoSelection::SINGLE
, SoSelection::TOGGLE
, or SoSelection::SHIFT
.
Definition at line 165 of file SoSelection.h.
SoCallbackList* SoSelection::selCBList [protected] |
Definition at line 347 of file SoSelection.h.
SoPathList SoSelection::selectionList [protected] |
Definition at line 344 of file SoSelection.h.
SoCallbackList* SoSelection::startCBList [protected] |
Definition at line 349 of file SoSelection.h.