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 __hpux
00070 # undef IN_PATH
00071 #endif
00072
00073 #ifdef _WIN32
00074 #pragma warning(push)
00075 #pragma warning(disable:4251)
00076 #endif
00077
00137 class SoAction: public SoTypedObject {
00138
00139 public:
00143 virtual ~SoAction();
00144
00148 static SoType getClassTypeId();
00149
00158 virtual void apply(SoNode *node);
00159
00168 virtual void apply(SoPath *path);
00169
00182 virtual void apply(const SoPathList &pathList,
00183 SbBool obeysRules = FALSE);
00184
00194 virtual void clearApplyResult() {};
00195
00201 virtual void invalidateState();
00202
00209 void stopActionInBranch()
00210 { m_continueInBranchFlag = FALSE; }
00211
00217 SbBool getContinueActionInBranchFlag() const
00218 { return m_continueInBranchFlag; }
00219
00223 void resetContinueActionInBranchFlag()
00224 { m_continueInBranchFlag = TRUE; }
00225
00229 enum DistribMode {
00231 LOCAL_ONLY,
00233 CLUSTER_ONLY,
00235 ALL
00236 };
00237
00245 void useAlternateRep(const SbBool enable);
00246
00251 SbBool isUsingAlternateRep() const;
00252
00259 void setSceneManager(SoSceneManager* mgr)
00260 { m_sceneManager = mgr; }
00261
00265 SoSceneManager* getSceneManager() const
00266 { return m_sceneManager; }
00267
00285 virtual void forwardTraversal( SoNode* node );
00286
00287 private:
00288
00289
00290 static void nullAction(SoAction *, SoNode *);
00291
00292
00293 enum AppliedCode {
00294 NODE,
00295 PATH,
00296 PATH_LIST
00297 };
00298
00299
00300
00301 enum PathCode {
00302 NO_PATH,
00303 IN_PATH,
00304 BELOW_PATH,
00305 OFF_PATH
00306 };
00307
00308
00309 AppliedCode getWhatAppliedTo() const { return appliedTo.code; }
00310
00311
00312
00313
00314 SoNode * getNodeAppliedTo() const { return appliedTo.node.ptr(); }
00315 SoPath * getPathAppliedTo() const { return appliedTo.path.ptr(); }
00316
00317
00318
00319
00320 const SoPathList * getPathListAppliedTo() const
00321 { return appliedTo.pathList; }
00322 const SoPathList * getOriginalPathListAppliedTo() const
00323 { return appliedTo.origPathList; }
00324 SbBool isLastPathListAppliedTo() const
00325 { return appliedTo.isLastPathList; }
00326
00338 PathCode getPathCode(int &numIndices, const int *&indices)
00339 { if (appliedTo.curPathCode == IN_PATH) {
00340 usePathCode(numIndices, indices);
00341 }
00342 return appliedTo.curPathCode;
00343 }
00344
00345 PathCode getPathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices)
00346 {
00347 if (appliedTo.curPathCode == IN_PATH) {
00348 usePathCodeMI(numIndices, indices, instanceIndices);
00349 }
00350 return appliedTo.curPathCode;
00351 }
00352
00353
00354
00355 void traverse(SoNode *node);
00356
00357
00358
00359 SbBool hasTerminated() const { return terminated; }
00360
00361
00362
00363
00364 const SoPath * getCurPath();
00365
00366
00367
00368
00369 SoState * getState() const { return state; }
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 virtual void setUpState();
00381
00386 virtual const SoEnabledElementsList & getEnabledElements() const;
00387
00392 void setPipeId( int id )
00393 { m_pipeId = id; }
00394
00399 int getPipeId() const
00400 { return m_pipeId; }
00401
00403 bool isBeingApplied() { return m_isBeingApplied; }
00404
00411 virtual bool preDelayedTraversal()
00412 { return true; }
00413
00420 virtual void postDelayedTraversal()
00421 {}
00422
00423 private:
00424 static void initClass();
00425 static void exitClass();
00426
00427
00428 static void initClasses();
00429 static void exitClasses();
00430
00432 virtual bool isEnabledElement( const SoType& ) const;
00433
00434
00435
00436
00437
00438
00439
00440
00441 PathCode getCurPathCode() const { return appliedTo.curPathCode;}
00442
00443
00444
00445
00446 void pushCurPath(int childIndex, int &lastFound);
00447
00448
00449
00450
00451 void pushCurPathMI(int childIndex, int &lastFound, int instanceIndex);
00452 void popCurPath(PathCode prevPathCode);
00453
00454 virtual SoNode * getCurPathTail();
00455
00456
00457 bool isForwardTraversing() const { return appliedTo.isForwardTraversing; }
00458
00459
00460 SoNode* getForwardTraversalCaller() const { return appliedTo.forwardTraversalCaller.ptr(); }
00461
00462
00463 void usePathCode(int &numIndices, const int *&indices);
00464
00465 void usePathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices);
00466
00467
00468
00469 void pushCurPath()
00470 { curPath.append(-1); }
00471 void popPushCurPath(int childIndex)
00472 { curPath.setTail(childIndex);}
00473
00474 void popPushCurPathMI(int childIndex, int instanceIndex)
00475 { curPath.setTail(childIndex, instanceIndex);}
00476 void popCurPath()
00477 { curPath.pop(); }
00478
00479
00480
00481
00482
00483
00484 void switchToPathTraversal(SoPath *path);
00485
00486 #if 1 SoDEPRECATED
00491 virtual void switchToNodeTraversal( SoNode* node );
00492 #endif
00494 SbBool hasChangedState() { return m_hasStateChanged; }
00495
00496 DistribMode getDistribMode() { return m_distribMode; }
00497
00498
00499 inline void lock()
00500 { m_criticalSection->lock(); }
00501
00502
00503 inline void unlock()
00504 { m_criticalSection->unlock(); }
00505
00506
00514 inline bool isAbortable() const
00515 { return m_isAbortable; }
00516
00520 inline void setAbortable(bool flag)
00521 { m_isAbortable = flag; }
00522
00527 bool shouldAbort() const;
00528
00541 void abort();
00542
00546 bool isAborted() const;
00547
00548 private:
00549
00550 SoAction();
00551
00552
00553
00554 SoAction(const SoAction&);
00555
00556
00557
00558
00559 virtual void beginTraversal(SoNode *node);
00560
00561
00562
00563 virtual void endTraversal(SoNode *) { ; }
00564
00565
00566
00567 void setTerminated(SbBool flag) { terminated = flag; }
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577 virtual SbBool shouldCompactPathLists() const;
00578
00579 SoINTERNAL private:
00580 SoState *state;
00581
00582
00583 SbBool m_continueInBranchFlag;
00584
00585
00586
00587 SoLightPath curPath;
00588
00589
00590 static SoEnabledElementsList *enabledElements;
00591
00592
00593 static SoActionMethodList *methods;
00594
00595 SbBool m_hasStateChanged;
00596
00597 virtual bool mustTraverseDepth() { return false; }
00598
00599 DistribMode m_distribMode;
00600
00601 private:
00602
00603 virtual SoActionMethodList* getActionMethods();
00604 SbBool getUseAlternateRep() const
00605 { return m_useAlternatRep; }
00606
00607 SbBool isForcedUseAlternateRep() const
00608 { return m_forceUseAlternateRep; }
00609
00610 SoMultiPassManager* getMultiPassManager() const
00611 { return m_multiPassManager; }
00612
00613 bool isApplyingDelayed() const;
00614
00615 SoActionImpl* getImpl() { return m_impl; }
00616
00617 private:
00618
00619
00620 static SoType classTypeId;
00621 static bool s_defaultAlternateRepUsage;
00622
00623 SbThreadMutex* m_criticalSection;
00624
00625
00626
00627
00628 struct AppliedTo {
00629 AppliedCode code;
00630 SoRef<SoNode> node;
00631 SoRef<SoPath> path;
00632 const SoPathList *pathList;
00633 const SoPathList *origPathList;
00634 SoRef<SoCompactPathList> compactPathList;
00635 int isLastPathList;
00636 PathCode curPathCode;
00637 bool isForwardTraversing;
00638 SoRef<SoNode> forwardTraversalCaller;
00639
00640
00641 AppliedTo();
00642 } appliedTo;
00643
00644
00645
00646 bool m_isBeingApplied;
00647
00648
00649
00650 SbBool m_useAlternatRep;
00651
00652
00653
00654 SbBool m_forceUseAlternateRep;
00655
00656
00657
00658 SoRef<SoTempPath> tempPath;
00659
00660
00661
00662
00663 int enabledElementsCounter;
00664
00665
00666 SbBool terminated;
00667
00668
00669
00670 int index;
00671
00672
00673
00674 void cleanUp();
00675
00676
00677 void splitPathList(const SoPathList &sortedList,
00678 const SoPathList &origPathList);
00679
00680
00681 void apply(const SoPathList &sortedList,
00682 const SoPathList &origPathList,
00683 SbBool isLastPathList);
00684
00685 int m_pipeId;
00686
00687 SoSceneManager* m_sceneManager;
00688
00689 SoMultiPassManager* m_multiPassManager;
00690
00691 bool m_isAbortable;
00692
00693 SoActionImpl* m_impl;
00694
00695 friend class SoDB;
00696 friend class SoMultiPassElement;
00697 };
00698
00699 #ifndef HIDDEN_FROM_DOC
00701 //
00702
00703
00704
00705
00706
00707
00708 #define SO_ENABLE(actionClass, elementClass) \
00709 if ( elementClass::getClassTypeId().isBad() ) \
00710 elementClass::initClass(); \
00711 actionClass::enableElement(elementClass::getClassTypeId(), \
00712 elementClass::getClassStackIndex())
00713
00714
00716
00717 #include <Inventor/lists/SoActionMethodList.h>
00718 #include <Inventor/lists/SoEnabledElementsList.h>
00719
00720 #endif // HIDDEN_FROM_DOC
00721
00722 #ifdef _WIN32
00723 #pragma warning(pop)
00724 #endif
00725
00726 #endif
00727
00728