I got a question concerning the undo/redo function in OCAF. I tried to understand how to realize a undo/redo-function by looking at the source code of the OCAF-sample.
Is it right that I have to specify the beginning of the commands that the user can undo with D->NewCommand();, as it is written in line 354 of SampleOcafDoc.cpp-file of the OCAF-Sample? Do I specify the end of the command-sequence that should be undone with D->CommitCommand();, as it is written in line 372 in the same file? Does this mean, that everything that stands between those two commands will be undone, when the undo-method is called?
Thanks for your help,
Christian Alvarez
Discussion
1 archived reply
Posts are displayed in their archived order.
01Commenter-1
Hello Christian,
To define the begin and theend of a transaction use NewCommand() method of TDocStd, like the following:
D->NewCommand(); //Closes the previous and opens
//a new transaction
//Some OCAF command's calls
D->NewCommand(); //Look above comment ;-)
if you need to undo the last transaction call Undo() method.
Best Regards.
Commenter-1.
PS For better understanding the OCAF transaction mechanism and how OCAF works look at the sources or consider taking OCAF training course.