[vtkusers] Getting an actor from vtkPicker

Malcolm Drummond malcolm at geovision.co.za
Fri Feb 27 10:38:25 EST 2004


Hi

Try calling InitTraversal() to place you at the beginning of the collection
before calling GetNextActor()

HTH
Malcolm

----- Original Message -----
From: "Wiebke Timm" <wiebke.timm at uni-bielefeld.de>
To: <vtkusers at vtk.org>
Sent: Friday, February 27, 2004 2:25 PM
Subject: [vtkusers] Getting an actor from vtkPicker


> 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
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list