[vtkusers] Getting pointer to currently picked actor
beekmaarten at yahoo.com
Wed Aug 13 12:29:41 EDT 2014
I noticed that getting the currently picked actor from the picker in the interactor doesn't always work.
Some interactor styles and widgets (e.g. vtkInteractorstyleTrackballActor) have their own picker which is used for the picking but which is different from the one in the interactor.
I wrote a class that has awareness of the interactor.
I would like to use this->Interactor->GetPicker() to get access to the currently picked object. However this doesn't work with observers like vtkInteractorstyleTrackballActor. Using this->Interactor->GetInteractorStyle()->GetPicker() is also not an option because not all observers use their own picker (and a GetPicker() function does not exist in vtkInteractorstyleTrackballActor).
The hack I made was to derive from vtkInteractorstyleTrackballActor and overload the SetInteractor() function:
void MyClass::SetInteractor(vtkRenderWindowInteractor* rwi)
if( this->Interactor != NULL )
vtkCellPicker* picker = vtkCellPicker::New;
This works. But I'd like to use MyClass with different observers w/o having to derive from all of them...
I've also looked at the PickingManager class since all observers seems to register their pickers, but firstly it is not enabled by default and secondly to get the current selection I have to call GetAssemblyPath() which performs a pick which I don't want because this invokes a PickEvent.. I use the event in MyClass but only when I pick an object, not when I want the currently picked object. Giving vtkPickingManager a public SelectedPicker() function (like
vtkPickingManager::Internal has) would do the trick here..
I guess my question is:
How would a write code to get the currently picked object that works with various observers when I only have awareness of the interactor?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers