[vtkusers] update pipeline

Shashwath T.R. trshash at gmail.com
Mon Oct 24 03:37:56 EDT 2011


Try calling win.Render() in the callback function... The pipeline is
updated, but it renders only when you explicitly say "Render".

Shash

On Mon, Oct 24, 2011 at 12:42 AM, David Froger <david.froger at gmail.com>wrote:

> Hi,
>
> I'm new  to vtk.  I'm trying to  use Vtk+Python+Tkinter to  read MultiBlock
> from
> Ensight files,  plot unstructrued  data that are extracted  from the
> MultiBlock,
> and interactively select a time to re-read and re-draw the data.
>
> Here is what I did:
>
> import Tkinter as Tk
>
> import vtk
> from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor
>
> # Read the source file
> reader = vtk.vtkGenericEnSightReader()
> reader.SetCaseFileName('data.case')
> reader.SetTimeValue(0.1)
> reader.Update()
>
> # Extract the block 1
> multiBlock = reader.GetOutput()
> triangularData = multiBlock.GetBlock(1)
>
> # Create the Mapper
> mapper = vtk.vtkDataSetMapper()
> mapper.SetInput(triangularData)
>
> # Create the Actor
> actor = vtk.vtkActor()
> actor.SetMapper(mapper)
>
> # Create the Renderer
> renderer = vtk.vtkRenderer()
> renderer.AddActor(actor)
> renderer.SetBackground(1, 1, 1) # Set background to white
>
> # create root window
> root = Tk.Tk()
>
> # create the WindowInteractor
> win = vtkTkRenderWindowInteractor(root, width=300, height=300)
> win.Initialize()
> win.GetRenderWindow().AddRenderer(renderer)
> style = vtk.vtkInteractorStyleTrackballCamera()
> win.SetInteractorStyle(style)
> win.pack(fill='both', expand=1, side='bottom')
> win.Start()
>
> # Function called when Button "Ok" is pressed.
> # Get the time value from the Entry widget, and
> # pass it to the vtkGenericEnSightReader
> def update():
>    text = entry.get()
>    try:
>        time = float(text)
>        reader.SetTimeValue(time)
>        reader.Update()
>    except ValueError:
>        print "Float recquired"
>
> # Create Label, a Entry and a Button where user inputs time value.
> Tk.Label(text='time=').pack(side='left')
> entry = Tk.Entry()
> entry.pack(side='left')
> button = Tk.Button(text='Ok',command=update).pack(side='left')
>
> root.mainloop()
>
> Inputing  a  time  in  the  tkinter  widget  updates  the  Reader,  but
>  not the
> vtkTkRenderWindowInteractor.  Obviously,  the pipe is broken when the block
> 1 is
> extracted.  I've tried to  use the vtkExtractBlock filter,  but  it only
> returns
> MultiBlock, and the mapper input has to be a Block.
>
> How can I do?
>
> Thanks for reading and for any suggestion that could help me!
>
> Best,
> David.
> --
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111024/9d99929d/attachment.htm>


More information about the vtkusers mailing list