I would like to have Undo and Redo functions in my program. I'm searching for general methods of these functions. Does anybody know good ways to implement Undo/Redo?
I'm writing a graphical application in which I can draw and manipulate 3d objects. For example, I've drawn a 3d cube and now I move it across 3d space (by selecting the cube, then select the Move command and then dragging the mouse across the screen). I would like to Undo this command. Another example: a 3d cube has 6 faces. Suppose I delete on of these faces. How to Undo that operation?
I'm looking for a general solution, if there is such a thing for Undo operations.
The easiest way to make the engine perform multi-level undos, is to have it understand a simple scripted language. So that every 3D object is composed of a number of operations. e.g
A command to the engine might look like :
Rotate( -1, 45)
this being a simple rotation 45° anti-clockwise. To perform the Undo you would have to create an Undo 'engine' which would issue the opposite effect to the orignal command :
Rotate(1, 45)
Having the engine parse human readable commands will make your life far easier for debugging. You could of course keep issuing Undos until the object is removed and the script is empty, using this method would also allow Undo-ing to be available even after the object has been saved and reloaded.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.