<s> """<STR_LIT>""" <EOL> from tvtk . pyface . tvtk_scene import TVTKScene <EOL> from pyface . workbench . api import WorkbenchWindow <EOL> from traits . api import HasTraits , List , Instance , Property <EOL> from traits . api import provides , on_trait_change <EOL> from tvtk . plugins . scene . scene_editor import SceneEditor <EOL> from . i_scene_manager import ISceneManager <EOL> @ provides ( ISceneManager ) <EOL> class SceneManager ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> current_scene = Property ( Instance ( TVTKScene ) ) <EOL> scenes = List ( TVTKScene ) <EOL> window = Instance ( WorkbenchWindow ) <EOL> _current_scene = Instance ( TVTKScene ) <EOL> def _get_current_scene ( self ) : <EOL> """<STR_LIT>""" <EOL> scene_count = len ( self . scenes ) <EOL> if scene_count == <NUM_LIT:0> : <EOL> scene = None <EOL> elif scene_count == <NUM_LIT:1> : <EOL> scene = self . scenes [ <NUM_LIT:0> ] <EOL> else : <EOL> scene = self . _current_scene <EOL> return scene <EOL> def _set_current_scene ( self , scene ) : <EOL> """<STR_LIT>""" <EOL> self . _current_scene = scene <EOL> return <EOL> @ on_trait_change ( '<STR_LIT>' ) <EOL> def _on_editor_opened ( self , obj , trait_name , old , new ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( new , SceneEditor ) : <EOL> self . scenes . append ( new . scene ) <EOL> return <EOL> @ on_trait_change ( '<STR_LIT>' ) <EOL> def _on_editor_closed ( self , obj , trait_name , old , new ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( new , SceneEditor ) : <EOL> self . scenes . remove ( new . scene ) <EOL> return <EOL> @ on_trait_change ( '<STR_LIT>' ) <EOL> def _on_active_editor_changed ( self , obj , trait_name , old , new ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( new , SceneEditor ) : <EOL> self . current_scene = new . scene <EOL> else : <EOL> self . current_scene = None <EOL> return </s>
