|
|
@ -87,10 +87,13 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
def create_menus(self):
|
|
|
|
def create_menus(self):
|
|
|
|
print('Creating menus…')
|
|
|
|
print('Creating menus…')
|
|
|
|
self.menubar = self.menuBar()
|
|
|
|
self.menubar = self.menuBar()
|
|
|
|
mode_menu = self.menubar.addMenu('&Mode')
|
|
|
|
mode_menu = self.menubar.addMenu('&Highlight')
|
|
|
|
short_path_act = QtGui.QAction("Sh. path &DAG", self)
|
|
|
|
edge_weight_act = QtGui.QAction("Edge costs", self)
|
|
|
|
short_path_act.triggered.connect(self.shortestPathMode)
|
|
|
|
edge_weight_act.triggered.connect(self.edgeWeightMode)
|
|
|
|
mode_menu.addAction(short_path_act)
|
|
|
|
mode_menu.addAction(edge_weight_act)
|
|
|
|
|
|
|
|
topodiff_act = QtGui.QAction("Topology differences", self)
|
|
|
|
|
|
|
|
topodiff_act.triggered.connect(self.topoDiffMode)
|
|
|
|
|
|
|
|
mode_menu.addAction(topodiff_act)
|
|
|
|
|
|
|
|
|
|
|
|
# Hack!
|
|
|
|
# Hack!
|
|
|
|
autoload_act = QtGui.QAction("&Load automatically", self)
|
|
|
|
autoload_act = QtGui.QAction("&Load automatically", self)
|
|
|
@ -149,7 +152,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
|
def load_positions(self):
|
|
|
|
def load_positions(self):
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open vertex positions', '.', 'OSPF files(*.visu);;All files(*)')[0]
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open vertex positions', '.', 'OSPF visualisation files (*.visu);;All files(*)')[0]
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
self.positions_from_file(filename)
|
|
|
|
self.positions_from_file(filename)
|
|
|
|
|
|
|
|
|
|
|
@ -190,15 +193,18 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
if oe.cost == 0 or oe.cost > e.cost:
|
|
|
|
if oe.cost == 0 or oe.cost > e.cost:
|
|
|
|
for_edge[(a,b)] = (e, sty)
|
|
|
|
for_edge[(a,b)] = (e, sty)
|
|
|
|
# Actually apply the style:
|
|
|
|
# Actually apply the style:
|
|
|
|
for v, sty in for_vertex.items():
|
|
|
|
for v in self.visu_graph[0].keys():
|
|
|
|
|
|
|
|
sty = for_vertex.get(v, {})
|
|
|
|
self.graphicsitems[v].apply_style(sty)
|
|
|
|
self.graphicsitems[v].apply_style(sty)
|
|
|
|
for e, tup in for_edge.items():
|
|
|
|
for e in self.visu_graph[1]:
|
|
|
|
self.graphicsitems[e].apply_style(tup[1])
|
|
|
|
sty = for_edge[e][1] if e in for_edge else {}
|
|
|
|
|
|
|
|
self.graphicsitems[e].apply_style(sty)
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
|
def dagMode(self):
|
|
|
|
def dagMode(self, vtxid):
|
|
|
|
self.mode = self.Mode.ShortestPathDAG
|
|
|
|
self.mode = self.Mode.ShortestPathDAG
|
|
|
|
self.highlighter = HighlightSPDAG(...)
|
|
|
|
self.highlighter = HighlightSPDAG(vtxid)
|
|
|
|
|
|
|
|
self.start_vertex = vtxid
|
|
|
|
self.apply_styles()
|
|
|
|
self.apply_styles()
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
@ -214,13 +220,15 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
self.apply_styles()
|
|
|
|
self.apply_styles()
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
|
def shortestPathMode(self):
|
|
|
|
def shortestPathMode(self, vtxid):
|
|
|
|
self.mode = self.Mode.ShortestPath
|
|
|
|
self.mode = self.Mode.ShortestPath
|
|
|
|
...
|
|
|
|
self.end_vertex = vtxid
|
|
|
|
|
|
|
|
self.highlighter = HighlightShortestPath((self.start_vertex, self.end_vertex))
|
|
|
|
|
|
|
|
self.apply_styles()
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
|
def openRefTopology(self):
|
|
|
|
def openRefTopology(self):
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open reference topology', '.', 'OSPF files(*.ospf);;All files(*)')[0]
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open reference topology', '.', 'OSPF files (*.ospf);;All files(*)')[0]
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
self.ref_topo_provider = OspfFileTopologyProvider(filename)
|
|
|
|
self.ref_topo_provider = OspfFileTopologyProvider(filename)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -247,7 +255,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|
|
|
|
|
|
|
|
|
|
|
@Slot()
|
|
|
|
@Slot()
|
|
|
|
def curTopologyFromFile(self):
|
|
|
|
def curTopologyFromFile(self):
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open current topology', '.', 'OSPF files(*.ospf);;All files(*)')[0]
|
|
|
|
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Open current topology', '.', 'OSPF files (*.ospf);;All files(*)')[0]
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
if filename == '': return # Do nothing
|
|
|
|
self.cur_topo_provider = OspfFileTopologyProvider(filename)
|
|
|
|
self.cur_topo_provider = OspfFileTopologyProvider(filename)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|