Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/interaction/include/Inventor/nodes/SoSelection.h
Go to the documentation of this file.
00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 
00038 /*
00039  * Copyright (C) 1990-93   Silicon Graphics, Inc.
00040  *
00041  _______________________________________________________________________
00042  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00043  |
00044  |
00045  |   $Revision: 1.1.1.1 $
00046  |
00047  |   Description:
00048  |      This file defines the SoSelection node class.
00049  |
00050  |   Classes:   SoSelection
00051  |
00052  |   Author(s)  : David Mott, Thad Beier
00053  |
00054  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00055  _______________________________________________________________________
00056  */
00057 
00058 #ifndef  _SO_SELECTION_
00059 #define  _SO_SELECTION_
00060 
00061 #include <Inventor/SbColor.h>
00062 #include <Inventor/misc/SoCallbackList.h>
00063 #include <Inventor/nodes/SoSeparator.h>
00064 
00065 class SoCallbackList;
00066 class SoEvent;
00067 class SoHandleEventAction;
00068 class SoSearchAction;
00069 class SoPickedPoint;
00070 class SoPickedPointList;
00071 class SoTypeList;
00072 class SoSelection;
00073 class SoPath;
00074 
00076 typedef INVENTOR_API void SoSelectionPathCB(void *userData, SoPath *path);
00077 typedef INVENTOR_API void SoSelectionClassCB(void *userData, SoSelection *sel);
00078 typedef INVENTOR_API SoPath * SoSelectionPickCB(void *userData, const SoPickedPoint *pick);
00079 
00080 
00083 
00123 
00124 
00125 class INVENTOR_API SoSelection : public SoSeparator {
00126 
00127     SO_NODE_HEADER(SoSelection);
00128 
00129   public:
00130 
00132     SoSelection();
00135     SoSelection(int nChildren);
00136     
00140 
00142     enum Policy {
00146         SINGLE,
00147         
00151         TOGGLE,
00152         
00156         SHIFT
00157     };
00158 
00160 
00161 
00165     SoSFEnum            policy; 
00166 
00168 
00175     void                select(const SoPath *path);    
00176 
00182     void                select(SoNode *node);
00183 
00185     void                deselect(const SoPath *path);
00188     void                deselect(int which);
00189 
00195     void                deselect(SoNode *node);
00196 
00199     void                toggle(const SoPath *path);
00200 
00206     void                toggle(SoNode *node);
00207 
00209     SbBool              isSelected(const SoPath *path) const;
00213     SbBool              isSelected(SoNode *node) const;
00214 
00216     void                deselectAll();
00217 
00219     int                 getNumSelected() const  { return selectionList.getLength(); }
00221     const SoPathList    *getList() const { return &selectionList; }
00223     SoPath              *getPath(int index) const;
00224 
00226     SoPath *            operator [](int i) const
00227                         { return getPath(i); }
00228 
00232     void    addSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00234     void    removeSelectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00235 
00239     void    addDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00241     void    removeDeselectionCallback(SoSelectionPathCB *f, void *userData = NULL);
00242 
00250     void    addStartCallback(SoSelectionClassCB *f, void *userData = NULL);
00252         void    removeStartCallback(SoSelectionClassCB *f, void *userData = NULL);
00253 
00260     void    addFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
00262     void    removeFinishCallback(SoSelectionClassCB *f, void *userData = NULL);
00263 
00314     void    setPickFilterCallback(
00315                 SoSelectionPickCB *f,
00316                 void *userData = NULL, 
00317                 SbBool callOnlyIfSelectable = TRUE); 
00318 
00327     void    setPickMatching(SbBool pickTwice) { pickMatching = pickTwice; }
00329     SbBool  isPickMatching() const { return pickMatching; }
00331     SbBool  getPickMatching() const { return pickMatching; }
00332     
00333   SoINTERNAL public:
00336     void   addChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
00337     void   removeChangeCallback(SoSelectionClassCB *f, void *userData = NULL);
00338 
00340     static void         initClass();
00341 
00342   protected:
00344     SoPathList          selectionList;
00345 
00347     SoCallbackList      *selCBList;
00348     SoCallbackList      *deselCBList;
00349     SoCallbackList      *startCBList;
00350     SoCallbackList      *finishCBList;
00351     
00353     SoSelectionPickCB   *pickCBFunc;
00354     void                *pickCBData;
00355     SbBool              callPickCBOnlyIfSelectable;
00356     
00358     SoCallbackList      *changeCBList;
00359     
00361     SoPath              *mouseDownPickPath;
00362     SbBool              pickMatching;
00363 
00369     void                invokeSelectionPolicy(SoPath *path, SbBool shiftDown);
00370     void                performSingleSelection(SoPath *path);
00371     void                performToggleSelection(SoPath *path);
00372     
00375     SoPath              *copyFromThis(const SoPath *path) const;
00376     
00378     void                addPath(SoPath *path);
00379     void                removePath(int which);
00380     
00383     int                 findPath(const SoPath *path) const;
00384 
00387     virtual void        handleEvent(SoHandleEventAction *action);
00388     
00390     ~SoSelection();
00391 
00392   private:
00393 
00395     static SoSearchAction *searchAction;
00396 
00398     void                constructorCommon();  
00399 };
00400 
00401 
00402 
00403 #endif /* _SO_SELECTION_ */