00001 #ifndef COIN_SOBASEKIT_H
00002 #define COIN_SOBASEKIT_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
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);
00128 void createFieldList(void);
00129 virtual void createDefaultParts(void);
00130 const SoNodekitParts * getNodekitPartsList(void) const;
00131 const SbList<SoSFNode*> & getCatalogInstances(void) const;
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