Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/nodekits/include/Inventor/nodekits/SoBaseKit.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 SoBaseKit class. A base class for all
00048  |      of the SoNodeKit classes
00049  |
00050  |   Author(s)          : Paul Isaacs, Thad Beier
00051  |
00052  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00053  _______________________________________________________________________
00054 */
00055 
00056 #ifndef  _SO_BASE_KIT_
00057 #define  _SO_BASE_KIT_
00058 
00059 #include <Inventor/misc/SoChildList.h>
00060 #include <Inventor/fields/SoFieldData.h>
00061 #include <Inventor/nodes/SoSubNode.h>
00062 #include <Inventor/fields/SoSFName.h>
00063 #include <Inventor/nodes/SoNode.h>
00064 #include <Inventor/nodekits/SoNodekitParts.h>
00065 #include <Inventor/nodekits/SoSubKit.h>
00066 #include <Inventor/SoNodeKitPath.h>
00067 
00068 class SoSeparator;
00069 class SbBox3f;
00070 class SbDict;
00071 class SoGroup;
00072 
00073 
00076 
00260 
00261 
00262 class INVENTOR_API SoBaseKit : public SoNode {
00263 
00269     SO_NODE_HEADER(SoBaseKit);
00270 
00271   private:
00272     static SoNodekitCatalog *nodekitCatalog; /* design of this class */
00273     static const SoNodekitCatalog **parentNodekitCatalogPtr; /* parent design */
00274   public:
00276     static const SoNodekitCatalog *getClassNodekitCatalog()
00277         { return nodekitCatalog; }
00278 
00279     /* Returns an SoNodekitCatalog for the node */
00285     virtual const SoNodekitCatalog *getNodekitCatalog() const;
00287 
00288   protected:
00289     static const SoNodekitCatalog **getClassNodekitCatalogPtr()
00290         { return (const SoNodekitCatalog **)&nodekitCatalog; }
00291 
00293     SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
00294 
00295   public:
00296 
00298     SoBaseKit();
00299 
00351     virtual SoNode *getPart( const SbName &partName, SbBool makeIfNeeded );
00352 
00357     SbString getPartString( const SoBase *part );
00358 
00371     virtual SoNodeKitPath *createPathToPart( const SbName &partName, 
00372                     SbBool makeIfNeeded, const SoPath *pathToExtend = NULL );
00373 
00397     virtual SbBool setPart( const SbName &partName, SoNode *from );
00398 
00403     SbBool set(char *nameValuePairListString);
00404     SbBool set(char *partNameString, char *parameterString);
00405 
00408     static SbBool isSearchingChildren() { return searchingChildren; }
00411     static void   setSearchingChildren( SbBool newVal );
00412 
00413   SoEXTENDER public:
00414     virtual void doAction( SoAction *action );
00416     virtual void callback( SoCallbackAction *action );
00417     virtual void GLRender( SoGLRenderAction *action );
00418     virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00419     virtual void getMatrix(SoGetMatrixAction *action );
00420     virtual void handleEvent( SoHandleEventAction *action );
00421     virtual void rayPick( SoRayPickAction *action );
00422     virtual void search( SoSearchAction *action );
00423     virtual void write( SoWriteAction *action );
00424 
00425   SoINTERNAL public:
00426     static void initClass();
00427 
00429     virtual SoChildList *getChildren() const;
00430 
00431     static SoNode *typeCheck( const SbName &partName, const SoType &partType, 
00432                               SoNode *node );
00433 
00434     void printDiagram();
00435     void printSubDiagram( const SbName &rootName, int level );
00436     void printTable();
00437 
00440     virtual void        addWriteReference(SoOutput *out,
00441                                           SbBool isFromField = FALSE);
00442 
00443     friend class SoNodekitCatalogEntry;
00444     friend class SoNodekitParts;
00445     friend class SoV1BaseKit;
00446 
00456     SbBool forceChildDrivenWriteRefs( SoOutput *out );
00457 
00458   protected:
00459 
00460     SoChildList *children;
00461 
00463     virtual SoNode *    addToCopyDict() const;
00464 
00466     virtual void        copyContents(const SoFieldContainer *fromFC,
00467                                      SbBool copyConnections);
00468 
00471     SoGroup *getContainerNode( const SbName &listName,
00472                                SbBool makeIfNeeded = TRUE );
00473 
00478     virtual SoNode *getAnyPart( const SbName &partName, SbBool makeIfNeeded, 
00479                         SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
00480     virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName, 
00481                     SbBool makeIfNeeded, 
00482                     SbBool leafCheck = FALSE, SbBool publicCheck = FALSE,
00483                    const SoPath *pathToExtend = NULL );
00484     virtual SbBool setAnyPart( const SbName &partName, SoNode *from, 
00485                        SbBool anyPart = TRUE );
00486 
00488     SoNodekitParts      *nodekitPartsList;
00489 
00491     void createNodekitPartsList();
00494     virtual void createDefaultParts();
00495 
00497     const SoNodekitParts *getNodekitPartsList() const 
00498                             { return nodekitPartsList; };
00499 
00501     void catalogError();
00502 
00513     virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00514     SbBool connectionsSetUp;
00515 
00517     virtual SbBool readInstance(SoInput *in, unsigned short flags);
00518     
00529     virtual void setDefaultOnNonWritingFields();
00530 
00550     void countMyFields(SoOutput *out);
00551 
00552     virtual ~SoBaseKit();
00553 
00554   private:
00555     void skipWhiteSpace(char *&string);
00556 
00559     SbBool isNodeFieldValuesImportant( SoNode *n );
00560 
00563     void createFieldDataForWriting();
00566     SoFieldData *fieldDataForWriting;
00567 
00569     SbBool readMyFields(SoInput *in, SoFieldData *&unknownFieldData );
00570 
00579     void undoSetDefaultOnFieldsThatMustWrite();
00580 
00582     int  getNumChildren() const { return (children->getLength()); }
00583     void removeChild( int index );
00584     void removeChild( SoNode *child  ) { removeChild(findChild(child)); }
00585     void addChild( SoNode *child );
00586     int  findChild( const SoNode *child ) const;
00587     void insertChild( SoNode *child, int newChildIndex );
00588     SoNode *getChild( int index) const { return (*children)[index]; }
00589     void replaceChild( int index, SoNode *newChild);
00590     void replaceChild( SoNode *oldChild, SoNode *newChild)
00591         { replaceChild(findChild(oldChild),newChild); }
00592 
00593     static SbBool searchingChildren;
00594 };
00595 
00608 
00609 
00610 #ifdef DEBUG
00611 #define SO_GET_PART( kitContainingPart, partName, partClassName )              \
00612         ((partClassName *) SoBaseKit::typeCheck( partName,                     \
00613                                partClassName::getClassTypeId(),               \
00614                                kitContainingPart->getPart( partName, TRUE )))
00615 
00616 #define SO_CHECK_PART( kitContainingPart, partName, partClassName )            \
00617         ((partClassName *) SoBaseKit::typeCheck( partName,                    \
00618                                partClassName::getClassTypeId(),               \
00619                                kitContainingPart->getPart( partName, FALSE )))
00620 
00621 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName )         \
00622         ((partClassName *) SoBaseKit::typeCheck( partName,                    \
00623                 partClassName::getClassTypeId(),                              \
00624                 kitContainingPart->getAnyPart( partName, TRUE, FALSE, FALSE )))
00625 
00626 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName )       \
00627         ((partClassName *) SoBaseKit::typeCheck( partName,                    \
00628                 partClassName::getClassTypeId(),                              \
00629                 kitContainingPart->getAnyPart( partName, FALSE, FALSE, FALSE )))
00630 #else
00631 
00632 #define SO_GET_PART( kitContainingPart, partName, partClassName )             \
00633         ((partClassName *) kitContainingPart->getPart( partName, TRUE ))
00634 #define SO_CHECK_PART( kitContainingPart, partName, partClassName )           \
00635         ((partClassName *) kitContainingPart->getPart( partName, FALSE ))
00636 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName )        \
00637         ((partClassName *) kitContainingPart->getAnyPart( partName, TRUE,    \
00638                                                           FALSE, FALSE ))
00639 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName )      \
00640         ((partClassName *) kitContainingPart->getAnyPart( partName, FALSE,   \
00641                                                           FALSE, FALSE ))
00642 #endif
00643 
00644 #endif  /* _SO_BASE_KIT_ */