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
00303 class SoBaseKit : public SoNode, public SoGetView {
00304
00305
00306
00307
00308
00309
00310 SO_NODE_HEADER(SoBaseKit);
00311
00312 public:
00316 SoSFBool boundingBoxIgnoring;
00317
00318 private:
00319
00320 static SoNodekitCatalog *nodekitCatalog;
00321
00322 static const SoNodekitCatalog **parentNodekitCatalogPtr;
00323
00324 public:
00328 static const SoNodekitCatalog *getClassNodekitCatalog();
00329
00336
00337 virtual const SoNodekitCatalog *getNodekitCatalog() const;
00338
00339
00340 private:
00341 static const SoNodekitCatalog **getClassNodekitCatalogPtr();
00342
00343
00344 SO_KIT_CATALOG_ENTRY_HEADER(callbackList);
00345
00346 public:
00347
00351 SoBaseKit();
00352
00393 virtual SoNode *getPart( const SbName &partName, SbBool makeIfNeeded );
00394
00400 SbString getPartString( const SoBase *part );
00401
00402
00413 virtual SoNodeKitPath *createPathToPart( const SbName &partName,
00414 SbBool makeIfNeeded, const SoPath *pathToExtend = NULL );
00415
00439 virtual SbBool setPart( const SbName &partName, SoNode *newPart );
00440
00458 SoNONUNICODE SbBool set(char *nameValuePairListString);
00459
00475 SbBool set( const SbString& nameValuePairListString);
00476
00495 SoNONUNICODE SbBool set(const char *partNameString, const char *parameterString);
00496
00513 SbBool set( const SbString& partNameString, const SbString& parameterString);
00514
00519 static void setSearchingChildren( SbBool newVal );
00520
00525 static SbBool isSearchingChildren() { return searchingChildren; }
00526
00527 private:
00528
00535 inline virtual SbBool isBoundingBoxIgnoring() const
00536 { return boundingBoxIgnoring.getValue(); }
00537
00538 virtual void doAction( SoAction *action );
00539
00540 virtual void callback( SoCallbackAction *action );
00541 virtual void GLRender( SoGLRenderAction *action );
00542 virtual void getBoundingBox( SoGetBoundingBoxAction *action );
00543 virtual void getMatrix(SoGetMatrixAction *action );
00544 virtual void handleEvent( SoHandleEventAction *action );
00545 virtual void rayPick( SoRayPickAction *action );
00546 virtual void search( SoSearchAction *action );
00547 virtual void write( SoWriteAction *action );
00548 virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action);
00549
00550 private:
00551 static void initClass();
00552 static void exitClass();
00553
00554
00555
00556
00557
00558 SbBool set(char *partNameString, char *parameterString)
00559 { return set((const char*)partNameString, (const char*)parameterString); };
00560
00561
00562 virtual SoChildList *getChildren() const;
00563
00564 static SoNode *typeCheck( const SbName &partName, const SoType &partType,
00565 SoNode *node );
00566
00567 void printDiagram();
00568 void printSubDiagram( const SbName &rootName, int level );
00569 void printTable();
00570
00571
00572
00573 virtual void addWriteReference(SoOutput *out,
00574 SbBool isFromField = FALSE);
00575
00576 friend class SoNodekitCatalogEntry;
00577 friend class SoNodekitParts;
00578 friend class SoV1BaseKit;
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 SbBool forceChildDrivenWriteRefs( SoOutput *out );
00590
00591
00592 static void enableNotification(SbBool);
00593 static SbBool isEnabledNotification();
00594
00595 virtual SbBool setAnyPart( const SbName &partName, SoNode *from, SbBool anyPart = TRUE );
00596
00597 SoNode *internalGetAnyPart( const SbName &partName, SbBool makeIfNeeded,
00598 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
00599
00600 private:
00601
00602 SoChildList *children;
00603
00604
00605 virtual SoNode * addToCopyDict() const;
00606
00607
00608 virtual void copyContents(const SoFieldContainer *fromFC,
00609 SbBool copyConnections);
00610
00611
00612
00613 SoGroup *getContainerNode( const SbName &listName,
00614 SbBool makeIfNeeded = TRUE );
00615
00616
00617
00618
00619
00620 virtual SoNode *getAnyPart( const SbName &partName, SbBool makeIfNeeded,
00621 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE );
00622 virtual SoNodeKitPath *createPathToAnyPart(const SbName &partName,
00623 SbBool makeIfNeeded,
00624 SbBool leafCheck = FALSE, SbBool publicCheck = FALSE,
00625 const SoPath *pathToExtend = NULL );
00626
00627
00628 SoNodekitParts *nodekitPartsList;
00629
00630
00631 void createNodekitPartsList();
00632
00633
00634 virtual void createDefaultParts();
00635
00636
00637 const SoNodekitParts *getNodekitPartsList() const
00638 { return nodekitPartsList; };
00639
00640
00641 void catalogError();
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653 virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00654 SbBool connectionsSetUp;
00655
00656
00657 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669 virtual void setDefaultOnNonWritingFields();
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 void countMyFields(SoOutput *out);
00691
00692 virtual ~SoBaseKit();
00693
00694 static SbBool m_enableBaseKitNotification;
00695
00696
00697 virtual void internalRemoveChild( int index ) { removeChild(index); }
00698 virtual void internalRemoveChild( SoNode *child ) { removeChild(findChild(child)); }
00699 virtual void internalRemoveAllChildren() { removeAllChildren(); }
00700 virtual void internalAddChild( SoNode *child ) { addChild(child); }
00701 virtual int internalFindChild( const SoNode *child ) const { return findChild(child); }
00702 virtual void internalInsertChild( SoNode *child, int newChildIndex ) { insertChild(child, newChildIndex); }
00703 virtual SoNode *internalGetChild( int index) const { return getChild(index); }
00704 virtual void internalReplaceChild( int index, SoNode *newChild) { replaceChild(index, newChild); }
00705 virtual void internalReplaceChild( SoNode *oldChild, SoNode *newChild) { replaceChild(oldChild,newChild); }
00706
00707 private:
00708
00709
00710 void endWrite( SoOutput* out );
00711
00712 private:
00713 void skipWhiteSpace(char *&string);
00714
00715
00716
00717 SbBool isNodeFieldValuesImportant( SoNode *n );
00718
00719
00720
00721 void createFieldDataForWriting();
00722
00723
00724
00725 SoFieldData *fieldDataForWriting;
00726
00727
00728
00729
00730 SbPList savedList;
00731
00732
00733 SbBool readMyFields(SoInput *in, SoFieldData *&unknownFieldData );
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 void undoSetDefaultOnFieldsThatMustWrite();
00744
00745
00746 int getNumChildren() const { return (children->getLength()); }
00747 void removeChild( int index );
00748 void removeChild( SoNode *child ) { removeChild(findChild(child)); }
00749 void removeAllChildren();
00750 void addChild( SoNode *child );
00751 int findChild( const SoNode *child ) const;
00752 void insertChild( SoNode *child, int newChildIndex );
00753 SoNode *getChild( int index) const { return (*children)[index]; }
00754 void replaceChild( int index, SoNode *newChild);
00755 void replaceChild( SoNode *oldChild, SoNode *newChild)
00756 { replaceChild(findChild(oldChild),newChild); }
00757
00758 static SbBool searchingChildren;
00759 };
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775 #if defined(_DEBUG)
00776 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
00777 ((partClassName *) SoBaseKit::typeCheck( partName, \
00778 partClassName::getClassTypeId(), \
00779 kitContainingPart->getPart( partName, TRUE )))
00780
00781 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
00782 ((partClassName *) SoBaseKit::typeCheck( partName, \
00783 partClassName::getClassTypeId(), \
00784 kitContainingPart->getPart( partName, FALSE )))
00785
00786 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
00787 ((partClassName *) SoBaseKit::typeCheck( partName, \
00788 partClassName::getClassTypeId(), \
00789 kitContainingPart->getAnyPart( partName, TRUE, FALSE, FALSE )))
00790
00791 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
00792 ((partClassName *) SoBaseKit::typeCheck( partName, \
00793 partClassName::getClassTypeId(), \
00794 kitContainingPart->getAnyPart( partName, FALSE, FALSE, FALSE )))
00795 #else
00796
00797 #define SO_GET_PART( kitContainingPart, partName, partClassName ) \
00798 ((partClassName *) kitContainingPart->getPart( partName, TRUE ))
00799 #define SO_CHECK_PART( kitContainingPart, partName, partClassName ) \
00800 ((partClassName *) kitContainingPart->getPart( partName, FALSE ))
00801 #define SO_GET_ANY_PART( kitContainingPart, partName, partClassName ) \
00802 ((partClassName *) kitContainingPart->getAnyPart( partName, TRUE, \
00803 FALSE, FALSE ))
00804 #define SO_CHECK_ANY_PART( kitContainingPart, partName, partClassName ) \
00805 ((partClassName *) kitContainingPart->getAnyPart( partName, FALSE, \
00806 FALSE, FALSE ))
00807 #endif
00808
00809 #endif
00810
00811