Node and Link copy


#1

I have a GoNode subclass with an Initialize method that creates and
adds the childs (a goroundedrectangle and x ports and a GoText)…
if i dont override CopyObject …when creating a copy some stuff gets
screwed… i was thinking of overriding the CopyObject method and make
my childs non copyable so that when CopyObject was called i could call

bas.CopyObject
and then call Initialize on my object so it recreates itself… but
when setting my childs to non copyable…they still get copied by
base.CopyObject… what do i need to do? Isnt this incoherent with the
property?


#2

GoObject.Copyable just controls whether the user can interactively make a copy of that object. It has no effect on whether your code can make a copy of that object. The same is true for most (all?) of those “-ble” GoObject properties.
I think you need to make sure that your node class does copy properly, in the normal manner. If you try calling Initialize again, you may well lose some interesting state.


#3

Well …what does actually get copied from a GoNode? because it looks
like all the stuff added to my GoNode via the Add(GoObject) method get
copied…but they seem to only be a reference…i get weird results…
thats why i wanted to copy those my self …This brings me to the
following point… whats the best way to subclass a GoNode? I usually
subclass it and then i have an Initialize method that adds the
GoObjects that form my GoNode…is this the right way? In my case i have
a GoNode to which i can add arbitrary number of ports and in some case
a GoText plus a GoShape…all my GoNodes represent something different
(functions, operators, variables, constants…) so they all have
additional properties.


#4

That sounds OK. There are a lot of example node classes in the sample applications, particularly in Demo1. You might find Processor’s ActivityNode useful too.


#5

I think ActivityNode is to simple… What i want to know is what
happens when i copy a GoNode that contains a GoShape, GoText and X
Ports …Seems like it copies the GoShape and GoText and Ports…but
when debugging, my copied node’s GoShape seems to be the same has the
copied GoShape…but the copied node position is right…so i dont
really understand whats being done…


#6

If you don’t have any fields that reference child objects, everything ought to just work.
If you do have some fields that refer to child objects, then you need to make sure those references are updated in the copied object. Look at CopyChildren, in the documentation and in the samples.


#7

GOT IT!!! It works now after base.CopyChildren i use the GoCopyDictionary to update my references! Thanks