Add PoC visualisation [WIP]
It almost works… meaning it manages to segfault.older_libs
parent
b49b6a7ad9
commit
a759cdfd93
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Get topologies
|
||||
|
||||
import sys
|
||||
from birdvisu import maps_new
|
||||
from birdvisu.maps_new import providers
|
||||
|
||||
ref_topo_file = 'reference.ospf'
|
||||
if len(sys.argv) > 1:
|
||||
ref_topo_file = sys.argv[1]
|
||||
|
||||
with open(ref_topo_file) as ref_file:
|
||||
ref_topo = providers.OspfFileTopologyProvider(ref_file).get_topology()
|
||||
|
||||
cur_topo = providers.RunningBirdTopologyProvider().get_topology()
|
||||
|
||||
# Combine topologies
|
||||
|
||||
combiner = maps_new.TopologyCombiner()
|
||||
# NOTE: the following string literals convey meaning for annotators, so they
|
||||
# should not be changed carelessly.
|
||||
combiner.add_topology('reference', ref_topo)
|
||||
combiner.add_topology('actual', cur_topo)
|
||||
|
||||
final_topo = combiner.get_complete_topology()
|
||||
|
||||
# Annotate it
|
||||
|
||||
from birdvisu.visualisation import annotators
|
||||
|
||||
annotated_topology = maps_new.annotate_topology(final_topo,
|
||||
# A semi-canonical set of annotators:
|
||||
[
|
||||
annotators.difference_annotator,
|
||||
annotators.extract_positions,
|
||||
annotators.random_position,
|
||||
annotators.assign_brushes,
|
||||
annotators.create_qgritems,
|
||||
]
|
||||
)
|
||||
|
||||
# Render the widget
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
app = QtWidgets.QApplication([])
|
||||
scene = QtWidgets.QGraphicsScene()
|
||||
|
||||
for tagsrc in [
|
||||
annotated_topology.router_annotations.values(),
|
||||
annotated_topology.network_annotations.values(),
|
||||
annotated_topology.link_annotations.values(),
|
||||
]:
|
||||
for taglist in tagsrc:
|
||||
assert len(taglist) > 0
|
||||
assert isinstance(taglist[-1], QtWidgets.QGraphicsItem)
|
||||
scene.addItem(taglist[-1])
|
||||
|
||||
view = QtWidgets.QGraphicsView(scene)
|
||||
view.show()
|
||||
|
||||
app.exec()
|
Loading…
Reference in New Issue