Coin Logo http://www.sim.no/
http://www.coin3d.org/

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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
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  (static_cast<_classname_ *>(_kit_->getPart(_name_, FALSE)))
00049 
00050 #define SO_GET_ANY_PART(_kit_, _name_, _classname_) \
00051  (static_cast<_classname_ *>(_kit_->getAnyPart(_name_, TRUE, FALSE, FALSE)))
00052 
00053 #define SO_CHECK_ANY_PART(_kit_, _name_, _classname_) \
00054  (static_cast<_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 
00103 protected:
00104   virtual ~SoBaseKit();
00105 
00106   static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void);
00107 
00108   virtual SoNode * addToCopyDict(void) const;
00109   virtual void copyContents(const SoFieldContainer * fromfc,
00110                             SbBool copyconnections);
00111 
00112   SoGroup * getContainerNode(const SbName & listname,
00113                              SbBool makeifneeded = TRUE);
00114   virtual SoNode * getAnyPart(const SbName & partname, SbBool makeifneeded,
00115                               SbBool leafcheck = FALSE,
00116                               SbBool publiccheck = FALSE);
00117   virtual SoNodeKitPath * createPathToAnyPart(const SbName & partname,
00118                                               SbBool makeifneeded,
00119                                               SbBool leafcheck = FALSE,
00120                                               SbBool publiccheck = FALSE,
00121                                               const SoPath * pathtoextend = NULL);
00122   virtual SbBool setAnyPart(const SbName & partname, SoNode * from,
00123                             SbBool anypart = TRUE);
00124   void createNodekitPartsList(void); // not part of Coin
00125   void createFieldList(void); // replaces above method
00126   virtual void createDefaultParts(void);
00127   const SoNodekitParts * getNodekitPartsList(void) const; // not part of Coin
00128   const SbList<SoSFNode*> & getCatalogInstances(void) const; // replaces above method
00129 
00130   void catalogError(void);
00131   virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
00132   virtual SbBool readInstance(SoInput * in, unsigned short flags);
00133   virtual void setDefaultOnNonWritingFields(void);
00134   void countMyFields(SoOutput * out);
00135 
00136   virtual SbBool setPart(const int partNum, SoNode * node);
00137 
00138   SoChildList * children;
00139   SbBool connectionsSetUp;
00140 
00141 private:
00142   friend class SoInteractionKit;
00143   static SbBool findPart(const SbString & partname, SoBaseKit *& kit,
00144                          int & partnum, SbBool & islist, int & listidx,
00145                          const SbBool makeifneeded, SoPath * path = NULL,
00146                          const SbBool recsearch = FALSE);
00147   static void atexit_cleanupkit(void);
00148 
00149   SbBool makePart(const int partnum);
00150   int getRightSiblingIndex(const int partnum);
00151   int findNodeInThisKit(SoNode *node, const int parentnum = -1) const;
00152 
00153   static SoNodekitCatalog * classcatalog;
00154   static const SoNodekitCatalog ** parentcatalogptr;
00155   static SbBool searchchildren;
00156 
00157   class SoBaseKitP * pimpl;
00158   friend class SoBaseKitP;
00159 };
00160 
00161 #endif // !COIN_SOBASEKIT_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Fri Dec 11 2015 03:24:53 for Coin by Doxygen 1.7.6.1.