Custom undo/redo function for all process

Hi all

I am currently working on developing a custom program using 3D Slicer and have a question I’d like to discuss in here.

We need for an undo-redo feature for all functions (including camera view adjustments).

Upon my investigation, it seems this feature is not currently implemented. I also get to find “UndoEnabledOn” function but could not find example for all process, only fiducial.

We has considered saving executed functions (such as Python scripts) separately and then reverting by executing those or saving states at specific timelines.

What would be the most efficient way to implement an undo-redo feature?

1 Like

The undo/redo architecture at the MRML level should work fine, but sometimes the GUI/Logic levels get out of sync. See more info here You can pretty easily experiment with it to see how well it works for specific uses.

Another option is to auto-save the whole mrml scene periodically. If the bulk data has not changed this can be a very quick operation and allow you to reset to a known state easily.

1 Like