Add an option to use empty topology for reference

topo-mov
LEdoian 1 year ago
parent b591adf5ff
commit 3987ffa44a

@ -20,6 +20,15 @@ class TopologyProvider(ABC):
@abstractmethod
def get_topology(self) -> TopologyV3: ...
class DummyTopologyProvider(TopologyProvider):
"""Returns an empty topology.
Useful when we do not want to compare anything."""
def get_topology(self):
topo = TopologyV3()
topo.freeze()
return topo
class OspfFileParseError(Exception): pass
class OspfFileTopologyParser:

@ -11,7 +11,7 @@ from birdvisu.annotations import AnnotatedTopology, AnnotatorID
from birdvisu.annotations.analysis import TopologyDifference, ShortestPathTree
from birdvisu.annotations.layout import PlaceVerticesFromFile, PlaceUnplacedVertices, EdgeWidthByCost, HighlightTopoDiff, HighlightSPDAG, HighlightShortestPath
from birdvisu.ospfsock import BirdSocketConnection
from birdvisu.providers import BirdSocketTopologyProvider, OspfFileTopologyProvider, OspfFileParseError
from birdvisu.providers import BirdSocketTopologyProvider, OspfFileTopologyProvider, OspfFileParseError, DummyTopologyProvider
from birdvisu.topo_v3 import TopologyV3, VertexID
from birdvisu.graphics_items import RouterGraphicsItem, NetworkGraphicsItem, EdgeGraphicsItem
@ -106,9 +106,13 @@ class MainWindow(QtWidgets.QMainWindow):
self.menubar.addAction(autoload_act)
topo_menu = self.menubar.addMenu('&Topology')
ref_menu = topo_menu.addMenu("&Reference")
open_ref_act = QtGui.QAction("&Load reference", self)
open_ref_act.triggered.connect(self.openRefTopology)
topo_menu.addAction(open_ref_act)
ref_menu.addAction(open_ref_act)
no_ref_act = QtGui.QAction("&No reference topology", self)
no_ref_act.triggered.connect(self.noRefTopology)
ref_menu.addAction(no_ref_act)
cur_topo_menu = topo_menu.addMenu("Load &current")
running_bird_act = QtGui.QAction('&BIRD', self)
@ -231,6 +235,11 @@ class MainWindow(QtWidgets.QMainWindow):
self.highlighter = HighlightShortestPath((self.start_vertex, self.end_vertex))
self.apply_styles()
@Slot()
def noRefTopology(self):
self.ref_topo_provider = DummyTopologyProvider()
self.refreshTopologies()
@Slot()
def openRefTopology(self):
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open reference topology', '.', 'OSPF files (*.ospf);;All files(*)')[0]

Loading…
Cancel
Save