def mouse_translate(self, x, y, dx, dy): self.setup_projection() glTranslatef(0, 0, - self.dist) z = util.model_to_screen(0, 0, 0)[2] d = (util.screen_to_model(x, y, z) - util.screen_to_model(x - dx, y - dy, z)) self.unset_projection() self.x += d[0]; self.y += d[1]
def mouse_translate(self, x, y, dx, dy): glPushMatrix() glLoadIdentity() glTranslatef(0, 0, -self._dist) z = model_to_screen(0, 0, 0)[2] d = vec_subs(screen_to_model(x, y, z), screen_to_model(x-dx, y-dy, z)) glPopMatrix() self._x += d[0] self._y += d[1]
def mouse_translate(self, x, y, dx, dy): glPushMatrix() glLoadIdentity() glTranslatef(0,0,-self._dist) z = model_to_screen(0,0,0)[2] d = vec_subs(screen_to_model(x,y,z), screen_to_model(x-dx,y-dy,z)) glPopMatrix() self._x += d[0] self._y += d[1]
def pick_point_screen(self, p, x, y): sx, sy, z = util.model_to_screen(*p.xyz) if x - 5 < sx < x + 5 and y - 5 < sy < y + 5: # knob raise PickedPlotObject(p, p.xyz, z)