On 28/03/2010 01:20, Christopher Barker wrote:
> Werner F. Bruhin wrote:
>>> I like to "append" rackUnits, i.e. not hardcode the startPos.
>>>
>>> But I can't find a method/variable in the canvas giving me the extend of
>>> the existing objects - is there one or how else could I calculate what
>>> the next free position to the right is?
>>>
>> I found a solution, but is this fine or is there a cleaner one?
>>
>>           bBox = self.canvas.BoundingBox[1]
>
> yup -- that's it.
>
>>           if bBox[0]>0:
>
> Why the check for 0 here?
It contains "NaN" on initial call, i.e. when there is no object on the 
canvas yet.
  Note that the bounding box is a bounding box
> object, which is a subclass of a numpy array, but also has other nifty
> methods -- see the code in floatcanvas.utilities
So, should really use:
bBox.IsNull()

If I keep using the bb.
>
> However, I'm not sure I'd do it this way -- the canvas keeps track of
> the bounding box so that it knows what/when to draw, and you can zoom
> the it, etc. There may be times when it is our of sync -- in which case,
> I think there is a flag something like Canvas.BoundBoxDirty (or
> something like that -- I"d have to look at the code) that should be set.
Yes that is there, so should make sure that it is False if I keep using 
the above and if not force a redraw.
>
> But I'd think that I wouldn't rely on the Canvas for this -- rather, you
> have you Rack objects, can't you use the coordinates of the existing
> racks directly? You might create a subclass of the Group object that
> adds some extra methods for querying this sort of thing.
I guess I could keep track on the "root" group.

Thanks
Werner

_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to