Results 1 to 2 of 2

Thread: OpenGL Undo/Redo

  1. #1
    Join Date
    Mar 2015
    Posts
    11
    Qt products
    Qt3
    Platforms
    Windows

    Default OpenGL Undo/Redo

    Hello,

    I was creating sample application (3D Cad) and I need to add Redo and Undo functionality.

    Any tips how to do that?

    Thanks

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: OpenGL Undo/Redo

    It depends on your implementation, but typically you can have a data type to represent current "state" of the object (like list of all objects/points on the scene). On each state change (like adding new point, moving or resizing lines etc.) you can append new "state" to the "state list". Undo could simply move back one index in this list and display corresponding state. On redo just move the current index forward etc. Simple to implement, but can require a lot of memory if you would like to work on large scenes.
    Another option is to store a some kind of "state change", so instead of storing full list of objects on each change, keep only the "description" of the change applied, like "added point x,y", "moved point p -> q", "deleted point x,y" etc. Now undo could simply apply the inverse of the last "state change" and move one index back in the "state change list". This solution will require to store less data, but can be more complicated to implement.
    Sorry for the lack of details, but it really depends on the underlying data structures etc.
    Hope this helps.

Similar Threads

  1. Undo/Redo Functionality
    By Gurjot in forum Newbie
    Replies: 2
    Last Post: 10th October 2014, 09:45
  2. Replies: 0
    Last Post: 21st January 2014, 06:05
  3. qt undo/redo
    By giugio in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2012, 16:31
  4. undo/redo example has refactored
    By n_vova in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2012, 10:04
  5. QTextEdit undo/redo
    By Derf in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2009, 09:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.