[vtkusers] interaction problem after timer added
David Gobbi
david.gobbi at gmail.com
Thu Jan 21 16:07:26 EST 2016
I looked into this a bit more, and here's what I discovered about this bug.
1) the vtkInteractorStyle::OnTimer() method is calling Rotate().
2) the Rotate() method checks the most recent mouse delta:
int dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0];
int dy = rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
3) this delta is used to rotate the camera
Even if the mouse is no longer moving, the last "delta" is nonzero,
and therefore the camera is rotated whenever OnTimer() is called,
even in trackball mode.
Do any of the other VTK developers who are more familiar with
vtkInteractorStyle want to look into this?
- David
On Thu, Jan 21, 2016 at 9:10 AM, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Gary,
>
> I downloaded your program and confirmed your findings: if the timer
> is running, then the trackball-mode rotation does not stop when the
> mouse stops.
>
> This definitely looks like a bug in VTK itself, so I don't think there
> is any way for you to fix it inside your program.
>
> Can you report it on the VTK bugtracker? (http://www.vtk.org/Bug)
>
> - David
>
>
> On Thu, Jan 21, 2016 at 8:29 AM, gary_jia <jialei.gary at gmail.com> wrote:
>
>> Hi everyone,
>> When I use the vtkInteractorStyleTrackballCamera, the object movement
>> will stop when the mouse freezes ( with mouse button still down). After I
>> added a timer, the object keep moving even when the mouse stop moving.
>> Only
>> after I release the mouse button, the movement stops.
>> Could you help to tell me how to stop the movement immediately after
>> the
>> mouse stop even with any mouse button still down when with a timer
>> running?
>>
>> Thank you!
>>
>> my code:
>>
>> #!/usr/bin/env python
>> import vtk
>>
>> class vtkTimerCallback():
>> def __init__(self):
>> self.timer_count = 0
>>
>> def execute(self,obj,event):
>> print(self.timer_count)
>> self.timer_count += 1
>>
>> src = vtk.vtkCubeSource()
>>
>> mapper = vtk.vtkPolyDataMapper()
>> mapper.SetInputConnection(src.GetOutputPort())
>>
>> actor = vtk.vtkActor()
>> actor.SetMapper(mapper)
>>
>> main_render = vtk.vtkRenderer()
>> main_render.AddActor(actor)
>>
>> renWin = vtk.vtkRenderWindow()
>> renWin.AddRenderer(main_render)
>>
>> iren = vtk.vtkRenderWindowInteractor()
>> iren.SetRenderWindow(renWin)
>> iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
>> iren.Initialize()
>>
>> cb = vtkTimerCallback()
>> cb.actor = actor
>> iren.AddObserver('TimerEvent', cb.execute)
>> timerId = iren.CreateRepeatingTimer(50);
>> iren.Start()
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160121/b52a21e6/attachment.html>
More information about the vtkusers
mailing list