Roassal3 icon indicating copy to clipboard operation
Roassal3 copied to clipboard

RSComposite>>shapeFromModel:

Open bergel opened this issue 5 years ago • 4 comments

I found a bug:

c := RSComposite new.
c addShape: (RSBox new model: 42).
c addShape: (RSEllipse new model: 43).
c shapeFromModel: 42

returns nil

Somehow related, the class RSComposite has nodes and children as instance variables. That is weird. Why these?

bergel avatar Aug 25 '20 10:08 bergel

Same as RSCanvas. RSComposite looks in nodes collection. instead of the entire shapes collection.

RSComposite >> #shapeFromModel: anObject
	"Retreive a shape from a given model. Return nil if not found"

	^ self nodes shapeFromModel: anObject

Then you should access to c shapes shapeFromModel: 42 or use: add: instead of addShape:

akevalion avatar Aug 31 '20 10:08 akevalion

Is this issue related to the new method deepShapeFromModel:

Maybe we can change this method in this way

shapeFromModel: anObject
	"Retreive a shape from a given model. Return nil if not found"

	^ self shapes shapeFromModel: anObject

akevalion avatar Sep 14 '20 22:09 akevalion

you can write it in 2 ways

c := RSComposite new.
c addShape: (RSBox new model: 42).
c addShape: (RSEllipse new model: 43).
c shapes shapeFromModel: 42

Or

c := RSComposite new.
c add: (RSBox new model: 42).
c add: (RSEllipse new model: 43).
c shapeFromModel: 42

akevalion avatar May 12 '21 16:05 akevalion

Very similar to #287

bergel avatar May 14 '21 20:05 bergel

By now user should query this objects with deepShapeFromModel:

akevalion avatar May 30 '23 11:05 akevalion