[vtkusers] Actor disappears when using one direction interactor style.
alican
alican1812 at hotmail.com
Sat Dec 30 08:12:44 EST 2017
I am trying to limit actor's movement to one direction only.
The question was already asked a couple of times and never answered.
It initially looked straightforward, however I cannot make it work.
When I start moving the mouse an actor is disappearing and for the life of
me I do not know why.
Can somebody please spot a problem?
Thank you
AC
void MoveInteractorStyle::OnMouseMove()
{
if (m_Move && m_pActor)
{
int* pos = GetInteractor()->GetEventPosition();
if (CommonUtils::isEmpty(m_CurrentPos))
{
m_CurrentPos = QVector3D(pos[0], pos[1], pos[2]);
return;
}
QVector3D newPos(pos[0], pos[1], pos[2]);
if (m_direction == X)
m_pActor->SetPosition(newPos[0], m_CurrentPos[1], m_CurrentPos[2]);
else if (m_direction == Y)
m_pActor->SetPosition(m_CurrentPos[0], newPos[1], m_CurrentPos[2]);
else if (m_direction == Z)
m_pActor->SetPosition(m_CurrentPos[0], m_CurrentPos[1], newPos[2]);
else
m_pActor->SetPosition(newPos[0], newPos[1], newPos[2]);
double* apos = m_pActor->GetPosition();
qDebug() << "x " << apos[0] << " y " << apos[1] << " z " << apos[2];
Pan();
//vtkInteractorStyleTrackballActor::OnMouseMove();
}
else
vtkInteractorStyleTrackballActor::OnMouseMove();
}
void MoveInteractorStyle::OnLeftButtonUp()
{
m_Move = false;
m_pActor = nullptr;
CommonUtils::empty(m_CurrentPos);
//vtkInteractorStyleTrackballActor::OnLeftButtonUp();
EndPan();
}
void MoveInteractorStyle::OnLeftButtonDown()
{
m_direction = X;
m_Move = true;
m_pActor = pickActor();
StartPan();
}
vtkActor* MoveInteractorStyle::pickActor()
{
int* clickPos = GetInteractor()->GetEventPosition();
// Pick from this location.
vtkSmartPointer<vtkPropPicker> picker =
vtkSmartPointer<vtkPropPicker>::New();
picker->Pick(clickPos[0], clickPos[1], 0, this->GetDefaultRenderer());
double* pos = picker->GetPickPosition();
return picker->GetActor();
}
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list