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_ACTION_
00052 #define _SO_ACTION_
00053
00054 #include <Inventor/SoLists.h>
00055 #include <Inventor/SoTypedObject.h>
00056 #include <Inventor/SoPath.h>
00057 #include <Inventor/STL/cassert>
00058 #include <SoDeprecationRules.h>
00059 #include <Inventor/misc/SoTempPath.h>
00060 #include <Inventor/misc/SoCompactPathList.h>
00061
00062 class SoEnabledElementsList;
00063 class SoActionMethodList;
00064 class SoSceneManager;
00065 class SoMultiPassManager;
00066 class SoTraversalPass;
00067 class SoActionImpl;
00068
00069 #ifdef _WIN32
00070 #pragma warning(push)
00071 #pragma warning(disable:4251)
00072 #endif
00073
00132 class SoAction: public SoTypedObject {
00133
00134 public:
00138 virtual ~SoAction();
00139
00143 static SoType getClassTypeId();
00144
00153 virtual void apply(SoNode *node);
00154
00163 virtual void apply(SoPath *path);
00164
00177 virtual void apply(const SoPathList &pathList,
00178 SbBool obeysRules = FALSE);
00179
00189 virtual void clearApplyResult() {};
00190
00196 virtual void invalidateState();
00197
00204 void stopActionInBranch()
00205 { m_continueInBranchFlag = FALSE; }
00206
00212 SbBool getContinueActionInBranchFlag() const
00213 { return m_continueInBranchFlag; }
00214
00218 void resetContinueActionInBranchFlag()
00219 { m_continueInBranchFlag = TRUE; }
00220
00228 void useAlternateRep(const SbBool enable);
00229
00234 SbBool isUsingAlternateRep() const;
00235
00242 void setSceneManager(SoSceneManager* mgr)
00243 { m_sceneManager = mgr; }
00244
00248 SoSceneManager* getSceneManager() const
00249 { return m_sceneManager; }
00250
00271 virtual void forwardTraversal( SoNode* node );
00272
00277 virtual void forwardTraversal( SoPath* path );
00278
00279
00280 public:
00281
00286 enum DistribMode {
00288 LOCAL_ONLY,
00290 CLUSTER_ONLY,
00292 ALL
00293 };
00294
00300 DistribMode getDistribMode() const
00301 { return m_distribMode; }
00302
00307 static void nullAction(SoAction *, SoNode *);
00308
00313 enum AppliedCode {
00315 NODE,
00317 PATH,
00319 PATH_LIST
00320 };
00321
00327 enum PathCode {
00329 NO_PATH,
00331 IN_PATH,
00333 BELOW_PATH,
00335 OFF_PATH
00336 };
00337
00342 AppliedCode getWhatAppliedTo() const { return appliedTo.code; }
00343
00349 SoNode * getNodeAppliedTo() const { return appliedTo.node.ptr(); }
00350
00356 SoPath * getPathAppliedTo() const { return appliedTo.path.ptr(); }
00357
00366 const SoPathList * getPathListAppliedTo() const
00367 { return appliedTo.pathList; }
00368
00377 const SoPathList * getOriginalPathListAppliedTo() const
00378 { return appliedTo.origPathList; }
00379
00387 SbBool isLastPathListAppliedTo() const
00388 { return appliedTo.isLastPathList; }
00389
00402 PathCode getPathCode(int &numIndices, const int *&indices)
00403 { if (appliedTo.curPathCode == IN_PATH) {
00404 usePathCode(numIndices, indices);
00405 }
00406 return appliedTo.curPathCode;
00407 }
00408
00412 PathCode getPathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices)
00413 {
00414 if (appliedTo.curPathCode == IN_PATH) {
00415 usePathCodeMI(numIndices, indices, instanceIndices);
00416 }
00417 return appliedTo.curPathCode;
00418 }
00419
00424 void traverse(SoNode *node);
00425
00430 SbBool hasTerminated() const { return terminated; }
00431
00438 const SoPath * getCurPath();
00439
00446 SoState* getState() const
00447 { return m_state; }
00448
00449
00450
00451
00452
00453
00461 virtual void setUpState();
00462
00469 virtual const SoEnabledElementsList & getEnabledElements() const;
00470
00476 void setPipeId( int id )
00477 { m_pipeId = id; }
00478
00484 int getPipeId() const
00485 { return m_pipeId; }
00486
00491 bool isBeingApplied() { return m_isBeingApplied; }
00492
00500 virtual bool preDelayedTraversal()
00501 { return true; }
00502
00510 virtual void postDelayedTraversal()
00511 {}
00512
00513 private:
00514 static void initClass();
00515 static void exitClass();
00516
00517
00518 static void initClasses();
00519 static void exitClasses();
00520
00522 virtual bool isEnabledElement( const SoType& ) const;
00523
00524
00525
00526
00527
00528
00529
00530
00531 PathCode getCurPathCode() const { return appliedTo.curPathCode;}
00532
00533
00534
00535
00536 void pushCurPath(int childIndex, int &lastFound);
00537
00538
00539
00540
00541 void pushCurPathMI(int childIndex, int &lastFound, int instanceIndex);
00542 void popCurPath(PathCode prevPathCode);
00543
00544 virtual SoNode * getCurPathTail();
00545
00546
00547 bool isForwardTraversing() const { return appliedTo.isForwardTraversing; }
00548
00549
00550 SoNode* getForwardTraversalCaller() const { return appliedTo.forwardTraversalCaller.ptr(); }
00551
00552
00553 void usePathCode(int &numIndices, const int *&indices);
00554
00555 void usePathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices);
00556
00557
00558
00559 void pushCurPath()
00560 { curPath.append(-1); }
00561 void popPushCurPath(int childIndex)
00562 { curPath.setTail(childIndex);}
00563
00564 void popPushCurPathMI(int childIndex, int instanceIndex)
00565 { curPath.setTail(childIndex, instanceIndex);}
00566 void popCurPath()
00567 { curPath.pop(); }
00568
00569
00570
00571 SbBool hasChangedState() const
00572 { return m_hasStateChanged; }
00573 #if 1 SoDEPRECATED
00578 virtual void switchToNodeTraversal( SoNode* node );
00579 SoDEPRECATED
00584 void switchToPathTraversal( SoPath* path )
00585 {
00586 forwardTraversal( path );
00587 }
00588 #endif
00591 DistribMode getDistribMode() { return m_distribMode; }
00592
00593
00594
00595 inline void lock()
00596 { m_criticalSection->lock(); }
00597
00598
00599 inline void unlock()
00600 { m_criticalSection->unlock(); }
00601
00602
00610 inline bool isAbortable() const
00611 { return m_isAbortable; }
00612
00616 inline void setAbortable(bool flag)
00617 { m_isAbortable = flag; }
00618
00623 bool shouldAbort() const;
00624
00637 void abort();
00638
00642 bool isAborted() const;
00643
00644 private:
00645
00646 SoAction();
00647
00648
00649
00650 SoAction(const SoAction&);
00651
00652
00653
00654
00655 virtual void beginTraversal(SoNode *node);
00656
00657
00658
00659 virtual void endTraversal(SoNode *) { ; }
00660
00661
00662
00663 void setTerminated(SbBool flag) { terminated = flag; }
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673 virtual SbBool shouldCompactPathLists() const;
00674
00679 void setDistribMode(DistribMode mode )
00680 { m_distribMode = mode; }
00681
00682 SoINTERNAL private:
00683
00684
00685 static SoEnabledElementsList *enabledElements;
00686
00687
00688 static SoActionMethodList *methods;
00689
00690 SoLightPath* getCurLightPath()
00691 { return &curPath; }
00692
00693 private:
00694
00695 virtual SoActionMethodList* getActionMethods();
00696 SbBool getUseAlternateRep() const
00697 { return m_useAlternatRep; }
00698
00699 SbBool isForcedUseAlternateRep() const
00700 { return m_forceUseAlternateRep; }
00701
00702 SoMultiPassManager* getMultiPassManager() const
00703 { return m_multiPassManager; }
00704
00705 bool isApplyingDelayed() const;
00706
00707 SoActionImpl* getImpl() { return m_impl; }
00708
00709 private:
00710
00711 SoState* m_state;
00712
00713
00714 static SoType classTypeId;
00715 static bool s_defaultAlternateRepUsage;
00716
00717
00718 SbThreadMutex* m_criticalSection;
00719
00720
00721 SbBool m_continueInBranchFlag;
00722
00723
00724 SoLightPath curPath;
00725
00726 SbBool m_hasStateChanged;
00727
00728
00729 DistribMode m_distribMode;
00730
00731
00732
00733
00734 struct AppliedTo {
00735 AppliedCode code;
00736 SoRef<SoNode> node;
00737 SoRef<SoPath> path;
00738 const SoPathList *pathList;
00739 const SoPathList *origPathList;
00740 SoRef<SoCompactPathList> compactPathList;
00741 int isLastPathList;
00742 PathCode curPathCode;
00743 bool isForwardTraversing;
00744 SoRef<SoNode> forwardTraversalCaller;
00745
00746
00747 AppliedTo();
00748 } appliedTo;
00749
00750
00751
00752 bool m_isBeingApplied;
00753
00754
00755
00756 SbBool m_useAlternatRep;
00757
00758
00759
00760 SbBool m_forceUseAlternateRep;
00761
00762
00763
00764 SoRef<SoTempPath> tempPath;
00765
00766
00767
00768
00769 int enabledElementsCounter;
00770
00771
00772 SbBool terminated;
00773
00774
00775
00776 int index;
00777
00778
00779
00780 void cleanUp();
00781
00782
00783 void splitPathList(const SoPathList &sortedList,
00784 const SoPathList &origPathList);
00785
00786
00787 void apply(const SoPathList &sortedList,
00788 const SoPathList &origPathList,
00789 SbBool isLastPathList);
00790
00791 int m_pipeId;
00792
00793 SoSceneManager* m_sceneManager;
00794
00795 SoMultiPassManager* m_multiPassManager;
00796
00797 bool m_isAbortable;
00798
00799 SoActionImpl* m_impl;
00800
00801 friend class SoDB;
00802 friend class SoMultiPassElement;
00803 };
00804
00805 #ifndef HIDDEN_FROM_DOC
00807 //
00808
00809
00810
00811
00812
00813
00814 #define SO_ENABLE(actionClass, elementClass) \
00815 if ( elementClass::getClassTypeId().isBad() ) \
00816 elementClass::initClass(); \
00817 actionClass::enableElement(elementClass::getClassTypeId(), \
00818 elementClass::getClassStackIndex())
00819
00820
00822
00823 #include <Inventor/lists/SoActionMethodList.h>
00824 #include <Inventor/lists/SoEnabledElementsList.h>
00825
00826 #endif // HIDDEN_FROM_DOC
00827
00828 #ifdef _WIN32
00829 #pragma warning(pop)
00830 #endif
00831
00832 #endif
00833
00834