00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SOBASEKIT_H
00021 #define COIN_SOBASEKIT_H
00022
00023 #include <Inventor/nodekits/SoSubKit.h>
00024 #include <Inventor/nodes/SoNode.h>
00025 #ifdef COIN_INTERNAL
00026 class SoNodeKitPath;
00027 #else // !COIN_INTERNAL
00028
00029 #include <Inventor/SoNodeKitPath.h>
00030 #endif // !COIN_INTERNAL
00031
00032 class SoGroup;
00033 class SoNodekitParts;
00034 class SoNodekitCatalog;
00035 class SoPath;
00036
00037
00038
00039 #define SO_GET_PART(_kit_, _name_, _classname_) \
00040 ((_classname_ *)_kit_->getPart(_name_, TRUE))
00041
00042 #define SO_CHECK_PART(_kit_, _name_, _classname_) \
00043 ((_classname_ *)_kit_->getPart(_name_, FALSE))
00044
00045 #define SO_GET_ANY_PART(_kit_, _name_, _classname_) \
00046 ((_classname_ *)_kit_->getAnyPart(_name_, TRUE, FALSE, FALSE))
00047
00048 #define SO_CHECK_ANY_PART(_kit_, _name_, _classname_) \
00049 ((_classname_ *)_kit_->getAnyPart(_name_, FALSE, FALSE, FALSE))
00050
00051
00052 class COIN_DLL_API SoBaseKit : public SoNode {
00053 typedef SoNode inherited;
00054
00055 SO_NODE_HEADER(SoBaseKit);
00056
00057 SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
00058
00059 public:
00060 static void initClass(void);
00061 SoBaseKit(void);
00062
00063 static const SoNodekitCatalog * getClassNodekitCatalog(void);
00064 virtual const SoNodekitCatalog * getNodekitCatalog(void) const;
00065
00066 virtual SoNode * getPart(const SbName & partname, SbBool makeifneeded);
00067 SbString getPartString(const SoBase * part);
00068 virtual SoNodeKitPath * createPathToPart(const SbName & partname,
00069 SbBool makeifneeded,
00070 const SoPath * pathtoextend = NULL);
00071 virtual SbBool setPart(const SbName & partname, SoNode * from);
00072 SbBool set(const char * namevaluepairliststring);
00073 SbBool set(const char * partnamestring, const char * parameterstring);
00074
00075 virtual void doAction(SoAction * action);
00076 virtual void callback(SoCallbackAction * action);
00077 virtual void GLRender(SoGLRenderAction * action);
00078 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00079 virtual void getMatrix(SoGetMatrixAction * action);
00080 virtual void handleEvent(SoHandleEventAction * action);
00081 virtual void rayPick(SoRayPickAction * action);
00082 virtual void search(SoSearchAction * action);
00083 virtual void write(SoWriteAction * action);
00084 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00085
00086 virtual SoChildList * getChildren(void) const;
00087
00088 void printDiagram(void);
00089 void printSubDiagram(const SbName & rootname, int level);
00090 void printTable(void);
00091
00092 virtual void addWriteReference(SoOutput * out, SbBool isfromfield = FALSE);
00093 SbBool forceChildDrivenWriteRefs(SoOutput * out);
00094
00095 static SbBool isSearchingChildren(void);
00096 static void setSearchingChildren(const SbBool newval);
00097 static SoNode * typeCheck(const SbName & partname, const SoType & parttype,
00098 SoNode * node);
00099
00100
00101 protected:
00102 virtual ~SoBaseKit();
00103
00104 static const SoNodekitCatalog ** getClassNodekitCatalogPtr(void);
00105
00106 virtual SoNode * addToCopyDict(void) const;
00107 virtual void copyContents(const SoFieldContainer * fromfc,
00108 SbBool copyconnections);
00109
00110 SoGroup * getContainerNode(const SbName & listname,
00111 SbBool makeifneeded = TRUE);
00112 virtual SoNode * getAnyPart(const SbName & partname, SbBool makeifneeded,
00113 SbBool leafcheck = FALSE,
00114 SbBool publiccheck = FALSE);
00115 virtual SoNodeKitPath * createPathToAnyPart(const SbName & partname,
00116 SbBool makeifneeded,
00117 SbBool leafcheck = FALSE,
00118 SbBool publiccheck = FALSE,
00119 const SoPath * pathtoextend = NULL);
00120 virtual SbBool setAnyPart(const SbName & partname, SoNode * from,
00121 SbBool anypart = TRUE);
00122 void createNodekitPartsList(void);
00123 void createFieldList(void);
00124 virtual void createDefaultParts(void);
00125 const SoNodekitParts * getNodekitPartsList(void) const;
00126 const SbList<SoSFNode*> & getCatalogInstances(void) const;
00127
00128 void catalogError(void);
00129 virtual SbBool setUpConnections(SbBool onoff, SbBool doitalways = FALSE);
00130 virtual SbBool readInstance(SoInput * in, unsigned short flags);
00131 virtual void setDefaultOnNonWritingFields(void);
00132 void countMyFields(SoOutput * out);
00133
00134 virtual SbBool setPart(const int partNum, SoNode * node);
00135
00136 SoChildList * children;
00137 SbBool connectionsSetUp;
00138
00139 private:
00140 friend class SoInteractionKit;
00141 static SbBool findPart(const SbString & partname, SoBaseKit *& kit,
00142 int & partnum, SbBool & islist, int & listidx,
00143 const SbBool makeifneeded, SoPath * path = NULL,
00144 const SbBool recsearch = FALSE);
00145
00146 SbBool makePart(const int partnum);
00147 int getRightSiblingIndex(const int partnum);
00148 int findNodeInThisKit(SoNode *node, const int parentnum = -1) const;
00149
00150 static SoNodekitCatalog * classcatalog;
00151 static const SoNodekitCatalog ** parentcatalogptr;
00152 static SbBool searchchildren;
00153
00154 class SoBaseKitP * pimpl;
00155 friend class SoBaseKitP;
00156 };
00157
00158 #endif // !COIN_SOBASEKIT_H