[Pythoncad-developer] Undo functionality
CAD Application entire developed in Python
Status: Beta
Brought to you by:
matteoboscolo
From: <ger...@gm...> - 2010-02-06 18:22:03
|
Hi All, I was thinking about implementing undo functionality in combination with the database. I am not aware how this is solved in the current version but with a database we can make the undo recording persistent (you can undo changes from a previous drawing session). The idea is not to modify entities in the database but mark the old entity state as deleted and insert a new record for the modified entity state. Then there are two records in the database, one is the previous state and one is the the current state of the entity. Of course the entities that are marked as deleted (previous state) are not drawn. When the user does undo the current state is marked as deleted and the previous state is marked as not deleted. A redo does this marking in the opposite direction. If we add a column "state" and a column "undo_mark" to our entity table we can achieve this. The column "state" holds the delete (or not) state. The column "undo_mark" holds the value of the undo id. Because the user can modify many entities at once all those entities get the same "undo_mark". This way the history of the drawing is kept in the database and the user can undo and redo actions from previous sessions. If we also add a time stamp we even can provide functionality that will show how the drawing looked at a certain date. I think this functionality can have some use and is something other CAD programs does not always provide. Undo and redo are simple database queries that are easy to implement. We must keep the display list in sync with the state of the database but I think this also it not difficult. We also need a function that compresses the drawing by removing the history. If it needs clarification, let me know I will try to explain. Do you think it is useful? Regards, Gertwin |