Using vtkPicker with Python/Vtk

Vetle Roeim vetler at ifi.uio.no
Sun Jan 9 12:15:00 EST 2000


I'm trying to use vtkPicker and its associated sub-classes in a project,
using Python and vtkRenderWidget.
This is not described in "Vtk User's Guide", but I understand that
vtkRenderWidget is rather new, so it is understandable.

On page 62 of the User's Guide, it says how to use vtkPicker with
vtkRenderWindowInteractor. Although it is possible to use
vtkRenderWindowInteractor in Python, it is not possible to do so if you
wish to use the renderwindow as a Tk widget (I experienced strange
behaviour when I tried this).

Fortunately, vtkRenderWidget implements most of the
vtkRenderWindowInteractor's functionality, but it seems to dislike
picking.

There does not exist a "SetPicker()" method in vtkRenderWidget, so I tried
setting the picker explicitly, like this:
    picker = vtkCellPicker()
    picker.SetPickMethod( foo )
    renderWidget.__ActorPicker = new_picker

It does not work as expected. 'foo' is a function that prints a string to
standard output. Here is the complete script I used to test the feature:

    #!/usr/bin/env python

    import Tkinter
    from VTK import *

    root = Tkinter.Tk()

    ren = vtkRenderer()
    renderWidget = vtkTkRenderWidget( root )
    renderWidget.pack()
    renWin = renderWidget.GetRenderWindow()
    renWin.AddRenderer( ren )

    def foo():
        print 'foobar'

    picker = vtkCellPicker()
    picker.SetPickMethod( foo )
    renderWidget.__ActorPicker = picker

    coneSource = vtkConeSource()
    coneMapper = vtkPolyDataMapper()
    coneMapper.SetInput( coneSource.GetOutput() )
    coneActor = vtkActor()
    coneActor.SetMapper( coneMapper )

    ren.AddActor( coneActor )
    picker.AddPickList( coneActor )

    root.mainloop()

So, my question is; how should I do this? How is it possible to use
picking together with vtkRenderWidget?



Thanks,
Vetle Roeim
Student at Department of Informatics, University of Oslo, Norway




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list