[vtkusers] How to read the pick actor in vtk ?

David Doria daviddoria at gmail.com
Wed Mar 7 17:57:51 EST 2012


On Wed, Mar 7, 2012 at 7:31 AM, ankitramani <ankitvtk at googlemail.com> wrote:
> I am using following code to get a picked actor. But it is not working.
> ****************************************************************************
>                                if (event ==
> vtkCommand::LeftButtonPressEvent)
>                                {
>                                        int currPos[2];
>                                        interactor->GetEventPosition(currPos);
>                                        vtkPropPicker *picker=vtkPropPicker::New();
>                                        picker->Pick(currPos[0], currPos[1], 0,  this->renderer3D);
>                                        interactor->SetPicker(picker);
>
>                                        if(picker->GetActor() == tempCylinderActor)
>                                        {
>                                                this->tempAssembly->RemovePart(this->tempLineActor);
>                                        }
>                                }
> ****************************************************************************
> I am clicking on vtkActor "tempCylinderActor", but it is not goind inside
> "if loop"........please help me in getting picked actor...........

I updated the example to show that the actor getting picked is the one
you would expect:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/Picking

In the future, please provide us with more complete information. For
example, you should be able to explain why the conditional is not
passing (that is, if 'event'  is not vtkCommand::LeftButtonPressEvent,
then what is it?). Ideally, you should provide the shortest possible
compilable code demonstrating your problem (the size of the examples).
You will find that many people on this list do not see "......." as a
valid attempt at solving your problem.

David



More information about the vtkusers mailing list