Provided by: libcoin80-doc_3.1.4~abc9f50-4ubuntu2_all bug

NAME

       SoSelection -

       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.

SYNOPSIS

       #include <Inventor/nodes/SoSelection.h>

       Inherits SoSeparator.

       Inherited by SoExtSelection.

   Public Types
       enum Policy { SINGLE, TOGGLE, SHIFT }

   Public Member Functions
       virtual SoType getTypeId (void) const
           Returns the type identification of an object derived from a class inheriting SoBase.
           This is used for run-time type checking and 'downward' casting.
       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 Member Functions
       static SoType getClassTypeId (void)
       static void initClass (void)

   Public Attributes
       SoSFEnum policy

   Protected Member Functions
       virtual const SoFieldData * getFieldData (void) const
       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)

   Static Protected Member Functions
       static const SoFieldData ** getFieldDataPtr (void)

   Protected Attributes
       SoPathList selectionList
       SoCallbackList * selCBList
       SoCallbackList * deselCBList
       SoCallbackList * startCBList
       SoCallbackList * finishCBList
       SoSelectionPickCB * pickCBFunc
       void * pickCBData
       SbBool callPickCBOnlyIfSelectable
       SoCallbackList * changeCBList
       SoPath * mouseDownPickPath
       SbBool pickMatching

   Additional Inherited Members

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;

       // Callback function triggered for selection / deselection.
       void made_selection( void * userdata, SoPath * path )
       {
         (void)fprintf( stdout, "%sselected %s0,
                        userdata == (void *)1L ? "" : "de",
                        path->getTail()->getTypeId().getName().getString() );

         selection->touch(); // to redraw
       }

       // *************************************************************************

       // Print a quick instructions notice on stdout.
       void show_instructions( void )
       {
         (void)fprintf( stdout, "0his example program demonstrates the use of the SoSelection node type.0 );
         (void)fprintf( stdout, "0uick instructions:0 );
         (void)fprintf( stdout, "  * pick with left mouse button0 );
         (void)fprintf( stdout, "  * hold SHIFT to select multiple objects0 );
         (void)fprintf( stdout, "  * hit ESC to toggle back and forth to view mode0 );
         (void)fprintf( stdout, "0 );
       }

       // *************************************************************************

       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::init(). If
       you're using one of the standard GUI-toolkits (SoXt / SoQt / SoWin) SoInteraction::init()
       will be called for you from the So[Xt|Qt|Win]::init() method and you don't have to worry
       about it.

       With regard to using multiple SoSelection nodes at the same time in the same scene graph:
       this is possible, but it is not straightforward. The standard viewers provided by SoQt,
       SoWin, et al, will only snoop on one SoSelection node (part of the the legacy API from
       SGI's InventorXt), so selection changes on the others doesn't trigger redraws. You don't
       necessarily see what's happening in other words. You'll have to hook up manually and
       trigger redraws yourself.

       Also be aware that when having multiple SoSelection nodes in the scene graph active at the
       same time, the SoHandleEventAction traversals that you intend for selection-change on one
       SoSelection node will also affect all the other SoSelection nodes in the scene -- usually
       delesecting everything below them since you will be clicking outside the selectable
       objects. You'll therefore also have to manually override that behaviour, if you want
       selection change on one SoSelection node to not affect the others.

       FILE FORMAT/DEFAULTS:

       Selection {
           renderCaching AUTO
           boundingBoxCaching AUTO
           renderCulling AUTO
           pickCulling AUTO
           policy SHIFT
       }

Member Enumeration Documentation

   enum SoSelection::Policy
       Enum for different pick policies.

       Enumerator

       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.

       Note that if a new selection matches one already present in the selection list, neither a
       deselect nor a select notification callback will be made about that selection path.

       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)
       Default constructor.

   SoSelection::SoSelection (const intnChildren)
       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]
       Destructor.

Member Function Documentation

   SoType SoSelection::getTypeId (void) const [virtual]
       Returns the type identification of an object derived from a class inheriting SoBase. This
       is used for run-time type checking and 'downward' casting. Usage example:

       void foo(SoNode * node)
       {
         if (node->getTypeId() == SoFile::getClassTypeId()) {
           SoFile * filenode = (SoFile *)node;  // safe downward cast, knows the type
         }
       }

       For application programmers wanting to extend the library with new nodes, engines,
       nodekits, draggers or others: this method needs to be overridden in all subclasses. This
       is typically done as part of setting up the full type system for extension classes, which
       is usually accomplished by using the pre-defined macros available through for instance
       Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes),
       Inventor/engines/SoSubEngine.h (for engine classes) and so on.

       For more information on writing Coin extensions, see the class documentation of the
       toplevel superclasses for the various class groups.

       Reimplemented from SoSeparator.

       Reimplemented in SoExtSelection.

   const SoFieldData * SoSelection::getFieldData (void) const [protected],  [virtual]
       Returns a pointer to the class-wide field data storage object for this instance. If no
       fields are present, returns NULL.

       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 intwhich)
       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.

   SbBool SoSelection::isSelected (SoNode *node) const
       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 intindex) const
       Returns the index'th selected objects.

   SoPath * SoSelection::operator[] (const inti) const
       Operator for accessing selected objects.

   void SoSelection::addSelectionCallback (SoSelectionPathCB *f, void *userData = NULL)
       Adds a callback which will be called every time an object is selected.

       See Also:
           removeSelectionCallback()

   void SoSelection::removeSelectionCallback (SoSelectionPathCB *f, void *userData = NULL)
       Removes one of the selection callbacks.

       See Also:
           addSelectionCallback()

   void SoSelection::addDeselectionCallback (SoSelectionPathCB *f, void *userData = NULL)
       Adds a callback which will be called every time an object is deselected.

       See Also:
           removeDeselectionCallback()

   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)
       Removes f from the list of start callbacks.

       See Also:
           addStartCallback()

   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)
       Removes f from the list og finish callbacks.

       See Also:
           addFinishCallback()

   void SoSelection::setPickFilterCallback (SoSelectionPickCB *f, void *userData = NULL, const
       SbBoolcallOnlyIfSelectable = 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. The returned path will
       be ref'ed, copied, and then unref'ed again by the SoSelection node.

       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 SbBoolpickmatchflag)
       When pickmatchflag is TRUE (the default), the mouse button release pick must match the
       mouse button press pick before object is selected/deselected.
       This flag should normally not be of interest to application programmers.
   SbBool SoSelection::isPickMatching (void) const
       Returns TRUE if pick matching is enabled.
       See Also:
           setPickMatching()
   SbBool SoSelection::getPickMatching (void) const
       Returns TRUE if pick matching is enabled.
       See Also:
           setPickMatching()
   void SoSelection::addChangeCallback (SoSelectionClassCB *f, void *userData = NULL)
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.Used by render area to receive notification when
       the selection list changes.
   void SoSelection::removeChangeCallback (SoSelectionClassCB *f, void *userData = NULL)
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer. Used by render area to receive notification when
       the selection list changes.
   void SoSelection::invokeSelectionPolicy (SoPath *path, SbBoolshiftdown) [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void SoSelection::performSingleSelection (SoPath *path) [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void SoSelection::performToggleSelection (SoPath *path) [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoPath * SoSelection::copyFromThis (const SoPath *path) const [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void SoSelection::addPath (SoPath *path) [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void SoSelection::removePath (const intwhich) [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   int SoSelection::findPath (const SoPath *path) const [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void SoSelection::handleEvent (SoHandleEventAction *action) [protected],  [virtual]
       Action method for SoHandleEventAction.
       Inspects the event data from action, and processes it if it is something which this node
       should react to.
       Nodes influencing relevant state variables for how event handling is done also overrides
       this method.
       Reimplemented from SoSeparator.
       Reimplemented in SoExtSelection.

Member Data Documentation

   SoSFEnum SoSelection::policy
       Field for selection policy. Default value is SHIFT.
   SoPathList SoSelection::selectionList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoCallbackList * SoSelection::selCBList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoCallbackList * SoSelection::deselCBList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoCallbackList * SoSelection::startCBList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoCallbackList * SoSelection::finishCBList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoSelectionPickCB * SoSelection::pickCBFunc [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   void * SoSelection::pickCBData [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SbBool SoSelection::callPickCBOnlyIfSelectable [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoCallbackList * SoSelection::changeCBList [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SoPath * SoSelection::mouseDownPickPath [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.
   SbBool SoSelection::pickMatching [protected]
       This API member is considered internal to the library, as it is not likely to be of
       interest to the application programmer.

Author

       Generated automatically by Doxygen for Coin from the source code.