[vtkusers] InteractorStyle, pick when left button clic ?

nsarrasin nsarrasin at phenix-systems.com
Thu May 5 06:12:24 EDT 2011


Hi all,

In my application I would like to highlight the current actor picked.

With vtkInteractorStyle, pressing 'p' working great. So i've inherated from
vtkInteractorStyle (customInteractorStyle) and overloaded OnLeftButtonUp().

Then I've inserted the code on vtkInteractorStyle::OnChar() concerning 'p'
in customInteractorStyle::OnLeftButtonUp().

When I press 'p', it's ok (the picking is called from vtkInteractorStyle )
but when I click with my mouse on an actor I'm not getting the same behavior
:sometimes it doesn't pick the right actor, sometimes it doesn't pick...

Can someone explain me why ?

Thanks by advance

Here is the simple code of my function :

void customInteractorStyle::OnLeftButtonUp()
{
// code from vtkInteractorStyle::OnLeftButtonUp()
	switch (this->State) 
	{
	case VTKIS_DOLLY:
		this->EndDolly();
		break;

	case VTKIS_PAN:
		this->EndPan();
		break;

	case VTKIS_SPIN:
		this->EndSpin();
		break;

	case VTKIS_ROTATE:
		this->EndRotate();
		break;
	}

	if(!_MouseMotion) //if the mouse doesn't move
	{
// code from vtkInteractorStyle::OnChar() when perssing 'p'
		vtkRenderWindowInteractor *rwi = this->Interactor;

		vtkAssemblyPath *path = NULL;
		int *eventPos = rwi->GetEventPosition();
		this->FindPokedRenderer(eventPos[0], eventPos[1]);
		rwi->StartPickCallback();
		vtkAbstractPropPicker *picker = 
			vtkAbstractPropPicker::SafeDownCast(rwi->GetPicker());
		if ( picker != NULL )
		{
			picker->Pick(eventPos[0], eventPos[1], 
				0.0, this->CurrentRenderer);
			path = picker->GetPath();
		}
		if ( path == NULL )
		{
			this->HighlightProp(NULL);
			this->PropPicked = 0;
		}
		else
		{
			this->HighlightProp(path->GetFirstNode()->GetViewProp());
			this->PropPicked = 1;
		}
		rwi->EndPickCallback();
	} 

// code from vtkInteractorStyle::OnLeftButtonUp()
	if ( this->Interactor )
	{
		this->ReleaseFocus();
	}
}

--
View this message in context: http://vtk.1045678.n5.nabble.com/InteractorStyle-pick-when-left-button-clic-tp4372394p4372394.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list