@ -307,10 +307,6 @@ def highlight_selection():
Given the current move bounding box, highlights any points inside it.
"""
# TODO: There's an edge case here
# The edge case is that if you click and drag up top_left becomes
# bottom right so there must be a condition where they should be
# swapped.
top_left = get_bb_top_left()
bottom_right = get_bb_bottom_right()
@ -145,6 +145,13 @@ class PointSet:
def point_size(self):
return self.__point_size
def clear_selection(self):
Handy helper function to clear all selected points.
for p in self.__points:
p.unselect()
def add_point(self, x, y, attrs=[]):
Adds a point in screen coordinates and an optional attribute to
@ -83,3 +83,30 @@ def test_attributes_must_be_array_of_attributes():
with pytest.raises(ValueError):
l = PointSet(8)
l.add_point(1, 2, attrs=[1,2,3,4,5])
def test_clear_all_selected_points():
l.add_point(1, 2)
l.add_point(3, 4)
for p in l.points:
p.select()
selected = 0
if p.selected:
selected += 1
assert selected == 2
l.clear_selection()
unselected = 0
if not p.selected:
unselected += 1
assert unselected == 2