Commit 7dafbd79 authored by André Anjos's avatar André Anjos

[gui/widgets] Fix placement bugs

parent af8f2bd1
Pipeline #26591 passed with stages
in 12 minutes and 47 seconds
......@@ -421,7 +421,6 @@ class AnnotatorApp(tkinter.Tk):
self.canvas.reset_zoom_filter(self.zoom, filter_function)
self._load_annotations()
self._update_status()
def reset_annotation_zoom(self, zoom):
......@@ -452,8 +451,9 @@ class AnnotatorApp(tkinter.Tk):
for k in data:
if not k: continue
self.annotation.append(widgets.Annotation(self.canvas,
self.canvas.original_shape(), k, self.zoom, False,
self.marker_radius, self.skip_factor, self.default_mode))
self.canvas.original_shape(), widgets.zoom_points(self.zoom, k),
self.zoom, False, self.marker_radius, self.skip_factor,
self.default_mode))
if self.annotation:
self.annotation[-1].activate()
......@@ -462,6 +462,8 @@ class AnnotatorApp(tkinter.Tk):
if not self.annotation: #creates a first annotation object with no points
self.create_new_annotation()
self._update_status()
def _canvas_pointer_position(self):
"""Returns the relative position of the pointer w.r.t. canvas"""
......@@ -586,7 +588,7 @@ class AnnotatorApp(tkinter.Tk):
# ignore random events outside the drawing window
if self.canvas.pointer_is_outside_image(): return
y, x = widgets.unzoom_point(self.zoom, self._canvas_pointer_position())
y, x = self._canvas_pointer_position()
logger.debug('Appending point %d (%d, %d) to object %d...',
len(self.curr_annotation), y, x,
self.annotation.index(self.curr_annotation))
......@@ -600,7 +602,7 @@ class AnnotatorApp(tkinter.Tk):
# ignore random events outside the drawing window
if self.canvas.pointer_is_outside_image(): return
y, x = widgets.unzoom_point(self.zoom, self._canvas_pointer_position())
y, x = self._canvas_pointer_position()
logger.debug('Inserting point %d (%d, %d) to object %d...',
len(self.curr_annotation), y, x,
self.annotation.index(self.curr_annotation))
......
......@@ -254,6 +254,10 @@ class Annotation(object):
self.canvas.itemconfig(k, fill=COLOR_INACTIVE,
outline=COLOR_INACTIVE)
if p is None:
p = self.canvas.relative_pointer_position()
self._highlight_widget(self._closest_annotation(p))
def deactivate(self):
"""Makes the current widgets look "inactive" """
......@@ -278,6 +282,7 @@ class Annotation(object):
"""Appends a new point ``(y,x)`` to the annotation object"""
# add point
p = unzoom_point(self.zoom, p)
self.point.append(p)
self.widget.append(self._make_cross(p))
self._highlight_widget(-1)
......@@ -330,9 +335,10 @@ class Annotation(object):
# the pointer is in highlighting the annotation before
closest_point = second_closest
self.point.insert(closest_point, p)
uzp = unzoom_point(self.zoom, p)
self.point.insert(closest_point, uzp)
self.widget.insert(closest_point, self._make_cross(p))
self.widget.insert(closest_point, self._make_cross(uzp))
# TODO: renumber all labels, so they are in the right order
#for k, (_, _, t) in enumerate(self.widget):
......@@ -524,7 +530,9 @@ class Annotation(object):
dx = 0
self.point[closest_point] = (y+dy, x+dx)
self.canvas.move(self.widget[closest_point], dx, dy)
self.canvas.delete(self.widget[closest_point])
self.widget[closest_point] = self._make_cross(self.point[closest_point])
self._highlight_widget(closest_point)
self._update_decoration()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment