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