Re: Named connection points?




On Feb 17, 2012, at 3:43 PM, Hans Breuer wrote:

But I don't see why you could not use named constants for the connection point index instead.
The connection points are parsed in the order in the shape (see objects/custom/shape_info.c) and put into 
the connection point array in that order.

Ah - so the ordering of the connections points is guaranteed to be stable?  In that case, I agree that 
connection point order is a reasonable way to do this.  

I didn't do that to begin with because I couldn't convince myself that the order was stable - there was 
nothing I saw in the Custom Shape Module documentation online or in the comments of the custom shape code 
that  made clear that this was part of the API.  Did I miss something in the documentation?  If not, perhaps 
it would be useful to add a line to the Custom Shape Module documentation 
(http://dia-installer.de/doc/en/custom-shapes-chapter.html) that programmers can depend on the ordering 
stability of the connection points.

In any case (either with index or names) you have to ensure that your script and your shapes are matching.

Yes of course.  I think it's a bit easier with names because you can introspect on them in the python REPL 
using 'dir' and 'help' and such, but looking up the text of the shape module isn't very hard either.  It's a 
bit harder with built-in shapes since you have to read the C code for those, but that's not my use case here. 
 I consider that the having a stable ordering of connection points is sufficient for my purposes.

Thanks.

Dan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]