Commit a21ef70d authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis:

Traverse Node second pass

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5321 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9274fe73
......@@ -339,14 +339,16 @@ public:
/// Execute action on node first and then on its children
NodeFirst = 0x1,
/// Execute action the children first and then on this node
ChildrenFirst = 0x2
ChildrenFirst = 0x2,
/// Draw node in second pass
SecondPass = 0x4
};
/// Return how the node should be traversed
TraverseMode traverseMode () const { return traverseMode_; }
unsigned int traverseMode () const { return traverseMode_; }
/// Set traverse mode for node
void setTraverseMode(TraverseMode _mode) { traverseMode_ = _mode; }
void setTraverseMode(unsigned int _mode) { traverseMode_ = _mode; }
private:
......@@ -389,7 +391,7 @@ private:
bool dirty_;
/// traverse mode
TraverseMode traverseMode_;
unsigned int traverseMode_;
};
......
......@@ -90,21 +90,24 @@ traverse( BaseNode* _node,
if (_node->status() != BaseNode::HideNode)
{
_node->enter(_state, drawmode);
if (_node->traverseMode() == BaseNode::NodeFirst)
if (_node->traverseMode() & BaseNode::NodeFirst)
process_children &= _action(_node, _state);
}
if (process_children)
{
BaseNode::ChildIter cIt(_node->childrenBegin()),
cEnd(_node->childrenEnd());
for (; cIt != cEnd; ++cIt)
traverse(*cIt, _action, _state, _drawmode);
BaseNode::ChildIter cIt, cEnd(_node->childrenEnd());
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if (~(*cIt)->traverseMode() & BaseNode::SecondPass)
traverse(*cIt, _action, _state, _drawmode);
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if ((*cIt)->traverseMode() & BaseNode::SecondPass)
traverse(*cIt, _action, _state, _drawmode);
}
if (_node->status() != BaseNode::HideNode)
{
if (_node->traverseMode() == BaseNode::ChildrenFirst)
if (_node->traverseMode() & BaseNode::ChildrenFirst)
_action(_node, _state);
_node->leave(_state, drawmode);
}
......@@ -133,19 +136,22 @@ traverse( BaseNode* _node, Action& _action )
if (status != BaseNode::HideSubtree)
{
if (_node->status() != BaseNode::HideNode &&
_node->traverseMode() == BaseNode::NodeFirst)
_node->traverseMode() & BaseNode::NodeFirst)
process_children &= _action(_node);
if (process_children)
{
BaseNode::ChildIter cIt(_node->childrenBegin()),
cEnd(_node->childrenEnd());
for (; cIt != cEnd; ++cIt)
traverse(*cIt, _action);
BaseNode::ChildIter cIt, cEnd(_node->childrenEnd());
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if (~(*cIt)->traverseMode() & BaseNode::SecondPass)
traverse(*cIt, _action);
for (cIt = _node->childrenBegin(); cIt != cEnd; ++cIt)
if ((*cIt)->traverseMode() & BaseNode::SecondPass)
traverse(*cIt, _action);
}
if (_node->status() != BaseNode::HideNode &&
_node->traverseMode() == BaseNode::ChildrenFirst)
_node->traverseMode() & BaseNode::ChildrenFirst)
_action(_node);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment