From 6c91be573e9232b5193f55f1fe4ca08a41d5f59a Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 30 Sep 2022 07:41:56 +0200 Subject: [PATCH 1/2] Fix positioning of qgritems --- birdvisu/visualisation/annotators.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/birdvisu/visualisation/annotators.py b/birdvisu/visualisation/annotators.py index 766d3ee..c7f9e76 100644 --- a/birdvisu/visualisation/annotators.py +++ b/birdvisu/visualisation/annotators.py @@ -140,9 +140,14 @@ def create_qgritems(at): x = pos.x y = pos.y - shape = QtWidgets.QGraphicsRectItem(x, y, size, size) + shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size) shape.setBrush(brush) + shape.setPos(x, y) label = QtWidgets.QGraphicsSimpleTextItem(rk, parent=shape) + label.setY(size*0.8) + # Centering: + text_width = label.boundingRect().width() + label.setX(-text_width/2) at.router_annotations[rk].append(shape) for nk, n in topo.networks.items(): @@ -160,9 +165,14 @@ def create_qgritems(at): x = pos.x y = pos.y - shape = QtWidgets.QGraphicsRectItem(x, y, size, size) + shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size) shape.setBrush(brush) + shape.setPos(x, y) label = QtWidgets.QGraphicsSimpleTextItem(nk, parent=shape) + label.setY(size*0.8) + # Centering: + text_width = label.boundingRect().width() + label.setX(-text_width/2) at.network_annotations[nk].append(shape) for lk, l in topo.links.items(): From fe5ff025f5c5355b9471cc422a976313e261855b Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 30 Sep 2022 07:57:33 +0200 Subject: [PATCH 2/2] OSPF provider: quick ugly hack with various metrics This does not really make sense. But I want this to run, fixes will follow :-) --- birdvisu/maps_new/providers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/birdvisu/maps_new/providers.py b/birdvisu/maps_new/providers.py index 59f15a6..4a55e65 100644 --- a/birdvisu/maps_new/providers.py +++ b/birdvisu/maps_new/providers.py @@ -79,7 +79,8 @@ class OspfDataTopologyProvider(TopologyProvider): net_id = re.match(r'((network|stubnet|external) [^ ]+)', n).group(1) if net_id in self.network_renames: net_id = self.network_renames[net_id] - metric = int(re.search(r'metric ([0-9]+)', n).group(1)) + # FIXME: Hacking metric and metric2 together is a bad idea. + metric = int(re.search(r'metric2? ([0-9]+)', n).group(1)) ident = (r.ident, net_id) # I really hope that one router has at most one link to each network (incl. external) assert ident not in self.topology.links