00001
00002
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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_BASE_KIT_
00052 #define _SO_BASE_KIT_
00053
00054 #include <Inventor/misc/SoChildList.h>
00055 #include <Inventor/fields/SoFieldData.h>
00056 #include <Inventor/nodes/SoNode.h>
00057 #include <Inventor/fields/SoSFName.h>
00058 #include <Inventor/fields/SoSFBool.h>
00059 #include <Inventor/nodes/SoNode.h>
00060 #include <Inventor/nodekits/SoNodekitParts.h>
00061 #include <Inventor/nodekits/SoSubKit.h>
00062 #include <Inventor/SoNodeKitPath.h>
00063 #include <Inventor/SbViewportRegion.h>
00064
00065 class SoSeparator;
00066 class SbBox3f;
00067 class SbDict;
00068 class SoGroup;
00069
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00090
00302 class SoBaseKit : public SoNode, public SoGetView {
00303
00304
00305
00306
00307
00308
00309 SO_NODE_HEADER(SoBaseKit);
00310
00311 public:
00315 SoSFBool boundingBoxIgnoring;
00316
00317 private:
00318
00319 static SoNodekitCatalog *nodekitCatalog;
00320
00321 static const SoNodekitCatalog **parentNodekitCatalogPtr;
00322
00323 public:
00327 static const SoNodekitCatalog *getClassNodekitCatalog();
00328
00335
00336 virtual const SoNodekitCatalog *getNodekitCatalog() const;
00337
00338
00339 private:
00340 static const SoNodekitCatalog **getClassNodekitCatalogPtr();
00341
00342
00343 SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
00344
00345 public:
00346
00350 SoBaseKit();
00351
00392 virtual SoNode *getPart( const SbName &partName, SbBool makeIfNeeded );
00393
00413 template<typename PartType>
00414 PartType* getPart( const SbName& partName )
00415 {
00416 SoNode* part = getPart( partName, TRUE );
00417 #if defined(_DEBUG)
00418 part = typeCheck<PartType>( partName, part );
00419 #endif
00420 return static_cast<PartType*>(part);
00421 }
00422
00442 template<typename PartType>
00443 PartType* checkPart( const SbName& partName )
00444 {
00445 SoNode* part = getPart( partName, FALSE );
00446 #if defined(_DEBUG)
00447 part = typeCheck<PartType>( partName, part );
00448 #endif
00449 return static_cast<PartType*>(part);
00450 }
00451
00457 SbString getPartString( const SoBase *part );
00458
00459
00470 virtual SoNodeKitPath *createPathToPart( const SbName &partName,
00471 SbBool makeIfNeeded, const SoPath *pathToExtend = NULL );
00472
00496 virtual SbBool setPart( const SbName &partName, SoNode *newPart );
00497
00515 SoNONUNICODE SbBool set(char *nameValuePairListString);
00516
00532 SbBool set( const SbString& nameValuePairListString);
00533
00552 SoNONUNICODE SbBool set(const char *partNameString, const char *parameterString);
00553
00570 SbBool set( const SbString& partNameString, const SbString& parameterString);
00571
00576 static void setSearchingChildren( SbBool newVal );
00577
00582 static SbBool isSearchingChildren() { return searchingChildren; }
00583
00584 private:
00585
00592 inline virtual SbBool isBoundingBoxIgnoring() const
00593 { return boundingBoxIgnoring.getValue(); }
00594
00595 virtual void doAction( SoAction *action );
00596
00597 virtual void callback( SoCallbackAction *action );
00598 virtual void GLRender( SoGLRenderAction *action );
00599 virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00600 virtual void getMatrix(SoGetMatrixAction *action );
00601 virtual void handleEvent( SoHandleEventAction *action );
00602 virtual void rayPick( SoRayPickAction *action );
00603 virtual void search( SoSearchAction *action );
00604 virtual void write( SoWriteAction *action );
00605 virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action);
00606
00607 private:
00608 static void initClass();
00609 static void exitClass();
00610
00611
00612
00613
00614
00615 SbBool set(char *partNameString, char *parameterString)
00616 { return set((const char*)partNameString, (const char*)parameterString); };
00617
00618
00619 virtual SoChildList *getChildren() const;
00620
00621 static SoNode *typeCheck( const SbName &partName, const SoType &partType,
00622 SoNode *node );
00623
00625 template<typename PartType>
00626 static SoNode* typeCheck( const SbName& partName, SoNode* node )
00627 {
00628 return typeCheck( partName, PartType::getClassTypeId(), node );
00629 }
00630
00631 void printDiagram();
00632 void printSubDiagram( const SbName &rootName, int level );
00633 void printTable();
00634
00635
00636
00637 virtual void addWriteReference(SoOutput *out,
00638 SbBool isFromField = FALSE);
00639
00640 friend class SoNodekitCatalogEntry;
00641 friend class SoNodekitParts;
00642 friend class SoV1BaseKit;
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653 SbBool forceChildDrivenWriteRefs( SoOutput *out );
00654
00655
00656 static void enableNotification(SbBool);
00657 static SbBool isEnabledNotification();
00658
00659 virtual SbBool setAnyPart( const SbName &partName, SoNode *from, SbBool anyPart = TRUE );
00660
00661 SoNode *internalGetAnyPart( const SbName &partName, SbBool makeIfNeeded,
00662 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
00663
00664
00665 virtual void internalRemoveChild( int index ) { removeChild(index); }
00666 virtual void internalRemoveChild( SoNode *child ) { removeChild(findChild(child)); }
00667 virtual void internalRemoveAllChildren() { removeAllChildren(); }
00668 virtual void internalAddChild( SoNode *child ) { addChild(child); }
00669 virtual int internalFindChild( const SoNode *child ) const { return findChild(child); }
00670 virtual void internalInsertChild( SoNode *child, int newChildIndex ) { insertChild(child, newChildIndex); }
00671 virtual SoNode *internalGetChild( int index) const { return getChild(index); }
00672 virtual void internalReplaceChild( int index, SoNode *newChild) { replaceChild(index, newChild); }
00673 virtual void internalReplaceChild( SoNode *oldChild, SoNode *newChild) { replaceChild(oldChild,newChild); }
00674
00675
00676 virtual SoNode * addToCopyDict() const;
00677
00678
00679 virtual void copyContents(const SoFieldContainer *fromFC,
00680 SbBool copyConnections);
00681
00682 private:
00683
00684 SoChildList *children;
00685
00686
00687
00688 SoGroup *getContainerNode( const SbName &listName,
00689 SbBool makeIfNeeded = TRUE );
00690
00695 virtual SoNode *getAnyPart( const SbName &partName, SbBool makeIfNeeded,
00696 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
00697
00717 template<typename PartType>
00718 PartType* getAnyPart( const SbName& partName )
00719 {
00720 SoNode* part = getAnyPart( partName, TRUE, FALSE, FALSE );
00721 #if defined(_DEBUG)
00722 part = typeCheck<PartType>( partName, part );
00723 #endif
00724 return static_cast<PartType*>(part);
00725 }
00726
00746 template<typename PartType>
00747 PartType* checkAnyPart( const SbName& partName )
00748 {
00749 SoNode* part = getAnyPart( partName, FALSE, FALSE, FALSE );
00750 #if defined(_DEBUG)
00751 part = typeCheck<PartType>( partName, part );
00752 #endif
00753 return static_cast<PartType*>(part);
00754 }
00755
00756 virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName,
00757 SbBool makeIfNeeded,
00758 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE,
00759 const SoPath *pathToExtend = NULL );
00760
00761
00762 SoNodekitParts *nodekitPartsList;
00763
00764
00765 void createNodekitPartsList();
00766
00767
00768 virtual void createDefaultParts();
00769
00770
00771 const SoNodekitParts *getNodekitPartsList() const
00772 { return nodekitPartsList; };
00773
00774
00775 void catalogError();
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00788 SbBool connectionsSetUp;
00789
00790
00791 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803 virtual void setDefaultOnNonWritingFields();
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824 void countMyFields(SoOutput *out);
00825
00826 virtual ~SoBaseKit();
00827
00828 static SbBool m_enableBaseKitNotification;
00829
00830 private:
00831
00832
00833 void endWrite( SoOutput* out );
00834
00835 private:
00836 void skipWhiteSpace(char *&string);
00837
00838
00839
00840 SbBool isNodeFieldValuesImportant( SoNode *n );
00841
00842
00843
00844 void createFieldDataForWriting();
00845
00846
00847
00848 SoFieldData *fieldDataForWriting;
00849
00850
00851
00852
00853 SbPList savedList;
00854
00855
00856 SbBool readMyFields(SoInput *in, SoFieldData *&unknownFieldData );
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866 void undoSetDefaultOnFieldsThatMustWrite();
00867
00868
00869 int getNumChildren() const { return (children->getLength()); }
00870 void removeChild( int index );
00871 void removeChild( SoNode *child ) { removeChild(findChild(child)); }
00872 void removeAllChildren();
00873 void addChild( SoNode *child );
00874 int findChild( const SoNode *child ) const;
00875 void insertChild( SoNode *child, int newChildIndex );
00876 SoNode *getChild( int index) const { return (*children)[index]; }
00877 void replaceChild( int index, SoNode *newChild);
00878 void replaceChild( SoNode *oldChild, SoNode *newChild)
00879 { replaceChild(findChild(oldChild),newChild); }
00880
00881 static SbBool searchingChildren;
00882 };
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898 #if defined(_DEBUG)
00899 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
00900 ((partClassName *) SoBaseKit::typeCheck( partName, \
00901 partClassName::getClassTypeId(), \
00902 kitContainingPart->getPart( partName, TRUE )))
00903
00904 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
00905 ((partClassName *) SoBaseKit::typeCheck( partName, \
00906 partClassName::getClassTypeId(), \
00907 kitContainingPart->getPart( partName, FALSE )))
00908
00909 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
00910 ((partClassName *) SoBaseKit::typeCheck( partName, \
00911 partClassName::getClassTypeId(), \
00912 kitContainingPart->getAnyPart( partName, TRUE, FALSE, FALSE )))
00913
00914 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
00915 ((partClassName *) SoBaseKit::typeCheck( partName, \
00916 partClassName::getClassTypeId(), \
00917 kitContainingPart->getAnyPart( partName, FALSE, FALSE, FALSE )))
00918 #else
00919
00920 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
00921 ((partClassName *) kitContainingPart->getPart( partName, TRUE ))
00922 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
00923 ((partClassName *) kitContainingPart->getPart( partName, FALSE ))
00924 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
00925 ((partClassName *) kitContainingPart->getAnyPart( partName, TRUE, \
00926 FALSE, FALSE ))
00927 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
00928 ((partClassName *) kitContainingPart->getAnyPart( partName, FALSE, \
00929 FALSE, FALSE ))
00930 #endif
00931
00932 #endif
00933
00934