static void unrecognized(node_t * n, char *p)
{
- agerr(AGWARN, "node %s, port %s unrecognized\n", n->name, p);
+ agerr(AGWARN, "node %s, port %s unrecognized\n", agnameof(n), p);
}
static double quant(double val, double q)
PAD(dimen);
}
/* quantization */
- if ((temp = GD_drawing(n->graph)->quantum) > 0.0) {
+ if ((temp = GD_drawing(agraphof(n))->quantum) > 0.0) {
temp = POINTS(temp);
dimen.x = quant(dimen.x, temp);
dimen.y = quant(dimen.y, temp);
*/
if (streq(ND_shape(n)->name, "custom")) {
sfile = agget(n, "shapefile");
- imagesize = gvusershape_size(n->graph, sfile);
+ imagesize = gvusershape_size(agraphof(n), sfile);
if ((imagesize.x == -1) && (imagesize.y == -1)) {
agerr(AGWARN,
"No or improper shapefile=\"%s\" for node \"%s\"\n",
- (sfile ? sfile : "<nil>"), n->name);
+ (sfile ? sfile : "<nil>"), agnameof(n));
imagesize.x = imagesize.y = 0;
}
else {
- GD_has_images(n->graph) = TRUE;
+ GD_has_images(agraphof(n)) = TRUE;
imagesize.x += 2; /* some fixed padding */
imagesize.y += 2;
}
}
}
else if ((sfile = agget(n, "image")) && (*sfile != '\0')) {
- imagesize = gvusershape_size(n->graph, sfile);
+ imagesize = gvusershape_size(agraphof(n), sfile);
if ((imagesize.x == -1) && (imagesize.y == -1)) {
agerr(AGWARN,
"No or improper image=\"%s\" for node \"%s\"\n",
- (sfile ? sfile : "<nil>"), n->name);
+ (sfile ? sfile : "<nil>"), agnameof(n));
imagesize.x = imagesize.y = 0;
}
else {
- GD_has_images(n->graph) = TRUE;
+ GD_has_images(agraphof(n)) = TRUE;
imagesize.x += 2; /* some fixed padding */
imagesize.y += 2;
}
if ((width < bb.x) || (height < bb.y))
agerr(AGWARN,
"node '%s', graph '%s' size too small for label\n",
- n->name, n->graph->name);
+ agnameof(n), agraphof(n)->name);
bb.x = width;
bb.y = height;
}
boxf *bp = inside_context->s.bp;
node_t *n = inside_context->s.n;
- P = ccwrotatepf(p, 90*GD_rankdir(n->graph));
+ P = ccwrotatepf(p, 90*GD_rankdir(agraphof(n)));
/* Quick test if port rectangle is target */
if (bp) {
sides = poly->sides;
/* get point and node size adjusted for rankdir=LR */
- if (GD_flip(n->graph)) {
+ if (GD_flip(agraphof(n))) {
ysize = ND_lw(n) + ND_rw(n);
xsize = ND_ht(n);
} else {
defined = TRUE;
} else {
p.x = p.y = 0.;
- if (GD_flip(n->graph)) {
+ if (GD_flip(agraphof(n))) {
b.UR.x = ND_ht(n) / 2.;
b.LL.x = -b.UR.x;
b.UR.y = ND_lw(n);
break;
}
}
- p = cwrotatepf(p, 90*GD_rankdir(n->graph));
+ p = cwrotatepf(p, 90*GD_rankdir(agraphof(n)));
if (dyna) pp->side = side;
- else pp->side = invflip_side(side, GD_rankdir(n->graph));
+ else pp->side = invflip_side(side, GD_rankdir(agraphof(n)));
pp->bp = bp;
PF2P(p, pp->p);
- pp->theta = invflip_angle(theta, GD_rankdir(n->graph));
+ pp->theta = invflip_angle(theta, GD_rankdir(agraphof(n)));
if ((p.x == 0) && (p.y == 0))
pp->order = MC_SCALE/2;
else {
if (compassPort(n, bp, &rv, compass, sides, NULL)) {
agerr(AGWARN,
"node %s, port %s, unrecognized compass point '%s' - ignored\n",
- n->name, portname, compass);
+ agnameof(n), portname, compass);
}
}
else {
pointf P;
node_t *n = inside_context->s.n;
- P = ccwrotatepf(p, 90*GD_rankdir(n->graph));
+ P = ccwrotatepf(p, 90*GD_rankdir(agraphof(n)));
if (n != lastn) {
int outp;
int sides = BOTTOM | RIGHT | TOP | LEFT;
/* Always use rankdir to determine how records are laid out */
- flip = NOT(GD_realflip(n->graph));
+ flip = NOT(GD_realflip(agraphof(n)));
reclblp = ND_label(n)->text;
len = strlen(reclblp);
textbuf = N_NEW(len + 1, char);
if (mapbool(late_string(n, N_fixed, "false"))) {
if ((sz.x < info->size.x) || (sz.y < info->size.y)) {
/* should check that the record really won't fit, e.g., there may be no text.
- agerr(AGWARN, "node '%s' size may be too small\n",
- n->name);
- */
+ agerr(AGWARN, "node '%s' size may be too small\n", agnameof(n));
+*/
}
} else {
sz.x = MAX(info->size.x, sz.x);
if (compassPort(n, &subf->b, &rv, compass, subf->sides, NULL)) {
agerr(AGWARN,
"node %s, port %s, unrecognized compass point '%s' - ignored\n",
- n->name, portname, compass);
+ agnameof(n), portname, compass);
}
}
else if (compassPort(n, &f->b, &rv, portname, sides, NULL)) {
boxf bbox;
/* convert point to node coordinate system */
- p = ccwrotatepf(p, 90*GD_rankdir(n->graph));
+ p = ccwrotatepf(p, 90*GD_rankdir(agraphof(n)));
if (bp == NULL) {
fld0 = (field_t *) ND_shape_info(n);
info = (field_t *) ND_shape_info(n);
for (i = 0; i < info->n_flds; i++) {
- if (!GD_flip(n->graph)) {
+ if (!GD_flip(agraphof(n))) {
ls = info->fld[i]->b.LL.x;
rs = info->fld[i]->b.UR.x;
} else {
}
if (BETWEEN(ls, p.x, rs)) {
/* FIXME: I don't understand this code */
- if (GD_flip(n->graph)) {
+ if (GD_flip(agraphof(n))) {
rv[0] = flip_rec_boxf(info->fld[i]->b, ND_coord(n));
} else {
rv[0].LL.x = ND_coord(n).x + ls;
double x2;
node_t *n = inside_context->s.n;
- P = ccwrotatepf(p, 90*GD_rankdir(n->graph));
+ P = ccwrotatepf(p, 90*GD_rankdir(agraphof(n)));
x2 = ND_ht(n) / 2;
return ((P.y >= -x2) && (P.y <= x2) && (P.x >= -ND_lw(n)) && (P.x <= ND_rw(n)));
}
static char* closestSide (node_t* n, node_t* other, port* oldport)
{
boxf b;
- int rkd = GD_rankdir(n->graph->root);
+ int rkd = GD_rankdir(agraphof(n)->root);
point p = {0, 0};
point pt = cvtPt (ND_coord(n), rkd);
point opt = cvtPt (ND_coord(other), rkd);
if (oldport->bp) {
b = *oldport->bp;
} else {
- if (GD_flip(n->graph)) {
+ if (GD_flip(agraphof(n))) {
b.UR.x = ND_ht(n) / 2;
b.LL.x = -b.UR.x;
b.UR.y = ND_lw(n);
#ifdef DEBUG
static int debugleveln(edge_t* e, int i)
{
-#ifndef WITH_CGRAPH
- return (GD_showboxes(e->head->graph) == i ||
- GD_showboxes(e->tail->graph) == i ||
-#else /* WITH_CGRAPH */
- return (GD_showboxes(aghead(e)->graph) == i ||
- GD_showboxes(agtail(e)->graph) == i ||
-#endif /* WITH_CGRAPH */
+ return (GD_showboxes(agraphof(aghead(e))) == i ||
+ GD_showboxes(agraphof(agtail(e))) == i ||
ED_showboxes(e) == i ||
-#ifndef WITH_CGRAPH
- ND_showboxes(e->head) == i ||
- ND_showboxes(e->tail) == i);
-#else /* WITH_CGRAPH */
ND_showboxes(aghead(e)) == i ||
ND_showboxes(agtail(e)) == i);
-#endif /* WITH_CGRAPH */
}
static void showPoints(pointf ps[], int pn)
arrow_flags(e, &sflag, &eflag);
if (info->splineMerge(hn))
eflag = ARR_NONE;
-#ifndef WITH_CGRAPH
- if (info->splineMerge(fe->tail))
-#else /* WITH_CGRAPH */
if (info->splineMerge(agtail(fe)))
-#endif /* WITH_CGRAPH */
sflag = ARR_NONE;
if (j) {
i = sflag;
bezier *new_spline(edge_t * e, int sz)
{
bezier *rv;
-#ifndef WITH_CGRAPH
-
-#else /* WITH_CGRAPH */
- splines* sp_test;
-#endif /* WITH_CGRAPH */
while (ED_edge_type(e) != NORMAL)
e = ED_to_orig(e);
if (ED_spl(e) == NULL)
boxf *tbox, *hbox;
inside_t inside_context;
-#ifndef WITH_CGRAPH
- tn = fe->tail;
- g = tn->graph;
-#else /* WITH_CGRAPH */
tn = agtail(fe);
g = agraphof(tn);
-#endif /* WITH_CGRAPH */
newspl = new_spline(fe, pn);
for (orig = fe; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig));
/* may be a reversed flat edge */
-#ifndef WITH_CGRAPH
- if ((tn->u.rank == hn->u.rank) && (tn->u.order > hn->u.order)) {
-#else /* WITH_CGRAPH */
if ((ND_rank(tn) == ND_rank(hn)) && (ND_order(tn) > ND_order(hn))) {
-#endif /* WITH_CGRAPH */
node_t *tmp;
tmp = hn;
hn = tn;
tn = tmp;
}
-#ifndef WITH_CGRAPH
- if (tn == orig->tail) {
-#else /* WITH_CGRAPH */
if (tn == agtail(orig)) {
-#endif /* WITH_CGRAPH */
clipTail = ED_tail_port(orig).clip;
clipHead = ED_head_port(orig).clip;
tbox = ED_tail_port(orig).bp;
s_in = s_out = 0.0;
for (cnt_in = 0; (e = ND_in(n).list[cnt_in]); cnt_in++)
-#ifndef WITH_CGRAPH
- s_in += ND_coord(e->tail).x;
-#else /* WITH_CGRAPH */
s_in += ND_coord(agtail(e)).x;
-#endif /* WITH_CGRAPH */
for (cnt_out = 0; (e = ND_out(n).list[cnt_out]); cnt_out++)
-#ifndef WITH_CGRAPH
- s_out += ND_coord(e->head).x;
-#else /* WITH_CGRAPH */
s_out += ND_coord(aghead(e)).x;
-#endif /* WITH_CGRAPH */
p.x = ND_coord(n).x - (s_in / cnt_in);
-#ifndef WITH_CGRAPH
- p.y = ND_coord(n).y - ND_coord(ND_in(n).list[0]->tail).y;
-#else /* WITH_CGRAPH */
p.y = ND_coord(n).y - ND_coord(agtail(ND_in(n).list[0])).y;
-#endif /* WITH_CGRAPH */
m_in = atan2(p.y, p.x);
p.x = (s_out / cnt_out) - ND_coord(n).x;
-#ifndef WITH_CGRAPH
- p.y = ND_coord(ND_out(n).list[0]->head).y - ND_coord(n).y;
-#else /* WITH_CGRAPH */
p.y = ND_coord(aghead(ND_out(n).list[0])).y - ND_coord(n).y;
-#endif /* WITH_CGRAPH */
m_out = atan2(p.y, p.x);
return ((m_in + m_out) / 2.0);
}
node_t *n;
int (*pboxfn) (node_t*, port*, int, boxf*, int*);
-#ifndef WITH_CGRAPH
- n = e->tail;
-#else /* WITH_CGRAPH */
n = agtail(e);
-#endif /* WITH_CGRAPH */
if (ED_tail_port(e).dyna)
-#ifndef WITH_CGRAPH
- ED_tail_port(e) = resolvePort(e->tail, e->head, &ED_tail_port(e));
-#else
ED_tail_port(e) = resolvePort(agtail(e), aghead(e), &ED_tail_port(e));
-#endif
if (ND_shape(n))
pboxfn = ND_shape(n)->fns->pboxfn;
else
P->start.p = add_pointf(ND_coord(n), ED_tail_port(e).p);
if (merge) {
/*P->start.theta = - M_PI / 2; */
-#ifndef WITH_CGRAPH
- P->start.theta = conc_slope(e->tail);
-#else /* WITH_CGRAPH */
P->start.theta = conc_slope(agtail(e));
-#endif /* WITH_CGRAPH */
P->start.constrained = TRUE;
} else {
if (ED_tail_port(e).constrained) {
/* b0.LL.y = ND_coord(n).y + ND_ht(n)/2; */
b0.LL.y = P->start.p.y;
b0.UR.x = b.UR.x;
-#ifndef WITH_CGRAPH
- b0.UR.y = ND_coord(n).y + ND_ht(n)/2 + GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.UR.y = ND_coord(n).y + ND_ht(n)/2 + GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.UR.x = ND_coord(n).x - ND_lw(n) - (FUDGE-2);
b.UR.y = b0.LL.y;
b.LL.y = ND_coord(n).y - ND_ht(n)/2;
b0.LL.y = P->start.p.y;
/* b0.LL.y = ND_coord(n).y + ND_ht(n)/2; */
b0.UR.x = b.UR.x+1;
-#ifndef WITH_CGRAPH
- b0.UR.y = ND_coord(n).y + ND_ht(n)/2 + GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.UR.y = ND_coord(n).y + ND_ht(n)/2 + GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.LL.x = ND_coord(n).x + ND_rw(n) + (FUDGE-2);
b.UR.y = b0.LL.y;
b.LL.y = ND_coord(n).y - ND_ht(n)/2;
P->start.p.x += 1;
}
for (orig = e; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig));
-#ifndef WITH_CGRAPH
- if (n == orig->tail)
-#else /* WITH_CGRAPH */
if (n == agtail(orig))
-#endif /* WITH_CGRAPH */
ED_tail_port(orig).clip = FALSE;
else
ED_head_port(orig).clip = FALSE;
b0.UR.y = ND_coord(n).y - ND_ht(n)/2;
b0.UR.x = b.UR.x+1;
b0.LL.x = P->start.p.x;
-#ifndef WITH_CGRAPH
- b0.LL.y = b0.UR.y - GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.LL.y = b0.UR.y - GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.LL.x = ND_coord(n).x + ND_rw(n) + (FUDGE-2);
b.LL.y = b0.UR.y;
b.UR.y = ND_coord(n).y + ND_ht(n)/2;
endp->boxn = 1;
}
for (orig = e; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig));
-#ifndef WITH_CGRAPH
- if (n == orig->tail)
-#else /* WITH_CGRAPH */
if (n == agtail(orig))
-#endif /* WITH_CGRAPH */
ED_tail_port(orig).clip = FALSE;
else
ED_head_port(orig).clip = FALSE;
node_t *n;
int (*pboxfn) (node_t* n, port*, int, boxf*, int*);
-#ifndef WITH_CGRAPH
- n = e->head;
-#else /* WITH_CGRAPH */
n = aghead(e);
-#endif /* WITH_CGRAPH */
if (ED_head_port(e).dyna)
-#ifndef WITH_CGRAPH
- ED_head_port(e) = resolvePort(e->head, e->tail, &ED_head_port(e));
-#else /* WITH_CGRAPH */
ED_head_port(e) = resolvePort(aghead(e), agtail(e), &ED_head_port(e));
-#endif /* WITH_CGRAPH */
if (ND_shape(n))
pboxfn = ND_shape(n)->fns->pboxfn;
else
P->end.p = add_pointf(ND_coord(n), ED_head_port(e).p);
if (merge) {
/*P->end.theta = M_PI / 2; */
-#ifndef WITH_CGRAPH
- P->end.theta = conc_slope(e->head) + M_PI;
-#else /* WITH_CGRAPH */
P->end.theta = conc_slope(aghead(e)) + M_PI;
-#endif /* WITH_CGRAPH */
assert(P->end.theta < 2 * M_PI);
P->end.constrained = TRUE;
} else {
/* b0.UR.y = ND_coord(n).y - ND_ht(n)/2; */
b0.UR.y = P->end.p.y;
b0.UR.x = b.UR.x;
-#ifndef WITH_CGRAPH
- b0.LL.y = ND_coord(n).y - ND_ht(n)/2 - GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.LL.y = ND_coord(n).y - ND_ht(n)/2 - GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.UR.x = ND_coord(n).x - ND_lw(n) - (FUDGE-2);
b.LL.y = b0.UR.y;
b.UR.y = ND_coord(n).y + ND_ht(n)/2;
b0.UR.y = P->end.p.y;
/* b0.UR.y = ND_coord(n).y - ND_ht(n)/2; */
b0.UR.x = b.UR.x+1;
-#ifndef WITH_CGRAPH
- b0.LL.y = ND_coord(n).y - ND_ht(n)/2 - GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.LL.y = ND_coord(n).y - ND_ht(n)/2 - GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.LL.x = ND_coord(n).x + ND_rw(n) + (FUDGE-2);
b.LL.y = b0.UR.y;
b.UR.y = ND_coord(n).y + ND_ht(n)/2;
P->start.p.x -= 1;
}
for (orig = e; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig));
-#ifndef WITH_CGRAPH
- if (n == orig->head)
-#else /* WITH_CGRAPH */
if (n == aghead(orig))
-#endif /* WITH_CGRAPH */
ED_head_port(orig).clip = FALSE;
else
ED_tail_port(orig).clip = FALSE;
b0.LL.x = b.LL.x-1;
b0.UR.y = ND_coord(n).y - ND_ht(n)/2;
b0.UR.x = P->end.p.x;
-#ifndef WITH_CGRAPH
- b0.LL.y = b0.UR.y - GD_ranksep(n->graph)/2;
-#else /* WITH_CGRAPH */
b0.LL.y = b0.UR.y - GD_ranksep(agraphof(n))/2;
-#endif /* WITH_CGRAPH */
b.UR.x = ND_coord(n).x - ND_lw(n) - 2;
b.LL.y = b0.UR.y;
b.UR.y = ND_coord(n).y + ND_ht(n)/2;
break;
}
for (orig = e; ED_edge_type(orig) != NORMAL; orig = ED_to_orig(orig));
-#ifndef WITH_CGRAPH
- if (n == orig->head)
-#else /* WITH_CGRAPH */
if (n == aghead(orig))
-#endif /* WITH_CGRAPH */
ED_head_port(orig).clip = FALSE;
else
ED_tail_port(orig).clip = FALSE;
int pointn;
e = edges[ind];
-#ifndef WITH_CGRAPH
- n = e->tail;
-#else
n = agtail(e);
-#endif
stepx = (sizex / 2.) / cnt;
stepx = MAX(stepx,2.);
points[pointn++] = pointfof(hp.x - dx, hp.y - hy / 3);
points[pointn++] = hp;
if (ED_label(e)) {
-#ifndef WITH_CGRAPH
- if (GD_flip(e->tail->graph)) {
-#else
if (GD_flip(agraphof(agtail(e)))) {
-#endif
width = ED_label(e)->dimen.y;
height = ED_label(e)->dimen.x;
} else {
if (dx + stepx < width)
dx += width - stepx;
}
-#ifndef WITH_CGRAPH
- clip_and_install(e, e->head, points, pointn, sinfo);
-#else
clip_and_install(e, aghead(e), points, pointn, sinfo);
-#endif
#ifdef DEBUG
if (debugleveln(e,1))
showPoints (points, pointn);
int pointn;
e = edges[ind];
-#ifndef WITH_CGRAPH
- n = e->tail;
-#else
n = agtail(e);
-#endif
stepx = (sizex / 2.) / cnt;
stepx = MAX(stepx, 2.);
points[pointn++] = pointfof(hp.x - dx, hp.y + hy / 3);
points[pointn++] = hp;
if (ED_label(e)) {
-#ifndef WITH_CGRAPH
- if (GD_flip(e->tail->graph)) {
-#else
if (GD_flip(agraphof(agtail(e)))) {
-#endif
width = ED_label(e)->dimen.y;
height = ED_label(e)->dimen.x;
} else {
if (dx + stepx < width)
dx += width - stepx;
}
-#ifndef WITH_CGRAPH
- clip_and_install(e, e->head, points, pointn, sinfo);
-#else
clip_and_install(e, aghead(e), points, pointn, sinfo);
-#endif
#ifdef DEBUG
if (debugleveln(e,1))
showPoints (points, pointn);
int pointn;
e = edges[ind];
-#ifndef WITH_CGRAPH
- n = e->tail;
-#else
n = agtail(e);
-#endif
stepy = (sizey / 2.) / cnt;
stepy = MAX(stepy, 2.);
points[pointn++] = pointfof(hp.x + hx / 3, hp.y - dy);
points[pointn++] = hp;
if (ED_label(e)) {
-#ifndef WITH_CGRAPH
- if (GD_flip(e->tail->graph)) {
-#else
if (GD_flip(agraphof(agtail(e)))) {
-#endif
width = ED_label(e)->dimen.y;
height = ED_label(e)->dimen.x;
} else {
if (dy + stepy < height)
dy += height - stepy;
}
-#ifndef WITH_CGRAPH
- clip_and_install(e, e->head, points, pointn, sinfo);
-#else
clip_and_install(e, aghead(e), points, pointn, sinfo);
-#endif
#ifdef DEBUG
if (debugleveln(e,1))
showPoints (points, pointn);
int pointn;
e = edges[ind];
-#ifndef WITH_CGRAPH
- n = e->tail;
-#else /* WITH_CGRAPH */
n = agtail(e);
-#endif /* WITH_CGRAPH */
stepy = (sizey / 2.) / cnt;
stepy = MAX(stepy,2.);
points[pointn++] = pointfof(hp.x - hx / 3, hp.y - dy);
points[pointn++] = hp;
if (ED_label(e)) {
-#ifndef WITH_CGRAPH
- if (GD_flip(e->tail->graph)) {
-#else /* WITH_CGRAPH */
if (GD_flip(agraphof(agtail(e)))) {
-#endif /* WITH_CGRAPH */
width = ED_label(e)->dimen.y;
height = ED_label(e)->dimen.x;
} else {
if (dy + stepy < height)
dy += height - stepy;
}
-#ifndef WITH_CGRAPH
- clip_and_install(e, e->head, points, pointn, sinfo);
-#else /* WITH_CGRAPH */
clip_and_install(e, aghead(e), points, pointn, sinfo);
-#endif /* WITH_CGRAPH */
#ifdef DEBUG
if (debugleveln(e,1))
showPoints (points, pointn);
(!(ED_tail_port(e).side & (TOP|BOTTOM)))))) {
sw = SELF_EDGE_SIZE;
if (l) {
-#ifndef WITH_CGRAPH
- label_width = GD_flip(e->head->graph) ? l->dimen.y : l->dimen.x;
-#else /* WITH_CGRAPH */
label_width = GD_flip(agraphof(aghead(e))) ? l->dimen.y : l->dimen.x;
-#endif /* WITH_CGRAPH */
sw += label_width;
}
}
return n;
}
+#ifndef WITH_CGRAPH
/* returns index of an attribute if bound, else -1 */
int late_attr(void *obj, char *name)
+#else /* WITH_CGRAPH */
+/* returns index of an attribute if bound, else NULL */
+attrsym_t* late_attr(void *obj, char *name)
+#endif /* WITH_CGRAPH */
{
attrsym_t *a;
+#ifndef WITH_CGRAPH
if ((a = agfindattr(obj, name)) != 0)
return a->index;
+#else /* WITH_CGRAPH */
+ if ((a = agget(obj, name)) != 0)
+ return a;
+#endif /* WITH_CGRAPH */
else
+#ifndef WITH_CGRAPH
return -1;
+#else /* WITH_CGRAPH */
+ return NULL;
+#endif /* WITH_CGRAPH */
}
int late_int(void *obj, attrsym_t * attr, int def, int low)
int rv;
if (attr == NULL)
return def;
+#ifndef WITH_CGRAPH
p = agxget(obj, attr->index);
+#else /* WITH_CGRAPH */
+ p = agxget(obj, attr);
+#endif /* WITH_CGRAPH */
if (p[0] == '\0')
return def;
if ((rv = atoi(p)) < low)
double late_double(void *obj, attrsym_t * attr, double def, double low)
{
+#ifndef WITH_CGRAPH
char *p;
+#else /* WITH_CGRAPH */
+ char *p=NULL;
+#endif /* WITH_CGRAPH */
double rv;
if (attr == NULL)
return def;
+#ifndef WITH_CGRAPH
p = agxget(obj, attr->index);
+#else /* WITH_CGRAPH */
+ if(!obj)
+ return def;
+ p = agxget(obj, attr);
+ if (!p)
+ return def;
+#endif /* WITH_CGRAPH */
if (p[0] == '\0')
return def;
+#ifdef WITH_CGRAPH
+ if (!obj)
+ return def;
+#endif /* WITH_CGRAPH */
if ((rv = atof(p)) < low)
rv = low;
return rv;
char *late_string(void *obj, attrsym_t * attr, char *def)
{
+#ifndef WITH_CGRAPH
if (attr == NULL)
+#else /* WITH_CGRAPH */
+ if ((attr == NULL) || (obj==NULL))
+#endif /* WITH_CGRAPH */
return def;
+#ifndef WITH_CGRAPH
return agxget(obj, attr->index);
+#else /* WITH_CGRAPH */
+ return agxget(obj, attr);
+#endif /* WITH_CGRAPH */
}
char *late_nnstring(void *obj, attrsym_t * attr, char *def)
{
char *rv = late_string(obj, attr, def);
+#ifndef WITH_CGRAPH
if (rv[0] == '\0')
+#else /* WITH_CGRAPH */
+
+ if ((!rv)||(rv[0] == '\0'))
+#endif /* WITH_CGRAPH */
rv = def;
return rv;
}
{
if (attr == NULL)
return def;
+#ifndef WITH_CGRAPH
return mapbool(agxget(obj, attr->index));
+#else /* WITH_CGRAPH */
+
+ return mapbool(agxget(obj, attr));
+#endif /* WITH_CGRAPH */
}
/* union-find */
node_t *UF_find(node_t * n)
{
while (ND_UF_parent(n) && (ND_UF_parent(n) != n)) {
+#ifndef WITH_CGRAPH
if (ND_UF_parent(n)->u.UF_parent)
ND_UF_parent(n) = ND_UF_parent(n)->u.UF_parent;
+#else /* WITH_CGRAPH */
+ if (ND_UF_parent(ND_UF_parent(n)))
+ ND_UF_parent(n) = ND_UF_parent(ND_UF_parent(n));
+#endif /* WITH_CGRAPH */
n = ND_UF_parent(n);
}
return n;
ND_UF_size(v) = 1;
} else
v = UF_find(v);
+#ifndef WITH_CGRAPH
if (u->id > v->id) {
+#else /* WITH_CGRAPH */
+ if (ND_id(u) > ND_id(v)) {
+#endif /* WITH_CGRAPH */
ND_UF_parent(u) = v;
ND_UF_size(v) += ND_UF_size(u);
} else {
late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEHEIGHT);
ND_shape(n) =
bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n);
+#ifndef WITH_CGRAPH
str = agxget(n, N_label->index);
+#else
+ str = agxget(n, N_label);
+#endif
ND_label(n) = make_label((void*)n, str,
((aghtmlstr(str) ? LT_HTML : LT_NONE) | ( (shapeOf(n) == SH_RECORD) ? LT_RECD : LT_NONE)),
late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE),
boolean rv = FALSE;
if (sym) { /* mapbool isn't a good fit, because we want "" to mean true */
+#ifndef WITH_CGRAPH
str = agxget(e,sym->index);
+#else /* WITH_CGRAPH */
+ str = agxget(e,sym);
+#endif /* WITH_CGRAPH */
if (str && str[0]) rv = !mapbool(str);
else rv = FALSE;
}
chkPort (port (*pf)(node_t*, char*, char*), node_t* n, char* s)
{
port pt;
+#ifndef WITH_CGRAPH
char* cp = strchr(s,':');
+#else /* WITH_CGRAPH */
+ char* cp=NULL;
+ if(s)
+ cp= strchr(s,':');
+#endif /* WITH_CGRAPH */
if (cp) {
*cp = '\0';
pt = pf(n, s, cp+1);
int r = 0;
struct fontinfo fi;
struct fontinfo lfi;
- graph_t *sg = e->tail->graph;
+ graph_t *sg = agraphof(agtail(e));
fi.fontname = NULL;
lfi.fontname = NULL;
+#ifndef WITH_CGRAPH
if (E_label && (str = agxget(e, E_label->index)) && (str[0])) {
+#else
+ if (E_label && (str = agxget(e, E_label)) && (str[0])) {
+#endif
r = 1;
initFontEdgeAttr(e, &fi);
ED_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
/* vladimir */
+#ifndef WITH_CGRAPH
if (E_headlabel && (str = agxget(e, E_headlabel->index)) && (str[0])) {
+#else
+ if (E_headlabel && (str = agxget(e, E_headlabel)) && (str[0])) {
+#endif
initFontLabelEdgeAttr(e, &fi, &lfi);
ED_head_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
lfi.fontsize, lfi.fontname, lfi.fontcolor);
GD_has_labels(sg) |= HEAD_LABEL;
}
+#ifndef WITH_CGRAPH
if (E_taillabel && (str = agxget(e, E_taillabel->index)) && (str[0])) {
+#else
+ if (E_taillabel && (str = agxget(e, E_taillabel)) && (str[0])) {
+#endif
if (!lfi.fontname)
initFontLabelEdgeAttr(e, &fi, &lfi);
ED_tail_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
/* We still accept ports beginning with colons but this is deprecated */
str = agget(e, TAIL_ID);
- if (str[0])
- ND_has_port(e->tail) = TRUE;
- ED_tail_port(e) = chkPort (ND_shape(e->tail)->fns->portfn,e->tail, str);
+ if (str && str[0])
+ ND_has_port(agtail(e)) = TRUE;
+ ED_tail_port(e) = chkPort (ND_shape(agtail(e))->fns->portfn, agtail(e), str);
if (noClip(e, E_tailclip))
ED_tail_port(e).clip = FALSE;
str = agget(e, HEAD_ID);
- if (str[0])
- ND_has_port(e->head) = TRUE;
- ED_head_port(e) = chkPort(ND_shape(e->head)->fns->portfn,e->head, str);
+ if (str && str[0])
+ ND_has_port(aghead(e)) = TRUE;
+ ED_head_port(e) = chkPort(ND_shape(aghead(e))->fns->portfn, aghead(e), str);
if (noClip(e, E_headclip))
ED_head_port(e).clip = FALSE;
if (ED_spl(e) == 0)
continue;
for (i = 0; i < ED_spl(e)->size; i++) {
+#ifndef WITH_CGRAPH
for (j = 0; j < ED_spl(e)->list[i].size; j++) {
+#else
+ for (j = 0; j < (((Agedgeinfo_t*)AGDATA(e))->spl)->list[i].size; j++) {
+#endif
ptf = ED_spl(e)->list[i].list[j];
EXPANDBP(bb,ptf);
}
}
for (i = 1; i <= GD_n_cluster(g); i++) {
- B2BF(GD_clust(g)[i]->u.bb, BF);
+ B2BF(GD_bb(GD_clust(g)[i]), BF);
EXPANDBB(bb,BF);
}
{
if (ap == NULL) {
switch (agobjkind(obj)) {
+#ifndef WITH_CGRAPH
case AGGRAPH:
ap = agraphattr(g, name, "");
+#else /* WITH_CGRAPH */
+ case AGRAPH:
+ ap = agattr(g, AGRAPH,name, "",1);
+#endif /* WITH_CGRAPH */
break;
case AGNODE:
+#ifndef WITH_CGRAPH
ap = agnodeattr(g, name, "");
+#else /* WITH_CGRAPH */
+ ap = agattr(g,AGNODE, name, "",1);
+#endif /* WITH_CGRAPH */
break;
case AGEDGE:
+#ifndef WITH_CGRAPH
ap = agedgeattr(g, name, "");
+#else /* WITH_CGRAPH */
+ ap = agattr(g,AGEDGE, name, "",1);
+#endif /* WITH_CGRAPH */
break;
}
}
+#ifndef WITH_CGRAPH
agxset(obj, ap->index, value);
+#else /* WITH_CGRAPH */
+ agxset(obj, ap, value);
+#endif /* WITH_CGRAPH */
return ap;
}
sprintf(num, "%d", idx++);
agxbput(xb, num);
agxbputc(xb, ':');
- agxbput(xb, cg->name);
+ agxbput(xb, agnameof(cg));
+
+#ifndef WITH_CGRAPH
+ cn = agnode(agroot(cg), agxbuse(xb));
+#else
+ cn = agnode(agroot(cg), agxbuse(xb), 1);
+ agbindrec(cn, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
- cn = agnode(cg->root, agxbuse(xb));
SET_CLUST_NODE(cn);
+#ifndef WITH_CGRAPH
aginsert(cg, cn);
aginsert(clg, n);
+#else /* WITH_CGRAPH */
+ agsubnode(cg,cn,1);
+ //aginsert(cg, cn);
+ agsubnode(clg,n,1);
+ //aginsert(clg, n);
+#endif /* WITH_CGRAPH */
/* set attributes */
- N_label = setAttr(cn->graph, cn, "label", "", N_label);
- N_style = setAttr(cn->graph, cn, "style", "invis", N_style);
- N_shape = setAttr(cn->graph, cn, "shape", "box", N_shape);
+ N_label = setAttr(agraphof(cn), cn, "label", "", N_label);
+ N_style = setAttr(agraphof(cn), cn, "style", "invis", N_style);
+ N_shape = setAttr(agraphof(cn), cn, "shape", "box", N_shape);
/* N_width = setAttr (cn->graph, cn, "width", "0.0001", N_width); */
return cn;
*/
static edge_t *cloneEdge(edge_t * e, node_t * ct, node_t * ch)
{
- graph_t *g = ct->graph;
+ graph_t *g = agraphof(ct);
+#ifndef WITH_CGRAPH
edge_t *ce = agedge(g, ct, ch);
+#else /* WITH_CGRAPH */
+ edge_t *ce = agedge(g, ct, ch,NULL,1);
+#endif /* WITH_CGRAPH */
agcopyattr(e, ce);
return ce;
dummy.p[0] = t;
dummy.p[1] = h;
- dummy.t = e->tail;
- dummy.h = e->head;
+ dummy.t = agtail(e);
+ dummy.h = aghead(e);
dtinsert(map, &dummy);
dummy.p[0] = h;
dummy.p[1] = t;
- dummy.t = e->head;
- dummy.h = e->tail;
+ dummy.t = aghead(e);
+ dummy.h = agtail(e);
dtinsert(map, &dummy);
}
{
void *key[2];
- key[0] = e->tail;
- key[1] = e->head;
+ key[0] = agtail(e);
+ key[1] = aghead(e);
return (item *) dtmatch(map, &key);
}
* so we could use a simpler model in which we create a single cluster
* node for each cluster used in a cluster edge.
*/
+#ifndef WITH_CGRAPH
#define MAPC(n) (strncmp((n)->name,"cluster",7)?NULL:agfindsubg((n)->graph, (n)->name))
+#else /* WITH_CGRAPH */
+#define MAPC(n) (strncmp(agnameof(n),"cluster",7)?NULL:agsubg(agraphof(n), agnameof(n),0))
+#endif /* WITH_CGRAPH */
static void
checkCompound(edge_t * e, graph_t * clg, agxbuf * xb, Dt_t * map)
graph_t *hg;
node_t *cn;
node_t *cn1;
- node_t *t = e->tail;
- node_t *h = e->head;
+ node_t *t = agtail(e);
+ node_t *h = aghead(e);
edge_t *ce;
item *ip;
if (!tg && !hg)
return;
if (tg == hg) {
- agerr(AGWARN, "cluster cycle %s -- %s not supported\n", t->name,
- t->name);
+ agerr(AGWARN, "cluster cycle %s -- %s not supported\n", agnameof(t),
+ agnameof(t));
return;
}
ip = mapEdge(map, e);
if (tg) {
if (agcontains(hg, tg)) {
agerr(AGWARN, "tail cluster %s inside head cluster %s\n",
- tg->name, hg->name);
+ agnameof(tg), agnameof(hg));
return;
}
if (agcontains(tg, hg)) {
agerr(AGWARN, "head cluster %s inside tail cluster %s\n",
- hg->name, tg->name);
+ agnameof(hg),agnameof(tg));
return;
}
cn = clustNode(t, tg, xb, clg);
} else {
if (agcontains(hg, t)) {
agerr(AGWARN, "tail node %s inside head cluster %s\n",
- t->name, hg->name);
+ agnameof(t), agnameof(hg));
return;
}
cn = clustNode(h, hg, xb, clg);
}
} else {
if (agcontains(tg, h)) {
- agerr(AGWARN, "head node %s inside tail cluster %s\n", h->name,
- tg->name);
+ agerr(AGWARN, "head node %s inside tail cluster %s\n", agnameof(h),
+ agnameof(tg));
return;
}
cn = clustNode(t, tg, xb, clg);
unsigned char buf[SMALLBUF];
map = dtopen(&mapDisc, Dtoset);
+#ifndef WITH_CGRAPH
clg = agsubg(g, "__clusternodes");
+#else /* WITH_CGRAPH */
+ clg = agsubg(g, "__clusternodes",1);
+ agbindrec(clg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
agxbinit(&xb, SMALLBUF, buf);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
if (IS_CLUST_NODE(n)) continue;
*/
static node_t *mapN(node_t * n, graph_t * clg)
{
+#ifndef WITH_CGRAPH
extern Agdict_t *agdictof(void *);
+#endif /* WITH_CGRAPH */
node_t *nn;
char *name;
- graph_t *g = n->graph;
+ graph_t *g = agraphof(n);
+#ifndef WITH_CGRAPH
Agdict_t *d;
+#endif /* WITH_CGRAPH */
Agsym_t **list;
Agsym_t *sym;
if (!(IS_CLUST_NODE(n)))
return n;
+#ifndef WITH_CGRAPH
aginsert(clg, n);
-
- name = strchr(n->name, ':');
+#else /* WITH_CGRAPH */
+ agsubnode(clg, n,1);
+#endif /* WITH_CGRAPH */
+ name = strchr(agnameof(n), ':');
assert(name);
name++;
+#ifndef WITH_CGRAPH
if ((nn = agfindnode(g, name)))
+#else /* WITH_CGRAPH */
+ if ((nn = agnode(g, name,0)))
+#endif /* WITH_CGRAPH */
return nn;
+#ifndef WITH_CGRAPH
nn = agnode(g, name);
+#else /* WITH_CGRAPH */
+ nn = agnode(g, name,1);
+ agbindrec(nn, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
/* Set all attributes to default */
+#ifndef WITH_CGRAPH
d = agdictof(n);
list = d->list;
while ((sym = *list++)) {
/* Can use pointer comparison because of ref strings. */
if (agxget(nn, sym->index) != sym->value)
agxset(nn, sym->index, sym->value);
+#else /* WITH_CGRAPH */
+ sym=0;
+ while (sym = agnxtattr(g, AGNODE, sym))
+ {
+ if (agxget(nn, sym) != sym->defval)
+ agxset(nn, sym, sym->defval);
+#endif /* WITH_CGRAPH */
}
-
return nn;
}
static void undoCompound(edge_t * e, graph_t * clg)
{
- node_t *t = e->tail;
- node_t *h = e->head;
+ node_t *t = agtail(e);
+ node_t *h = aghead(e);
node_t *ntail;
node_t *nhead;
edge_t *e;
graph_t *clg;
+#ifndef WITH_CGRAPH
clg = agsubg(g, "__clusternodes");
+#else /* WITH_CGRAPH */
+ clg = agsubg(g, "__clusternodes",1);
+ agbindrec(clg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
undoCompound(e, clg);
* with given name. If one does not exist, create it with the
* supplied function fun with default value def.
*/
+#ifndef WITH_CGRAPH
attrsym_t*
safe_dcl(graph_t * g, void *obj, char *name, char *def,
attrsym_t * (*fun) (Agraph_t *, char *, char *))
+#else /* WITH_CGRAPH */
+attrsym_t*
+safe_dcl(graph_t * g, int obj_kind, char *name, char *def)
+#endif /* WITH_CGRAPH */
{
+#ifndef WITH_CGRAPH
attrsym_t *a = agfindattr(obj, name);
if (a == NULL)
a = fun(g, name, def);
+#else /* WITH_CGRAPH */
+ attrsym_t *a = agattr(g,obj_kind,name,(char*)0);
+ if (!a) /*attribute exists*/
+ a=agattr(g,obj_kind,name,def);
+#endif /* WITH_CGRAPH */
return a;
}
{
gv_free_splines(e);
free_label(ED_label(e));
+#ifndef WITH_CGRAPH
memset(&(e->u), 0, sizeof(Agedgeinfo_t));
+#else /* WITH_CGRAPH */
+ /*FIX HERE , shallow cleaning may not be enough here */
+ agdelrec(agraphof(e), e, "Agedgeinfo_t");
+#endif /* WITH_CGRAPH */
}
void gv_cleanup_node(node_t * n)
if (ND_shape(n))
ND_shape(n)->fns->freefn(n);
free_label(ND_label(n));
+#ifndef WITH_CGRAPH
memset(&(n->u), 0, sizeof(Agnodeinfo_t));
+#else /* WITH_CGRAPH */
+ /*FIX HERE , shallow cleaning may not be enough here */
+ agdelrec(agraphof(n), n, "Agnodeinfo_t");
+#endif /* WITH_CGRAPH */
}
void gv_nodesize(node_t * n, boolean flip)