# Helper class

import osg2

class PrintTreeTraverser(object):
   def __init__(self):
      self.depth = 0

   def traverse(self, node):
      return osg2.traverse(node, self.enter, self.exit)

   def enter(self, node):
      core = node.getCore()      
      print "  "*self.depth, "Enter: %s [%s]"%(osg2.getName(node),core)
      self.depth += 1
      return osg2.Action.Continue

   def exit(self, node, result):
      self.depth -= 1
      core = node.getCore()
      print "  "*self.depth, "Exit: %s [%s]"%(osg2.getName(node),core)
      return result
