fixed: auto_ptr -> unique_ptr
[opensg.git] / Bindings / Python / helpers / helpers.py
blob7f41a83058d91e40dd32065e44366b570db3720d
1 # PyOpenSG is (C) Copyright 2005-2009 by Allen Bierbaum
3 # This file is part of PyOpenSG.
5 # PyOpenSG is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option)
8 # any later version.
10 # PyOpenSG is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13 # more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Helper class
20 import osg2
22 class PrintTreeTraverser(object):
23 def __init__(self):
24 self.depth = 0
26 def traverse(self, node):
27 return osg2.osg.traverse(node, self.enter, self.exit)
29 def enter(self, node):
30 core = node.getCore()
31 print " "*self.depth, "Enter: %s [%s]"%(osg2.osg.getName(node),core)
32 self.depth += 1
33 return osg2.osg.Action.Continue
35 def exit(self, node, result):
36 self.depth -= 1
37 core = node.getCore()
38 print " "*self.depth, "Exit: %s [%s]"%(osg2.osg.getName(node),core)
39 return result