Main Page Modules Class Hierarchy Alphabetical List Compound List File List Compound Members
SoSelection Class Reference
The SoSelection class manages a list of selected nodes.
More...
#include <Inventor/nodes/SoSelection.h>
Inheritance diagram for SoSelection::
List of all members.
Public Types |
enum | Policy { SINGLE,
TOGGLE,
SHIFT
} |
Public Methods |
| SoSelection (void) |
| SoSelection (const int nChildren) |
void | select (const SoPath *path) |
void | select (SoNode *node) |
void | deselect (const SoPath *path) |
void | deselect (const 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 |
void | deselectAll (void) |
int | getNumSelected (void) const |
const SoPathList * | getList (void) const |
SoPath * | getPath (const int index) const |
SoPath * | operator[] (const int i) 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, const SbBool callOnlyIfSelectable=TRUE) |
void | setPickMatching (const SbBool pickMatching) |
SbBool | isPickMatching (void) const |
SbBool | getPickMatching (void) const |
void | addChangeCallback (SoSelectionClassCB *f, void *userData=NULL) |
void | removeChangeCallback (SoSelectionClassCB *f, void *userData=NULL) |
Static Public Methods |
void | initClass (void) |
Public Attributes |
SoSFEnum | policy |
Protected Methods |
virtual | ~SoSelection () |
void | invokeSelectionPolicy (SoPath *path, SbBool shiftDown) |
void | performSingleSelection (SoPath *path) |
void | performToggleSelection (SoPath *path) |
SoPath * | copyFromThis (const SoPath *path) const |
void | addPath (SoPath *path) |
void | removePath (const int which) |
int | findPath (const SoPath *path) const |
virtual void | handleEvent (SoHandleEventAction *action) |
Protected Attributes |
SoPathList | selectionList |
SoCallbackList * | selCBList |
SoCallbackList * | deselCBList |
SoCallbackList * | startCBList |
SoCallbackList * | finishCBList |
SoSelectionPickCB * | pickCBFunc |
void * | pickCBData |
SbBool | callPickCBOnlyIfSelectable |
SoCallbackList * | changeCBList |
SoPath * | mouseDownPickPath |
SbBool | pickMatching |
Detailed Description
The SoSelection class manages a list of selected nodes.
Inserting an SoSelection node in your scene graph enables you to let the user "pick" with the left mousebutton to select/deselect objects below the SoSelection node.
Using an SoBoxHighlightRenderAction or an SoLineHighlightRenderAction to render scenegraphs containing SoSelection nodes provides a convenient way of providing visual feedback about the selections to the application user.
Beware that one common faulty assumption which is made about the node is that the scene will automatically be re-rendered whenever the user pick objects. This is not the case, the application programmer must himself schedule a redraw. A straightforward way to accomplish this is to SoNode::touch() the SoSelection node in the selection / deselection callback.
A "skeleton" for basic use of SoSelection nodes is given below:
extern SoSeparator * make_scenegraph( void );
static SoSelection * selection = NULL;
void made_selection( void * userdata, SoPath * path )
{
(void)fprintf( stdout, "%sselected %s\n",
userdata == (void *)1L ? "" : "de",
path->getTail()->getTypeId().getName().getString() );
selection->touch();
}
void show_instructions( void )
{
(void)fprintf( stdout, "\nThis example program demonstrates the use of the SoSelection node type.\n" );
(void)fprintf( stdout, "\nQuick instructions:\n\n" );
(void)fprintf( stdout, " * pick with left mouse button\n" );
(void)fprintf( stdout, " * hold SHIFT to select multiple objects\n" );
(void)fprintf( stdout, " * hit ESC to toggle back and forth to view mode\n" );
(void)fprintf( stdout, "\n" );
}
int main( int argc, char ** argv )
{
QWidget * window = SoQt::init( argv[0] );
show_instructions();
selection = new SoSelection;
selection->policy = SoSelection::SHIFT;
selection->ref();
selection->addChild( make_scenegraph() );
selection->addSelectionCallback( made_selection, (void *)1L );
selection->addDeselectionCallback( made_selection, (void *)0L );
SoQtExaminerViewer * examinerviewer = new SoQtExaminerViewer( window );
examinerviewer->setSceneGraph( selection );
examinerviewer->setGLRenderAction( new SoBoxHighlightRenderAction );
examinerviewer->setViewing( FALSE );
examinerviewer->show();
SoQt::show( window );
SoQt::mainLoop();
delete examinerviewer;
selection->unref();
return 0;
}
This node is not initialized in SoDB::init(), since it is part of the interaction kit "add-on". Before using this node, you should therefore call SoInteraction::initClass(). If you're using one of the standard GUI-toolkits (SoXt / SoQt / SoGtk / SoWin) SoInteraction::initClass() will be called for you from the So[Xt|Qt|Gtk|Win]init() method and you don't have to worry about it.
Member Enumeration Documentation
|
Enum for different pick policies. -
Enumeration values:
-
SINGLE
|
Only one object can be selected at any time. When the user picks a new object, the previous selection will be unselected. If the user picks on nothing, the current selection will be unselected. |
TOGGLE
|
Picking an object toggles its selection state. |
SHIFT
|
Same as SINGLE, but when shift key is pressed the selection policy will be changed to TOGGLE. |
|
Constructor & Destructor Documentation
SoSelection::SoSelection
|
(  |
void |
|
) |
|
|
SoSelection::SoSelection
|
(  |
const int |
nChildren |
) |
|
|
|
Constructor.
The argument should be the approximate number of children which is expected to be inserted below this node. The number need not be exact, as it is only used as a hint for better memory resource allocation. |
SoSelection::~SoSelection
|
(  |
|
) |
[protected, virtual] |
|
Member Function Documentation
void SoSelection::initClass
|
(  |
void |
|
) |
[static] |
|
|
Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system.
Reimplemented from SoSeparator.
Reimplemented in SoExtSelection. |
void SoSelection::select
|
(  |
const SoPath * |
path |
) |
|
|
|
Adds path to the list of selected objects. |
void SoSelection::select
|
(  |
SoNode * |
node |
) |
|
|
|
Adds node to the list of selected objects. The scene graph below the Selection node will be searched, and the path to node will be added if found. |
void SoSelection::deselect
|
(  |
const SoPath * |
path |
) |
|
|
|
Remove path from the list of selected objects. |
void SoSelection::deselect
|
(  |
const int |
which |
) |
|
|
|
Remove objects which from the list of selected objects. |
void SoSelection::deselect
|
(  |
SoNode * |
node |
) |
|
|
|
Remove node from the list of selected objects. The scene graph below the Selection node will be searched, and the path to node will be removed if found. |
void SoSelection::toggle
|
(  |
const SoPath * |
path |
) |
|
|
|
If path is not already selected, add path to the list of selected objects. Otherwise remove path from the list of selected objects. |
void SoSelection::toggle
|
(  |
SoNode * |
node |
) |
|
|
|
If node is not already selected, add path to the list of selected objects. Otherwise remove node from the list of selected objects. |
SbBool SoSelection::isSelected
|
(  |
const SoPath * |
path |
) |
const |
|
|
Return TRUE if path is in the list of selected objects. |
|
Return TRUE if the path to node is in the list of selected objects. |
void SoSelection::deselectAll
|
(  |
void |
|
) |
|
|
|
Clears the selection list. |
int SoSelection::getNumSelected
|
(  |
void |
|
) |
const |
|
|
Returns the number of selected objects. |
const SoPathList * SoSelection::getList
|
(  |
void |
|
) |
const |
|
|
Returns the list of selected objects. |
SoPath * SoSelection::getPath
|
(  |
const int |
index |
) |
const |
|
|
Returns the index'th selected objects. |
SoPath * SoSelection::operator[]
|
(  |
const int |
i |
) |
const |
|
|
Operator for accessing selected objects. |
void SoSelection::addSelectionCallback
|
(  |
SoSelectionPathCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::removeSelectionCallback
|
(  |
SoSelectionPathCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::addDeselectionCallback
|
(  |
SoSelectionPathCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::removeDeselectionCallback
|
(  |
SoSelectionPathCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
|
Removes one of the deselection callbacks.
-
See also:
-
addDeselctionCallback()
|
void SoSelection::addStartCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
|
Adds a callback which will be invoked when the user start an interactive change to the list of selected objects.
This callback is useful for storing the old selection list for undo/redo functionality.
-
See also:
-
addFinishCallback()
|
void SoSelection::removeStartCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::addFinishCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
|
Adds a callback which will be invoked when the user has finished an interactive change to the list of selected objects.
-
See also:
-
addStartCallback()
|
void SoSelection::removeFinishCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::setPickFilterCallback
|
(  |
SoSelectionPickCB * |
f, |
|
|
|
|
|
void * |
userData = NULL, |
|
|
|
|
|
const SbBool |
callOnlyIfSelectable = TRUE |
|
)  |
|
|
|
Sets the pick filter callback. This callback will be called when a path is about to be added to or removed from the list of selected objects. The callback function should return a replacement path that should be used instead of the picked path. If no callback is set (the default), the picked path will be used for selecting/deselecting.
Possible return values from the callback:
- NULL: simulate that nothing was picked. This will clear the selection for the SINGLE policy. The handle event action will be halted.
- A path: the path will be selected/deselected. The handle event action will be halted.
- A path containing only the Selection node: as NULL, but action will not be halted.
- An empty path or a path not containing the Selection node: the pick will be ignored.
if callOnlyIfSelectable is TRUE, the callback will only be called if the Selection node is in the picked path. |
void SoSelection::setPickMatching
|
(  |
const SbBool |
pickMatching |
) |
|
|
|
When pickMatching is TRUE (the default), the mouse button release pick must match the mouse button press pick before object is selected/deselected. |
SbBool SoSelection::isPickMatching
|
(  |
void |
|
) |
const |
|
SbBool SoSelection::getPickMatching
|
(  |
void |
|
) |
const |
|
void SoSelection::addChangeCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
|
\internal. Used by render area to receive notification when the selection list changes. |
void SoSelection::removeChangeCallback
|
(  |
SoSelectionClassCB * |
f, |
|
|
|
|
|
void * |
userData = NULL |
|
)  |
|
|
void SoSelection::invokeSelectionPolicy
|
(  |
SoPath * |
path, |
|
|
|
|
|
SbBool |
shiftdown |
|
)  |
[protected] |
|
void SoSelection::performSingleSelection
|
(  |
SoPath * |
path |
) |
[protected] |
|
void SoSelection::performToggleSelection
|
(  |
SoPath * |
path |
) |
[protected] |
|
SoPath * SoSelection::copyFromThis
|
(  |
const SoPath * |
path |
) |
const [protected] |
|
void SoSelection::addPath
|
(  |
SoPath * |
path |
) |
[protected] |
|
void SoSelection::removePath
|
(  |
const int |
which |
) |
[protected] |
|
int SoSelection::findPath
|
(  |
const SoPath * |
path |
) |
const [protected] |
|
Member Data Documentation
|
Field for selection policy. Default value is SHIFT. |
SoSelectionPickCB * SoSelection::pickCBFunc [protected]
|
|
void * SoSelection::pickCBData [protected]
|
|
SbBool SoSelection::callPickCBOnlyIfSelectable [protected]
|
|
SoPath * SoSelection::mouseDownPickPath [protected]
|
|
SbBool SoSelection::pickMatching [protected]
|
|
The documentation for this class was generated from the following files:
Generated at Tue Mar 5 03:31:30 2002 for Coin by
1.2.9 written by Dimitri van Heesch,
© 1997-2001