From 27e446793c1682a2683b6c85f43542dd4c7ffa10 Mon Sep 17 00:00:00 2001 From: Arjan Molenaar Date: Sun, 31 Oct 2021 15:44:43 +0100 Subject: [PATCH] Only do routing when line ends are moved --- gaphas/collision.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gaphas/collision.py b/gaphas/collision.py index c95f0e9a..6b36cbcf 100644 --- a/gaphas/collision.py +++ b/gaphas/collision.py @@ -17,6 +17,7 @@ from operator import attrgetter, itemgetter from typing import Callable, Iterable, Literal, NamedTuple, Tuple, Union +from gaphas.connections import Handle from gaphas.decorators import g_async from gaphas.geometry import intersect_rectangle_line from gaphas.item import Item, Line @@ -56,10 +57,14 @@ def _measure(*args, **kwargs): class CollisionAvoidingLineHandleMoveMixin: view: GtkView item: Item + handle: Handle def move(self, pos: Pos) -> None: super().move(pos) # type: ignore[misc] - self.update_line_to_avoid_collisions() + line = self.item + assert isinstance(line, Line) + if self.handle in (line.head, line.tail): + self.update_line_to_avoid_collisions() @g_async(single=True) def update_line_to_avoid_collisions(self):