Support add/delete pattern & curve
This commit is contained in:
@@ -43,11 +43,29 @@ def set_curve_cache(name: str, cs: ChangeSet) -> SqlChangeSet:
|
||||
f_x, f_y = xy['x'], xy['y']
|
||||
undo_sql += f"\ninsert into curves (id, x, y) values ({f_id}, {f_x}, {f_y});"
|
||||
|
||||
redo_cs = g_update_prefix | { 'type': 'curve' } | new
|
||||
undo_cs = g_update_prefix | { 'type': 'curve' } | old
|
||||
redo_cs = { 'type': 'curve' } | new
|
||||
undo_cs = { 'type': 'curve' } | old
|
||||
|
||||
return SqlChangeSet(redo_sql, undo_sql, redo_cs, undo_cs)
|
||||
|
||||
|
||||
def set_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return execute_command(name, set_curve_cache(name, cs))
|
||||
result = set_curve_cache(name, cs)
|
||||
result.redo_cs |= g_update_prefix
|
||||
result.undo_cs |= g_update_prefix
|
||||
return execute_command(name, result)
|
||||
|
||||
|
||||
def add_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
result = set_curve_cache(name, cs)
|
||||
result.redo_cs |= g_add_prefix
|
||||
result.undo_cs |= g_delete_prefix
|
||||
return execute_command(name, result)
|
||||
|
||||
|
||||
def delete_curve(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
cs.operations[0]['coords'] = []
|
||||
result = set_curve_cache(name, cs)
|
||||
result.redo_cs |= g_delete_prefix
|
||||
result.undo_cs |= g_add_prefix
|
||||
return execute_command(name, result)
|
||||
|
||||
Reference in New Issue
Block a user