joshheinrichs/delaunay-triangulation

Undo/Redo Actions

Closed this issue · 3 comments

Would be nice to be able to undo/redo various actions. Since pretty much every action is done via vertexes, it wouldn't be too crazy to store a history of changes (added vertex i, removed vertex j, moved vertexes k, j l, etc.). This will probably require reworking how tools interact with the model a bit (adding some sort of action enum?).

The simplest way to do this currently would be to store the vertex state in JSON for every action that's taken, and when an undo or redo action is performed, simply load the previous/next JSON, which is stored in some sort of undo/redo string stack. Not the most efficient solution, but would be insanely easy to implement by comparison.

Added preliminary functionality, although it is currently disabled for movement until a distinction can be made between movement being made, and movement being finished.

Bit hacky, but can now undo and redo movement. Could use optimization in the future, but it's good enough for now.