self.balls.save_to_file(self.project.focus_points_file)
fc.destroy()
-
def load_project(self, project):
self.project = project
self.balls = self.load_balls_from_file(project.focus_points_file)
self.draw.set_from_pixbuf(pixbuf)
self.load_balls_to_treeview()
+ self.set_widgets_sensitivity(True)
def unload_project(self):
self.project = None
self.image = None
self.balls = BallManager()
self.draw.queue_draw()
+ self.set_widgets_sensitivity(False)
+
+ def set_widgets_sensitivity(self, sensitive):
+ for i in 'toolbutton1', 'toolbutton5', 'scrolledwindow1', 'hbox2':
+ self.wid(i).set_sensitive(sensitive)
def load_balls_to_treeview(self):
self.model.clear()
i.selected = False
ball.selected = True
+ # available space to the image
+ w = self.evtbox.get_allocation().width
+ h = self.evtbox.get_allocation().height
+
+ # point begining from the left image border
+ wib = self.point_with_border(ball)
+
+ print wib.x, w
+
+ self.wid('viewport').get_vadjustment().value = wib.x # + (w / 2)
+ self.wid('viewport').get_hadjustment().value = wib.y # + (h / 2)
+
self.draw.queue_draw()
def select_fp_from_image(self, ball):
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