<s> """<STR_LIT>""" <EOL> import re <EOL> from traits . api import HasTraits , Property , Any , Instance , Trait , List , Str , Dict , Python <EOL> from traitsui . api import TreeEditor , TreeNodeObject , ObjectTreeNode , View , Item , Group <EOL> from traitsui . menu import Menu , Action <EOL> from tvtk . api import tvtk <EOL> from tvtk import messenger <EOL> from tvtk . tvtk_base import TVTKBase <EOL> from tvtk . tvtk_base_handler import TVTKBaseHandler <EOL> from tvtk . common import camel2enthought <EOL> def is_iterable ( x ) : <EOL> return hasattr ( x , '<STR_LIT>' ) <EOL> def get_icon ( object_name ) : <EOL> """<STR_LIT>""" <EOL> icon_map = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:source>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> name = object_name . lower ( ) <EOL> for key in icon_map : <EOL> if name . endswith ( key ) : <EOL> return icon_map [ key ] <EOL> return '<STR_LIT>' <EOL> class TreeGenerator ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> def has_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def get_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def get_node ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def get_nodes ( self , menu ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> class SimpleTreeGenerator ( TreeGenerator ) : <EOL> """<STR_LIT>""" <EOL> def has_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( obj , ( tvtk . RenderWindow , tvtk . Renderer , <EOL> tvtk . Collection ) ) : <EOL> return True <EOL> for attribute in [ '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT:input>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if hasattr ( obj , attribute ) : <EOL> return True <EOL> return False <EOL> def get_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> kids = { } <EOL> def _add_kid ( key , x ) : <EOL> if x is None : <EOL> kids [ key ] = None <EOL> else : <EOL> if type ( x ) in ( type ( [ ] ) , type ( ( ) ) ) : <EOL> x1 = [ i for i in x if isinstance ( i , TVTKBase ) ] <EOL> if x1 : <EOL> kids [ key ] = x1 <EOL> elif isinstance ( x , TVTKBase ) : <EOL> kids [ key ] = x <EOL> if isinstance ( obj , tvtk . RenderWindow ) : <EOL> return { '<STR_LIT>' : obj . renderers } <EOL> elif isinstance ( obj , tvtk . Renderer ) : <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> return { '<STR_LIT>' : obj . view_props , <EOL> '<STR_LIT>' : obj . active_camera } <EOL> else : <EOL> return { '<STR_LIT>' : obj . props , <EOL> '<STR_LIT>' : obj . active_camera } <EOL> for attribute in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if hasattr ( obj , attribute ) : <EOL> _add_kid ( attribute , getattr ( obj , attribute ) ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> srcs = [ obj . get_source ( i ) for i in range ( obj . number_of_sources ) ] <EOL> _add_kid ( '<STR_LIT:source>' , srcs ) <EOL> elif hasattr ( obj , '<STR_LIT:source>' ) : <EOL> _add_kid ( '<STR_LIT:source>' , obj . source ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> inputs = [ ] <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> if obj . number_of_input_ports : <EOL> inputs = [ obj . get_input ( i ) for i in range ( obj . number_of_input_ports ) ] <EOL> else : <EOL> inputs = [ obj . get_input ( i ) for i in range ( obj . number_of_inputs ) ] <EOL> _add_kid ( '<STR_LIT:input>' , inputs ) <EOL> elif hasattr ( obj , '<STR_LIT:input>' ) : <EOL> _add_kid ( '<STR_LIT:input>' , obj . input ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> _add_kid ( '<STR_LIT>' , obj . producer_port ) <EOL> return kids <EOL> def get_node ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> if self . has_children ( obj ) : <EOL> return TVTKBranchNode ( object = obj , tree_generator = self ) <EOL> else : <EOL> return TVTKLeafNode ( object = obj ) <EOL> def get_nodes ( self , menu ) : <EOL> """<STR_LIT>""" <EOL> nodes = [ ObjectTreeNode ( node_for = [ TVTKBranchNode ] , <EOL> view = View ( Group ( Item ( '<STR_LIT:object>' , style = '<STR_LIT>' ) , <EOL> show_labels = False ) ) , <EOL> auto_open = False , <EOL> children = '<STR_LIT>' , label = '<STR_LIT:name>' , menu = menu , <EOL> rename = False , delete = False , copy = False , <EOL> insert = False ) , <EOL> ObjectTreeNode ( node_for = [ TVTKLeafNode ] , <EOL> view = View ( Group ( Item ( '<STR_LIT:object>' , style = '<STR_LIT>' ) , <EOL> show_labels = False ) ) , <EOL> auto_open = False , <EOL> label = '<STR_LIT:name>' , menu = menu , rename = False , <EOL> delete = False , copy = False , insert = False ) , <EOL> ObjectTreeNode ( node_for = [ TVTKCollectionNode ] , <EOL> auto_open = True , children = '<STR_LIT>' , <EOL> label = '<STR_LIT:name>' , menu = menu , rename = False , <EOL> delete = False , copy = False , insert = False ) , <EOL> ] <EOL> return nodes <EOL> class FullTreeGenerator ( SimpleTreeGenerator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ** traits ) : <EOL> super ( FullTreeGenerator , self ) . __init__ ( ** traits ) <EOL> self . last_transform = <NUM_LIT:0> <EOL> def get_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> vtk_obj = tvtk . to_vtk ( obj ) <EOL> methods = self . _get_methods ( vtk_obj ) <EOL> kids = { } <EOL> def _add_kid ( key , x ) : <EOL> if x is None : <EOL> kids [ key ] = None <EOL> else : <EOL> if type ( x ) in ( type ( [ ] ) , type ( ( ) ) ) : <EOL> x1 = [ i for i in x if isinstance ( i , TVTKBase ) ] <EOL> if x1 : <EOL> kids [ key ] = x1 <EOL> elif isinstance ( x , TVTKBase ) : <EOL> if hasattr ( x , '<STR_LIT>' ) : <EOL> if len ( list ( x ) ) and isinstance ( list ( x ) [ <NUM_LIT:0> ] , TVTKBase ) : <EOL> kids [ key ] = x <EOL> else : <EOL> kids [ key ] = x <EOL> for method in methods : <EOL> attr = camel2enthought ( method [ <NUM_LIT:0> ] ) <EOL> if hasattr ( obj , attr ) : <EOL> _add_kid ( attr , getattr ( obj , attr ) ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> srcs = [ obj . get_source ( i ) for i in range ( obj . number_of_sources ) ] <EOL> _add_kid ( '<STR_LIT:source>' , srcs ) <EOL> elif hasattr ( obj , '<STR_LIT:source>' ) : <EOL> _add_kid ( '<STR_LIT:source>' , obj . source ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> inputs = [ ] <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> if obj . number_of_input_ports : <EOL> inputs = list ( ) <EOL> for i in range ( obj . number_of_input_ports ) : <EOL> try : <EOL> inputs . append ( obj . get_input ( i ) ) <EOL> except TypeError : <EOL> pass <EOL> if not inputs : <EOL> inputs = [ obj . get_input ( ) ] <EOL> else : <EOL> inputs = [ obj . get_input ( i ) for i in range ( obj . number_of_inputs ) ] <EOL> _add_kid ( '<STR_LIT:input>' , inputs ) <EOL> elif hasattr ( obj , '<STR_LIT:input>' ) : <EOL> _add_kid ( '<STR_LIT:input>' , obj . input ) <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> _add_kid ( '<STR_LIT>' , obj . producer_port ) <EOL> return kids <EOL> def has_children ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( obj , ( tvtk . RenderWindow , tvtk . Renderer , <EOL> tvtk . Collection ) ) : <EOL> return True <EOL> for attribute in [ '<STR_LIT:source>' , '<STR_LIT>' , '<STR_LIT:input>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if hasattr ( obj , attribute ) : <EOL> return True <EOL> if self . get_children ( obj ) : <EOL> return True <EOL> return False <EOL> def _get_methods ( self , vtk_obj ) : <EOL> """<STR_LIT>""" <EOL> def _remove_method ( name , methods , method_names ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> idx = method_names . index ( name ) <EOL> except ValueError : <EOL> pass <EOL> else : <EOL> del methods [ idx ] , method_names [ idx ] <EOL> return methods , method_names <EOL> if not hasattr ( vtk_obj , '<STR_LIT>' ) : <EOL> return [ ] <EOL> methods = str ( vtk_obj ) <EOL> methods = methods . split ( "<STR_LIT:\n>" ) <EOL> del methods [ <NUM_LIT:0> ] <EOL> patn = re . compile ( "<STR_LIT>" ) <EOL> for method in methods [ : ] : <EOL> if patn . match ( method ) : <EOL> if method . find ( "<STR_LIT::>" ) == - <NUM_LIT:1> : <EOL> methods . remove ( method ) <EOL> elif method [ <NUM_LIT:1> ] . find ( "<STR_LIT:none>" ) > - <NUM_LIT:1> : <EOL> methods . remove ( method ) <EOL> else : <EOL> methods . remove ( method ) <EOL> for method in methods [ : ] : <EOL> if method . strip ( ) [ : <NUM_LIT:6> ] == "<STR_LIT>" : <EOL> if hasattr ( vtk_obj , "<STR_LIT>" ) : <EOL> methods . remove ( method ) <EOL> methods . append ( "<STR_LIT>" ) <EOL> elif method . strip ( ) [ : <NUM_LIT:5> ] == "<STR_LIT>" : <EOL> if hasattr ( vtk_obj , "<STR_LIT>" ) : <EOL> methods . remove ( method ) <EOL> methods . append ( "<STR_LIT>" ) <EOL> method_names = [ ] <EOL> for i in range ( <NUM_LIT:0> , len ( methods ) ) : <EOL> strng = methods [ i ] . replace ( "<STR_LIT:U+0020>" , "<STR_LIT>" ) <EOL> methods [ i ] = strng . split ( "<STR_LIT::>" ) <EOL> method_names . append ( methods [ i ] [ <NUM_LIT:0> ] ) <EOL> if re . match ( "<STR_LIT>" , vtk_obj . GetClassName ( ) ) : <EOL> methods . append ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if re . match ( "<STR_LIT>" , vtk_obj . GetClassName ( ) ) : <EOL> methods . append ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> methods . append ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> methods . append ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if vtk_obj . IsA ( '<STR_LIT>' ) : <EOL> if self . last_transform > <NUM_LIT:0> : <EOL> _remove_method ( '<STR_LIT>' , methods , method_names ) <EOL> else : <EOL> self . last_transform += <NUM_LIT:1> <EOL> else : <EOL> self . last_transform = <NUM_LIT:0> <EOL> for name in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> _remove_method ( name , methods , method_names ) <EOL> return methods <EOL> class CompositeIterable ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> tree_generator = Instance ( TreeGenerator ) <EOL> def __init__ ( self , args , ** traits ) : <EOL> super ( CompositeIterable , self ) . __init__ ( ** traits ) <EOL> self . args = args <EOL> def __iter__ ( self ) : <EOL> tg = self . tree_generator <EOL> for arg in self . args : <EOL> if is_iterable ( arg ) : <EOL> for x in arg : <EOL> yield tg . get_node ( x ) <EOL> else : <EOL> yield tg . get_node ( arg ) <EOL> def __len__ ( self ) : <EOL> x = <NUM_LIT:0> <EOL> for arg in self . args : <EOL> if is_iterable ( arg ) : <EOL> x += len ( arg ) <EOL> else : <EOL> x += <NUM_LIT:1> <EOL> return x <EOL> class TVTKLeafNode ( TreeNodeObject ) : <EOL> """<STR_LIT>""" <EOL> object = Instance ( TVTKBase ) <EOL> name = Property <EOL> __ = Python <EOL> def __hash__ ( self ) : <EOL> return hash ( tvtk . to_vtk ( self . object ) ) <EOL> def _get_name ( self ) : <EOL> return self . object . __class__ . __name__ <EOL> def tno_get_icon ( self , node , is_expanded ) : <EOL> """<STR_LIT>""" <EOL> icon = get_icon ( self . name ) <EOL> if icon : <EOL> return icon <EOL> else : <EOL> return super ( TVTKLeafNode , self ) . tno_get_icon ( node , is_expanded ) <EOL> class TVTKBranchNode ( TreeNodeObject ) : <EOL> """<STR_LIT>""" <EOL> object = Instance ( TVTKBase ) <EOL> children = Property <EOL> name = Property <EOL> tree_generator = Instance ( TreeGenerator ) <EOL> children_cache = Dict <EOL> __ = Python <EOL> def __init__ ( self , ** traits ) : <EOL> super ( TVTKBranchNode , self ) . __init__ ( ** traits ) <EOL> def __del__ ( self ) : <EOL> try : <EOL> self . _remove_listners ( ) <EOL> except : <EOL> pass <EOL> def __hash__ ( self ) : <EOL> return hash ( tvtk . to_vtk ( self . object ) ) <EOL> def _get_children_from_cache ( self ) : <EOL> return [ x for x in self . children_cache . values ( ) if x is not None ] <EOL> def _create_children ( self ) : <EOL> kids = self . tree_generator . get_children ( self . object ) <EOL> self . children_cache = kids <EOL> self . _setup_listners ( ) <EOL> def _setup_listners ( self ) : <EOL> object = self . object <EOL> kids = self . children_cache <EOL> for key , val in kids . items ( ) : <EOL> if isinstance ( val , tvtk . Collection ) : <EOL> vtk_obj = tvtk . to_vtk ( val ) <EOL> messenger . connect ( vtk_obj , '<STR_LIT>' , <EOL> self . _notify_children ) <EOL> else : <EOL> object . on_trait_change ( self . _notify_children , key ) <EOL> def _remove_listners ( self ) : <EOL> object = self . object <EOL> kids = self . children_cache <EOL> for key , val in kids . items ( ) : <EOL> if isinstance ( val , tvtk . Collection ) : <EOL> vtk_obj = tvtk . to_vtk ( val ) <EOL> messenger . disconnect ( vtk_obj , '<STR_LIT>' , <EOL> self . _notify_children ) <EOL> else : <EOL> object . on_trait_change ( self . _notify_children , key , remove = True ) <EOL> def _notify_children ( self , obj = None , name = None , old = None , new = None ) : <EOL> old_val = self . _get_children_from_cache ( ) <EOL> self . _remove_listners ( ) <EOL> self . _create_children ( ) <EOL> new_val = self . _get_children_from_cache ( ) <EOL> self . trait_property_changed ( '<STR_LIT>' , old_val , new_val ) <EOL> def _get_children ( self ) : <EOL> if not self . children_cache : <EOL> self . _create_children ( ) <EOL> kids = self . _get_children_from_cache ( ) <EOL> tg = self . tree_generator <EOL> return CompositeIterable ( kids , tree_generator = tg ) <EOL> def _get_name ( self ) : <EOL> return self . object . __class__ . __name__ <EOL> def tno_get_icon ( self , node , is_expanded ) : <EOL> """<STR_LIT>""" <EOL> icon = get_icon ( self . name ) <EOL> if icon : <EOL> return icon <EOL> else : <EOL> return super ( TVTKBranchNode , self ) . tno_get_icon ( node , is_expanded ) <EOL> class TVTKCollectionNode ( TreeNodeObject ) : <EOL> """<STR_LIT>""" <EOL> object = List ( TVTKBase ) <EOL> children = Property <EOL> name = Str <EOL> tree_generator = Instance ( TreeGenerator ) <EOL> __ = Python <EOL> def __init__ ( self , ** traits ) : <EOL> super ( TVTKCollectionNode , self ) . __init__ ( ** traits ) <EOL> def _get_children ( self ) : <EOL> tg = self . tree_generator <EOL> return CompositeIterable ( self . object , tree_generator = tg ) <EOL> class UICloseHandler ( TVTKBaseHandler ) : <EOL> """<STR_LIT>""" <EOL> browser = Any <EOL> def close ( self , info , is_ok ) : <EOL> """<STR_LIT>""" <EOL> obj = info . object <EOL> obj . on_trait_change ( self . browser . render , remove = True ) <EOL> return True <EOL> class PipelineBrowser ( HasTraits ) : <EOL> tree_generator = Trait ( FullTreeGenerator ( ) , <EOL> Instance ( TreeGenerator ) ) <EOL> renwins = List <EOL> root_object = List ( TVTKBase ) <EOL> _root = Any <EOL> def __init__ ( self , renwin = None , ** traits ) : <EOL> """<STR_LIT>""" <EOL> super ( PipelineBrowser , self ) . __init__ ( ** traits ) <EOL> self . ui = None <EOL> self . view = None <EOL> if renwin : <EOL> self . renwins . append ( renwin ) <EOL> self . _root_object_changed ( self . root_object ) <EOL> menu = Menu ( Action ( name = '<STR_LIT>' , action = '<STR_LIT>' ) , <EOL> Action ( name = '<STR_LIT>' , action = '<STR_LIT>' ) ) <EOL> self . menu = menu <EOL> nodes = self . tree_generator . get_nodes ( menu ) <EOL> self . tree_editor = TreeEditor ( nodes = nodes , <EOL> editable = False , <EOL> orientation = '<STR_LIT>' , <EOL> hide_root = True , <EOL> on_dclick = self . _on_dclick ) <EOL> self . view = View ( Group ( Item ( name = '<STR_LIT>' , <EOL> editor = self . tree_editor , <EOL> resizable = True ) , <EOL> show_labels = False , <EOL> show_border = False , <EOL> orientation = '<STR_LIT>' ) , <EOL> title = '<STR_LIT>' , <EOL> help = False , <EOL> resizable = True , undo = False , revert = False , <EOL> width = <NUM_LIT> , height = <NUM_LIT> ) <EOL> def show ( self , parent = None ) : <EOL> """<STR_LIT>""" <EOL> if self . ui and self . ui . control : <EOL> try : <EOL> self . ui . control . Raise ( ) <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> return <EOL> else : <EOL> if parent : <EOL> self . ui = self . view . ui ( self , parent = parent , kind = '<STR_LIT>' ) <EOL> else : <EOL> self . ui = self . view . ui ( self , parent = parent ) <EOL> def update ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . ui and self . ui . control : <EOL> try : <EOL> ed = self . ui . _editors [ <NUM_LIT:0> ] <EOL> ed . update_editor ( ) <EOL> self . ui . control . Refresh ( ) <EOL> except ( AttributeError , IndexError ) : <EOL> pass <EOL> refresh = update <EOL> def render ( self ) : <EOL> """<STR_LIT>""" <EOL> for rw in self . renwins : <EOL> rw . render ( ) <EOL> def _make_default_root ( self ) : <EOL> tree_gen = self . tree_generator <EOL> objs = [ x . render_window for x in self . renwins ] <EOL> node = TVTKCollectionNode ( object = objs , name = "<STR_LIT>" , <EOL> tree_generator = tree_gen ) <EOL> return node <EOL> def _tree_generator_changed ( self , tree_gen ) : <EOL> """<STR_LIT>""" <EOL> if self . _root : <EOL> root_obj = self . _root . object <EOL> else : <EOL> root_obj = self . root_object <EOL> if root_obj : <EOL> ro = root_obj <EOL> if not hasattr ( root_obj , '<STR_LIT>' ) : <EOL> ro = [ root_obj ] <EOL> self . _root = TVTKCollectionNode ( object = ro , <EOL> name = "<STR_LIT>" , <EOL> tree_generator = tree_gen ) <EOL> else : <EOL> self . _root = self . _make_default_root ( ) <EOL> self . tree_editor . nodes = tree_gen . get_nodes ( self . menu ) <EOL> self . update ( ) <EOL> def _root_object_changed ( self , root_obj ) : <EOL> """<STR_LIT>""" <EOL> tg = self . tree_generator <EOL> if root_obj : <EOL> self . _root = TVTKCollectionNode ( object = root_obj , name = "<STR_LIT>" , <EOL> tree_generator = tg ) <EOL> else : <EOL> self . _root = self . _make_default_root ( ) <EOL> self . root_object = self . _root . object <EOL> self . update ( ) <EOL> def _root_object_items_changed ( self , list_event ) : <EOL> """<STR_LIT>""" <EOL> self . _root_object_changed ( self . root_object ) <EOL> def _on_dclick ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( obj , '<STR_LIT:object>' ) and hasattr ( obj . object , '<STR_LIT>' ) : <EOL> object = obj . object <EOL> view = object . trait_view ( ) <EOL> view . handler = UICloseHandler ( browser = self ) <EOL> object . on_trait_change ( self . render ) <EOL> ui = object . edit_traits ( view = view ) <EOL> def main ( instantiate_gui = True ) : <EOL> """<STR_LIT>""" <EOL> from tvtk . tools import ivtk <EOL> v = ivtk . viewer ( browser = False , instantiate_gui = instantiate_gui ) <EOL> cs = tvtk . ConeSource ( ) <EOL> m = tvtk . PolyDataMapper ( input = cs . output ) <EOL> a = tvtk . Actor ( mapper = m ) <EOL> v . scene . add_actor ( a ) <EOL> v . scene . reset_zoom ( ) <EOL> b = PipelineBrowser ( v . scene ) <EOL> b . show ( ) <EOL> return v , b , a <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from pyface . api import GUI <EOL> gui = GUI ( ) <EOL> main ( instantiate_gui = False ) <EOL> gui . start_event_loop ( ) </s>
