Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/nodekits/include/Inventor/nodekits/SoNodeKitListPart.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,91   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  |   $Revision: 1.1.1.1 $
00045  |
00046  |   Description:
00047  |      Defines the SoNodeKitListPart class. 
00048  |      It behaves sort of like a group to the outsider, but it only allows
00049  |      certain types of nodes to be put beneath it.
00050  | 
00051  |      It contains hidden children, and is not derived from SoGroup.
00052  |      The addChild(), insertChild(), etc. methods all check that the
00053  |      new node is allowable beneath it.
00054  |
00055  |      The container node sits beteen the SoNodeKitListPart and the children.
00056  |      It's type is taken in the constructor, and must be derived from 
00057  |      SoGroup. By making the container an SoSeparator, SoSwitch, etc.,
00058  |      the SoNodeKitList can be made to encase its set of children in
00059  |      the appropriate behavior.
00060  |
00061  |   Author(s)          : Paul Isaacs
00062  |
00063  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00064  _______________________________________________________________________
00065 */
00066 
00067 #ifndef  _SO_NODE_KIT_LIST_PART_
00068 #define  _SO_NODE_KIT_LIST_PART_
00069 
00070 #include <Inventor/misc/SoChildList.h>
00071 #include <Inventor/fields/SoSFName.h>
00072 #include <Inventor/fields/SoMFName.h>
00073 #include <Inventor/fields/SoSFNode.h>
00074 #include <Inventor/nodes/SoSubNode.h>
00075 #include <Inventor/nodes/SoNode.h>
00076 #include <Inventor/nodekits/SoNodekitParts.h>
00077 #include <Inventor/nodekits/SoBaseKit.h>
00078 
00079 class SoGroup;
00080 
00081 class SoGetMatrixAction;
00082 class SoGLRenderAction;
00083 class SoGetBoundingBoxAction;
00084 class SoHandleEventAction;
00085 class SoSearchAction;
00086 class SoSearchAction;
00087 class SoCallbackAction;
00088 
00089 
00092 
00119 
00120 
00121 class INVENTOR_API SoNodeKitListPart : public SoNode {
00122 
00123     SO_NODE_HEADER(SoNodeKitListPart);
00124 
00125   public:
00126 
00128     SoNodeKitListPart();
00129 
00131     SoType         getContainerType() const;
00133     void           setContainerType( SoType newContainerType );
00134 
00138     const SoTypeList &getChildTypes() const;
00148     void             addChildType( SoType typeToAdd );
00149 
00152     SbBool        isTypePermitted( SoType typeToCheck ) const;
00156     SbBool        isChildPermitted( const SoNode *child ) const;
00157 
00162     void containerSet( const char *fieldDataString );
00163 
00170     void   lockTypes(); 
00175     SbBool isTypeLocked() const { return areTypesLocked; }
00176 
00181     void                addChild(SoNode *child);
00186     void                insertChild(SoNode *child, int childIndex);
00191     SoNode              *getChild(int index) const;
00196     int                 findChild(SoNode *child) const;
00201     int                 getNumChildren() const;
00206     void                removeChild(int index);
00211     void                removeChild(SoNode *child)
00212                 { removeChild( findChild(child));       }
00217     void                replaceChild(int index, SoNode *newChild);
00222     void                replaceChild( SoNode *oldChild, SoNode *newChild)
00223                 { replaceChild(findChild(oldChild), newChild); }
00224 
00227     virtual SbBool affectsState() const;
00228 
00229 
00230   SoEXTENDER public:
00231 
00233     virtual void doAction( SoAction *action );
00234     virtual void callback( SoCallbackAction *action );
00235     virtual void GLRender( SoGLRenderAction *action );
00236     virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00237     virtual void getMatrix(SoGetMatrixAction *action );
00238     virtual void handleEvent( SoHandleEventAction *action );
00239     virtual void pick( SoPickAction *action );
00240     virtual void search( SoSearchAction *action );
00241 
00242   SoINTERNAL public:
00243     static void initClass();
00244 
00246     virtual SoChildList *getChildren() const;
00247 
00248   protected:
00249 
00250     SoGroup *getContainerNode();
00251 
00253     virtual SbBool readInstance(SoInput *in, unsigned short flags);
00254 
00255     SoChildList *children;
00256 
00258     virtual void        copyContents(const SoFieldContainer *fromFC,
00259                                      SbBool copyConnections);
00260 
00261   protected:
00262     virtual ~SoNodeKitListPart();
00263 
00264   private:
00265     SoSFName containerTypeName;
00266     SoMFName childTypeNames;
00267     SoSFNode containerNode;
00268 
00269     SoTypeList childTypes;
00270 
00271     SbBool  areTypesLocked;
00272 
00273     friend class SoBaseKit;
00274 };
00275 
00276 #endif  /* _SO_NODE_KIT_LIST_PART_ */