From: ellson Date: Wed, 15 Oct 2008 14:25:16 +0000 (+0000) Subject: more cgraph X-Git-Tag: LAST_LIBGRAPH~32^2~3111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81003a3d4483d6ebc187fb1c6a09d782f36c3167;p=graphviz more cgraph --- diff --git a/lib/common/diagen.c b/lib/common/diagen.c index 5444e9f13..b5e8f5923 100644 --- a/lib/common/diagen.c +++ b/lib/common/diagen.c @@ -605,7 +605,7 @@ static void dia_ellipse(point p, int rx, int ry, int filled) switch (Obj) { case NODE: - nodeId = Curnode->id; + nodeId = AGID(Curnode); break; default: nodeId = -1; @@ -790,8 +790,8 @@ dia_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled) if (Curedge) { conn_h = conn_t = -1; - head = Curedge->head; - tail = Curedge->tail; + head = aghead(Curedge); + tail = agtail(Curedge); shape_t = ND_shape(tail)->name; @@ -866,17 +866,17 @@ dia_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled) if (arrow_at_start) { dia_printf (" \n", - head->id, conn_h); + AGID(head), conn_h); dia_printf (" \n", - (n - 1), tail->id, conn_t); + (n - 1), AGID(tail), conn_t); } else { dia_printf (" \n", - tail->id, conn_t); + AGID(tail), conn_t); dia_printf (" \n", - (n - 1), head->id, conn_h); + (n - 1), AGID(head), conn_h); } dia_fputs(" \n"); @@ -902,7 +902,7 @@ static void dia_polygon(point * A, int n, int filled) case NODE: dia_printf (" \n", - Curnode->id); + AGID(Curnode)); break; case EDGE: return; @@ -910,7 +910,7 @@ static void dia_polygon(point * A, int n, int filled) case CLST: dia_printf (" \n", - Curgraph->name); + agnameof(Curgraph)); break; default: dia_printf diff --git a/lib/common/emit.c b/lib/common/emit.c index f2c754f25..e8e758e22 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1010,7 +1010,7 @@ static boolean edge_in_layer(GVJ_t *job, graph_t * g, edge_t * e) if (pe[0]) return FALSE; for (cnt = 0; cnt < 2; cnt++) { - pn = late_string(cnt < 1 ? e->tail : e->head, N_layer, ""); + pn = late_string(cnt < 1 ? agtail(e) : aghead(e), N_layer, ""); if ((pn[0] == '\0') || selectedlayer(job, pn)) return TRUE; } @@ -1057,12 +1057,12 @@ static void emit_begin_node(GVJ_t * job, node_t * n) if (flags & GVRENDER_DOES_Z) { /* obj->z = late_double(n, N_z, 0.0, -MAXFLOAT); */ - if (GD_odim(n->graph) >=3) + if (GD_odim(agraphof(n)) >=3) obj->z = POINTS(ND_pos(n)[2]); else obj->z = 0.0; } - initObjMapData (job, ND_label(n), "node", n->id, n); + initObjMapData (job, ND_label(n), "node", AGID(n), n); if ((flags & (GVRENDER_DOES_MAPS | GVRENDER_DOES_TOOLTIPS)) && (obj->url || obj->explicit_tooltip)) { @@ -1206,13 +1206,13 @@ static void emit_node(GVJ_t * job, node_t * n) char *s; if (ND_shape(n) /* node has a shape */ - && node_in_layer(job, n->graph, n) /* and is in layer */ + && node_in_layer(job, agraphof(n), n) /* and is in layer */ && node_in_box(n, job->clip) /* and is in page/view */ && (ND_state(n) != gvc->common.viewNum)) /* and not already drawn */ { ND_state(n) = gvc->common.viewNum; /* mark node as drawn */ - gvrender_comment(job, n->name); + gvrender_comment(job, agnameof(n)); s = late_string(n, N_comment, ""); if (s[0]) gvrender_comment(job, s); @@ -1531,17 +1531,21 @@ static void emit_begin_edge(GVJ_t * job, edge_t * e, char** styles) */ if (styles && ED_spl(e)) gvrender_set_style(job, styles); +#ifndef WITH_CGRAPH if (E_penwidth && ((s=agxget(e,E_penwidth->index)) && s[0])) { +#else + if (E_penwidth && ((s=agxget(e,E_penwidth)) && s[0])) { +#endif penwidth = late_double(e, E_penwidth, 1.0, 0.0); gvrender_set_penwidth(job, penwidth); } if (flags & GVRENDER_DOES_Z) { - /* obj->tail_z = late_double(e->tail, N_z, 0.0, -1000.0); */ - /* obj->head_z = late_double(e->head, N_z, 0.0, -MAXFLOAT); */ - if (GD_odim(e->tail->graph) >=3) { - obj->tail_z = POINTS(ND_pos(e->tail)[2]); - obj->head_z = POINTS(ND_pos(e->head)[2]); + /* obj->tail_z = late_double(agtail(e), N_z, 0.0, -1000.0); */ + /* obj->head_z = late_double(aghead(e), N_z, 0.0, -MAXFLOAT); */ + if (GD_odim(agraphof(agtail(e))) >=3) { + obj->tail_z = POINTS(ND_pos(agtail(e))[2]); + obj->head_z = POINTS(ND_pos(aghead(e))[2]); } else { obj->tail_z = obj->head_z = 0.0; } @@ -1560,7 +1564,7 @@ static void emit_begin_edge(GVJ_t * job, edge_t * e, char** styles) if (flags & GVRENDER_DOES_MAPS) { s = agget(e, "id"); if (!s || !*s) { /* no external id, so use the internal one */ - sprintf(buf,"edge%d", e->id); + sprintf(buf,"edge%d", AGID(e)); s = buf; } obj->id = strdup_and_subst_obj(s, (void*)e); @@ -1835,16 +1839,16 @@ static void emit_edge(GVJ_t * job, edge_t * e) char **sp; char *p; - if (edge_in_box(e, job->clip) && edge_in_layer(job, e->head->graph, e) ) { + if (edge_in_box(e, job->clip) && edge_in_layer(job, agraphof(aghead(e)), e) ) { - s = malloc(strlen(e->tail->name) + 2 + strlen(e->head->name) + 1); - strcpy(s,e->tail->name); + s = malloc(strlen(agnameof(agtail(e))) + 2 + strlen(agnameof(aghead(e))) + 1); + strcpy(s,agnameof(agtail(e))); if (agisdirected(agraphof(aghead(e)))) strcat(s,"->"); else strcat(s,"--"); - strcat(s,e->head->name); + strcat(s,agnameof(aghead(e))); gvrender_comment(job, s); free(s); @@ -1937,7 +1941,7 @@ static void init_gvc(GVC_t * gvc, graph_t * g) /* default line style */ gvc->defaultlinestyle = defaultlinestyle; - gvc->graphname = g->name; + gvc->graphname = agnameof(g); } static void init_job_pad(GVJ_t *job) @@ -2193,7 +2197,7 @@ static void emit_view(GVJ_t * job, graph_t * g, int flags) for (n = agfstnode(g); n; n = agnxtnode(g, n)) { emit_node(job, n); for (e = agfstout(g, n); e; e = agnxtout(g, e)) { - emit_node(job, e->head); + emit_node(job, aghead(e)); emit_edge(job, e); } } @@ -2508,7 +2512,11 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) if (!pencolor) pencolor = DEFAULT_COLOR; if (!fillcolor) fillcolor = DEFAULT_FILL; +#ifndef WITH_CGRAPH if (G_penwidth && ((s=agxget(sg, G_penwidth->index)) && s[0])) { +#else + if (G_penwidth && ((s=agxget(sg, G_penwidth)) && s[0])) { +#endif penwidth = late_double(sg, G_penwidth, 1.0, 0.0); gvrender_set_penwidth(job, penwidth); } diff --git a/lib/common/labels.c b/lib/common/labels.c index 0de34153d..5ab912b24 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -127,19 +127,11 @@ textlabel_t *make_label(void *obj, char *str, int kind, double fontsize, char *f break; case AGNODE: n = (node_t*)obj; -#ifndef WITH_CGRAPH - g = n->graph->root; -#else g = agroot(agraphof(n)); -#endif break; case AGEDGE: e = (edge_t*)obj; -#ifndef WITH_CGRAPH - g = e->head->graph->root; -#else g = agroot(agraphof(aghead(e))); -#endif break; } rv->fontname = fontname; @@ -157,29 +149,15 @@ textlabel_t *make_label(void *obj, char *str, int kind, double fontsize, char *f rv->html = TRUE; if (make_html_label(obj, rv)) { switch (agobjkind(obj)) { -#ifndef WITH_CGRAPH - case AGGRAPH: - agerr(AGPREV, "in label of graph %s\n",sg->name); -#else case AGRAPH: agerr(AGPREV, "in label of graph %s\n",agnameof(sg)); -#endif break; case AGNODE: -#ifndef WITH_CGRAPH - agerr(AGPREV, "in label of node %s\n", n->name); -#else agerr(AGPREV, "in label of node %s\n", agnameof(n)); -#endif break; case AGEDGE: -#ifndef WITH_CGRAPH - agerr(AGPREV, "in label of edge %s %s %s\n", - e->tail->name, AG_IS_DIRECTED(g)?"->":"--", e->head->name); -#else agerr(AGPREV, "in label of edge %s %s %s\n", agnameof(agtail(e)), agisdirected(g)?"->":"--", agnameof(aghead(e))); -#endif break; } } @@ -302,11 +280,10 @@ char *strdup_and_subst_obj(char *str, void *obj) switch (agobjkind(obj)) { #ifndef WITH_CGRAPH case AGGRAPH: - g_str = ((graph_t *)obj)->name; #else case AGRAPH: - g_str = agnameof((graph_t *)obj); #endif + g_str = agnameof((graph_t *)obj); g_len = strlen(g_str); tl = GD_label((graph_t *)obj); if (tl) { @@ -315,15 +292,9 @@ char *strdup_and_subst_obj(char *str, void *obj) } break; case AGNODE: -#ifndef WITH_CGRAPH - g_str = ((node_t *)obj)->graph->name; - g_len = strlen(g_str); - n_str = ((node_t *)obj)->name; -#else g_str = agnameof(agraphof((node_t *)obj)); g_len = strlen(g_str); n_str = agnameof((node_t *)obj); -#endif n_len = strlen(n_str); tl = ND_label((node_t *)obj); if (tl) { @@ -332,16 +303,6 @@ char *strdup_and_subst_obj(char *str, void *obj) } break; case AGEDGE: -#ifndef WITH_CGRAPH - g_str = ((edge_t *)obj)->tail->graph->root->name; - g_len = strlen(g_str); - t_str = ((edge_t *)obj)->tail->name; - t_len = strlen(t_str); - pt = ED_tail_port((edge_t *)obj); - if ((tp_str = pt.name)) - tp_len = strlen(tp_str); - h_str = ((edge_t *)obj)->head->name; -#else g_str = agnameof(agroot(agraphof(agtail(((edge_t *)obj))))); g_len = strlen(g_str); t_str = agnameof(agtail(((edge_t *)obj))); @@ -350,7 +311,6 @@ char *strdup_and_subst_obj(char *str, void *obj) if ((tp_str = pt.name)) tp_len = strlen(tp_str); h_str = agnameof(aghead(((edge_t *)obj))); -#endif h_len = strlen(h_str); pt = ED_head_port((edge_t *)obj); if ((hp_str = pt.name)) @@ -361,11 +321,7 @@ char *strdup_and_subst_obj(char *str, void *obj) l_str = tl->text; if (str) l_len = strlen(l_str); } -#ifndef WITH_CGRAPH - if (((edge_t *)obj)->tail->graph->root->kind & AGFLAG_DIRECTED) -#else if (agisdirected(agroot(agraphof(agtail(((edge_t*)obj)))))) -#endif e_str = "->"; else e_str = "--"; diff --git a/lib/common/macros.h b/lib/common/macros.h index 6291b83ab..a94b97ee9 100644 --- a/lib/common/macros.h +++ b/lib/common/macros.h @@ -42,6 +42,7 @@ #define aghead(e) ((e)->head) #define agtail(e) ((e)->tail) #define agisdirected(g) ((g)->kind & AGFLAG_DIRECTED) +#define AGID(x) ((x)->id) #endif #ifndef streq diff --git a/lib/common/mifgen.c b/lib/common/mifgen.c index 344668f6f..0e50486bc 100644 --- a/lib/common/mifgen.c +++ b/lib/common/mifgen.c @@ -157,7 +157,7 @@ mif_begin_job(FILE * ofp, graph_t * g, const char **lib, char *user, " # Generated by %s version %s (%s)\n", info[0], info[1], info[2]); fprintf(Output_file, "# For: %s\n", user); - fprintf(Output_file, "# Title: %s\n", g->name); + fprintf(Output_file, "# Title: %s\n", agnameof(g)); fprintf(Output_file, "# Pages: %d\n", N_pages); fprintf(Output_file, "\n"); fprintf(Output_file, "id + 1, n->id, p->vtxshape); + " (type %s)\n", AGID(n) + 1, AGID(n), p->vtxshape); } static void vtx_end_node(void) @@ -336,7 +336,7 @@ static void vtx_begin_edge(edge_t * e) " (locked F)\n" " (start %d)\n" " (end %d)\n", - e->id + 1, e->id, e->tail->id + 1, e->head->id + 1); + AGID(e) + 1, AGID(e), AGID(agtail(e)) + 1, AGID(aghead(e)) + 1); } static void vtx_end_edge(void)