#include <OSGAction.h>
Inheritance diagram for osg::Action:

Public Types | |
| typedef ArgsCollector< Action * > | FunctorArgs |
| typedef TypedFunctor2Base< ResultE, CPtrRefCallArg< CNodePtr >, FunctorArgs > | Functor |
| enum | ResultE { Continue, Skip, Quit } |
Public Member Functions | |
| virtual | ~Action (void) |
| Destructor. | |
| void | registerEnterFunction (const FieldContainerType &type, const Functor &func) |
| void | registerLeaveFunction (const FieldContainerType &type, const Functor &func) |
| virtual ResultE | apply (std::vector< NodePtr >::iterator begin, std::vector< NodePtr >::iterator end) |
| virtual ResultE | apply (NodePtr node) |
| NodePtr | getActNode (void) |
| UInt32 | getNNodes (void) const |
| const NodePtr | getNode (int index) |
| void | addNode (NodePtr node) |
| void | useNodeList (void) |
| void | printTable (void) |
| UInt32 | getTravMask (void) const |
| void | setTravMask (UInt32 val) |
| bool | operator< (const Action &other) |
| assignment | |
| bool | operator== (const Action &other) |
| equal | |
| bool | operator!= (const Action &other) |
| unequal | |
Static Public Member Functions | |
| static const char * | getClassname (void) |
| static Action * | create (void) |
| create a new action | |
| static void | setPrototype (Action *proto) |
| static Action * | getPrototype (void) |
| static void | registerEnterDefault (const FieldContainerType &type, const Functor &func) |
| static void | registerLeaveDefault (const FieldContainerType &type, const Functor &func) |
Protected Member Functions | |
| Action (void) | |
| Constructor. | |
| Action (const Action &source) | |
| Copy-Constructor. | |
| ResultE | callEnter (NodePtr node) |
| ResultE | callLeave (NodePtr node) |
| virtual ResultE | start (void) |
| virtual ResultE | stop (ResultE res) |
| ResultE | recurse (NodePtr node) |
| ResultE | callNewList (void) |
| virtual std::vector< Functor > * | getDefaultEnterFunctors (void) |
| virtual std::vector< Functor > * | getDefaultLeaveFunctors (void) |
| void | setActNode (NodePtr node) |
Static Protected Member Functions | |
| static ResultE | _defaultEnterFunction (CNodePtr &node, Action *action) |
| static ResultE | _defaultLeaveFunction (CNodePtr &node, Action *action) |
Protected Attributes | |
| std::vector< Functor > | _enterFunctors |
| std::vector< Functor > | _leaveFunctors |
Private Member Functions | |
| ResultE | callStart (void) |
| ResultE | callStop (ResultE res) |
| Action & | operator= (const Action &source) |
| assignment | |
Private Attributes | |
| NodePtr | _actNode |
| std::vector< NodePtr > * | _actList |
| bool | _useNewList |
| std::vector< NodePtr > | _newList |
| UInt32 | _travMask |
Static Private Attributes | |
| static char | cvsid [] = "@(#)$Id: $" |
| static Action * | _prototype = NULL |
| static std::vector< Functor > * | _defaultEnterFunctors |
| static std::vector< Functor > * | _defaultLeaveFunctors |
Definition at line 79 of file OSGAction.h.
|
|
Definition at line 95 of file OSGAction.h. |
|
|
Definition at line 99 of file OSGAction.h. |
|
|
Definition at line 87 of file OSGAction.h. 00088 { 00089 Continue, // continue with my children 00090 Skip, // skip my children 00091 // really needed? Cancel, // skip my brothers, go one step up 00092 Quit // forget it, you're done 00093 };
|
|
|
Definition at line 191 of file OSGAction.cpp.
|
|
|
Definition at line 153 of file OSGAction.cpp. References _defaultEnterFunctors, _defaultLeaveFunctors, _enterFunctors, and _leaveFunctors. Referenced by create(). 00153 : _travMask(TypeTraits<UInt32>::getMax()) 00154 { 00155 if ( _defaultEnterFunctors ) 00156 _enterFunctors = *_defaultEnterFunctors; 00157 00158 if ( _defaultLeaveFunctors ) 00159 _leaveFunctors = *_defaultLeaveFunctors; 00160 }
|
|
|
Definition at line 165 of file OSGAction.cpp. 00165 : 00166 _enterFunctors( source._enterFunctors ), 00167 _leaveFunctors( source._leaveFunctors ), 00168 _travMask ( source._travMask ) 00169 { 00170 }
|
|
|
Reimplemented in osg::DrawAction, osg::IntersectAction, and osg::VRMLWriteAction. Definition at line 109 of file OSGAction.h.
|
|
|
Reimplemented in osg::DrawAction, osg::IntersectAction, osg::RenderAction, and osg::VRMLWriteAction. Definition at line 176 of file OSGAction.cpp. References _prototype, and Action(). 00177 { 00178 Action * act; 00179 00180 if ( _prototype ) 00181 act = new Action( *_prototype ); 00182 else 00183 act = new Action(); 00184 00185 return act; 00186 }
|
|
|
Definition at line 119 of file OSGAction.cpp. References _prototype. 00120 { 00121 _prototype = proto; 00122 }
|
|
|
Reimplemented in osg::DrawAction, osg::IntersectAction, osg::RenderAction, and osg::VRMLWriteAction. Definition at line 124 of file OSGAction.cpp. References _prototype. 00125 { 00126 return _prototype; 00127 }
|
|
||||||||||||
|
Reimplemented in osg::DrawAction, osg::IntersectAction, and osg::RenderAction. Definition at line 83 of file OSGAction.cpp. References _defaultEnterFunction(), _defaultEnterFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef(). 00085 { 00086 if ( ! _defaultEnterFunctors ) 00087 _defaultEnterFunctors = new std::vector<Action::Functor>; 00088 00089 while(type.getId() >= _defaultEnterFunctors->size()) 00090 { 00091 _defaultEnterFunctors->push_back( 00092 osgTypedFunctionFunctor2CPtrRef< 00093 ResultE, 00094 CNodePtr, 00095 Action * >(&Action::_defaultEnterFunction)); 00096 } 00097 00098 (*_defaultEnterFunctors)[ type.getId() ] = func; 00099 }
|
|
||||||||||||
|
Reimplemented in osg::DrawAction, osg::IntersectAction, and osg::RenderAction. Definition at line 101 of file OSGAction.cpp. References _defaultLeaveFunction(), _defaultLeaveFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef(). 00103 { 00104 if ( ! _defaultLeaveFunctors ) 00105 _defaultLeaveFunctors = new std::vector<Action::Functor>; 00106 00107 while(type.getId() >= _defaultLeaveFunctors->size()) 00108 { 00109 _defaultLeaveFunctors->push_back( 00110 osgTypedFunctionFunctor2CPtrRef< 00111 ResultE, 00112 CNodePtr, 00113 Action * >(&Action::_defaultLeaveFunction)); 00114 } 00115 00116 (*_defaultLeaveFunctors)[ type.getId() ] = func; 00117 }
|
|
||||||||||||
|
Definition at line 201 of file OSGAction.cpp. References _defaultEnterFunction(), _enterFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef(). 00203 { 00204 while ( type.getId() >= _enterFunctors.size() ) 00205 { 00206 _enterFunctors.push_back( 00207 osgTypedFunctionFunctor2CPtrRef< 00208 ResultE, 00209 CNodePtr, 00210 Action * >(&Action::_defaultEnterFunction)); 00211 } 00212 00213 _enterFunctors[ type.getId() ] = func; 00214 }
|
|
||||||||||||
|
Definition at line 216 of file OSGAction.cpp. References _defaultLeaveFunction(), _leaveFunctors, osg::TypeBase::getId(), and osg::osgTypedFunctionFunctor2CPtrRef(). 00218 { 00219 while ( type.getId() >= _leaveFunctors.size() ) 00220 { 00221 _leaveFunctors.push_back( 00222 osgTypedFunctionFunctor2CPtrRef< 00223 ResultE, 00224 CNodePtr, 00225 Action * >(&Action::_defaultLeaveFunction)); 00226 } 00227 00228 _leaveFunctors[ type.getId() ] = func; 00229 }
|
|
||||||||||||
|
Reimplemented in osg::VRMLWriteAction. Definition at line 235 of file OSGAction.cpp. References callStart(), callStop(), Continue, osg::NullFC, Quit, recurse(), and SWARNING. Referenced by osg::VRMLWriteAction::apply(), apply(), osg::Navigator::buttonRelease(), osg::Viewport::draw(), osg::PassiveViewport::draw(), osg::WalkNavigator::forward(), osg::Navigator::getIntersectionPoint(), osg::Viewport::render(), osg::PassiveViewport::render(), osg::WalkNavigator::right(), and osg::VRMLWriteAction::write(). 00237 { 00238 Action::ResultE res = Continue; 00239 00240 // call the start function and its' returns 00241 if ( ( res = callStart() ) != Continue ) 00242 return res; 00243 00244 // call the given nodes 00245 00246 for ( ; begin != end; begin ++ ) 00247 { 00248 if ( *begin == NullFC ) 00249 { 00250 SWARNING << "apply: encountered NullNode!" << std::endl; 00251 return Quit; 00252 } 00253 else 00254 { 00255 res = recurse( *begin ); 00256 00257 if ( res != Continue ) 00258 break; 00259 } 00260 } 00261 00262 // call the stop function and its' returns 00263 res = callStop( res ); 00264 00265 return res; 00266 }
|
|
|
Reimplemented in osg::VRMLWriteAction. Definition at line 268 of file OSGAction.cpp. References apply(), osg::NullFC, Quit, and SWARNING. 00269 { 00270 if(node == NullFC) 00271 { 00272 SWARNING << "apply: node is Null!" << std::endl; 00273 return Quit; 00274 } 00275 00276 std::vector<NodePtr> nodeList; 00277 00278 nodeList.push_back(node); 00279 00280 return apply(nodeList.begin(), nodeList.end()); 00281 }
|
|
|
|
Definition at line 92 of file OSGAction.inl. References _actList, and _actNode. Referenced by osg::Switch::draw(), osg::DistanceLOD::draw(), osg::Switch::intersect(), and osg::DrawActionBase::selectVisibles(). 00093 { 00094 if ( ! _actList ) 00095 { 00096 return _actNode->getNChildren(); 00097 } 00098 else 00099 { 00100 return (*_actList).size(); 00101 } 00102 }
|
|
|
Definition at line 67 of file OSGAction.inl. References _actList, and _actNode. Referenced by osg::Switch::draw(), osg::DistanceLOD::draw(), osg::Switch::intersect(), and osg::DrawActionBase::selectVisibles(). 00068 { 00069 if ( ! _actList ) 00070 { 00071 return _actNode->getChild( index ); 00072 } 00073 else 00074 { 00075 return (*_actList)[ index ]; 00076 } 00077 }
|
|
|
Definition at line 80 of file OSGAction.inl. References _newList. Referenced by osg::Switch::draw(), osg::ProxyGroup::draw(), osg::DistanceLOD::draw(), osg::Switch::intersect(), and osg::DrawActionBase::selectVisibles(). 00081 { 00082 _newList.push_back( node ); 00083 }
|
|
|
Definition at line 86 of file OSGAction.inl. References _useNewList. Referenced by osg::Switch::draw(), osg::ProxyGroup::draw(), osg::DistanceLOD::draw(), osg::RenderAction::pushVisibility(), and osg::DrawActionBase::selectVisibles(). 00087 { 00088 _useNewList = true; 00089 }
|
|
|
|
|
|
Definition at line 106 of file OSGAction.inl. References _travMask. Referenced by recurse(). 00107 { 00108 return _travMask; 00109 }
|
|
|
Definition at line 112 of file OSGAction.inl. References _travMask. Referenced by osg::Viewport::draw(), and osg::Viewport::render(). 00113 { 00114 _travMask = val; 00115 }
|
|
|
Definition at line 455 of file OSGAction.cpp.
|
|
|
Definition at line 463 of file OSGAction.cpp.
|
|
|
Definition at line 471 of file OSGAction.cpp.
|
|
|
Definition at line 124 of file OSGAction.inl. References _defaultEnterFunction(), _enterFunctors, osg::NodePtr::getCore(), getDefaultEnterFunctors(), osg::TypeBase::getId(), and osg::NodeCore::getType(). Referenced by recurse(). 00125 { 00126 ResultE result; 00127 00128 UInt32 uiFunctorIndex = node->getCore()->getType().getId(); 00129 CNodePtr cnode(node); 00130 00131 if ( uiFunctorIndex < _enterFunctors.size() ) 00132 result = _enterFunctors[uiFunctorIndex].call(cnode,this); 00133 else if ( getDefaultEnterFunctors() && 00134 uiFunctorIndex < getDefaultEnterFunctors()->size() ) 00135 { 00136 // field container registered method after this action was instantiated 00137 // copy the new functors from default vector 00138 std::vector<Functor> *defaultEnter = getDefaultEnterFunctors(); 00139 00140 while ( defaultEnter->size() > _enterFunctors.size() ) 00141 { 00142 _enterFunctors.push_back( (*defaultEnter)[_enterFunctors.size()] ); 00143 } 00144 result = _enterFunctors[uiFunctorIndex].call(cnode,this); 00145 } 00146 else // unknown field container 00147 result = _defaultEnterFunction(cnode,this); 00148 00149 return result; 00150 }
|
|
|
Definition at line 153 of file OSGAction.inl. References _defaultLeaveFunction(), _leaveFunctors, osg::NodePtr::getCore(), getDefaultLeaveFunctors(), osg::TypeBase::getId(), and osg::NodeCore::getType(). Referenced by recurse(). 00154 { 00155 ResultE result; 00156 00157 UInt32 uiFunctorIndex = node->getCore()->getType().getId(); 00158 CNodePtr cnode(node); 00159 00160 if ( uiFunctorIndex < _leaveFunctors.size() ) 00161 result = _leaveFunctors[uiFunctorIndex].call(cnode,this); 00162 else if ( getDefaultLeaveFunctors() && 00163 uiFunctorIndex < getDefaultLeaveFunctors()->size() ) 00164 { 00165 // field container registered method after this action was instantiated 00166 // copy the new functors from default vector 00167 std::vector<Functor> *defaultLeave = getDefaultLeaveFunctors(); 00168 00169 while ( defaultLeave->size() > _leaveFunctors.size() ) 00170 { 00171 _leaveFunctors.push_back( (*defaultLeave)[_leaveFunctors.size()] ); 00172 } 00173 result = _leaveFunctors[uiFunctorIndex].call(cnode,this); 00174 } 00175 else // unknown field container 00176 result = _defaultLeaveFunction(cnode,this); 00177 00178 return result; 00179 }
|
|
|
Reimplemented in osg::DrawActionBase, osg::DrawAction, osg::IntersectAction, and osg::RenderAction. Definition at line 420 of file OSGAction.cpp. References Continue. Referenced by callStart(). 00421 { 00422 return Continue; 00423 }
|
|
|
Reimplemented in osg::RenderAction. Definition at line 425 of file OSGAction.cpp. Referenced by callStop().
|
|
|
Definition at line 288 of file OSGAction.cpp. References _actList, _actNode, _newList, _useNewList, callEnter(), callLeave(), callNewList(), Continue, osg::NodePtr::getCore(), getTravMask(), osg::NullFC, Quit, Skip, and SWARNING. Referenced by apply(), and callNewList(). 00289 { 00290 if ( node == NullFC ) 00291 return Continue; 00292 00293 if((node->getTravMask() & getTravMask()) == 0) 00294 return Continue; 00295 00296 NodeCorePtr core = node->getCore(); 00297 00298 if ( core == NullFC ) 00299 { 00300 SWARNING << "recurse: core is Null, don't know what to do!" 00301 << std::endl; 00302 return Quit; 00303 } 00304 00305 Action::ResultE result; 00306 00307 _actList = NULL; 00308 _actNode = node; 00309 _newList.clear(); 00310 _useNewList = false; 00311 00312 result = callEnter( node ); 00313 00314 if ( result != Continue ) 00315 { 00316 if ( result == Skip ) 00317 return Continue; 00318 00319 return result; 00320 } 00321 00322 if ( ! _newList.empty() ) 00323 { 00324 result = callNewList(); 00325 } 00326 else if ( ! _useNewList ) // new list is empty, but not used? 00327 { 00328 std::vector<NodePtr>::iterator it; 00329 00330 for ( it = node->getMFChildren()->begin(); it != node->getMFChildren()->end(); it ++ ) 00331 { 00332 result = recurse( *it ); 00333 00334 if ( result != Continue ) 00335 break; 00336 } 00337 } 00338 00339 _actNode = node; 00340 if ( result == Continue ) 00341 result = callLeave( node ); 00342 else 00343 callLeave( node ); 00344 00345 if ( result == Skip ) 00346 return Continue; 00347 00348 return result; 00349 }
|
|
|
Definition at line 352 of file OSGAction.cpp. References _actList, _newList, Continue, and recurse(). Referenced by callStart(), callStop(), and recurse(). 00353 { 00354 Action::ResultE result = Continue; 00355 00356 // need to make a copy, because the one in the action is cleared 00357 00358 std::vector<NodePtr> nodeList; 00359 nodeList.swap(_newList); 00360 00361 std::vector<NodePtr>::iterator it; 00362 00363 _actList = &nodeList; 00364 00365 for(it = nodeList.begin(); it != nodeList.end(); ++it) 00366 { 00367 result = recurse(*it); 00368 00369 if(result != Continue) 00370 break; 00371 } 00372 00373 return result; 00374 }
|
|
|
Reimplemented in osg::DrawActionBase, osg::DrawAction, osg::IntersectAction, osg::RenderAction, and osg::VRMLWriteAction. Definition at line 481 of file OSGAction.cpp. References _defaultEnterFunctors. Referenced by callEnter(). 00482 { 00483 return _defaultEnterFunctors; 00484 }
|
|
|
Reimplemented in osg::DrawActionBase, osg::DrawAction, osg::IntersectAction, osg::RenderAction, and osg::VRMLWriteAction. Definition at line 486 of file OSGAction.cpp. References _defaultLeaveFunctors. Referenced by callLeave(). 00487 { 00488 return _defaultLeaveFunctors; 00489 }
|
|
||||||||||||
|
Definition at line 498 of file OSGAction.cpp. References Continue. Referenced by callEnter(), osg::RenderAction::registerEnterDefault(), osg::IntersectAction::registerEnterDefault(), osg::DrawAction::registerEnterDefault(), registerEnterDefault(), and registerEnterFunction(). 00500 { 00501 return Continue; 00502 }
|
|
||||||||||||
|
Definition at line 504 of file OSGAction.cpp. References Continue. Referenced by callLeave(), osg::RenderAction::registerLeaveDefault(), osg::IntersectAction::registerLeaveDefault(), osg::DrawAction::registerLeaveDefault(), registerLeaveDefault(), and registerLeaveFunction(). 00506 { 00507 return Continue; 00508 }
|
|
|
Definition at line 61 of file OSGAction.inl. References _actNode. Referenced by osg::RenderAction::draw(). 00062 { 00063 _actNode = node; 00064 }
|
|
|
Definition at line 379 of file OSGAction.cpp. References _newList, callNewList(), Continue, and start(). Referenced by apply(). 00380 { 00381 Action::ResultE res = Continue; 00382 00383 // call the start and see if it returns some nodes 00384 00385 _newList.clear(); 00386 00387 if ( ( res = start() ) != Continue ) 00388 return res; 00389 00390 // got some nodes? call them 00391 00392 if ( ! _newList.empty() ) 00393 res = callNewList(); 00394 00395 // return the result 00396 00397 return res; 00398 }
|
|
|
Definition at line 402 of file OSGAction.cpp. References _newList, callNewList(), Continue, and stop(). Referenced by apply(). 00403 { 00404 // call the start and see if it returns some nodes 00405 00406 _newList.clear(); 00407 00408 if ( ( res = stop( res ) ) != Continue ) 00409 return res; 00410 00411 if ( ! _newList.empty() ) 00412 res = callNewList(); 00413 00414 return res; 00415 }
|
|
|
Definition at line 435 of file OSGAction.cpp. 00436 { 00437 if (this == &source) 00438 return *this; 00439 00440 // free mem alloced by members of 'this' 00441 00442 00443 // alloc new mem for members 00444 00445 // copy 00446 00447 return *this; 00448 }
|
|
|
Definition at line 261 of file OSGAction.h. Referenced by Action(), callEnter(), osg::DrawAction::DrawAction(), osg::IntersectAction::IntersectAction(), registerEnterFunction(), osg::RenderAction::RenderAction(), and osg::VRMLWriteAction::VRMLWriteAction(). |
|
|
Definition at line 262 of file OSGAction.h. Referenced by Action(), callLeave(), |