layout module¶
Module ‘layout’ provides the transformation between data and its visualization.
-
class
layout.
Layout
(scene)¶ Bases:
object
Provides graphical objects and their positioning on the scene.
-
clear
()¶ Clear the layout.
-
create_graphical_element
(net_element)¶ Create a graphical element for the given network element.
Parameters: net_element (interfaces.Datapath or interfaces.Node) – Network element to create a graphical counterpart for. Returns: - gui.canvas.Datapath – In case the input network element was a datapath.
- gui.canvas.Node – In case the input network element was a node.
-
create_graphical_link
(net_link)¶ Create a graphical link for the given network link.
Parameters: net_link (interfaces.Link) – Network link to create a graphical counterpart for. Returns: Return type: gui.canvas.Link
-
graph_create
(net_elements, net_links)¶ Create a graph structure from the given network data.
Parameters: - net_elements (list of interfaces.Datapath or interfaces.Node) – Datapaths and nodes connected in the network.
- net_links (list of interfaces.Link) – Links connected in the network.
-
graph_renew
()¶ Generate new positions for elements present in the graph.
-
move_element
(grph_element, pos)¶ Save the new position for the given graphical element.
Parameters: - grph_element (gui.canvas.Datapath or gui.canvas.Node) – Graphical element that was moved.
- pos (PyQt5.QtCore.QPointF) – New position of the graphical element.
-
remove_graphical_element
(net_element)¶ Remove the given network element from translations.
Parameters: net_element (interfaces.Datapath or interfaces.Node) – Network element to remove. Returns: - gui.canvas.Datapath – In case the network element is a datapath.
- gui.canvas.Node – In case the network element is a node.
- None – In case the network element is not in the dictionary.
-
remove_graphical_link
(net_link)¶ Remove the given network link from translations.
Parameters: net_link (interfaces.Link) – Network link to remove. Returns: - gui.canvas.Link
- None – In case the network link is not in the dictionary.
-
tree
(net_treetop)¶ Transform the visualization into a tree-like structure.
Parameters: net_treetop (list of interfaces.Datapath) – Datapaths from the top level of the network hierarchy.
-
tree_draw
(root, start_pos)¶ Draw the tree-like structure using a depth-first search.
Parameters: - root (TreeDatapath or TreeNode) – Root element for the search.
- start_pos (Coords) – Initial coordinates for the element.
Returns: End coordinates of the sub-tree.
Return type:
-
update
(add, remove, connect, disconnect)¶ Update the visualization.
Parameters: - add (list of interfaces.Datpaath or interfaces.Node) – Network devices that have been added to the network.
- remove (list of interfaces.Datapath or interfaces.Node) – Network devices that have been removed from the network.
- connect (list of interfaces.Link) – Network links that have been connected to the network.
- disconnect (list of interfaces.Link) – Network links that have been disconnected from the network.
-
update_stats
()¶ Update link utilization statistics.
-
-
class
layout.
Translation
¶ Bases:
object
Keeps relations between network elements and graphical elements.
-
clear
()¶ Sets all instance variables to empty dictionaries.
-
-
class
layout.
TreeDatapath
(grph_element)¶ Bases:
object
Tree representation for a datapath.
-
class
layout.
TreeNode
(grph_element)¶ Bases:
object
Tree representation for a node.