def picker_a0(self, a, evt): from ifigure.widgets.canvas.custom_picker import linehit_test, abs_d hit, extra, type, loc = super(FigAnnotate, self).picker_a0(a, evt) arr = a.arrow_patch.get_verts() x = arr[:, 0] y = arr[:, 1] self._drag_mode = 0 hit = False if abs_d(x[0], y[0], evt.x, evt.y) < 5: self._drag_mode = 1 hit = True elif abs_d(x[-1], y[-1], evt.x, evt.y) < 5: self._drag_mode = 2 hit = True for i in range(len(x) - 1): if (linehit_test(evt.x, evt.y, x[i], y[i], x[i + 1], y[i + 1]) < 5 and evt.x > min([x[i], x[i + 1]]) and evt.y > min([y[i], y[i + 1]]) and evt.x < max([x[i], x[i + 1]]) and evt.y < max([y[i], y[i + 1]])): hit = True self._drag_mode = 3 break return hit, extra, type, loc
def gp_hittest_rect(self, evt, gp1, gp2): x1, y1 = gp1.get_device_point() x2, y2 = gp2.get_device_point() if abs_d(x1, y1, evt.x, evt.y) < 9: return 1 if abs_d(x2, y1, evt.x, evt.y) < 9: return 2 if abs_d(x2, y2, evt.x, evt.y) < 9: return 3 if abs_d(x1, y2, evt.x, evt.y) < 9: return 4 # print (linehit_test(evt.x, evt.y, x1, y1, x2, y2), # evt.x >= min([x1, x2]), # evt.y >= min([y1, y2]), # evt.x <= max([x1, x2]), # evt.y <= max([y1, y2])) if (linehit_test(evt.x, evt.y, x1, y1, x2, y2) and evt.x >= min([x1, x2]) - 2 and evt.y >= min([y1, y2]) - 2 and evt.x <= max([x1, x2]) + 2 and evt.y <= max([y1, y2]) + 2): hit = True return 5 return 0
def gp_hittest_rect(self, evt, gp1, gp2): x1, y1 = gp1.get_device_point() x2, y2 = gp2.get_device_point() if abs_d(x1, y1, evt.x, evt.y) < 9: return 1 if abs_d(x2, y1, evt.x, evt.y) < 9: return 2 if abs_d(x2, y2, evt.x, evt.y) < 9: return 3 if abs_d(x1, y2, evt.x, evt.y) < 9: return 4 # print (linehit_test(evt.x, evt.y, x1, y1, x2, y2), # evt.x >= min([x1, x2]), # evt.y >= min([y1, y2]), # evt.x <= max([x1, x2]), # evt.y <= max([y1, y2])) if (linehit_test(evt.x, evt.y, x1, y1, x2, y2) and evt.x >= min([x1, x2])-2 and evt.y >= min([y1, y2])-2 and evt.x <= max([x1, x2])+2 and evt.y <= max([y1, y2])+2): hit = True return 5 return 0
def gp_hittest_p(self, evt, gp): x1, y1 = gp.get_device_point() return abs_d(x1, y1, evt.x, evt.y) < 9