Advertisement
Guest User

Untitled

a guest
May 7th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import numpy as np
  2. from mayavi import mlab
  3. from matplotlib.scale import scale_factory
  4. from traits.api import HasTraits, Range, Instance, Array,
  5. on_trait_change
  6. from traitsui.api import View, Item, Group
  7. from mayavi.core.pipeline_base import PipelineBase
  8. from mayavi.core.ui.api import MayaviScene, SceneEditor,
  9. MlabSceneModel
  10.  
  11. class Modell(HasTraits):
  12. p = Array
  13. n = Range(0, 9, 5)
  14. #p is a 4 dimensional Array p[10][20][20][20]
  15. scene = Instance(MlabSceneModel, ())
  16. plot = Instance(PipelineBase)
  17.  
  18. @on_trait_change('n,scene.activated')
  19. def update_plot(self):
  20. self.src = mlab.pipeline.scalar_field(self.p[self.n])
  21. if self.plot is None:
  22. self.plot = self.scene.mlab.pipeline.image_plane_widget(self.src,
  23. plane_orientation='z_axes',
  24. slice_index=10,
  25. vmin=0, vmax=120)
  26. else:
  27. '''here should be the update function, i tried using mlab_source.set(self.src=self.src)
  28. and all variations of expressions in the brackets but nothing worked.
  29. I also searched for functions in IPW itself but didn't find something that could help me.'''
  30.  
  31. #The layout of the dialog created
  32. view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
  33. height=400, width=400, show_label=False),
  34. Group('_', 'n'),
  35. resizable=True,
  36. )
  37.  
  38. my_model = Modell(p=p)
  39. my_model.configure_traits()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement