[vtkusers] Getting an actor from vtkPicker

Wiebke Timm wiebke.timm at uni-bielefeld.de
Fri Feb 27 07:25:36 EST 2004


Hi!

I'm trying to pick an Object which is drawn by a renderer using the 
vtkqt libraries. The setup looks like this:


    // create VtkQt widget
    ren = vtkRenderer::New();
    renwin = vtkRenderWindow::New();
    iren = vtkRenderWindowInteractor::New();
    vtkPicker* ppick = vtkPicker::New();

    iren->SetPicker(ppick);
    renwin->AddRenderer(ren);
    renwin->SetInteractor(iren);

    // instead of iren->Start()
    vtkQtObjectFactory::SetQtBase(f,NULL);
    renwin->Start();

    ren->AddActor(fishact);
    ren->AddActor(fishact2);
    ren->SetBackground(1,1,1);


fishact and fishact2 are vtkMyActor objects. vtkMyActor extends 
vtkActor by introducing an id value (which will help assigning actors 
to the objects which created them lateron).

When a button is pressed in the qt gui, the following code is executed:

vtkActorCollection* ac = ((vtkPicker*)(iren->GetPicker()))->GetActors();
    if(ac != NULL) {
       cout << "got actor collection:" << endl;
       ac->PrintSelf(cout,3);
       cout << endl;
       vtkProp* prop = ac->GetNextActor();
       if(prop != NULL) {
           cout << "fnord" << endl;
       }
}


The resulting output is

got actor collection:
    Debug: Off
    Modified Time: 2451
    Reference Count: 1
    Registered Events: (none)
    Number Of Items: 1


But that's it. No "fnord" is printed. That's what I don't understand: 
The actor collection obviously has one item because of "Number Of 
Items: 1". But GetNextActor() returns NULL!

Any ideas would be greatly appreciated!


Also I'm not sure if I have to set the picker (iren->SetPicker()) for 
the RenderInteractor because it should have one by itself. But I get a 
segfault in the code that is executed by the button when I don't set a 
picker...

Are there any Problems with extending vtkActor...?

Thanks!
    Wiebke




More information about the vtkusers mailing list