start on shape drawing
This commit is contained in:
parent
8278641cf4
commit
f3ca5682ac
3 changed files with 28 additions and 1 deletions
|
@ -17,6 +17,7 @@ from coretk.images import Images
|
||||||
from coretk.linkinfo import LinkInfo, Throughput
|
from coretk.linkinfo import LinkInfo, Throughput
|
||||||
from coretk.nodedelete import CanvasComponentManagement
|
from coretk.nodedelete import CanvasComponentManagement
|
||||||
from coretk.nodeutils import NodeUtils
|
from coretk.nodeutils import NodeUtils
|
||||||
|
from coretk.shape import Shape
|
||||||
from coretk.wirelessconnection import WirelessConnection
|
from coretk.wirelessconnection import WirelessConnection
|
||||||
|
|
||||||
NODE_TEXT_OFFSET = 5
|
NODE_TEXT_OFFSET = 5
|
||||||
|
@ -27,7 +28,8 @@ class GraphMode(enum.Enum):
|
||||||
EDGE = 1
|
EDGE = 1
|
||||||
PICKNODE = 2
|
PICKNODE = 2
|
||||||
NODE = 3
|
NODE = 3
|
||||||
OTHER = 4
|
ANNOTATION = 4
|
||||||
|
OTHER = 5
|
||||||
|
|
||||||
|
|
||||||
class ScaleOption(enum.Enum):
|
class ScaleOption(enum.Enum):
|
||||||
|
@ -38,12 +40,18 @@ class ScaleOption(enum.Enum):
|
||||||
TILED = 4
|
TILED = 4
|
||||||
|
|
||||||
|
|
||||||
|
class ShapeType(enum.Enum):
|
||||||
|
OVAL = 0
|
||||||
|
RECTANGLE = 1
|
||||||
|
|
||||||
|
|
||||||
class CanvasGraph(tk.Canvas):
|
class CanvasGraph(tk.Canvas):
|
||||||
def __init__(self, master, core, width, height, cnf=None, **kwargs):
|
def __init__(self, master, core, width, height, cnf=None, **kwargs):
|
||||||
if cnf is None:
|
if cnf is None:
|
||||||
cnf = {}
|
cnf = {}
|
||||||
kwargs["highlightthickness"] = 0
|
kwargs["highlightthickness"] = 0
|
||||||
super().__init__(master, cnf, **kwargs)
|
super().__init__(master, cnf, **kwargs)
|
||||||
|
self.app = master
|
||||||
self.mode = GraphMode.SELECT
|
self.mode = GraphMode.SELECT
|
||||||
self.selected = None
|
self.selected = None
|
||||||
self.node_draw = None
|
self.node_draw = None
|
||||||
|
@ -317,6 +325,9 @@ class CanvasGraph(tk.Canvas):
|
||||||
if self.mode == GraphMode.EDGE and is_node:
|
if self.mode == GraphMode.EDGE and is_node:
|
||||||
x, y = self.coords(selected)
|
x, y = self.coords(selected)
|
||||||
self.drawing_edge = CanvasEdge(x, y, x, y, selected, self)
|
self.drawing_edge = CanvasEdge(x, y, x, y, selected, self)
|
||||||
|
if self.mode == GraphMode.ANNOTATION:
|
||||||
|
shape = Shape(self.app, self, event.x, event.y)
|
||||||
|
print(shape)
|
||||||
|
|
||||||
def click_motion(self, event):
|
def click_motion(self, event):
|
||||||
"""
|
"""
|
||||||
|
|
15
coretk/coretk/shape.py
Normal file
15
coretk/coretk/shape.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
"""
|
||||||
|
class for shapes
|
||||||
|
"""
|
||||||
|
# from coretk.images import ImageEnum, Images
|
||||||
|
|
||||||
|
|
||||||
|
class Shape:
|
||||||
|
def __init__(self, app, canvas, topleft_x, topleft_y):
|
||||||
|
self.app = app
|
||||||
|
self.canvas = canvas
|
||||||
|
self.x0 = topleft_x
|
||||||
|
self.y0 = topleft_y
|
||||||
|
self.id = self.canvas.create_oval(
|
||||||
|
topleft_x, topleft_y, topleft_x + 30, topleft_y + 30
|
||||||
|
)
|
|
@ -367,6 +367,7 @@ class Toolbar(ttk.Frame):
|
||||||
self.hide_pickers()
|
self.hide_pickers()
|
||||||
self.annotation_button.configure(image=image)
|
self.annotation_button.configure(image=image)
|
||||||
self.annotation_button.image = image
|
self.annotation_button.image = image
|
||||||
|
self.app.canvas.mode = GraphMode.ANNOTATION
|
||||||
|
|
||||||
def click_run_button(self):
|
def click_run_button(self):
|
||||||
logging.debug("Click on RUN button")
|
logging.debug("Click on RUN button")
|
||||||
|
|
Loading…
Add table
Reference in a new issue