[vtkusers] TimerEvents not fired while dragging mouse in vtkRenderWindow
Kolja Petersen
petersenkolja at gmail.com
Wed Nov 15 12:28:43 EST 2017
On Wed, Nov 15, 2017 at 5:48 PM, Ken Martin <ken.martin at kitware.com> wrote:
> The interactor style may be doing a grab focus (which grabs all events
> until the motion is done). Try putting some printfs/breaks in the code
> that generates the timerevent in vtk. Then maybe you can follow the event
> and see who is consuming it etc,.
>
Or maybe I can't because the event forwarding is so entangled that nobody
dares to look into it again.
> Or try commenting out all the GrabFocus() calls in the style you are
> using.
>
Did that. Now the interactor is dead.
>
> On Wed, Nov 15, 2017 at 11:42 AM, Kolja Petersen <petersenkolja at gmail.com>
> wrote:
>
>> No, this is on Linux. Maybe you can try the code snippet yourself to see
>> what I am talking about? The problem is not, that the TimerEvents are
>> slowed down during mouse interaction, they are dropped completely.
>>
>> How can the app be redesigned?
>> First, I need the standard behaviour of vtkRenderWindowInteractor to
>> allow rotating, zooming, panning.
>> Second I need to update and redraw the scene repeatedly in constant
>> intervals. Of course, I could trigger these events independent from VTK
>> using a second thread. But these events need to operate on VTK objects from
>> the main thread. Because VTK is not thread safe (which I have experienced
>> by a number of segmentation faults when modifying VTK objects from
>> different threads), I see absolutely no way to correctly process both 1)
>> timer events and 2) user interaction events that block the timer events.
>> Kolja
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>> <#m_-1757675277711270463_m_869865242780024731_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Wed, Nov 15, 2017 at 5:25 PM, David Cole <DLRdave at aol.com> wrote:
>>
>>> Is this on Windows? WM_TIMER events are notorious for not firing
>>> frequently when lots of other user events are also happening. If the mouse
>>> is captured, they may not fire at all. This is not something unique to VTK,
>>> it happens with just any Windows program.
>>>
>>> You may need to consider redesigning a bit of your app if you must have
>>> code being executed regularly even during user interactions.
>>>
>>>
>>> David
>>>
>>> On Nov 15, 2017, at 5:26 AM, Kolja Petersen <petersenkolja at gmail.com>
>>> wrote:
>>>
>>> I replaced the line "iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)"
>>> with
>>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer,100000.) (also
>>> tried 10.0 instead of 100000.)
>>>
>>> Still no TimerEvents are reported as long as the mouse button is pressed.
>>>
>>> How are events consumed? My understanding is that AddObserver(...) adds
>>> just another listener, and that all listeners registered for a specific
>>> event are invoked one after the other. Which function would "consume"
>>> events in an interactor style? Is it possible to circumvent the consuming
>>> of events, or to re-emit the event after it has been consumed?
>>> Thank you
>>> Kolja
>>>
>>>
>>> On Tue, Nov 14, 2017 at 5:53 PM, Ken Martin <ken.martin at kitware.com>
>>> wrote:
>>>
>>>> I suspect timer events are fired but something else is consuming them.
>>>> Probably in the interactor style. Try adding your timer events with a
>>>> higher priority like 10.0 (third argument).
>>>>
>>>> On Mon, Nov 13, 2017 at 3:21 PM, Kolja Petersen <
>>>> petersenkolja at gmail.com> wrote:
>>>>
>>>>> Heya,
>>>>> I paste some code below, which displays an empty vtkRenderWindow with
>>>>> an interactor. The interactor fires a TimerEvent every 100ms as printed by
>>>>> the Observer.
>>>>> The problem: as long as I press a mouse button in the vtkRenderWindow,
>>>>> the TimerEvents stop to be reported, although I need to process data
>>>>> periodically in my application as a reaction to those TimerEvents.
>>>>>
>>>>> Why are no TimerEvents fired while a button is pressed, and how can I
>>>>> change this behaviour?
>>>>> Thank you
>>>>> Kolja
>>>>>
>>>>> import vtk
>>>>>
>>>>> class Observer(object):
>>>>> def __init__(self):
>>>>> self.cnt=0
>>>>> def __call__(self,caller,evt):
>>>>> self.cnt+=1
>>>>> print "count %d %s" % (self.cnt,evt)
>>>>>
>>>>> ren1 = vtk.vtkRenderer()
>>>>> ren1.SetBackground(0.1, 0.2, 0.4)
>>>>>
>>>>> renWin = vtk.vtkRenderWindow()
>>>>> renWin.AddRenderer(ren1)
>>>>> renWin.SetSize(300, 300)
>>>>>
>>>>> iren = vtk.vtkRenderWindowInteractor()
>>>>> iren.SetRenderWindow(renWin)
>>>>>
>>>>> style = vtk.vtkInteractorStyleTrackballCamera()
>>>>> iren.SetInteractorStyle(style)
>>>>>
>>>>> iren.Initialize()
>>>>> observer=Observer()
>>>>> iren.AddObserver(vtk.vtkCommand.TimerEvent,observer)
>>>>> iren.AddObserver(vtk.vtkCommand.MouseMoveEvent,observer)
>>>>> iren.AddObserver(vtk.vtkCommand.InteractionEvent,observer)
>>>>> iren.CreateRepeatingTimer(100)
>>>>> iren.Start()
>>>>>
>>>>>
>>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Virenfrei.
>>>>> www.avast.com
>>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>>>> <#m_-1757675277711270463_m_869865242780024731_m_-7045443072964375499_m_-5995428116567439952_m_5020402281578617109_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>>
>>>>> _______________________________________________
>>>>> 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:
>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Ken Martin PhD
>>>> Distinguished Engineer
>>>> Kitware Inc.
>>>> 28 Corporate Drive
>>>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&entry=gmail&source=g>
>>>> Clifton Park NY 12065
>>>> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065&entry=gmail&source=g>
>>>>
>>>> This communication, including all attachments, contains confidential
>>>> and legally privileged information, and it is intended only for the use of
>>>> the addressee. Access to this email by anyone else is unauthorized. If you
>>>> are not the intended recipient, any disclosure, copying, distribution or
>>>> any action taken in reliance on it is prohibited and may be unlawful. If
>>>> you received this communication in error please notify us immediately and
>>>> destroy the original message. Thank you.
>>>>
>>>
>>> _______________________________________________
>>> 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:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>>>
>>
>
>
> --
> Ken Martin PhD
> Distinguished Engineer
> Kitware Inc.
> 28 Corporate Drive
> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065+%3Chttps://maps.google.com/?q%3D28%2BCorporate%2BDrive%2BClifton%2BPark%2BNY%2B12065%26entry%3Dgmail%26source%3Dg%3E&entry=gmail&source=g>
> Clifton Park NY 12065
> <https://maps.google.com/?q=28+Corporate+Drive+Clifton+Park+NY+12065+%3Chttps://maps.google.com/?q%3D28%2BCorporate%2BDrive%2BClifton%2BPark%2BNY%2B12065%26entry%3Dgmail%26source%3Dg%3E&entry=gmail&source=g>
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee. Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message. Thank you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171115/6b0c6bf5/attachment.html>
More information about the vtkusers
mailing list