self.draw.queue_draw()
+ def select_fp_from_image(self, ball):
+ selection = self.treeview.get_selection()
+ selection.select_path(str(ball.position))
+
+ # making sure that only one ball is selected
+ for i in self.balls:
+ i.selected = False
+ ball.selected = True
+
+ self.draw.queue_draw()
+
def save_fp_list(self, *args):
assert self.project is not None
return False
- def ball_width_border(self, ball):
+ def point_with_border(self, ball):
iw, ih = self.draw.size_request()
w = self.draw.get_allocation().width
h = self.draw.get_allocation().height
def draw_ball(self, ball):
ctx = self.draw.window.cairo_create()
- ctx.arc(self.ball_width_border(ball).x,
- self.ball_width_border(ball).y,
+ ctx.arc(self.point_with_border(ball).x,
+ self.point_with_border(ball).y,
ball.radius, 0, 64*math.pi)
ctx.set_source_rgba(0.0, 0.0, 0.5, 0.4)
ctx.fill()
if ball.selected:
ctx.set_source_rgba(0.0, 0.5, 0.0, 0.4)
ctx.set_line_width(5)
- ctx.arc(self.ball_width_border(ball).x,
- self.ball_width_border(ball).y,
+ ctx.arc(self.point_with_border(ball).x,
+ self.point_with_border(ball).y,
ball.radius+1, 0, 64*math.pi)
ctx.stroke()
if event.button == 1:
for i in self.balls:
p1 = Point(event.x, event.y)
- p2 = self.ball_width_border(i)
+ p2 = self.point_with_border(i)
if Point.pythagorean(p1, p2) < i.radius:
self.last_x = event.x - i.p.x
self.last_y = event.y - i.p.y
+ self.select_fp_from_image(i)
self.new_ball = False
self.move_ball = i