|
|
|
from enum import Enum
|
|
|
|
|
|
|
|
class Mode(Enum):
|
|
|
|
"""
|
|
|
|
Class to make it easier to figure out what mode
|
|
|
|
we are operating in when the OpenGL window is
|
|
|
|
clicked.
|
|
|
|
"""
|
|
|
|
OFF = 0
|
|
|
|
ADD = 1
|
|
|
|
EDIT = 2
|
|
|
|
MOVE = 3
|
|
|
|
DELETE = 4
|
|
|
|
|
|
|
|
def __handle_add_point(ctx, event):
|
|
|
|
"""
|
|
|
|
TODO: These functions should all take a context to
|
|
|
|
the openGL widget that will perform the
|
|
|
|
function.
|
|
|
|
"""
|
|
|
|
print("[ADD] GOT POINT: ({}, {})".format(event.x(), event.y()))
|
|
|
|
|
|
|
|
def __handle_edit_point(ctx, event):
|
|
|
|
# TODO: This function and delete definitely need to make sure they are
|
|
|
|
# on a point we have.
|
|
|
|
#
|
|
|
|
# Since points are unique consider a hashmap of points to make O(1)
|
|
|
|
# lookups for addition and deletion. This list can be maintained here
|
|
|
|
# in this module. It should be a dictionary - from point to
|
|
|
|
# attributes in the case of algorithms that require points to have
|
|
|
|
# weights or something.
|
|
|
|
#
|
|
|
|
print("[EDIT] GOT POINT: ({}, {})".format(event.x(), event.y()))
|
|
|
|
|
|
|
|
def __handle_move_points(ctx, event):
|
|
|
|
print("[MOVE] Pressed - NOTE NEED DRAG EVENT")
|
|
|
|
|
|
|
|
def __handle_delete_point(ctx, event):
|
|
|
|
print("[DELETE] GOT POINT: ({}, {})".format(event.x(), event.y()))
|
|
|
|
|
|
|
|
|
|
|
|
# Simple dispatcher to make it easy to dispatch the right mode
|
|
|
|
# function when the OpenGL window is clicked.
|
|
|
|
MODE_MAP = {
|
|
|
|
Mode.OFF: lambda: None,
|
|
|
|
Mode.ADD: __handle_add_point,
|
|
|
|
Mode.EDIT: __handle_edit_point,
|
|
|
|
Mode.MOVE: __handle_move_points,
|
|
|
|
Mode.DELETE: __handle_delete_point
|
|
|
|
}
|