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
00270 private:
00271
00275 enum DistribMode {
00277 LOCAL_ONLY,
00279 CLUSTER_ONLY,
00281 ALL
00282 };
00283
00288 DistribMode getDistribMode() const
00289 { return m_distribMode; }
00290
00291
00292 static void nullAction(SoAction *, SoNode *);
00293
00294
00295 enum AppliedCode {
00296 NODE,
00297 PATH,
00298 PATH_LIST
00299 };
00300
00301
00302
00303 enum PathCode {
00304 NO_PATH,
00305 IN_PATH,
00306 BELOW_PATH,
00307 OFF_PATH
00308 };
00309
00310
00311 AppliedCode getWhatAppliedTo() const { return appliedTo.code; }
00312
00313
00314
00315
00316 SoNode * getNodeAppliedTo() const { return appliedTo.node.ptr(); }
00317 SoPath * getPathAppliedTo() const { return appliedTo.path.ptr(); }
00318
00319
00320
00321
00322 const SoPathList * getPathListAppliedTo() const
00323 { return appliedTo.pathList; }
00324 const SoPathList * getOriginalPathListAppliedTo() const
00325 { return appliedTo.origPathList; }
00326 SbBool isLastPathListAppliedTo() const
00327 { return appliedTo.isLastPathList; }
00328
00340 PathCode getPathCode(int &numIndices, const int *&indices)
00341 { if (appliedTo.curPathCode == IN_PATH) {
00342 usePathCode(numIndices, indices);
00343 }
00344 return appliedTo.curPathCode;
00345 }
00346
00347 PathCode getPathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices)
00348 {
00349 if (appliedTo.curPathCode == IN_PATH) {
00350 usePathCodeMI(numIndices, indices, instanceIndices);
00351 }
00352 return appliedTo.curPathCode;
00353 }
00354
00355
00356
00357 void traverse(SoNode *node);
00358
00359
00360
00361 SbBool hasTerminated() const { return terminated; }
00362
00363
00364
00365
00366 const SoPath * getCurPath();
00367
00368
00369
00370
00371 SoState* getState() const
00372 { return m_state; }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 virtual void setUpState();
00384
00389 virtual const SoEnabledElementsList & getEnabledElements() const;
00390
00395 void setPipeId( int id )
00396 { m_pipeId = id; }
00397
00402 int getPipeId() const
00403 { return m_pipeId; }
00404
00406 bool isBeingApplied() { return m_isBeingApplied; }
00407
00414 virtual bool preDelayedTraversal()
00415 { return true; }
00416
00423 virtual void postDelayedTraversal()
00424 {}
00425
00426 private:
00427 static void initClass();
00428 static void exitClass();
00429
00430
00431 static void initClasses();
00432 static void exitClasses();
00433
00435 virtual bool isEnabledElement( const SoType& ) const;
00436
00437
00438
00439
00440
00441
00442
00443
00444 PathCode getCurPathCode() const { return appliedTo.curPathCode;}
00445
00446
00447
00448
00449 void pushCurPath(int childIndex, int &lastFound);
00450
00451
00452
00453
00454 void pushCurPathMI(int childIndex, int &lastFound, int instanceIndex);
00455 void popCurPath(PathCode prevPathCode);
00456
00457 virtual SoNode * getCurPathTail();
00458
00459
00460 bool isForwardTraversing() const { return appliedTo.isForwardTraversing; }
00461
00462
00463 SoNode* getForwardTraversalCaller() const { return appliedTo.forwardTraversalCaller.ptr(); }
00464
00465
00466 void usePathCode(int &numIndices, const int *&indices);
00467
00468 void usePathCodeMI(int &numIndices, const int *&indices, const int *&instanceIndices);
00469
00470
00471
00472 void pushCurPath()
00473 { curPath.append(-1); }
00474 void popPushCurPath(int childIndex)
00475 { curPath.setTail(childIndex);}
00476
00477 void popPushCurPathMI(int childIndex, int instanceIndex)
00478 { curPath.setTail(childIndex, instanceIndex);}
00479 void popCurPath()
00480 { curPath.pop(); }
00481
00482
00483
00484
00485
00486
00487 void switchToPathTraversal(SoPath *path);
00488
00489
00490
00491 SbBool hasChangedState() const
00492 { return m_hasStateChanged; }
00493 #if 1 SoDEPRECATED
00498 virtual void switchToNodeTraversal( SoNode* node );
00499 #endif
00502 DistribMode getDistribMode() { return m_distribMode; }
00503
00504
00505
00506 inline void lock()
00507 { m_criticalSection->lock(); }
00508
00509
00510 inline void unlock()
00511 { m_criticalSection->unlock(); }
00512
00513
00521 inline bool isAbortable() const
00522 { return m_isAbortable; }
00523
00527 inline void setAbortable(bool flag)
00528 { m_isAbortable = flag; }
00529
00534 bool shouldAbort() const;
00535
00548 void abort();
00549
00553 bool isAborted() const;
00554
00555 private:
00556
00557 SoAction();
00558
00559
00560
00561 SoAction(const SoAction&);
00562
00563
00564
00565
00566 virtual void beginTraversal(SoNode *node);
00567
00568
00569
00570 virtual void endTraversal(SoNode *) { ; }
00571
00572
00573
00574 void setTerminated(SbBool flag) { terminated = flag; }
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584 virtual SbBool shouldCompactPathLists() const;
00585
00590 void setDistribMode(DistribMode mode )
00591 { m_distribMode = mode; }
00592
00593 SoINTERNAL private:
00594
00595
00596 static SoEnabledElementsList *enabledElements;
00597
00598
00599 static SoActionMethodList *methods;
00600
00601 SoLightPath* getCurLightPath()
00602 { return &curPath; }
00603
00604 private:
00605
00606 virtual SoActionMethodList* getActionMethods();
00607 SbBool getUseAlternateRep() const
00608 { return m_useAlternatRep; }
00609
00610 SbBool isForcedUseAlternateRep() const
00611 { return m_forceUseAlternateRep; }
00612
00613 SoMultiPassManager* getMultiPassManager() const
00614 { return m_multiPassManager; }
00615
00616 bool isApplyingDelayed() const;
00617
00618 SoActionImpl* getImpl() { return m_impl; }
00619
00620 private:
00621
00622 SoState* m_state;
00623
00624
00625 static SoType classTypeId;
00626 static bool s_defaultAlternateRepUsage;
00627
00628
00629 SbThreadMutex* m_criticalSection;
00630
00631
00632 SbBool m_continueInBranchFlag;
00633
00634
00635 SoLightPath curPath;
00636
00637 SbBool m_hasStateChanged;
00638
00639
00640 DistribMode m_distribMode;
00641
00642
00643
00644
00645 struct AppliedTo {
00646 AppliedCode code;
00647 SoRef<SoNode> node;
00648 SoRef<SoPath> path;
00649 const SoPathList *pathList;
00650 const SoPathList *origPathList;
00651 SoRef<SoCompactPathList> compactPathList;
00652 int isLastPathList;
00653 PathCode curPathCode;
00654 bool isForwardTraversing;
00655 SoRef<SoNode> forwardTraversalCaller;
00656
00657
00658 AppliedTo();
00659 } appliedTo;
00660
00661
00662
00663 bool m_isBeingApplied;
00664
00665
00666
00667 SbBool m_useAlternatRep;
00668
00669
00670
00671 SbBool m_forceUseAlternateRep;
00672
00673
00674
00675 SoRef<SoTempPath> tempPath;
00676
00677
00678
00679
00680 int enabledElementsCounter;
00681
00682
00683 SbBool terminated;
00684
00685
00686
00687 int index;
00688
00689
00690
00691 void cleanUp();
00692
00693
00694 void splitPathList(const SoPathList &sortedList,
00695 const SoPathList &origPathList);
00696
00697
00698 void apply(const SoPathList &sortedList,
00699 const SoPathList &origPathList,
00700 SbBool isLastPathList);
00701
00702 int m_pipeId;
00703
00704 SoSceneManager* m_sceneManager;
00705
00706 SoMultiPassManager* m_multiPassManager;
00707
00708 bool m_isAbortable;
00709
00710 SoActionImpl* m_impl;
00711
00712 friend class SoDB;
00713 friend class SoMultiPassElement;
00714 };
00715
00716 #ifndef HIDDEN_FROM_DOC
00718 //
00719
00720
00721
00722
00723
00724
00725 #define SO_ENABLE(actionClass, elementClass) \
00726 if ( elementClass::getClassTypeId().isBad() ) \
00727 elementClass::initClass(); \
00728 actionClass::enableElement(elementClass::getClassTypeId(), \
00729 elementClass::getClassStackIndex())
00730
00731
00733
00734 #include <Inventor/lists/SoActionMethodList.h>
00735 #include <Inventor/lists/SoEnabledElementsList.h>
00736
00737 #endif // HIDDEN_FROM_DOC
00738
00739 #ifdef _WIN32
00740 #pragma warning(pop)
00741 #endif
00742
00743 #endif
00744
00745