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
00268 virtual void forwardTraversal( SoNode* node );
00269
00274 virtual void forwardTraversal( SoPath* path );
00275
00276
00277 public:
00278
00283 enum DistribMode {
00285 LOCAL_ONLY,
00287 CLUSTER_ONLY,
00289 ALL
00290 };
00291
00297 DistribMode getDistribMode() const
00298 { return m_distribMode; }
00299
00304 static void nullAction(SoAction *, SoNode *);
00305
00310 enum AppliedCode {
00312 NODE,
00314 PATH,
00316 PATH_LIST
00317 };
00318
00324 enum PathCode {
00326 NO_PATH,
00328 IN_PATH,
00330 BELOW_PATH,
00332 OFF_PATH
00333 };
00334
00339 AppliedCode getWhatAppliedTo() const { return appliedTo.code; }
00340
00346 SoNode * getNodeAppliedTo() const { return appliedTo.node.ptr(); }
00347
00353 SoPath * getPathAppliedTo() const { return appliedTo.path.ptr(); }
00354
00363 const SoPathList * getPathListAppliedTo() const
00364 { return appliedTo.pathList; }
00365
00374 const SoPathList * getOriginalPathListAppliedTo() const
00375 { return appliedTo.origPathList; }
00376
00384 SbBool isLastPathListAppliedTo() const
00385 { return appliedTo.isLastPathList; }
00386
00399 PathCode getPathCode(int &numIndices, const int *&indices)
00400 { if (appliedTo.curPathCode == IN_PATH) {
00401 usePathCode(numIndices, indices);
00402 }
00403 return appliedTo.curPathCode;
00404 }
00405
00409 PathCode getPathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices)
00410 {
00411 if (appliedTo.curPathCode == IN_PATH) {
00412 usePathCodeMI(numIndices, indices, instanceIndices);
00413 }
00414 return appliedTo.curPathCode;
00415 }
00416
00421 void traverse(SoNode *node);
00422
00427 SbBool hasTerminated() const { return terminated; }
00428
00435 const SoPath * getCurPath();
00436
00443 SoState* getState() const
00444 { return m_state; }
00445
00446
00447
00448
00449
00450
00458 virtual void setUpState();
00459
00466 virtual const SoEnabledElementsList & getEnabledElements() const;
00467
00473 void setPipeId( int id )
00474 { m_pipeId = id; }
00475
00481 int getPipeId() const
00482 { return m_pipeId; }
00483
00488 bool isBeingApplied() { return m_isBeingApplied; }
00489
00497 virtual bool preDelayedTraversal()
00498 { return true; }
00499
00507 virtual void postDelayedTraversal()
00508 {}
00509
00510 private:
00511 static void initClass();
00512 static void exitClass();
00513
00514
00515 static void initClasses();
00516 static void exitClasses();
00517
00519 virtual bool isEnabledElement( const SoType& ) const;
00520
00521
00522
00523
00524
00525
00526
00527
00528 PathCode getCurPathCode() const { return appliedTo.curPathCode;}
00529
00530
00531
00532
00533 void pushCurPath(int childIndex, int &lastFound);
00534
00535
00536
00537
00538 void pushCurPathMI(int childIndex, int &lastFound, int instanceIndex);
00539 void popCurPath(PathCode prevPathCode);
00540
00541 virtual SoNode * getCurPathTail();
00542
00543
00544 bool isForwardTraversing() const { return appliedTo.isForwardTraversing; }
00545
00546
00547 SoNode* getForwardTraversalCaller() const { return appliedTo.forwardTraversalCaller.ptr(); }
00548
00549
00550 void usePathCode(int &numIndices, const int *&indices);
00551
00552 void usePathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices);
00553
00554
00555
00556 void pushCurPath()
00557 { curPath.append(-1); }
00558 void popPushCurPath(int childIndex)
00559 { curPath.setTail(childIndex);}
00560
00561 void popPushCurPathMI(int childIndex, int instanceIndex)
00562 { curPath.setTail(childIndex, instanceIndex);}
00563 void popCurPath()
00564 { curPath.pop(); }
00565
00566
00567
00568 SbBool hasChangedState() const
00569 { return m_hasStateChanged; }
00570 #if 1 SoDEPRECATED
00575 virtual void switchToNodeTraversal( SoNode* node );
00576 SoDEPRECATED
00581 void switchToPathTraversal( SoPath* path )
00582 {
00583 forwardTraversal( path );
00584 }
00585 #endif
00588 DistribMode getDistribMode() { return m_distribMode; }
00589
00590
00591
00592 inline void lock()
00593 { m_criticalSection->lock(); }
00594
00595
00596 inline void unlock()
00597 { m_criticalSection->unlock(); }
00598
00599
00607 inline bool isAbortable() const
00608 { return m_isAbortable; }
00609
00613 inline void setAbortable(bool flag)
00614 { m_isAbortable = flag; }
00615
00620 bool shouldAbort() const;
00621
00634 void abort();
00635
00639 bool isAborted() const;
00640
00641 private:
00642
00643 SoAction();
00644
00645
00646
00647 SoAction(const SoAction&);
00648
00649
00650
00651
00652 virtual void beginTraversal(SoNode *node);
00653
00654
00655
00656 virtual void endTraversal(SoNode *) { ; }
00657
00658
00659
00660 void setTerminated(SbBool flag) { terminated = flag; }
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670 virtual SbBool shouldCompactPathLists() const;
00671
00676 void setDistribMode(DistribMode mode )
00677 { m_distribMode = mode; }
00678
00679 SoINTERNAL private:
00680
00681
00682 static SoEnabledElementsList *enabledElements;
00683
00684
00685 static SoActionMethodList *methods;
00686
00687 SoLightPath* getCurLightPath()
00688 { return &curPath; }
00689
00690 private:
00691
00692 virtual SoActionMethodList* getActionMethods();
00693 SbBool getUseAlternateRep() const
00694 { return m_useAlternatRep; }
00695
00696 SbBool isForcedUseAlternateRep() const
00697 { return m_forceUseAlternateRep; }
00698
00699 SoMultiPassManager* getMultiPassManager() const
00700 { return m_multiPassManager; }
00701
00702 bool isApplyingDelayed() const;
00703
00704 SoActionImpl* getImpl() { return m_impl; }
00705
00706 private:
00707
00708 SoState* m_state;
00709
00710
00711 static SoType classTypeId;
00712 static bool s_defaultAlternateRepUsage;
00713
00714
00715 SbThreadMutex* m_criticalSection;
00716
00717
00718 SbBool m_continueInBranchFlag;
00719
00720
00721 SoLightPath curPath;
00722
00723 SbBool m_hasStateChanged;
00724
00725
00726 DistribMode m_distribMode;
00727
00728
00729
00730
00731 struct AppliedTo {
00732 AppliedCode code;
00733 SoRef<SoNode> node;
00734 SoRef<SoPath> path;
00735 const SoPathList *pathList;
00736 const SoPathList *origPathList;
00737 SoRef<SoCompactPathList> compactPathList;
00738 int isLastPathList;
00739 PathCode curPathCode;
00740 bool isForwardTraversing;
00741 SoRef<SoNode> forwardTraversalCaller;
00742
00743
00744 AppliedTo();
00745 } appliedTo;
00746
00747
00748
00749 bool m_isBeingApplied;
00750
00751
00752
00753 SbBool m_useAlternatRep;
00754
00755
00756
00757 SbBool m_forceUseAlternateRep;
00758
00759
00760
00761 SoRef<SoTempPath> tempPath;
00762
00763
00764
00765
00766 int enabledElementsCounter;
00767
00768
00769 SbBool terminated;
00770
00771
00772
00773 int index;
00774
00775
00776
00777 void cleanUp();
00778
00779
00780 void splitPathList(const SoPathList &sortedList,
00781 const SoPathList &origPathList);
00782
00783
00784 void apply(const SoPathList &sortedList,
00785 const SoPathList &origPathList,
00786 SbBool isLastPathList);
00787
00788 int m_pipeId;
00789
00790 SoSceneManager* m_sceneManager;
00791
00792 SoMultiPassManager* m_multiPassManager;
00793
00794 bool m_isAbortable;
00795
00796 SoActionImpl* m_impl;
00797
00798 friend class SoDB;
00799 friend class SoMultiPassElement;
00800 };
00801
00802 #ifndef HIDDEN_FROM_DOC
00804 //
00805
00806
00807
00808
00809
00810
00811 #define SO_ENABLE(actionClass, elementClass) \
00812 if ( elementClass::getClassTypeId().isBad() ) \
00813 elementClass::initClass(); \
00814 actionClass::enableElement(elementClass::getClassTypeId(), \
00815 elementClass::getClassStackIndex())
00816
00817
00819
00820 #include <Inventor/lists/SoActionMethodList.h>
00821 #include <Inventor/lists/SoEnabledElementsList.h>
00822
00823 #endif // HIDDEN_FROM_DOC
00824
00825 #ifdef _WIN32
00826 #pragma warning(pop)
00827 #endif
00828
00829 #endif
00830
00831