|
|
@ -9,6 +9,7 @@ from dataclasses import dataclass
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import random
|
|
|
|
import random
|
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
|
|
|
|
from .qt_widgets import MyGraphicsRectItem
|
|
|
|
|
|
|
|
|
|
|
|
# Classification
|
|
|
|
# Classification
|
|
|
|
|
|
|
|
|
|
|
@ -140,7 +141,7 @@ def create_qgritems(at):
|
|
|
|
x = pos.x
|
|
|
|
x = pos.x
|
|
|
|
y = pos.y
|
|
|
|
y = pos.y
|
|
|
|
|
|
|
|
|
|
|
|
shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size)
|
|
|
|
shape = MyGraphicsRectItem(-size/2, -size/2, size, size)
|
|
|
|
shape.setBrush(brush)
|
|
|
|
shape.setBrush(brush)
|
|
|
|
shape.setPos(x, y)
|
|
|
|
shape.setPos(x, y)
|
|
|
|
shape.setToolTip(rk)
|
|
|
|
shape.setToolTip(rk)
|
|
|
@ -149,6 +150,7 @@ def create_qgritems(at):
|
|
|
|
# Centering:
|
|
|
|
# Centering:
|
|
|
|
text_width = label.boundingRect().width()
|
|
|
|
text_width = label.boundingRect().width()
|
|
|
|
label.setX(-text_width/2)
|
|
|
|
label.setX(-text_width/2)
|
|
|
|
|
|
|
|
shape.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable | QtWidgets.QGraphicsItem.ItemIsSelectable)
|
|
|
|
at.router_annotations[rk].append(shape)
|
|
|
|
at.router_annotations[rk].append(shape)
|
|
|
|
|
|
|
|
|
|
|
|
for nk, n in topo.networks.items():
|
|
|
|
for nk, n in topo.networks.items():
|
|
|
@ -166,7 +168,7 @@ def create_qgritems(at):
|
|
|
|
x = pos.x
|
|
|
|
x = pos.x
|
|
|
|
y = pos.y
|
|
|
|
y = pos.y
|
|
|
|
|
|
|
|
|
|
|
|
shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size)
|
|
|
|
shape = MyGraphicsRectItem(-size/2, -size/2, size, size)
|
|
|
|
shape.setBrush(brush)
|
|
|
|
shape.setBrush(brush)
|
|
|
|
shape.setPos(x, y)
|
|
|
|
shape.setPos(x, y)
|
|
|
|
shape.setToolTip(nk)
|
|
|
|
shape.setToolTip(nk)
|
|
|
@ -175,6 +177,7 @@ def create_qgritems(at):
|
|
|
|
# Centering:
|
|
|
|
# Centering:
|
|
|
|
text_width = label.boundingRect().width()
|
|
|
|
text_width = label.boundingRect().width()
|
|
|
|
label.setX(-text_width/2)
|
|
|
|
label.setX(-text_width/2)
|
|
|
|
|
|
|
|
shape.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable | QtWidgets.QGraphicsItem.ItemIsSelectable)
|
|
|
|
at.network_annotations[nk].append(shape)
|
|
|
|
at.network_annotations[nk].append(shape)
|
|
|
|
|
|
|
|
|
|
|
|
for lk, l in topo.links.items():
|
|
|
|
for lk, l in topo.links.items():
|
|
|
@ -183,16 +186,24 @@ def create_qgritems(at):
|
|
|
|
|
|
|
|
|
|
|
|
rpos = None
|
|
|
|
rpos = None
|
|
|
|
for tag in at.router_annotations[rid][-1::-1]:
|
|
|
|
for tag in at.router_annotations[rid][-1::-1]:
|
|
|
|
|
|
|
|
if isinstance(tag, QtWidgets.QGraphicsRectItem):
|
|
|
|
|
|
|
|
ritem = tag
|
|
|
|
if isinstance(tag, Position):
|
|
|
|
if isinstance(tag, Position):
|
|
|
|
rpos = tag
|
|
|
|
rpos = tag
|
|
|
|
break
|
|
|
|
break
|
|
|
|
npos = None
|
|
|
|
npos = None
|
|
|
|
for tag in at.network_annotations[nid][-1::-1]:
|
|
|
|
for tag in at.network_annotations[nid][-1::-1]:
|
|
|
|
|
|
|
|
if isinstance(tag, QtWidgets.QGraphicsRectItem):
|
|
|
|
|
|
|
|
nitem = tag
|
|
|
|
if isinstance(tag, Position):
|
|
|
|
if isinstance(tag, Position):
|
|
|
|
npos = tag
|
|
|
|
npos = tag
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
line = QtWidgets.QGraphicsLineItem(rpos.x, rpos.y, npos.x, npos.y)
|
|
|
|
line = QtWidgets.QGraphicsLineItem(rpos.x, rpos.y, npos.x, npos.y)
|
|
|
|
|
|
|
|
ritem.setData(0, line)
|
|
|
|
|
|
|
|
nitem.setData(0, line)
|
|
|
|
|
|
|
|
line.setData(0, nitem)
|
|
|
|
|
|
|
|
line.setData(1, ritem)
|
|
|
|
at.link_annotations[lk].append(line)
|
|
|
|
at.link_annotations[lk].append(line)
|
|
|
|
return at
|
|
|
|
return at
|
|
|
|
|
|
|
|
|
|
|
|