Re: Named connection points

On Sun, Feb 19, 2012 at 7:00 AM,  <dia-list-request gnome org> wrote:
Date: Sat, 18 Feb 2012 15:34:25 -0500
From: Dan Katz <dpkatz bc gmail com>
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.

I don't use Python, though I would think it would have a mechanism for
defining named constants in a file that can be included by reference
by your program.

In C/C++, something like the following could be done:

enum OpAmpCP {

Then in the program:

#include "shapeDefinitions.h"

/* other code */

ShapeType = parseShape(objectIndex, attributes, connections);
switch (ShapeType) {
    case OpAmp:
        makeConnection(objectIndex, OpAmp_Pos, connections[OpAmp_Pos]);
        /* more code */
    /* cases for other shapes */

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