Skip to content

Commit

Permalink
Only do routing when line ends are moved
Browse files Browse the repository at this point in the history
  • Loading branch information
amolenaar committed Oct 31, 2021
1 parent 32c2da1 commit 27e4467
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gaphas/collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 27e4467

Please sign in to comment.