|
|
@ -13,7 +13,7 @@ if len(sys.argv) > 1:
|
|
|
|
ref_topo = OspfFileTopologyProvider(ref_topo_file).get_topology()
|
|
|
|
ref_topo = OspfFileTopologyProvider(ref_topo_file).get_topology()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
cur_topo = BirdSocketTopologyProvider(instance='ospfv2', area=1).get_topology()
|
|
|
|
cur_topo = BirdSocketTopologyProvider(instance='ospf1', area=0).get_topology()
|
|
|
|
except OSError as e:
|
|
|
|
except OSError as e:
|
|
|
|
raise NotImplementedError('Cannot create a mock topology atm') from e
|
|
|
|
raise NotImplementedError('Cannot create a mock topology atm') from e
|
|
|
|
|
|
|
|
|
|
|
@ -50,37 +50,61 @@ for ann_id in annotators:
|
|
|
|
|
|
|
|
|
|
|
|
# Show it
|
|
|
|
# Show it
|
|
|
|
|
|
|
|
|
|
|
|
from birdvisu.visualisation import annotators
|
|
|
|
#from birdvisu.visualisation import annotators
|
|
|
|
from birdvisu import maps_new
|
|
|
|
#from birdvisu import maps_new
|
|
|
|
|
|
|
|
|
|
|
|
# annotators.create_qgritems does not like being run without Qt initialization.
|
|
|
|
# annotators.create_qgritems does not like being run without Qt initialization.
|
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
app = QtWidgets.QApplication([])
|
|
|
|
app = QtWidgets.QApplication([])
|
|
|
|
|
|
|
|
|
|
|
|
annotated_topology = maps_new.annotate_topology(combined_topology,
|
|
|
|
#annotated_topology = maps_new.annotate_topology(combined_topology,
|
|
|
|
# A semi-canonical set of annotators:
|
|
|
|
# # A semi-canonical set of annotators:
|
|
|
|
[
|
|
|
|
# [
|
|
|
|
annotators.extract_positions,
|
|
|
|
# annotators.extract_positions,
|
|
|
|
annotators.random_position,
|
|
|
|
# annotators.random_position,
|
|
|
|
annotators.assign_brushes,
|
|
|
|
# annotators.assign_brushes,
|
|
|
|
annotators.create_qgritems,
|
|
|
|
# annotators.create_qgritems,
|
|
|
|
]
|
|
|
|
# ]
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shapes = dict()
|
|
|
|
|
|
|
|
for k, v in annot_topo.topology.vertices.items():
|
|
|
|
|
|
|
|
size = 30 if k.is_router else 10
|
|
|
|
|
|
|
|
x, y = randint(0, 1920), randint(0, 1080)
|
|
|
|
|
|
|
|
shape = QtWidgets.QGraphicsRectItem(-size/2, -size/2, size, size)
|
|
|
|
|
|
|
|
shape.setPos(x,y)
|
|
|
|
|
|
|
|
# TODO:brush
|
|
|
|
|
|
|
|
label_text = str(IPv4Address(k.router_id)) if k.is_router else str(k.address) # Surprisingly works for all the possible addresses.
|
|
|
|
|
|
|
|
label = QtWidgets.QGraphicsSimpleTextItem(label_text, parent=shape)
|
|
|
|
|
|
|
|
label.setY(size*0.8)
|
|
|
|
|
|
|
|
text_width = label.boundingRect().width()
|
|
|
|
|
|
|
|
label.setX(-text_width/2)
|
|
|
|
|
|
|
|
shapes[k] = shape
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for e in annot_topo.topology.edges:
|
|
|
|
|
|
|
|
start = shapes[e.source].pos()
|
|
|
|
|
|
|
|
end = shapes[e.target].pos()
|
|
|
|
|
|
|
|
qlinef = QtCore.QLineF(start, end)
|
|
|
|
|
|
|
|
line = QtWidgets.QGraphicsLineItem(qlinef)
|
|
|
|
|
|
|
|
shapes[e] = line
|
|
|
|
|
|
|
|
|
|
|
|
# Render the widget
|
|
|
|
# Render the widget
|
|
|
|
|
|
|
|
|
|
|
|
scene = QtWidgets.QGraphicsScene()
|
|
|
|
scene = QtWidgets.QGraphicsScene()
|
|
|
|
|
|
|
|
|
|
|
|
for tagsrc in [
|
|
|
|
#for tagsrc in [
|
|
|
|
annotated_topology.router_annotations.values(),
|
|
|
|
# annotated_topology.router_annotations.values(),
|
|
|
|
annotated_topology.network_annotations.values(),
|
|
|
|
# annotated_topology.network_annotations.values(),
|
|
|
|
annotated_topology.link_annotations.values(),
|
|
|
|
# annotated_topology.link_annotations.values(),
|
|
|
|
]:
|
|
|
|
# ]:
|
|
|
|
for taglist in tagsrc:
|
|
|
|
# for taglist in tagsrc:
|
|
|
|
assert len(taglist) > 0
|
|
|
|
# assert len(taglist) > 0
|
|
|
|
assert isinstance(taglist[-1], QtWidgets.QGraphicsItem)
|
|
|
|
# assert isinstance(taglist[-1], QtWidgets.QGraphicsItem)
|
|
|
|
scene.addItem(taglist[-1])
|
|
|
|
# scene.addItem(taglist[-1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for sh in shapes.values(): scene.addItem(sh)
|
|
|
|
|
|
|
|
|
|
|
|
view = QtWidgets.QGraphicsView(scene)
|
|
|
|
view = QtWidgets.QGraphicsView(scene)
|
|
|
|
#view.show()
|
|
|
|
#view.show()
|
|
|
|