|
|
|
@ -48,6 +48,9 @@ __left_click_flag = __ClickFlag.NONE
|
|
|
|
|
# Variable to track the mouse state during selection movement |
|
|
|
|
__last_mouse_pos = None |
|
|
|
|
|
|
|
|
|
# Used to implement mouse dragging when clicked |
|
|
|
|
__left_click_down = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def refresh_point_list(ctx): |
|
|
|
|
""" |
|
|
|
@ -173,6 +176,7 @@ def __handle_move_points(ctx, event):
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
global __left_click_flag |
|
|
|
|
global __left_mouse_down |
|
|
|
|
global __last_mouse_pos |
|
|
|
|
|
|
|
|
|
set_drawing_event(event) |
|
|
|
@ -182,28 +186,40 @@ def __handle_move_points(ctx, event):
|
|
|
|
|
# Necessary to capture keyboard events |
|
|
|
|
ctx.opengl_widget.setFocusPolicy(Qt.StrongFocus) |
|
|
|
|
|
|
|
|
|
# If we release the mouse, we want to quickly alert drag mode. |
|
|
|
|
if (event.button() == Qt.LeftButton and |
|
|
|
|
event.type() == QEvent.MouseButtonRelease): |
|
|
|
|
|
|
|
|
|
__left_mouse_down = False |
|
|
|
|
|
|
|
|
|
# This if statement block is used to set the bounding box for |
|
|
|
|
# drawing and call the selection procedure. |
|
|
|
|
if (event.button() == Qt.LeftButton and |
|
|
|
|
event.type() == QEvent.MouseButtonPress): |
|
|
|
|
|
|
|
|
|
__left_mouse_down = True |
|
|
|
|
|
|
|
|
|
if __left_click_flag is __ClickFlag.NONE: |
|
|
|
|
__left_click_flag = __ClickFlag.SELECTION_BOX |
|
|
|
|
set_move_bb_top_left(event.x(), event.y()) |
|
|
|
|
|
|
|
|
|
elif __left_click_flag is __ClickFlag.SELECTION_BOX: |
|
|
|
|
|
|
|
|
|
elif (__left_click_flag is __ClickFlag.SELECTION_BOX |
|
|
|
|
and __left_mouse_down): |
|
|
|
|
# We are now in the click-and-hold to signal move |
|
|
|
|
# tracking and translation |
|
|
|
|
__left_click_flag = __ClickFlag.SELECTION_MOVE |
|
|
|
|
__last_mouse_pos = (event.x(), event.y()) |
|
|
|
|
|
|
|
|
|
elif (__left_click_flag is __ClickFlag.SELECTION_BOX |
|
|
|
|
# Post-selection handlers |
|
|
|
|
if (__left_click_flag is __ClickFlag.SELECTION_BOX |
|
|
|
|
and event.type() == QEvent.MouseMove): |
|
|
|
|
|
|
|
|
|
set_move_bb_bottom_right(event.x(), event.y()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif (__left_click_flag is __ClickFlag.SELECTION_MOVE |
|
|
|
|
and __last_mouse_pos is not None |
|
|
|
|
and __left_mouse_down |
|
|
|
|
and event.type() == QEvent.MouseMove): |
|
|
|
|
|
|
|
|
|
dx = abs(__last_mouse_pos[0] - event.x()) |
|
|
|
|