<div dir="ltr">2016-06-16 14:39 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">2016-06-16 14:37 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Launching QVTKRenderWindowInteractor.py as a script, which brings up the built-in cone example, if I hit 't' to switch to trackball style interaction and then rotate the camera around for a few seconds, when I release the mouse there's a noticable delay before the movement stops.<br><br></div>The delay seems related to the time the interaction went on: If I rotate around for a longer period, the period between releasing the mouse and the movement finally stopping is longer.<br><br></div>Any idea what might be going on here?<span><font color="#888888"><br></font></span></div></div></blockquote></span></div></div></div></blockquote><div><br></div><div>This is now becoming a real problem, since I see the same behavior in a custom interactor style I'm working on.<br><br></div><div>Here's the relevant part of the code:<br><br><br>class InteractorStyle(vtkInteractorStyleUser):<br><br>    def __init__(self, *args, **kwargs):<br>        super().__init__(*args, **kwargs)<br><br>        # To ensure GetCurrentRenderer() returns the relevant renderer in the handlers<br>        # below, set the current renderer to the one found poked by the interactor when<br>        # the mouse moves or a mouse button is pressed.<br>        for event in [<br>                vtkCommand.MouseMoveEvent,<br>                vtkCommand.LeftButtonPressEvent,<br>                vtkCommand.RightButtonPressEvent,<br>                vtkCommand.MiddleButtonPressEvent]:<br>            self.AddObserver(event,<br>                             lambda *_: self.SetCurrentRenderer(<br>                                 self.GetInteractor().FindPokedRenderer(<br>                                     self.x(), self.y())))<br><br>        # Hook up event callbacks.<br>        for event, callback in [<br>                (vtkCommand.MouseMoveEvent, self.onMouseMoveEvent),<br>                (vtkCommand.LeftButtonPressEvent, self.onLeftButtonPressEvent),<br>                (vtkCommand.LeftButtonReleaseEvent, self.onLeftButtonReleaseEvent),<br>                (vtkCommand.RightButtonPressEvent, self.onRightButtonPressEvent),<br>                (vtkCommand.RightButtonReleaseEvent, self.onRightButtonReleaseEvent),<br>                (vtkCommand.MiddleButtonPressEvent, self.onMiddleButtonPressEvent),<br>                (vtkCommand.MiddleButtonReleaseEvent, self.onMiddleButtonReleaseEvent),<br>                (vtkCommand.KeyPressEvent, self.onKeyPressEvent),<br>                (vtkCommand.KeyReleaseEvent, self.onKeyReleaseEvent),<br>                (vtkCommand.CharEvent, self.onCharEvent),<br>                (vtkCommand.ExposeEvent, self.onExposeEvent),<br>                (vtkCommand.EnterEvent, self.onEnterEvent),<br>                (vtkCommand.LeaveEvent, self.onLeaveEvent),<br>                (vtkCommand.ConfigureEvent, self.onConfigureEvent),<br>                (vtkCommand.TimerEvent, self.onTimerEvent),<br>                (vtkCommand.UserEvent, self.onUserEvent)]:<br>            self.AddObserver(event, callback)<br><br>    def onMouseMoveEvent(self, sender, event):<br>        pass<br><br>    def onLeftButtonPressEvent(self, sender, event):<br>        pass<br><br>    def onLeftButtonReleaseEvent(self, sender, event):<br>        pass<br><br>    def onRightButtonPressEvent(self, sender, event):<br>        pass<br><br>    def onRightButtonReleaseEvent(self, sender, event):<br>        pass<br><br>    def onMiddleButtonPressEvent(self, sender, event):<br>        pass<br><br>    def onMiddleButtonReleaseEvent(self, sender, event):<br>        pass<br><br>    def onKeyPressEvent(self, sender, event):<br>        pass<br><br>    def onKeyReleaseEvent(self, sender, event):<br>        pass<br><br>    def onCharEvent(self, sender, event):<br>        pass<br><br>    def onExposeEvent(self, sender, event):<br>        pass<br><br>    def onEnterEvent(self, sender, event):<br>        pass<br><br>    def onLeaveEvent(self, sender, event):<br>        pass<br><br>    def onConfigureEvent(self, sender, event):<br>        pass<br><br>    def onTimerEvent(self, sender, event):<br>        pass<br><br>    def onUserEvent(self, sender, event):<br>        pass<br><br>    def x(self):<br>        """Current event X position"""<br>        return self.GetInteractor().GetEventPosition()[0]<br><br>    def y(self):<br>        """Current event Y position"""<br>        return self.GetInteractor().GetEventPosition()[1]<br><br>    def lastX(self):<br>        """Last event X position"""<br>        return self.GetInteractor().GetLastEventPosition()[0]<br><br>    def lastY(self):<br>        """Last event Y position"""<br>        return self.GetInteractor().GetLastEventPosition()[1]<br><br>    def control(self):<br>        """Control modifier?"""<br>        return self.GetInteractor().GetControlKey()<br><br>    def shift(self):<br>        """Shift modifier?"""<br>        return self.GetInteractor().GetShiftKey()<br><br><br>class CloseUpInteractorStyle(InteractorStyle):<br><br>    # States<br>    Idle = 0<br>    Panning = 1<br>    Rotating = 2<br>    Tumbling = 3<br>    Zooming = 4<br><br>    def __init__(self, *args, **kwargs):<br>        super().__init__(*args, **kwargs)<br><br>        self.state = self.Idle<br><br>    def onLeftButtonPressEvent(self, sender, event):<br>        if self.GetCurrentRenderer() is None:<br>            return<br><br>        self.state = self.Rotating<br><br>    def onLeftButtonReleaseEvent(self, sender, event):<br><br>        self.state = self.Idle<br><br>    def onMouseMoveEvent(self, sender, event):<br>        if self.GetCurrentRenderer() is None:<br>            return<br><br>        if self.state == self.Rotating:<br>            self._rotate()<br><br>    def _rotate(self):<br>        if self.GetCurrentRenderer() is None:<br>            return<br><br>        dx = self.x() - self.lastX()<br><br>        renderer = self.GetCurrentRenderer()<br>        interactor = self.GetInteractor()<br><br>        (windowWidth, _) = renderer.GetRenderWindow().GetSize()<br>        azimuth = -200.0 * dx / windowWidth<br><br>        print('azimuth: {}'.format(azimuth))<br>        camera = renderer.GetActiveCamera()<br>        camera.Azimuth(azimuth)<br>        camera.OrthogonalizeViewUp()<br><br>        interactor.Render()<br><br></div><div>The InteractorStyle class is just a helper base class I use for custom interactor styles, it observes all events on itself and calls corresponding methods (to be overridden).<br><br></div><div>The CloseUpInteractorStyle is my basic interactor style embryo. All it does is handle click + horizontal movement of the mouse by setting the azimuth of the camera.<br><br></div><div>The same strange "lagging" behavior can be observed when click-moving the mouse somewhat rapidly for a few seconds.<br><br></div><div>I'm attaching the full code, which also includes VTKWidget, a somewhat simplified / cut down version of QVTKRenderWindowInteractor I'm using (by note that I'm seeing the same problem with an unmodified QVTKRenderWindowInteractor).<br><br></div><div>Is the rendering not keeping up with the rate of the mouse events? Do I need to perform some kind of event compression manually?<br><br></div><div>Any advice is much appriciated!<br><br></div><div>Elvis<br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span><font color="#888888"></font></span></div></div></blockquote><div><br></div></span><div>When using the joystick style ('j', the default) the behavior is normal. Movement stops as soon as the mouse button is released.<br><br></div><div>Elvis<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span><font color="#888888"><br></font></span></div><span><font color="#888888">Elvis<br></font></span></div>
</blockquote></div><br></div></div>
</blockquote></div><br></div></div>