def _keyboard( self, code, x, y ): symbol = self._keyboard_translate(code) modifiers = glut.glutGetModifiers() modifiers = self._modifiers_translate(modifiers) state= self.dispatch_event('on_key_press', symbol, modifiers) if not state and symbol == key.ESCAPE: #FIXME raise Exception," FIX EXIT MODE " #sys.exit()
def _modifiers(self, query_now=True): if query_now: glutmod = glut.glutGetModifiers() mod = () if glut.GLUT_ACTIVE_SHIFT & glutmod: mod += keys.SHIFT, if glut.GLUT_ACTIVE_CTRL & glutmod: mod += keys.CONTROL, if glut.GLUT_ACTIVE_ALT & glutmod: mod += keys.ALT, self._modifiers_cache = mod return self._modifiers_cache
def motionFunc(self, x, y): dx = x - self.mouseLastPos[0] dy = y - self.mouseLastPos[1] modifiers = GLUT.glutGetModifiers() tb = self.scene.tb if modifiers == GLUT.GLUT_ACTIVE_SHIFT: tb.zoom_to(dx, -dy) elif modifiers == GLUT.GLUT_ACTIVE_CTRL: tb.trans_to(dx, -dy) else: tb.drag_to(x, y, dx, -dy) self.mouseLastPos = np.array([x, y])
def Mouse(self, button, state, x, y): if state == 0: self.mouse_last_drag_pos = (x, y) modifiers = GLUT.glutGetModifiers() if (button == 1) or (modifiers & GLUT.GLUT_ACTIVE_ALT): self.mouse_drag_mode = 'dolly' elif (button == 2) or (modifiers & GLUT.GLUT_ACTIVE_CTRL): self.mouse_drag_mode = 'pan' else: self.mouse_drag_mode = 'orbit' if state == 1: self.mouse_last_drag_pos = None self.mouse_drag_mode = None
def keyboard_s(self, key, x, y): mkey = glut.glutGetModifiers() if mkey == glut.GLUT_ACTIVE_CTRL: pass elif mkey == glut.GLUT_ACTIVE_ALT: pass else: if key == glut.GLUT_KEY_UP: self.rotate["x"] += 1 elif key == glut.GLUT_KEY_DOWN: self.rotate["x"] -= 1 elif key == glut.GLUT_KEY_LEFT: self.rotate["y"] -= 1 elif key == glut.GLUT_KEY_RIGHT: self.rotate["y"] += 1 glut.glutSetWindow(self.window_handle) glut.glutPostRedisplay()
def _special_up(self, code, x, y): modifiers = glut.glutGetModifiers() self.dispatch_event("on_key_release", self._keyboard_translate(code), self._modifiers_translate(modifiers))
def _keyboard(self, code, x, y): symbol = self._keyboard_translate(code) modifiers = glut.glutGetModifiers() modifiers = self._modifiers_translate(modifiers) self.dispatch_event("on_key_press", symbol, modifiers)
def _special( self, code, x, y ): modifiers = glut.glutGetModifiers() self.dispatch_event('on_key_press', self._keyboard_translate(code), self._modifiers_translate(modifiers))
def _keyboard_up(self, code, x, y): modifiers = glut.glutGetModifiers() self.dispatch_event('on_key_release', self._keyboard_translate(code), self._modifiers_translate(modifiers))
def _keyboard(self, code, x, y): symbol = self._keyboard_translate(code) modifiers = glut.glutGetModifiers() modifiers = self._modifiers_translate(modifiers) self.dispatch_event('on_key_press', symbol, modifiers)
def _special(self, code, x, y): modifiers = glut.glutGetModifiers() self.dispatch_event('on_key_press', self._keyboard_translate(code), self._modifiers_translate(modifiers))