undo functioning in GUI in MATLAB .

hello all , Working on image processing with using GUIDE , want to know that how to add "UNDO & REDO" buttons in GUI ?
Thanks in advance :)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Sept. de 2015
Editada: Walter Roberson el 30 de Sept. de 2015

0 votos

For each change, you have to keep a record of the original state and the new state. Undo involves changing the current state to the original state and internally marking that you are now one further back in the chain. Redo involves changing the current state to the remembered state and internally marking that you are now one further along in the chain.
You need to decide what you want to happen if someone does something, undoes it, and then does something different. It is common that at that point the rest of the "redo" chain would be wiped out, but that is not the only possibility.
There is no MATLAB function to implement this for you. Changing current state can be a lot of work. For example if you triggered a call that did half an hour of calculations and changed 5 gigabytes of database, then undoing that work can be messy.
If you find that re-doing an action involves writing code that moves cursors and pressed buttons on the user's behalf, then chances are you need to re-think your design.

6 comentarios

yogesh jain
yogesh jain el 30 de Sept. de 2015
Thanks a lot for concept . Let me be specific about it , I have to undo-redo the changes in 3D images , what will be the approach ?
Walter Roberson
Walter Roberson el 30 de Sept. de 2015
Let me be specific. I am thinking of renovating my deck. If I do not like the change, I might want to undo the renovation. What would be the approach?
Image Analyst
Image Analyst el 30 de Sept. de 2015
Why can't you just save copies of your variables before you change them, like to another variable or a disk file or whatever? Then just assign the last variable to the "current" variable if you want to undo/reset back to that point in time?
Walter Roberson
Walter Roberson el 30 de Sept. de 2015
Note that the easiest way to save the state of your controls is to savefig() and restore using openfig() . This is not going to be the fastest way though, and it would require saving one .fig file for every undo-able change.
yogesh jain
yogesh jain el 1 de Oct. de 2015
@Image analyst - thank you sir but could u suggest me some functions and steps for doing that process ?
@Walter Roberson - Thanks to you too .
Walter Roberson
Walter Roberson el 1 de Oct. de 2015
Function to save copies of variables: save()

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Sept. de 2015

Comentada:

el 1 de Oct. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by