Rev | Line | |
---|
[37] | 1 | // |
---|
| 2 | // undo.cc: |
---|
| 3 | // Save every variable that changes, so that we can exactly "undo" |
---|
| 4 | // an operation by putting everything back the way it was. This |
---|
| 5 | // allows us to try mesh simplification changes, and abort the |
---|
| 6 | // changes if we detect something bad happening (like a topology |
---|
| 7 | // change...) |
---|
| 8 | |
---|
| 9 | #include <stdio.h> |
---|
| 10 | #include <stdlib.h> |
---|
| 11 | #include <math.h> |
---|
| 12 | #include <ply.h> |
---|
| 13 | #include <Linear.h> |
---|
| 14 | #include <string.h> |
---|
| 15 | #include <strings.h> |
---|
| 16 | |
---|
| 17 | #include "Mesh.h" |
---|
| 18 | #include "plyio.h" |
---|
| 19 | #include "undo.h" |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | // Buffer stuff to remember, undo. |
---|
| 24 | |
---|
| 25 | int google = 3; |
---|
| 26 | int google22 = 3; |
---|
| 27 | |
---|
| 28 | // Variables for storing the undo operation list |
---|
| 29 | bool saveUndo = FALSE; |
---|
| 30 | char undoBuf[sizeof(void *)*MAXUNDOBUFSIZE]; |
---|
| 31 | char *undoPtr; |
---|
| 32 | void *undoLoc[MAXUNDOBUFSIZE]; |
---|
| 33 | int undoSize[MAXUNDOBUFSIZE]; |
---|
| 34 | int undoN = 0; |
---|
| 35 | |
---|
| 36 | // Variables for saving calls to delete(). We don't actually |
---|
| 37 | // delete until we see the commit... |
---|
| 38 | // (not implemented yet) |
---|
| 39 | void *undoFree[MAXUNDOBUFSIZE]; |
---|
| 40 | int undoFreeN = 0; |
---|
| 41 | |
---|
| 42 | void undo(void) |
---|
| 43 | { |
---|
| 44 | // Undo all the saves, in backward order |
---|
| 45 | while (--undoN >= 0) { |
---|
| 46 | undoPtr -= undoSize[undoN]; |
---|
| 47 | bcopy(undoPtr, (char *) undoLoc[undoN], undoSize[undoN]); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | // Turn saving off, until we checkpoint again |
---|
| 51 | SaveOff(); |
---|
| 52 | |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | void SaveCheckpoint(void) |
---|
| 56 | { |
---|
| 57 | // Commit previous operations -- delete anything sitting around... |
---|
| 58 | // (not implemented yet) |
---|
| 59 | undoFreeN = 0; |
---|
| 60 | |
---|
| 61 | // Initialize variables to start saving again... |
---|
| 62 | saveUndo = TRUE; |
---|
| 63 | undoN = 0; |
---|
| 64 | undoPtr = undoBuf; |
---|
| 65 | |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | void SaveOff(void) |
---|
| 70 | { |
---|
| 71 | // Turn off saving |
---|
| 72 | saveUndo = FALSE; |
---|
| 73 | |
---|
| 74 | undoFreeN = 0; |
---|
| 75 | undoN = 0; |
---|
| 76 | undoPtr = undoBuf; |
---|
| 77 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.