From: erg Date: Thu, 14 Jul 2005 22:58:42 +0000 (+0000) Subject: Fix bug 741 X-Git-Tag: LAST_LIBGRAPH~32^2~7437 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91d7cbd880f6579d0dd9d733fef28f03c82e9922;p=graphviz Fix bug 741 --- diff --git a/lib/common/input.c b/lib/common/input.c index dcfcea418..036bb3336 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -464,6 +464,7 @@ void graph_init(graph_t * g, boolean use_rankdir) double xf; static char *rankname[] = { "local", "global", "none", NULL }; static int rankcode[] = { LOCAL, GLOBAL, NOCLUST, LOCAL }; + int rankdir; GD_drawing(g) = NEW(layout_t); @@ -491,16 +492,24 @@ void graph_init(graph_t * g, boolean use_rankdir) /* setting rankdir=LR is only defined in dot, * but having it set causes shape code and others to use it. * The result is confused output, so we turn it off unless requested. + * This effective rankdir is stored in the bottom 2 bits of g->u.rankdir. + * Sometimes, the code really needs the graph's rankdir, e.g., neato -n + * with record shapes, so we store the real rankdir in the next 2 bits. */ - GD_rankdir(g) = RANKDIR_TB; - if (use_rankdir && (p = agget(g, "rankdir"))) { + rankdir = RANKDIR_TB; + if ((p = agget(g, "rankdir"))) { if (streq(p, "LR")) - GD_rankdir(g) = RANKDIR_LR; + rankdir = RANKDIR_LR; else if (streq(p, "BT")) - GD_rankdir(g) = RANKDIR_BT; + rankdir = RANKDIR_BT; else if (streq(p, "RL")) - GD_rankdir(g) = RANKDIR_RL; + rankdir = RANKDIR_RL; } + if (use_rankdir) + g->u.rankdir = (rankdir << 2) || rankdir; + else + g->u.rankdir = (rankdir << 2); + xf = late_double(g, agfindattr(g, "nodesep"), DEFAULT_NODESEP, MIN_NODESEP); GD_nodesep(g) = POINTS(xf); diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 76676679e..cf775218c 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -1662,17 +1662,21 @@ static void record_init(node_t * n) { field_t *info; point ul, sz; - int len; + int flip, len; char *textbuf; /* temp buffer for storing labels */ int sides = BOTTOM | RIGHT | TOP | LEFT; + if (Nop) + flip = NOT(GD_realflip(n->graph)); + else + flip = NOT(GD_flip(n->graph)); reclblp = ND_label(n)->text; len = strlen(reclblp); textbuf = N_NEW(len + 1, char); - if (!(info = parse_reclbl(n,NOT(GD_flip(n->graph)), TRUE, textbuf))) { + if (!(info = parse_reclbl(n, flip, TRUE, textbuf))) { agerr(AGERR, "bad label format %s\n", ND_label(n)->text); reclblp = "\\N"; - info = parse_reclbl(n, NOT(GD_flip(n->graph)), TRUE, textbuf); + info = parse_reclbl(n, flip, TRUE, textbuf); } free(textbuf); diff --git a/lib/common/types.h b/lib/common/types.h index 72c2e58c6..bd8d4566f 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -418,8 +418,10 @@ extern "C" { #define GD_installed(g) (g)->u.installed #define GD_label(g) (g)->u.label #define GD_leader(g) (g)->u.leader -#define GD_rankdir(g) (g)->u.rankdir +#define GD_rankdir(g) ((g)->u.rankdir & 0x3) #define GD_flip(g) (GD_rankdir(g) & 1) +#define GD_realrankdir(g) ((g)->u.rankdir >> 2) +#define GD_realflip(g) (GD_realrankdir(g) & 1) #define GD_ln(g) (g)->u.ln #define GD_maxrank(g) (g)->u.maxrank #define GD_maxset(g) (g)->u.maxset