From d4c5d4970d9a62d3c937a08a4c4b19520069ddee Mon Sep 17 00:00:00 2001 From: ellson Date: Wed, 15 Oct 2008 12:57:08 +0000 Subject: [PATCH] more cgraph merging --- lib/common/arrows.c | 4 ++-- lib/common/diagen.c | 16 ---------------- lib/common/emit.c | 6 +----- lib/common/htmltable.c | 42 ++++++------------------------------------ lib/common/input.c | 18 ++---------------- lib/common/macros.h | 7 +++++++ 6 files changed, 18 insertions(+), 75 deletions(-) diff --git a/lib/common/arrows.c b/lib/common/arrows.c index 42915cb55..7338b7614 100644 --- a/lib/common/arrows.c +++ b/lib/common/arrows.c @@ -214,9 +214,9 @@ void arrow_flags(Agedge_t * e, int *sflag, int *eflag) int s0, e0; /* pick up arrowhead of opposing edge */ #ifdef WITH_CGRAPH - f = agedge(agraphof(e), aghead(e), agtail(e), (char *)NULL, FALSE); + f = agedge(agraphof(aghead(e)), aghead(e), agtail(e), (char *)NULL, FALSE); #else - f = agfindedge(e->tail->graph, e->head, e->tail); + f = agfindedge(agraphof(aghead(e)), aghead(e), agtail(e)); #endif arrow_flags(f, &s0, &e0); *eflag = *eflag | s0; diff --git a/lib/common/diagen.c b/lib/common/diagen.c index 65faf9c64..5444e9f13 100644 --- a/lib/common/diagen.c +++ b/lib/common/diagen.c @@ -834,22 +834,14 @@ dia_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled) || (strcmp(shape_t, "circle") == 0) || (strcmp(shape_t, "doublecircle") == 0)) { cp_h = diaptf(ND_coord(head)); -#ifdef WITH_CGRAPH if (agisdirected(Rootgraph)) -#else - if (AG_IS_DIRECTED(Rootgraph)) -#endif conn_h = ellipse_connection(cp_h, diapt(A[n - 1])); else conn_h = ellipse_connection(cp_h, diapt(A[0])); } else if (strcmp(shape_t, "record") == 0) { } else { -#ifdef WITH_CGRAPH if (agisdirected(Rootgraph)) -#else - if (AG_IS_DIRECTED(Rootgraph)) -#endif conn_h = box_connection(head, diapt(A[n - 1])); else conn_h = box_connection(head, diapt(A[0])); @@ -859,21 +851,13 @@ dia_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled) || (strcmp(shape_t, "circle") == 0) || (strcmp(shape_t, "doublecircle") == 0)) { cp_t = diaptf(ND_coord(tail)); -#ifdef WITH_CGRAPH if (agisdirected(Rootgraph)) -#else - if (AG_IS_DIRECTED(Rootgraph)) -#endif conn_t = ellipse_connection(cp_t, diapt(A[0])); else conn_t = ellipse_connection(cp_t, diapt(A[n - 1])); } else if (strcmp(shape_t, "record") == 0) { } else { -#ifdef WITH_CGRAPH if (agisdirected(Rootgraph)) -#else - if (AG_IS_DIRECTED(Rootgraph)) -#endif conn_t = box_connection(tail, diapt(A[0])); else conn_t = box_connection(tail, diapt(A[n - 1])); diff --git a/lib/common/emit.c b/lib/common/emit.c index 19583041b..f2c754f25 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1839,11 +1839,7 @@ static void emit_edge(GVJ_t * job, edge_t * e) s = malloc(strlen(e->tail->name) + 2 + strlen(e->head->name) + 1); strcpy(s,e->tail->name); -#ifdef WITH_CGRAPH - if (agisdirected(agraphof(e))) -#else - if (AG_IS_DIRECTED(e->tail->graph)) -#endif + if (agisdirected(agraphof(aghead(e)))) strcat(s,"->"); else diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index a339606b3..8e6c1a12c 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -1226,7 +1226,7 @@ void makeGraphs(htmltbl_t * tbl, graph_t * rowg, graph_t * colg) ED_minlen(e) = y; /* ED_minlen(e) = cp->data.box.UR.y; */ #ifdef DEBUG - fprintf(stderr, "row edge %s -> %s %d\n", t->name, h->name, + fprintf(stderr, "row edge %s -> %s %d\n", agnameof(t), agnameof(h), ED_minlen(e)); #endif elist_append(e, ND_out(t)); @@ -1600,7 +1600,6 @@ size_html_tbl(graph_t *g, htmltbl_t * tbl, htmlcell_t * parent, htmlenv_t * env) static char *nameOf(void *obj, agxbuf * xb) { Agedge_t *ep; -#ifdef WITH_CGRAPH switch (agobjkind(obj)) { case AGRAPH: agxbput(xb, agnameof(((Agraph_t *) obj))); @@ -1612,31 +1611,12 @@ static char *nameOf(void *obj, agxbuf * xb) ep = (Agedge_t *) obj; agxbput(xb, agnameof(agtail(ep))); agxbput(xb, agnameof(aghead(ep))); - if (agisdirected(agraphof(ep))) + if (agisdirected(agraphof(aghead(ep)))) agxbput(xb, "->"); else agxbput(xb, "--"); break; } -#else - switch (agobjkind(obj)) { - case AGGRAPH: - agxbput(xb, ((Agraph_t *) obj)->name); - break; - case AGNODE: - agxbput(xb, ((Agnode_t *) obj)->name); - break; - case AGEDGE: - ep = (Agedge_t *) obj; - agxbput(xb, ep->tail->name); - agxbput(xb, ep->head->name); - if (AG_IS_DIRECTED(ep->tail->graph)) - agxbput(xb, "->"); - else - agxbput(xb, "--"); - break; - } -#endif return agxbuse(xb); } @@ -1785,9 +1765,12 @@ int make_html_label(void *obj, textlabel_t * lp) char *s; env.obj = obj; -#ifdef WITH_CGRAPH switch (agobjkind(obj)) { +#ifdef WITH_CGRAPH case AGRAPH: +#else + case AGGRAPH: +#endif env.g = ((Agraph_t *) obj)->root; break; case AGNODE: @@ -1797,19 +1780,6 @@ int make_html_label(void *obj, textlabel_t * lp) env.g = agraphof(aghead (((Agedge_t *) obj))); break; } -#else - switch (agobjkind(obj)) { - case AGGRAPH: - env.g = ((Agraph_t *) obj)->root; - break; - case AGNODE: - env.g = ((Agnode_t *) obj)->graph; - break; - case AGEDGE: - env.g = ((Agedge_t *) obj)->head->graph; - break; - } -#endif g = env.g->root; env.finfo.size = lp->fontsize; diff --git a/lib/common/input.c b/lib/common/input.c index 7418ae9e6..9329284d8 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -254,8 +254,7 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) Verbose = gvc->common.verbose; CmdName = gvc->common.cmdname; -#ifdef WITH_CGRAPH -#else +#ifndef WITH_CGRAPH aginit(); #endif nfiles = 0; @@ -405,8 +404,7 @@ void dotneato_args_initialize(GVC_t * gvc, int argc, char **argv) } /* set persistent attributes here (if not already set from command line options) */ -#ifdef WITH_CGRAPH -#else +#ifndef WITH_CGRAPH if (!(agfindattr(agprotograph()->proto->n, "label"))) agnodeattr(NULL, "label", NODENAME_ESC); #endif @@ -941,11 +939,7 @@ void do_graph_label(graph_t * sg) /* set label position */ pos = agget(sg, "labelloc"); -#ifdef WITH_CGRAPH if (sg != agroot(sg)) { -#else - if (sg != sg->root) { -#endif if (pos && (pos[0] == 'b')) pos_flag = LABEL_AT_BOTTOM; else @@ -965,22 +959,14 @@ void do_graph_label(graph_t * sg) } GD_label_pos(sg) = pos_flag; -#ifdef WITH_CGRAPH if (sg == agroot(sg)) -#else - if (sg == sg->root) -#endif return; /* Set border information for cluster labels to allow space */ dimen = GD_label(sg)->dimen; PAD(dimen); -#ifdef WITH_CGRAPH if (!GD_flip(agroot(sg))) { -#else - if (!GD_flip(sg->root)) { -#endif if (GD_label_pos(sg) & LABEL_AT_TOP) pos_ix = TOP_IX; else diff --git a/lib/common/macros.h b/lib/common/macros.h index 3ce634576..6291b83ab 100644 --- a/lib/common/macros.h +++ b/lib/common/macros.h @@ -35,6 +35,13 @@ #define SET_RANKDIR(g,rd) (GD_rankdir2(g) = rd) #else #define SET_RANKDIR(g,rd) ((g)->u.rankdir = (rd)) +#define agnameof(x) ((x)->name) +/* warning, agraphof doesn't work for edges */ +#define agraphof(n) ((n)->graph) +#define agroot(g) ((g)->root) +#define aghead(e) ((e)->head) +#define agtail(e) ((e)->tail) +#define agisdirected(g) ((g)->kind & AGFLAG_DIRECTED) #endif #ifndef streq -- 2.40.0