# SoBaseKit.h

    00001 #ifndef COIN_SOBASEKIT_H
    00002 #define COIN_SOBASEKIT_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    00024  *
    00025 \**************************************************************************/
    00026
    00027 #include <Inventor/nodekits/SoSubKit.h>
    00028 #include <Inventor/nodes/SoNode.h>
    00029 #ifdef COIN_INTERNAL
    00030 class SoNodeKitPath;
    00031 #else // !COIN_INTERNAL
    00032 // Include these header files for better Open Inventor compatibility.
    00033 #include <Inventor/SoNodeKitPath.h>
    00034 #include <Inventor/misc/SoChildList.h>
    00035 #endif // !COIN_INTERNAL
    00036
    00037 class SoGroup;
    00038 class SoNodekitParts;
    00039 class SoNodekitCatalog;
    00040 class SoPath;
    00041
    00042 // Convenience macros. FIXME: document. 20000113 mortene.
    00043
    00044 #define SO_GET_PART(_kit_, _name_, _classname_) \
    00045  ((_classname_ *)_kit_->getPart(_name_, TRUE))
    00046
    00047 #define SO_CHECK_PART(_kit_, _name_, _classname_) \
    00048  ((_classname_ *)_kit_->getPart(_name_, FALSE))
    00049
    00050 #define SO_GET_ANY_PART(_kit_, _name_, _classname_) \
    00051  ((_classname_ *)_kit_->getAnyPart(_name_, TRUE, FALSE, FALSE))
    00052
    00053 #define SO_CHECK_ANY_PART(_kit_, _name_, _classname_) \
    00054  ((_classname_ *)_kit_->getAnyPart(_name_, FALSE, FALSE, FALSE))
    00055
    00056
    00057 class COIN_DLL_API SoBaseKit : public SoNode {
    00058   typedef SoNode inherited;
    00059
    00060   SO_NODE_HEADER(SoBaseKit);
    00061
    00062   SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
    00063
    00064 public:
    00065   static void initClass(void);
    00066   SoBaseKit(void);
    00067
    00068   static const SoNodekitCatalog * getClassNodekitCatalog(void);
    00069   virtual const SoNodekitCatalog * getNodekitCatalog(void) const;
    00070
    00071   virtual SoNode * getPart(const SbName & partname, SbBool makeifneeded);
    00072   SbString getPartString(const SoBase * part);
    00073   virtual SoNodeKitPath * createPathToPart(const SbName & partname,
    00074                                            SbBool makeifneeded,
    00075                                            const SoPath * pathtoextend = NULL);
    00076   virtual SbBool setPart(const SbName & partname, SoNode * from);
    00077   SbBool set(const char * namevaluepairliststring);
    00078   SbBool set(const char * partnamestring, const char * parameterstring);
    00079
    00080   virtual void doAction(SoAction * action);
    00081   virtual void callback(SoCallbackAction * action);
    00082   virtual void GLRender(SoGLRenderAction * action);
    00083   virtual void getBoundingBox(SoGetBoundingBoxAction * action);
    00084   virtual void getMatrix(SoGetMatrixAction * action);
    00085   virtual void handleEvent(SoHandleEventAction * action);
    00086   virtual void rayPick(SoRayPickAction * action);
    00087   virtual void search(SoSearchAction * action);
    00088   virtual void write(SoWriteAction * action);
    00089   virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
    00090
    00091   virtual SoChildList * getChildren(void) const;
    00092
    00093   void printDiagram(void);
    00094   void printSubDiagram(const SbName & rootname, int level);
    00095   void printTable(void);
    00096
    00097   virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
    00098   SbBool forceChildDrivenWriteRefs(SoOutput * out);
    00099
    00100   static SbBool isSearchingChildren(void);
    00101   static void setSearchingChildren(const SbBool newval);
    00102   static SoNode * typeCheck(const SbName & partname, const SoType & parttype,
    00103                             SoNode * node);
    00104
    00105
    00106 protected:
    00107   virtual ~SoBaseKit();
    00108
    00109   static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void);
    00110
    00111   virtual SoNode * addToCopyDict(void) const;
    00112   virtual void copyContents(const SoFieldContainer * fromfc,
    00113                             SbBool copyconnections);
    00114
    00115   SoGroup * getContainerNode(const SbName & listname,
    00116                              SbBool makeifneeded = TRUE);
    00117   virtual SoNode * getAnyPart(const SbName & partname, SbBool makeifneeded,
    00118                               SbBool leafcheck = FALSE,
    00119                               SbBool publiccheck = FALSE);
    00120   virtual SoNodeKitPath * createPathToAnyPart(const SbName & partname,
    00121                                               SbBool makeifneeded,
    00122                                               SbBool leafcheck = FALSE,
    00123                                               SbBool publiccheck = FALSE,
    00124                                               const SoPath * pathtoextend = NULL);
    00125   virtual SbBool setAnyPart(const SbName & partname, SoNode * from,
    00126                             SbBool anypart = TRUE);
    00127   void createNodekitPartsList(void); // not part of Coin
    00128   void createFieldList(void); // replaces above method
    00129   virtual void createDefaultParts(void);
    00130   const SoNodekitParts * getNodekitPartsList(void) const; // not part of Coin
    00131   const SbList<SoSFNode*> & getCatalogInstances(void) const; // replaces above method
    00132
    00133   void catalogError(void);
    00134   virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
    00135   virtual SbBool readInstance(SoInput * in, unsigned short flags);
    00136   virtual void setDefaultOnNonWritingFields(void);
    00137   void countMyFields(SoOutput * out);
    00138
    00139   virtual SbBool setPart(const int partNum, SoNode * node);
    00140
    00141   SoChildList * children;
    00142   SbBool connectionsSetUp;
    00143
    00144 private:
    00145   friend class SoInteractionKit;
    00146   static SbBool findPart(const SbString & partname, SoBaseKit *& kit,
    00147                          int & partnum, SbBool & islist, int & listidx,
    00148                          const SbBool makeifneeded, SoPath * path = NULL,
    00149                          const SbBool recsearch = FALSE);
    00150
    00151   SbBool makePart(const int partnum);
    00152   int getRightSiblingIndex(const int partnum);
    00153   int findNodeInThisKit(SoNode *node, const int parentnum = -1) const;
    00154
    00155   static SoNodekitCatalog * classcatalog;
    00156   static const SoNodekitCatalog ** parentcatalogptr;
    00157   static SbBool searchchildren;
    00158
    00159   class SoBaseKitP * pimpl;
    00160   friend class SoBaseKitP;
    00161 };
    00162
    00163 #endif // !COIN_SOBASEKIT_H