From 90e2b8d3657bb4007e6d2b7a33d8ee5d1e8a21ef Mon Sep 17 00:00:00 2001 From: huyenngn Date: Mon, 16 Sep 2024 22:11:48 +0200 Subject: [PATCH 1/2] fix(diagram): Fix oblique snapping with straight edges --- capellambse/aird/_edge_factories.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/capellambse/aird/_edge_factories.py b/capellambse/aird/_edge_factories.py index 36f5dc81..e3823932 100644 --- a/capellambse/aird/_edge_factories.py +++ b/capellambse/aird/_edge_factories.py @@ -317,10 +317,14 @@ def snap_oblique( ) delta = (points[i] - source).angleto(new_point - source) if abs(delta) >= 1: + if len(points) >= 3: + next_point = points[next_i - i + next_i] + else: + next_point = source new_point = target.vector_snap( source, style=diagram.RoutingStyle.OBLIQUE, - source=points[next_i - i + next_i], + source=next_point, ) points[i] = new_point From 93f09cef24ec411be0b536e20104a713a8ec0844 Mon Sep 17 00:00:00 2001 From: huyenngn Date: Mon, 16 Sep 2024 22:11:48 +0200 Subject: [PATCH 2/2] fix: Don't draw port labels twice --- capellambse/svg/drawing.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/capellambse/svg/drawing.py b/capellambse/svg/drawing.py index c2cc499e..1db6fcaf 100644 --- a/capellambse/svg/drawing.py +++ b/capellambse/svg/drawing.py @@ -555,18 +555,20 @@ def _draw_symbol( labels=floating_labels_, id_=id_, ) - else: - gcls = "".join(f" context-{i}" for i in context_) - grp = self.__drawing.g(class_=f"Box {class_}{gcls}", id_=id_) - grp.add( - self.__drawing.use( - href=f"#{class_}Symbol", - insert=pos, - size=size, - class_=class_, - **obj_style._to_dict(), - ) + self.__drawing.add(grp) + return + + gcls = "".join(f" context-{i}" for i in context_) + grp = self.__drawing.g(class_=f"Box {class_}{gcls}", id_=id_) + grp.add( + self.__drawing.use( + href=f"#{class_}Symbol", + insert=pos, + size=size, + class_=class_, + **obj_style._to_dict(), ) + ) self.__drawing.add(grp) if floating_labels_: