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.mobilityplayer import MobilityPlayer
|
||||
from core.gui.dialogs.sessions import SessionsDialog
|
||||
from core.gui.graph import tags
|
||||
from core.gui.graph.edges import CanvasEdge
|
||||
from core.gui.graph.node import CanvasNode
|
||||
from core.gui.graph.shape import AnnotationData, Shape
|
||||
|
@ -389,9 +388,7 @@ class CoreClient:
|
|||
self.app.canvas.shapes[shape.id] = shape
|
||||
except ValueError:
|
||||
logging.exception("unknown shape: %s", shape_type)
|
||||
|
||||
for tag in tags.ABOVE_WALLPAPER_TAGS:
|
||||
self.app.canvas.tag_raise(tag)
|
||||
self.app.canvas.organize()
|
||||
|
||||
def create_new_session(self):
|
||||
"""
|
||||
|
|
|
@ -331,8 +331,6 @@ class CanvasEdge(Edge):
|
|||
dst_pos = self.canvas.coords(self.dst)
|
||||
self.move_dst(dst_pos)
|
||||
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)
|
||||
|
||||
def is_wireless(self) -> bool:
|
||||
|
|
|
@ -139,7 +139,7 @@ class CanvasGraph(tk.Canvas):
|
|||
self.show_ip6s.set(True)
|
||||
|
||||
# delete any existing drawn items
|
||||
for tag in tags.COMPONENT_TAGS:
|
||||
for tag in tags.RESET_TAGS:
|
||||
self.delete(tag)
|
||||
|
||||
# set the private variables to default value
|
||||
|
@ -591,6 +591,7 @@ class CanvasGraph(tk.Canvas):
|
|||
if self.mode == GraphMode.EDGE and is_node:
|
||||
pos = self.coords(selected)
|
||||
self.drawing_edge = CanvasEdge(self, selected, pos, pos)
|
||||
self.organize()
|
||||
|
||||
if self.mode == GraphMode.ANNOTATION:
|
||||
if is_marker(self.annotation_type):
|
||||
|
@ -866,10 +867,11 @@ class CanvasGraph(tk.Canvas):
|
|||
self.wallpaper_scaled()
|
||||
elif option == ScaleOption.TILED:
|
||||
logging.warning("tiled background not implemented yet")
|
||||
self.organize()
|
||||
|
||||
# raise items above wallpaper
|
||||
for component in tags.ABOVE_WALLPAPER_TAGS:
|
||||
self.tag_raise(component)
|
||||
def organize(self) -> None:
|
||||
for tag in tags.ORGANIZE_TAGS:
|
||||
self.tag_raise(tag)
|
||||
|
||||
def set_wallpaper(self, filename: str):
|
||||
logging.debug("setting wallpaper: %s", filename)
|
||||
|
|
|
@ -146,8 +146,7 @@ class Shape:
|
|||
self.canvas.coords(self.id, self.x1, self.y1, x1, y1)
|
||||
|
||||
def shape_complete(self, x: float, y: float):
|
||||
for component in tags.ABOVE_SHAPE:
|
||||
self.canvas.tag_raise(component)
|
||||
self.canvas.organize()
|
||||
s = ShapeDialog(self.app, self)
|
||||
s.show()
|
||||
|
||||
|
|
|
@ -11,19 +11,21 @@ NODE = "node"
|
|||
WALLPAPER = "wallpaper"
|
||||
SELECTION = "selectednodes"
|
||||
MARKER = "marker"
|
||||
ABOVE_WALLPAPER_TAGS = [
|
||||
ORGANIZE_TAGS = [
|
||||
WALLPAPER,
|
||||
GRIDLINE,
|
||||
SHAPE,
|
||||
SHAPE_TEXT,
|
||||
EDGE,
|
||||
LINK_LABEL,
|
||||
WIRELESS_EDGE,
|
||||
LINK_LABEL,
|
||||
ANTENNA,
|
||||
NODE,
|
||||
NODE_LABEL,
|
||||
SELECTION,
|
||||
MARKER,
|
||||
]
|
||||
ABOVE_SHAPE = [GRIDLINE, EDGE, LINK_LABEL, WIRELESS_EDGE, ANTENNA, NODE, NODE_LABEL]
|
||||
COMPONENT_TAGS = [
|
||||
RESET_TAGS = [
|
||||
EDGE,
|
||||
NODE,
|
||||
NODE_LABEL,
|
||||
|
|
Loading…
Reference in a new issue