[vtkusers] Actor disappears when using one direction interactor style.
Paul Douglas Hahn
pdhahn at compintensehpc.com
Sat Dec 30 15:05:30 EST 2017
New to VTK, I found out I had to deal with triggering a repaint after
changing positions of things in the scene from within event handlers --
with charts at least (context2d). I am not expert enough to give you an
explicit answer for a fix, but the symptoms you describe do sound
similar -- i.e., there needs to be a repaint triggered, at the end of
the mouse move event handler and particularly at the end of mouse button
up. I presume the former should probably happen in Pan(), and the latter
in endPan(), but is not? But it could be some other issue, I suppose, so
please take this newbie reply with a grain of salt.
- Paul
On 12/30/2017 07:12 AM, alican wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>
--
Paul D. Hahn
CompIntense HPC, LLC
More information about the vtkusers
mailing list