53 node* n =
dynamic_cast<node*
>(instance);
67 pinstance->set_focused_child(i);
106 std::string visit_order;
107 bool stop_if_not_implemented;
111 template <
typename TCH>
114 template <
typename TCH>
119 const std::string& _visit_order =
"pnc",
121 bool _stop_if_not_implemented =
false,
bool _ignore_activation_state =
false);
133#include <cgv/config/lib_end.h>
The action class is used in tree traversals together with the traverser.
T * get_interface()
use dynamic type cast to check for the given interface
virtual data::ref_ptr< group, true > get_group()
perform downcast to group
unsigned int get_nr_children() const
return the number of children
base_ptr get_child(unsigned int i) const
return the i-th child
The node class keeps a pointer to its parent.
node_ptr get_parent() const
return the parent node
interface of a handler for traverse callbacks
virtual bool on_enter_children(group_ptr g)
called before the children of a group node g are processed, return whether these should be skipped....
virtual bool on_enter_parent(node_ptr n)
called before the parent of a node n is processed, return whether this should be skipped....
virtual bool on_enter_node(base_ptr b)
called before a node b is processed, return, whether to skip this node. If the node is skipped,...
virtual bool on_leave_node(base_ptr b)
called when a node b is left, return whether to terminate traversal
virtual bool on_leave_parent(node_ptr n)
called when the parent of a node n has been left, return whether to terminate traversal
virtual bool on_leave_children(group_ptr g)
called when the children of a group node g have been left, return whether to terminate traversal
nodes should inherit from this policy class to allow selective tree traversals
bool get_active() const
return whether the current node is active
int get_policy() const
return the policy without the stop on success flag
void set_policy(int _policy)
set a new policy, always add stop on success flag if needed
bool stop_on_failure() const
return whether to stop on failure
void set_focused_child(int _focused_child)
set the focused child
void set_active(bool _active)
set the active flag of the current node
bool stop_on_success() const
return whether to stop on success
int get_focused_child() const
return the focused child or -1 if none is focused
traverse_policy(int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1)
construct default traverse policy that visits everything
bool traverse_tmp_1(base_ptr dest, base_ptr src, bool &force_termination, TCH &tch)
traverse a single object, template over a static traverse callback handler interface
traverser(action &_a, const std::string &_visit_order="pnc", TraverseStrategy _strategy=TS_DEPTH_FIRST, bool _stop_if_not_implemented=false, bool _ignore_activation_state=false)
construct from reference on action and traversal order string
bool ignore_activation_state
whether to ignore the active flag of the traverse policy of the traversed object
bool traverse(base_ptr start, traverse_callback_handler *tch=0)
traverse a tree starting at given node according to set strategy, order and dest and previously comin...
traverser & set_visit_order(const std::string &_visit_order)
set a different visiting order of node, children and parent
traverser & set_strategy(TraverseStrategy _strategy)
set a different traverse strategy
bool traverse_tmp_2(base_ptr p, base_ptr dest, base_ptr src, traverse_policy *tp, bool &force_termination, TCH &tch)
helper method encapsulating common functionality
bool empty() const
check if pointer is not yet set
the base namespace holds the base hierarchy, support for plugin registration and signals
bool grab_focus(X *instance)
try to grab the focus in the path of this node to the root of the tree
TraverseStrategy
not yet implemented
data::ref_ptr< base, true > base_ptr
ref counted pointer to base
TraversePolicy
different traversal policies
@ TP_AUTO_FOCUS
first traverse focused and then the remaining children
@ TP_STOP_ON_FAILURE
this is an optional flag for traversals with methods that return a bool. If the returned bool is true...
@ TP_ONLY_FOCUS
traverse all children
@ TP_FIRST_FOCUS
traverse only the focused child
@ TP_STOP_ON_SUCCESS
like previous but change focus to the child, where traversal succeeded
data::ref_ptr< node, true > node_ptr
ref counted pointer to a node
data::ref_ptr< group, true > group_ptr
ref counted pointer to a node
this header is dependency free