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