def _OnMotion(self, obj=None, event=""): # JDG retire this after we eliminate Atamai event handling if self._RenderWindowInteractor.GetInteractorStyle( ) != self.interactor_style: return #(x, y) = obj.GetEventPosition() #(oldx, oldy) = obj.GetLastEventPosition() x, y = obj.GetLastPos() oldx, oldy = obj.GetOldPos() if x == oldx and y == oldy: return e = EventHandler.Event() e.type = '6' e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' # JDG changed e.num to reflect real mouse button state e.num = obj.GetButton() (e.width, e.height) = obj.GetInteractor().GetSize() (e.x, e.y) = (x, y) # self.PrintEvent(e) self.HandleEvent(e)
def _TrapLeave(self): e = EventHandler.Event() e.type = '8' e.state = 1 * (self._InteractorStyle.GetShiftKey() > 0) | \ 4 * (self._InteractorStyle.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = 0 (e.width, e.height) = self._RenderWindowInteractor.GetSize() (e.x, e.y) = self._InteractorStyle.GetLastPos() # self.PrintEvent(e) self.HandleEvent(e)
def _TrapKeyRelease(self): e = EventHandler.Event() e.type = '3' e.state = 1 * (self._InteractorStyle.GetShiftKey() > 0) | \ 4 * (self._InteractorStyle.GetCtrlKey() > 0) | \ self._State e.keysym = self._InteractorStyle.GetKeySym() e.char = chr(self._InteractorStyle.GetChar()) e.num = 0 (e.width, e.height) = self._RenderWindowInteractor.GetSize() (e.x, e.y) = self._InteractorStyle.GetLastPos() # self.PrintEvent(e) self.HandleEvent(e)
def _TrapButtonRelease(self, num): e = EventHandler.Event() e.type = '5' e.state = 1 * (self._InteractorStyle.GetShiftKey() > 0) | \ 4 * (self._InteractorStyle.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = num (e.width, e.height) = self._RenderWindowInteractor.GetSize() (e.x, e.y) = self._RenderWindowInteractor.GetEventPosition() self._State = self._State & ~(0x80 << num) # clear bit for button self.HandleEvent(e)
def _OnLeave(self, obj=None, event=""): e = EventHandler.Event() e.type = '8' e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetControlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = 0 (e.width, e.height) = obj.GetSize() (e.x, e.y) = obj.GetEventPosition() # self.PrintEvent(e) self.HandleEvent(e)
def _OnConfigure(self, obj=None, event=""): e = EventHandler.Event() e.type = '22' e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = 0 (e.width, e.height) = obj.GetInteractor().GetSize() (e.x, e.y) = obj.GetInteractor().GetLastEventPosition() # self.PrintEvent(e) self.HandleEvent(e)
def _TrapButtonPress(self, num): e = EventHandler.Event() e.type = '4' e.state = 1 * (self._InteractorStyle.GetShiftKey() > 0) | \ 4 * (self._InteractorStyle.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = num (e.width, e.height) = self._RenderWindowInteractor.GetSize() (e.x, e.y) = self._RenderWindowInteractor.GetEventPosition() # should be changed to the below eventually: #(e.x, e.y) = self._InteractorStyle.GetLastPos() self._State = self._State | (0x80 << num) # set bit for button self.HandleEvent(e)
def _TrapMotion(self): (x, y) = self._InteractorStyle.GetLastPos() (oldx, oldy) = self._InteractorStyle.GetOldPos() if x == oldx and y == oldy: return e = EventHandler.Event() e.type = '6' e.state = 1 * (self._InteractorStyle.GetShiftKey() > 0) | \ 4 * (self._InteractorStyle.GetCtrlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = 0 (e.width, e.height) = self._RenderWindowInteractor.GetSize() (e.x, e.y) = (x, y) # self.PrintEvent(e) self.HandleEvent(e) self._TrapTimer()
def _HandleConfigure(self, event): # pass off the configure event to the Panes width = event.width height = event.height if not (width and height): return if len(self._RenderPanes) == 0: raise Exception("No attached render panes!!") for pane in self._RenderPanes: # set up the new viewport for the pane xmin, ymin, xmax, ymax = pane.GetViewport() left, bottom, right, top = pane.GetViewportOffsets() xmin = (xmin * width + left) / width xmax = (xmax * width + right) / width ymin = (ymin * height + bottom) / height ymax = (ymax * height + top) / height pane.GetRenderer().SetViewport(xmin, ymin, xmax, ymax) # pass the event along to the renderer xmin = int(xmin * width + 0.5) xmax = int(xmax * width + 0.5) ymin = int(ymin * height + 0.5) ymax = int(ymax * height + 0.5) e = EventHandler.Event() e.type = '22' e.x = xmin e.y = ymin e.width = xmax - xmin e.height = ymax - ymin e.state = 0 e.num = 0 pane.HandleEvent(e)
def _OnMotion(self, obj=None, event=""): # JDG retire this after we eliminate Atamai event handling if self._RenderWindowInteractor.GetInteractorStyle( ) != self.interactor_style: return (x, y) = obj.GetEventPosition() (oldx, oldy) = obj.GetLastEventPosition() if x == oldx and y == oldy: return e = EventHandler.Event() e.type = '6' e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetControlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = 0 (e.width, e.height) = obj.GetSize() (e.x, e.y) = (x, y) # self.PrintEvent(e) self.HandleEvent(e)
def _OnButtonRelease(self, obj=None, event=""): # JDG retire this after we eliminate Atamai event handling if self._RenderWindowInteractor.GetInteractorStyle( ) != self.interactor_style: return e = EventHandler.Event() e.type = '5' e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetControlKey() > 0) | \ self._State e.keysym = '??' e.char = '\0' e.num = { "LeftButtonReleaseEvent": 1, "MiddleButtonReleaseEvent": 2, "RightButtonReleaseEvent": 3 }[event] (e.width, e.height) = obj.GetSize() (e.x, e.y) = obj.GetEventPosition() self._State = self._State & ~(0x80 << e.num) # clear bit for button self.HandleEvent(e)
def _OnKeyRelease(self, obj=None, event=""): # JDG retire this after we eliminate Atamai event handling if self._RenderWindowInteractor.GetInteractorStyle( ) != self.interactor_style: return e = EventHandler.Event() e.type = '3' e.alt_key = obj.GetAltKey() e.ctrl_key = obj.GetControlKey() e.shift_key = obj.GetShiftKey() e.state = 1 * (obj.GetShiftKey() > 0) | \ 4 * (obj.GetControlKey() > 0) | \ self._State e.keysym = obj.GetKeySym() e.char = obj.GetKeyCode() e.num = 0 (e.width, e.height) = obj.GetSize() (e.x, e.y) = obj.GetLastEventPosition() # self.PrintEvent(e) self.HandleEvent(e)