]> granicus.if.org Git - graphviz/commitdiff
more cgraph merging
authorellson <devnull@localhost>
Wed, 15 Oct 2008 12:57:08 +0000 (12:57 +0000)
committerellson <devnull@localhost>
Wed, 15 Oct 2008 12:57:08 +0000 (12:57 +0000)
lib/common/arrows.c
lib/common/diagen.c
lib/common/emit.c
lib/common/htmltable.c
lib/common/input.c
lib/common/macros.h

index 42915cb553cebebb86c9c1b01cb2c3e02feca6b7..7338b7614bb2002d6e8a39d925539e704bc66004 100644 (file)
@@ -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;
index 65faf9c64c9dcf454e249d53fd22af63e14d2a40..5444e9f13a08a092f4024b4cdde1109904718676 100644 (file)
@@ -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]));
index 19583041b38d18ee06d0379e422838b11ff7810d..f2c754f251ba6d2d7a29ced80e815dad0d264a34 100644 (file)
@@ -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
index a339606b3aefec17d8e3d109b366441734876ae3..8e6c1a12c53b8feaf42c21553b43c344959e0bcb 100644 (file)
@@ -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;
index 7418ae9e63eb2b9437cb7880a115c0f03f138bdc..9329284d87b0ea6fcebb5efb6c12a95fba8a1464 100644 (file)
@@ -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
index 3ce634576fa3d7a105e9185eecfa5cf3b5f9a65e..6291b83abca3d92c033095ef9ccd79ee99abd844 100644 (file)
 #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