From aad68fb2021dacfd1b3e6efef7a0c9fa547f85a9 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Wed, 7 Aug 2019 22:35:57 -0700 Subject: [PATCH] Some drawing mode notes --- clusterview/mode.py | 17 ++++++++++++++--- clusterview/opengl_widget.py | 13 +++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/clusterview/mode.py b/clusterview/mode.py index b0ee528..5b361b9 100644 --- a/clusterview/mode.py +++ b/clusterview/mode.py @@ -23,11 +23,12 @@ def __handle_add_point(ctx, event): representation, and adds it to the list. """ print("[ADD] GOT POINT: ({}, {})".format(event.x(), event.y())) + + set_drawing_mode(Mode.ADD, event) + # Convert to our point representation and add to list widget # Point representation is a class called Point with coordinates, # and attributes (currently always None) - # - set_drawing_mode(Mode.ADD, event) def __handle_edit_point(ctx, event): # TODO: This function and delete definitely need to make sure they are @@ -43,15 +44,25 @@ def __handle_edit_point(ctx, event): # applicable. print("[EDIT] GOT POINT: ({}, {})".format(event.x(), event.y())) + # Store old x, y from event + set_drawing_mode(Mode.DELETE, event) + # after this remove the point from the list def __handle_move_points(ctx, event): # TODO: Should move the associated points in the list to the new location. print("[MOVE] Pressed - NOTE NEED DRAG EVENT") + # Store list of old points that are captured + + set_drawing_mode(Mode.MOVE, event) + + # Find and move all points from the old list to their new locations def __handle_delete_point(ctx, event): - # TODO: Needs to also delete the point from the list. print("[DELETE] GOT POINT: ({}, {})".format(event.x(), event.y())) + set_drawing_mode(Mode.DELETE, event) + + # Find the point from event and remove it from the list # Simple dispatcher to make it easy to dispatch the right mode # function when the OpenGL window is clicked. diff --git a/clusterview/opengl_widget.py b/clusterview/opengl_widget.py index f4f2943..9e02be6 100644 --- a/clusterview/opengl_widget.py +++ b/clusterview/opengl_widget.py @@ -115,3 +115,16 @@ def draw_point(x, y, color): glColor4f(ct[0], ct[1], ct[2], ct[3]) glVertex3f(x, y, 0.0) # Z is currently fixed to 0 glEnd() + + +def delete_point(x, y): + """ + Deletes a point. + + The list deletion happens in the clusterview.mode module. This + function just overwrites the point color with the background. + + @param x The x-coordinate. + @param y The y-coordinate. + """ + raise NotImplementedError("delete_point not implemented.")