[PythonCAD] More repo code updates

Art Haas ahaas at airmail.net
Fri Oct 29 01:58:25 CEST 2004


On Thu, Oct 28, 2004 at 03:11:36PM -0200, Gustavo Barbieri wrote:
> On Thu, 28 Oct 2004 11:51:25 -0500, Art Haas <ahaas at airmail.net> wrote:
> [ ... snip ... ]
> 
> But I saw you have some problems with undo. How do you implement that?
> IMHO if you have objects implemented correctly (they do know their
> color, position, ...) you could just keep a list of deleted objects
> that is the size of your wanted undo steps and remove the references
> to them from other groups (layers, drawings, ...). That would avoid
> every problems you may have with undo.

Deleted objects are stored by saving the values of various attributes of
the object, but the object itself is destroyed. For example, a Point has 
'x' and 'y' coordinates, plus some internal bookkeeping values. So, when
a Point instance is deleted, the values of these attributes are stored
in an EntityData instance (see PythonCAD/Generic/entity.py), and the
object is deleted.

The problem I saw with keeping the deleted objects around dealt with the
interrelationship between various objects. A Segment instance keeps
references to two Point instances, and these two Point instances also
store a reference to the Segment. I thought that trying to store the
entity values, and using those values to recreate the entity should the
user do so, was a better approach to recreating the entity than leaving
all the reference between entities yet marking deleted entities in some
fashion. I still like my approach, but if better approaches are
presented a switch can certainly be considered.

Art Haas
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822


More information about the PythonCAD mailing list