|
|
@ -6,7 +6,7 @@ from .mode import Mode |
|
|
|
from .opengl_widget import (get_bb_bottom_right, get_bb_top_left, |
|
|
|
from .opengl_widget import (get_bb_bottom_right, get_bb_top_left, |
|
|
|
set_current_points, set_drawing_event, |
|
|
|
set_current_points, set_drawing_event, |
|
|
|
set_move_bb_top_left, set_move_bb_bottom_right, |
|
|
|
set_move_bb_top_left, set_move_bb_bottom_right, |
|
|
|
reset_move_bbs) |
|
|
|
reset_move_bbs, viewport_height, viewport_width) |
|
|
|
from .points import PointSet |
|
|
|
from .points import PointSet |
|
|
|
|
|
|
|
|
|
|
|
class __ClickFlag: |
|
|
|
class __ClickFlag: |
|
|
@ -33,7 +33,7 @@ __POINT_SIZE = 8 |
|
|
|
|
|
|
|
|
|
|
|
# There are a lot of module-global variables being used because of the |
|
|
|
# There are a lot of module-global variables being used because of the |
|
|
|
# nature of state management in OpenGL. |
|
|
|
# nature of state management in OpenGL. |
|
|
|
__point_set = PointSet(__POINT_SIZE) |
|
|
|
__point_set = PointSet(__POINT_SIZE, viewport_height(), viewport_width()) |
|
|
|
|
|
|
|
|
|
|
|
# Module level flag for left click events (used to detect a left |
|
|
|
# Module level flag for left click events (used to detect a left |
|
|
|
# click hold drag) |
|
|
|
# click hold drag) |
|
|
@ -57,7 +57,6 @@ def __refresh_point_list(ctx): |
|
|
|
for p in __point_set.points: |
|
|
|
for p in __point_set.points: |
|
|
|
ctx.point_list_widget.addItem("({}, {})".format(p.x, p.y)) |
|
|
|
ctx.point_list_widget.addItem("({}, {})".format(p.x, p.y)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __handle_add_point(ctx, event): |
|
|
|
def __handle_add_point(ctx, event): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Event handler for the add point mode. |
|
|
|
Event handler for the add point mode. |
|
|
@ -89,7 +88,6 @@ def __handle_add_point(ctx, event): |
|
|
|
ctx.opengl_widget.update() |
|
|
|
ctx.opengl_widget.update() |
|
|
|
ctx.point_list_widget.update() |
|
|
|
ctx.point_list_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __handle_edit_point(ctx, event): |
|
|
|
def __handle_edit_point(ctx, event): |
|
|
|
# TODO: This function and delete definitely need to make sure they are |
|
|
|
# TODO: This function and delete definitely need to make sure they are |
|
|
|
# on a point we have. |
|
|
|
# on a point we have. |
|
|
@ -111,7 +109,6 @@ def __handle_edit_point(ctx, event): |
|
|
|
ctx.update() |
|
|
|
ctx.update() |
|
|
|
# after this remove the point from the list |
|
|
|
# after this remove the point from the list |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ogl_keypress_handler(ctx, event): |
|
|
|
def ogl_keypress_handler(ctx, event): |
|
|
|
""" |
|
|
|
""" |
|
|
|
A keypress handler attached to the OpenGL widget. |
|
|
|
A keypress handler attached to the OpenGL widget. |
|
|
@ -142,7 +139,6 @@ def ogl_keypress_handler(ctx, event): |
|
|
|
|
|
|
|
|
|
|
|
ctx.opengl_widget.update() |
|
|
|
ctx.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __handle_move_points(ctx, event): |
|
|
|
def __handle_move_points(ctx, event): |
|
|
|
""" |
|
|
|
""" |
|
|
|
A relatively complicated state machine that handles the process of |
|
|
|
A relatively complicated state machine that handles the process of |
|
|
@ -195,21 +191,21 @@ def __handle_move_points(ctx, event): |
|
|
|
# If we used the deltas directly the points would |
|
|
|
# If we used the deltas directly the points would |
|
|
|
# fly off screen quickly as we got farther from our |
|
|
|
# fly off screen quickly as we got farther from our |
|
|
|
# start. |
|
|
|
# start. |
|
|
|
|
|
|
|
try: |
|
|
|
# TODO: THIS IS NUTS RIGHT NOW |
|
|
|
if dx > 0: |
|
|
|
# WE SHOULD NOT ALLOW ANY POINT TO EXCEED |
|
|
|
p.move(1, 0) |
|
|
|
# THE MAXIMUM SIZE OF THE SCREEN. |
|
|
|
if dx < 0: |
|
|
|
|
|
|
|
p.move(-1, 0) |
|
|
|
if dx > 0 and dy > 0: |
|
|
|
if dy > 0: |
|
|
|
p.move(10, 10) |
|
|
|
p.move(0, 1) |
|
|
|
elif dx > 0 and dy == 0: |
|
|
|
if dy < 0: |
|
|
|
p.move(10, 0) |
|
|
|
p.move(0, -1) |
|
|
|
elif dx < 0 and dy == 0: |
|
|
|
|
|
|
|
p.move(-10, 0) |
|
|
|
except ExceededWindowBoundsError: |
|
|
|
elif dx == 0 and dy > 0: |
|
|
|
# This point has indicated a move would exceed |
|
|
|
p.move(0, 10) |
|
|
|
# it's bounds, so we'll just go to the next |
|
|
|
elif dx == 0 and dy < 0: |
|
|
|
# point. |
|
|
|
p.move(0, -10) |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif (__left_click_flag is not __ClickFlag.NONE and |
|
|
|
elif (__left_click_flag is not __ClickFlag.NONE and |
|
|
@ -222,8 +218,6 @@ def __handle_move_points(ctx, event): |
|
|
|
# Satisfy the post condition by resetting the bounding box |
|
|
|
# Satisfy the post condition by resetting the bounding box |
|
|
|
reset_move_bbs() |
|
|
|
reset_move_bbs() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.point_list_widget.update() |
|
|
|
ctx.point_list_widget.update() |
|
|
|
ctx.opengl_widget.update() |
|
|
|
ctx.opengl_widget.update() |
|
|
|
|
|
|
|
|
|
|
|