Hello, <br>
<br>
I have a scene with some 2d actors and I want to be able to move them with mouse interaction.<br>
The behaviour would be this: <br>
1. When the left button is pressed I call the picker with the current
mouse point. Ten get the picked actor, if exists at least one under
that point.<br>
2. Once picked, move the actor when the mouse moves and the button remains clicked<br>
<br>
I have some questions:<br>
-what's the best picker class to do this?<br>
-how can I control the tolerance so I don't have to click in the exact pixel if I want to pick a thin line, for example<br>
-what's the better methods to retrieve the actors? ( GetPropAssembly()? GetActors()? )<br>
<br>
Some example code with the explanation would be apreciated.<br>
<br>
Now I'm doing this when the left button is clicked but I'am not
controlling the tolerance of the picker, so I have to pick over an
exact pixel of the actor to get it<br>
The picker ( m_linePicker ) is a vtkPropPicker<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(128, 0, 0);"> </span></pre>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(128, 0, 0);"> int</span> x, y;
x = <b>this</b>->getInteractor()->GetEventPosition()[<span style="color: rgb(0, 0, 255);">0</span>];
y = <b>this</b>->getInteractor()->GetEventPosition()[<span style="color: rgb(0, 0, 255);">1</span>];
m_linePicker->Pick( x, y, <span style="color: rgb(128, 0, 128);">0.0</span>, <b>this</b>->getRenderer() );
vtkAssemblyPath * Path;
m_actorsAssembly = NULL;
vtkProp *prop = NULL;
<b>if</b> ( m_linePicker->GetPropAssembly() )
{
prop = m_linePicker->GetPath()->GetFirstNode()->GetViewProp();
m_actorsAssembly = vtkPropAssembly::SafeDownCast( prop );
}
<b>else</b>
prop = m_linePicker->GetViewProp();
<b>if</b> ( m_actorsAssembly )
{
m_picked = <b>true</b>;
vtkPropCollection *col = m_actorsAssembly->GetParts();
col->InitTraversal();
m_pickedAxisActor = vtkAxisActor2D::SafeDownCast( col->GetNextProp() );
m_pickedActorPosition = m_pickedAxisActor->GetPosition();
m_initialPickedActorPositionX = m_pickedActorPosition[<span style="color: rgb(0, 0, 255);">0</span>];
m_initialPickedActorPositionY = m_pickedActorPosition[<span style="color: rgb(0, 0, 255);">1</span>];
m_initialPickX = x;
m_initialPickY = y;
}
<b>else</b>
<b>if</b> ( prop )
{
m_picked = <b>true</b>;
m_pickedAxisActor = vtkAxisActor2D::SafeDownCast( prop );
<b>if</b>( m_pickedAxisActor )
{
m_pickedActorPosition = m_pickedAxisActor->GetPosition();
m_initialPickedActorPositionX = m_pickedActorPosition[<span style="color: rgb(0, 0, 255);">0</span>];
m_initialPickedActorPositionY = m_pickedActorPosition[<span style="color: rgb(0, 0, 255);">1</span>];
m_initialPickX = x;
m_initialPickY = y;
}
}</pre>