pygui: created a singular func for ordering items on canvas by tags, updates so that drawing edges are behind nodes
This commit is contained in:
parent
50816b3b80
commit
91220078f1
5 changed files with 14 additions and 16 deletions
|
@ -20,7 +20,6 @@ from core.gui.dialogs.emaneinstall import EmaneInstallDialog
|
||||||
from core.gui.dialogs.error import ErrorDialog
|
from core.gui.dialogs.error import ErrorDialog
|
||||||
from core.gui.dialogs.mobilityplayer import MobilityPlayer
|
from core.gui.dialogs.mobilityplayer import MobilityPlayer
|
||||||
from core.gui.dialogs.sessions import SessionsDialog
|
from core.gui.dialogs.sessions import SessionsDialog
|
||||||
from core.gui.graph import tags
|
|
||||||
from core.gui.graph.edges import CanvasEdge
|
from core.gui.graph.edges import CanvasEdge
|
||||||
from core.gui.graph.node import CanvasNode
|
from core.gui.graph.node import CanvasNode
|
||||||
from core.gui.graph.shape import AnnotationData, Shape
|
from core.gui.graph.shape import AnnotationData, Shape
|
||||||
|
@ -389,9 +388,7 @@ class CoreClient:
|
||||||
self.app.canvas.shapes[shape.id] = shape
|
self.app.canvas.shapes[shape.id] = shape
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logging.exception("unknown shape: %s", shape_type)
|
logging.exception("unknown shape: %s", shape_type)
|
||||||
|
self.app.canvas.organize()
|
||||||
for tag in tags.ABOVE_WALLPAPER_TAGS:
|
|
||||||
self.app.canvas.tag_raise(tag)
|
|
||||||
|
|
||||||
def create_new_session(self):
|
def create_new_session(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -331,8 +331,6 @@ class CanvasEdge(Edge):
|
||||||
dst_pos = self.canvas.coords(self.dst)
|
dst_pos = self.canvas.coords(self.dst)
|
||||||
self.move_dst(dst_pos)
|
self.move_dst(dst_pos)
|
||||||
self.check_wireless()
|
self.check_wireless()
|
||||||
self.canvas.tag_raise(self.src)
|
|
||||||
self.canvas.tag_raise(self.dst)
|
|
||||||
logging.debug("Draw wired link from node %s to node %s", self.src, dst)
|
logging.debug("Draw wired link from node %s to node %s", self.src, dst)
|
||||||
|
|
||||||
def is_wireless(self) -> bool:
|
def is_wireless(self) -> bool:
|
||||||
|
|
|
@ -139,7 +139,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
self.show_ip6s.set(True)
|
self.show_ip6s.set(True)
|
||||||
|
|
||||||
# delete any existing drawn items
|
# delete any existing drawn items
|
||||||
for tag in tags.COMPONENT_TAGS:
|
for tag in tags.RESET_TAGS:
|
||||||
self.delete(tag)
|
self.delete(tag)
|
||||||
|
|
||||||
# set the private variables to default value
|
# set the private variables to default value
|
||||||
|
@ -591,6 +591,7 @@ class CanvasGraph(tk.Canvas):
|
||||||
if self.mode == GraphMode.EDGE and is_node:
|
if self.mode == GraphMode.EDGE and is_node:
|
||||||
pos = self.coords(selected)
|
pos = self.coords(selected)
|
||||||
self.drawing_edge = CanvasEdge(self, selected, pos, pos)
|
self.drawing_edge = CanvasEdge(self, selected, pos, pos)
|
||||||
|
self.organize()
|
||||||
|
|
||||||
if self.mode == GraphMode.ANNOTATION:
|
if self.mode == GraphMode.ANNOTATION:
|
||||||
if is_marker(self.annotation_type):
|
if is_marker(self.annotation_type):
|
||||||
|
@ -866,10 +867,11 @@ class CanvasGraph(tk.Canvas):
|
||||||
self.wallpaper_scaled()
|
self.wallpaper_scaled()
|
||||||
elif option == ScaleOption.TILED:
|
elif option == ScaleOption.TILED:
|
||||||
logging.warning("tiled background not implemented yet")
|
logging.warning("tiled background not implemented yet")
|
||||||
|
self.organize()
|
||||||
|
|
||||||
# raise items above wallpaper
|
def organize(self) -> None:
|
||||||
for component in tags.ABOVE_WALLPAPER_TAGS:
|
for tag in tags.ORGANIZE_TAGS:
|
||||||
self.tag_raise(component)
|
self.tag_raise(tag)
|
||||||
|
|
||||||
def set_wallpaper(self, filename: str):
|
def set_wallpaper(self, filename: str):
|
||||||
logging.debug("setting wallpaper: %s", filename)
|
logging.debug("setting wallpaper: %s", filename)
|
||||||
|
|
|
@ -146,8 +146,7 @@ class Shape:
|
||||||
self.canvas.coords(self.id, self.x1, self.y1, x1, y1)
|
self.canvas.coords(self.id, self.x1, self.y1, x1, y1)
|
||||||
|
|
||||||
def shape_complete(self, x: float, y: float):
|
def shape_complete(self, x: float, y: float):
|
||||||
for component in tags.ABOVE_SHAPE:
|
self.canvas.organize()
|
||||||
self.canvas.tag_raise(component)
|
|
||||||
s = ShapeDialog(self.app, self)
|
s = ShapeDialog(self.app, self)
|
||||||
s.show()
|
s.show()
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,21 @@ NODE = "node"
|
||||||
WALLPAPER = "wallpaper"
|
WALLPAPER = "wallpaper"
|
||||||
SELECTION = "selectednodes"
|
SELECTION = "selectednodes"
|
||||||
MARKER = "marker"
|
MARKER = "marker"
|
||||||
ABOVE_WALLPAPER_TAGS = [
|
ORGANIZE_TAGS = [
|
||||||
|
WALLPAPER,
|
||||||
GRIDLINE,
|
GRIDLINE,
|
||||||
SHAPE,
|
SHAPE,
|
||||||
SHAPE_TEXT,
|
SHAPE_TEXT,
|
||||||
EDGE,
|
EDGE,
|
||||||
LINK_LABEL,
|
|
||||||
WIRELESS_EDGE,
|
WIRELESS_EDGE,
|
||||||
|
LINK_LABEL,
|
||||||
ANTENNA,
|
ANTENNA,
|
||||||
NODE,
|
NODE,
|
||||||
NODE_LABEL,
|
NODE_LABEL,
|
||||||
|
SELECTION,
|
||||||
|
MARKER,
|
||||||
]
|
]
|
||||||
ABOVE_SHAPE = [GRIDLINE, EDGE, LINK_LABEL, WIRELESS_EDGE, ANTENNA, NODE, NODE_LABEL]
|
RESET_TAGS = [
|
||||||
COMPONENT_TAGS = [
|
|
||||||
EDGE,
|
EDGE,
|
||||||
NODE,
|
NODE,
|
||||||
NODE_LABEL,
|
NODE_LABEL,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue