<s> """<STR_LIT>""" <EOL> from os . path import dirname <EOL> import os <EOL> from pyface . qt import QtGui <EOL> from pyface . api import ImageResource , FileDialog , OK <EOL> from pyface . action . api import ToolBarManager , Group , Action <EOL> from tvtk . api import tvtk <EOL> from traits . api import Instance , false , Either , List <EOL> from . scene import Scene <EOL> class DecoratedScene ( Scene ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( tvtk , '<STR_LIT>' ) : <EOL> marker = Instance ( tvtk . OrientationMarkerWidget , ( ) ) <EOL> axes = Instance ( tvtk . AxesActor , ( ) ) <EOL> else : <EOL> marker = None <EOL> axes = None <EOL> show_axes = false <EOL> actions = List ( Either ( Action , Group ) ) <EOL> def __init__ ( self , parent , ** traits ) : <EOL> super ( DecoratedScene , self ) . __init__ ( parent , ** traits ) <EOL> self . _setup_axes_marker ( ) <EOL> def __get_pure_state__ ( self ) : <EOL> """<STR_LIT>""" <EOL> d = super ( DecoratedScene , self ) . __get_pure_state__ ( ) <EOL> for x in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> d . pop ( x , None ) <EOL> return d <EOL> def _create_control ( self , parent ) : <EOL> """<STR_LIT>""" <EOL> self . _panel = QtGui . QMainWindow ( ) <EOL> tbm = self . _get_tool_bar_manager ( ) <EOL> self . _tool_bar = tbm . create_tool_bar ( self . _panel ) <EOL> self . _panel . addToolBar ( self . _tool_bar ) <EOL> self . _content = super ( DecoratedScene , self ) . _create_control ( self . _panel ) <EOL> self . _panel . setCentralWidget ( self . _content ) <EOL> return self . _panel <EOL> def _setup_axes_marker ( self ) : <EOL> axes = self . axes <EOL> if axes is None : <EOL> return <EOL> axes . set ( <EOL> normalized_tip_length = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> normalized_shaft_length = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> shaft_type = '<STR_LIT>' <EOL> ) <EOL> p = axes . x_axis_caption_actor2d . caption_text_property <EOL> axes . y_axis_caption_actor2d . caption_text_property = p <EOL> axes . z_axis_caption_actor2d . caption_text_property = p <EOL> p . set ( color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , shadow = False , italic = False ) <EOL> self . _background_changed ( self . background ) <EOL> self . marker . set ( key_press_activation = False ) <EOL> self . marker . orientation_marker = axes <EOL> def _get_tool_bar_manager ( self ) : <EOL> """<STR_LIT>""" <EOL> tbm = ToolBarManager ( * self . actions ) <EOL> return tbm <EOL> def _get_image_path ( self ) : <EOL> """<STR_LIT>""" <EOL> import tvtk . pyface . api <EOL> return dirname ( tvtk . pyface . api . __file__ ) <EOL> def _toggle_projection ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _panel is not None : <EOL> self . parallel_projection = not self . parallel_projection <EOL> def _toggle_axes ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> if self . _panel is not None : <EOL> self . show_axes = not self . show_axes <EOL> def _save_snapshot ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _panel is not None : <EOL> wildcard = "<STR_LIT>" <EOL> dialog = FileDialog ( <EOL> parent = self . _panel , <EOL> title = '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> default_filename = "<STR_LIT>" , <EOL> wildcard = wildcard <EOL> ) <EOL> if dialog . open ( ) == OK : <EOL> self . save ( dialog . path ) <EOL> def _configure_scene ( self ) : <EOL> """<STR_LIT>""" <EOL> self . edit_traits ( ) <EOL> def _show_axes_changed ( self ) : <EOL> marker = self . marker <EOL> if ( self . _vtk_control is not None ) and ( marker is not None ) : <EOL> if not self . show_axes : <EOL> marker . interactor = None <EOL> marker . enabled = False <EOL> else : <EOL> marker . interactor = self . interactor <EOL> marker . enabled = True <EOL> self . render ( ) <EOL> def _background_changed ( self , value ) : <EOL> axes = self . axes <EOL> if ( self . _vtk_control is not None ) and ( axes is not None ) : <EOL> p = self . axes . x_axis_caption_actor2d . caption_text_property <EOL> m = self . marker <EOL> s = value [ <NUM_LIT:0> ] + value [ <NUM_LIT:1> ] + value [ <NUM_LIT:2> ] <EOL> if s <= <NUM_LIT:1.0> : <EOL> p . color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> m . set_outline_color ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> else : <EOL> p . color = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> m . set_outline_color ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . render ( ) <EOL> def _actions_default ( self ) : <EOL> return [ <EOL> Group ( <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . x_minus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . x_plus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . y_minus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . y_plus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . z_minus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . z_plus_view , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . isometric_view , <EOL> ) , <EOL> ) , <EOL> Group ( <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = '<STR_LIT>' , <EOL> style = "<STR_LIT>" , <EOL> on_perform = self . _toggle_projection , <EOL> checked = self . parallel_projection , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = '<STR_LIT>' , <EOL> style = "<STR_LIT>" , <EOL> enabled = ( self . marker is not None ) , <EOL> on_perform = self . _toggle_axes , <EOL> checked = self . show_axes , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = '<STR_LIT>' , <EOL> style = "<STR_LIT>" , <EOL> on_perform = self . _full_screen_fired , <EOL> ) , <EOL> ) , <EOL> Group ( <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = "<STR_LIT>" , <EOL> on_perform = self . _save_snapshot , <EOL> ) , <EOL> Action ( <EOL> image = ImageResource ( '<STR_LIT>' , <EOL> search_path = [ self . _get_image_path ( ) ] , <EOL> ) , <EOL> tooltip = '<STR_LIT>' , <EOL> style = "<STR_LIT>" , <EOL> on_perform = self . _configure_scene , <EOL> ) , <EOL> ) , <EOL> ] </s>
