Browse Source

Some notes

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
dc664a0c3d
  1. 14
      clusterview/mode_handlers.py
  2. 20
      clusterview/opengl_widget.py

14
clusterview/mode_handlers.py

@ -9,13 +9,11 @@ def __handle_add_point(ctx, event):
`set_drawing_mode`, converts a point to our point
representation, and adds it to the list.
"""
print("[ADD] GOT POINT: ({}, {})".format(event.x(), event.y()))
set_drawing_event(event)
ctx.update()
# Convert to our point representation and add to list widget
# Point representation is a class called Point with coordinates,
# and attributes (currently always None)
# Also force widget to update - also everywhere below any time you
# modify the point list you need to force update the point list widget.
def __handle_edit_point(ctx, event):
# TODO: This function and delete definitely need to make sure they are
@ -29,7 +27,6 @@ def __handle_edit_point(ctx, event):
#
# Should move the associated point in the list to the new location if
# applicable.
print("[EDIT] GOT POINT: ({}, {})".format(event.x(), event.y()))
# Store old x, y from event
set_drawing_event(event)
@ -38,18 +35,15 @@ def __handle_edit_point(ctx, event):
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_event(event)
ctx.update()
# Find and move all points from the old list to their new locations
def __handle_delete_point(ctx, event):
print("[DELETE] GOT POINT: ({}, {})".format(event.x(), event.y()))
set_drawing_event(event)
ctx.update()
# Find the point from event and remove it from the list
# Simple dispatcher to make it easy to dispatch the right mode

20
clusterview/opengl_widget.py

@ -55,15 +55,8 @@ def set_drawing_context(ctx):
"""
global __current_context
print("CALLING SET DRAWING CONTEXT: {}".format(ctx))
__current_context = ctx
print("WIDTH OF OPENGL WINDOW: {}".format(__WIDTH))
print("HEIGHT OF OPENGL WINDOW: {}".format(__HEIGHT))
print("SETTING: {}".format(__current_context))
def set_drawing_mode(mode):
"""
@ -79,7 +72,6 @@ def set_drawing_mode(mode):
global __current_context
global __current_mode
print("SET DRAWING MODE CONTEXT: {}".format(__current_context))
if __current_context is None:
raise InvalidStateError("Drawing context must be set before setting " +
"drawing mode")
@ -87,12 +79,8 @@ def set_drawing_mode(mode):
if not isinstance(mode, Mode):
raise ValueError("Mode in set_drawing_mode must be of type Mode")
print("CALL FROM SET_DRAWING_MODE(MODE = {})".format(mode))
__current_mode = mode
print("SET LOCALS (CURRENT MODE: {})".format(__current_mode))
def set_drawing_event(event):
"""
@ -107,13 +95,9 @@ def set_drawing_event(event):
raise InvalidStateError("Drawing context must be set before setting " +
"drawing mode")
print("CALL FROM SET_DRAWING_EVENT(event = {})".format(event))
if event is not None:
__current_event = event
print("SET LOCALS (CURRENT EVENT: {})".format(__current_event))
def initialize_gl():
"""
@ -175,7 +159,6 @@ def __clamp_x(x):
@returns The clamped x coordinate.
"""
x_w = (x / (__WIDTH / 2.0) - 1.0)
print(x_w)
return x_w
@ -188,7 +171,6 @@ def __clamp_y(y):
@returns The clamped y coordinate.
"""
y_w = -1.0 * (y / (__HEIGHT / 2.0) - 1.0)
print(y_w)
return y_w
@ -215,8 +197,6 @@ def draw_points(x, y, color):
ct = COLOR_TO_RGBA[color]
print("DRAW POINT - DRAWING WITH COLOR {}".format(ct))
glViewport(0, 0, __WIDTH, __HEIGHT)
glPointSize(__POINT_SIZE)
glColor4f(ct[0], ct[1], ct[2], ct[3])

Loading…
Cancel
Save