Il giorno sab, 17/04/2010 alle 11.28 +0200, Gael Varoquaux ha scritto:
> On Fri, Apr 16, 2010 at 05:48:15PM +0200, Luca Penasa wrote:
> > Im trying out mayavi and related python modules for creating a little
> > gui for visualizing a vtkUnstructuredGrid object.
> > My code is similar (couse i started from from that...) to the one
> > presented into this example:
> > http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_mlab_interactive_dialog.html#example-mlab-interactive-dialog
>
> > BUT i visualize a vtkobject loaded from a .vtk file in this way:
>
> > vtksource = tvtk.UnstructuredGrid(vtkUnstructuredGrid)
> > source = VTKDataSource(data = vtksource)
>
> > after loading the file i create all i need for visualizing, like in the
> > example cited above, in this way:
>
> > HasTraits.scene.engine.add_source(source)
> > from enthought.mayavi.modules.surface import Surface
> > surface = Surface()
> > HasTraits.scene.engine.add_filter(surface)
>
> > at the end i call configure_traits() for show the window
>
>
> > ---> is this the best way to insert a vtkUnstructuredGrid into a scene?
>
> If you start from a file, you can simply do:
>
> source = mlab.pipeline.open('file.vtk')
I think this is not my case becouse i want to visualize/modify a
vtkUnstructuredGrid object that other scripts loaded for me.
>
> > ---> code i have yet writed make some changes on the vtkUnstructuredGrid
> > object using the vtk functionalities (rotating, translating and other
> > similar stuff...) and i would like that everytime i make changes on my
> > vtk-object the visualization update itself in agree with my changes.
> > how can i get this?? Is not there something
> > like ...engine.update_source() or ...engine.set_source(UpdatedSource) or
> > change_source(UpdatedSource). Is there a way to force a re-read of the
> > source, leaving untouched the filters pipeline??
>
> I believe that
>
> source.reader.modified()
> source.update()
I have tried calling update() on my VTKDataSource() object but maybe
this only update the content of the VTKDataSource() object and not what
is rendered into my window. How could i force a re-rendering?
I am trying to write down something like this (hope i can explain
myself):
@on_trait_change('alpha,beta,scene.activated')
def update_plot(self): #first renderind or updating!!
if self.first == 0: #if is the first time, go there -> i think
this part works fine (FIRST RENDERING):
self.tvtksource = CloudToSource(self.cloud)
self.source = VTKDataSource(data = self.tvtksource)
self.scene.engine.add_source(self.source)
from enthought.mayavi.modules.surface import Surface
surface = Surface()
self.scene.engine.add_filter(surface)
self.first = 1
else: #if a first rendering was yet done -> this does not work,
i need to update all the pipeline and visualization after changes on my
object 'self.cloud'(UPDATING)
self.cloud.RotateX(self.alpha) #some changes on cloud-object
self.cloud.RotateY(self.beta) #the same
self.source.update() #and now???? -> not working
self.scene.render() #???
print('change to ' + str(self.alpha))
Thank you Gael, i hope you can give me some suggestions!!
--
---------------------------
Luca Penasa
Student at Geosciences Dpt.
University of Padua (IT)
[email protected]
---------------------------
--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it http://www.email.it/f
Sponsor:
COSTA HOTELS:
* Cerchi un hotel le tue vacanze in Riviera? Visita costahotels.it
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=10344&d=17-4
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
MayaVi-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mayavi-users