Coverage for PyRx.mayaviActions : 70%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#$Id: mayaviActions.py 16 2009-11-16 21:44:21Z sarkiss $
#Customized from tvtk/plugins/scene/ui/actions.py by Sargis Dallakyan (sargis@scripps.edu)
# Enthought library imports.
""" Base class for actions that require a scene manager. """
#### 'SceneAction' interface ##############################################
# The scene manager. 'enthought.tvtk.plugins.scene.i_scene_manager import ISceneManager' ))
""" Trait property getter. """
from enthought.tvtk.plugins.scene.i_scene_manager import ( ISceneManager )
return self.window.get_service(ISceneManager)
""" An action that saves a scene to an image. """
#### 'Action' interface ###################################################
""" Performs the action. """
extensions = [ '*.png', '*.jpg', '*.jpeg', '*.tiff', '*.bmp', '*.ps', '*.eps', '*.tex', '*.rib', '*.wrl', '*.oogl', '*.pdf', '*.vrml', '*.obj', '*.iv' ]
wildcard = '|'.join(extensions)
dialog = FileDialog( parent = self.frame, title = 'Save scene to image', action = 'save as', wildcard = wildcard ) if dialog.open() == OK: scene = self.frame.mayaviEngine.scene if scene is not None: scene.save(dialog.path)
return
""" An action that saves a scene to an image. """
#### 'Action' interface ###################################################
# Name of the action.
#### 'SaveSceneToImage' interface #########################################
# The save method name.
# The wildcard for the file dialog.
########################################################################### # 'Action' interface. ###########################################################################
""" Perform the action. """
dialog = FileDialog( parent = self.frame, title = 'Save scene to %s' % self.name, action = 'save as', wildcard = self.wildcard ) if dialog.open() == OK: scene = self.frame.mayaviEngine.scene if scene is not None: method = getattr(scene, self.save_method) method(dialog.path)
return
# These are all specific subclasses that save particular images. 'All files (*.*)|*.*'
'JPEG images (*.jpeg)|*.jpeg|' \ 'All files (*.*)|*.*'
'All files (*.*)|*.*'
'TIFF images (*.tiff)|*.tiff|' \ 'All files (*.*)|*.*'
'All files (*.*)|*.*'
'EPS files (*.eps)|*.eps|' \ 'PS files (*.ps)|*.ps|' \ 'PDF files (*.pdf)|*.pdf|' \ 'TeX files (*.tex)|*.tex'
'All files (*.*)|*.*'
'All files (*.*)|*.*'
'All files (*.*)|*.*'
'All files (*.*)|*.*'
'All files (*.*)|*.*'
# Local imports
###################################################################### # `SaveVisualization` class. ###################################################################### """ An action that saves the current visualization. """
########################################################################### # 'Action' interface. ###########################################################################
""" Performs the action. """ wildcard = 'MayaVi2 files (*.mv2)|*.mv2|' + FileDialog.WILDCARD_ALL dialog = FileDialog(parent=self.frame, title='Save MayaVi2 file', action='save as', wildcard=wildcard ) if dialog.open() == OK: self.frame.mayaviEngine.engine.save_visualization(dialog.path)
###################################################################### # `LoadVisualization` class. ###################################################################### """ An action that loads a visualization from file. """
########################################################################### # 'Action' interface. ###########################################################################
""" Performs the action. """ wildcard = 'MayaVi2 files (*.mv2)|*.mv2|' + FileDialog.WILDCARD_ALL parent = self.frame dialog = FileDialog(parent=parent, title='Open MayaVi2 file', action='open', wildcard=wildcard ) if dialog.open() == OK: if not isfile(dialog.path): error("File '%s' does not exist"%dialog.path, parent) return self.frame.mayaviEngine.engine.load_visualization(dialog.path)
###################################################################### # `RunScript` class. ###################################################################### """ An action that runs a mayavi script.
WARNING: this can be dangerous since the file runs execfile! """
########################################################################### # 'Action' interface. ###########################################################################
""" Performs the action. """ wildcard = 'Python files (*.py)|*.py' parent = self.frame dialog = FileDialog(parent=parent, title='Open Python file', action='open', wildcard=wildcard ) if dialog.open() == OK: if not isfile(dialog.path): parent.log.error("File '%s' does not exist"%dialog.path) return
# Get the globals. # The following code is taken from scripts/mayavi2.py. g = sys.modules['__main__'].__dict__ execfile(dialog.path, g, g)
#mayaviMenu = MenuManager(SaveVisualization(frame), LoadVisualization(frame)) #menu.AppendMenu(-1, "Mayavi", mayaviMenu.create_menu(frame)) SaveSceneToPS(frame), SaveSceneToGL2PS(frame), SaveSceneToRIB(frame), SaveSceneToOOGL(frame), SaveSceneToIV(frame), SaveSceneToVRML(frame), SaveSceneToOBJ(frame))
|