From 61b47604d5528737dcbdaf6615f194b2597d9eae Mon Sep 17 00:00:00 2001 From: ellson Date: Thu, 23 Oct 2008 01:04:54 +0000 Subject: [PATCH] cgraph fixes --- plugin/core/gvloadimage_core.c | 3 -- plugin/core/gvrender_core_dot.c | 88 +++++++++++++++++++++++++++++++++ plugin/core/gvrender_core_fig.c | 6 ++- plugin/core/gvrender_core_map.c | 10 +++- plugin/core/gvrender_core_ps.c | 4 +- plugin/core/gvrender_core_svg.c | 13 +++-- plugin/core/gvrender_core_tk.c | 17 +++---- plugin/core/gvrender_core_vml.c | 5 +- 8 files changed, 119 insertions(+), 27 deletions(-) diff --git a/plugin/core/gvloadimage_core.c b/plugin/core/gvloadimage_core.c index 8d6932dc8..c5d881d4e 100644 --- a/plugin/core/gvloadimage_core.c +++ b/plugin/core/gvloadimage_core.c @@ -28,9 +28,6 @@ #include "gvplugin_loadimage.h" #include "gvio.h" -/* for n->name */ -#include "graph.h" - extern void core_loadimage_xdot(GVJ_t*, usershape_t*, boxf, boolean); extern void epsf_emit_body(GVJ_t *job, usershape_t *us); extern shape_desc *find_user_shape(char *name); diff --git a/plugin/core/gvrender_core_dot.c b/plugin/core/gvrender_core_dot.c index b4b8275b9..44756a85d 100644 --- a/plugin/core/gvrender_core_dot.c +++ b/plugin/core/gvrender_core_dot.c @@ -32,7 +32,11 @@ #include "gvplugin_render.h" #include "gvplugin_device.h" +#ifndef WITH_CGRAPH #include "graph.h" +#else +#include "cgraph.h" +#endif #include "agxbuf.h" #include "utils.h" @@ -155,9 +159,17 @@ static void xdot_end_node(GVJ_t* job) { Agnode_t* n = job->obj->u.n; if (agxblen(xbufs[EMIT_NDRAW])) +#ifndef WITH_CGRAPH agxset(n, xd->n_draw->index, agxbuse(xbufs[EMIT_NDRAW])); +#else /* WITH_CGRAPH */ + agxset(n, xd->n_draw, agxbuse(xbufs[EMIT_NDRAW])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_NLABEL])) +#ifndef WITH_CGRAPH agxset(n, xd->n_l_draw->index, agxbuse(xbufs[EMIT_NLABEL])); +#else /* WITH_CGRAPH */ + agxset(n, xd->n_l_draw, agxbuse(xbufs[EMIT_NLABEL])); +#endif /* WITH_CGRAPH */ } static void xdot_end_edge(GVJ_t* job) @@ -165,26 +177,58 @@ static void xdot_end_edge(GVJ_t* job) Agedge_t* e = job->obj->u.e; if (agxblen(xbufs[EMIT_EDRAW])) +#ifndef WITH_CGRAPH agxset(e, xd->e_draw->index, agxbuse(xbufs[EMIT_EDRAW])); +#else /* WITH_CGRAPH */ + agxset(e, xd->e_draw, agxbuse(xbufs[EMIT_EDRAW])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_TDRAW])) +#ifndef WITH_CGRAPH agxset(e, xd->t_draw->index, agxbuse(xbufs[EMIT_TDRAW])); +#else /* WITH_CGRAPH */ + agxset(e, xd->t_draw, agxbuse(xbufs[EMIT_TDRAW])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_HDRAW])) +#ifndef WITH_CGRAPH agxset(e, xd->h_draw->index, agxbuse(xbufs[EMIT_HDRAW])); +#else /* WITH_CGRAPH */ + agxset(e, xd->h_draw, agxbuse(xbufs[EMIT_HDRAW])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_ELABEL])) +#ifndef WITH_CGRAPH agxset(e, xd->e_l_draw->index,agxbuse(xbufs[EMIT_ELABEL])); +#else /* WITH_CGRAPH */ + agxset(e, xd->e_l_draw,agxbuse(xbufs[EMIT_ELABEL])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_TLABEL])) +#ifndef WITH_CGRAPH agxset(e, xd->tl_draw->index, agxbuse(xbufs[EMIT_TLABEL])); +#else /* WITH_CGRAPH */ + agxset(e, xd->tl_draw, agxbuse(xbufs[EMIT_TLABEL])); +#endif /* WITH_CGRAPH */ if (agxblen(xbufs[EMIT_HLABEL])) +#ifndef WITH_CGRAPH agxset(e, xd->hl_draw->index, agxbuse(xbufs[EMIT_HLABEL])); +#else /* WITH_CGRAPH */ + agxset(e, xd->hl_draw, agxbuse(xbufs[EMIT_HLABEL])); +#endif /* WITH_CGRAPH */ } static void xdot_end_cluster(GVJ_t * job) { Agraph_t* cluster_g = job->obj->u.sg; +#ifndef WITH_CGRAPH agxset(cluster_g, xd->g_draw->index, agxbuse(xbufs[EMIT_CDRAW])); +#else /* WITH_CGRAPH */ + agxset(cluster_g, xd->g_draw, agxbuse(xbufs[EMIT_CDRAW])); +#endif /* WITH_CGRAPH */ if (GD_label(cluster_g)) +#ifndef WITH_CGRAPH agxset(cluster_g, xd->g_l_draw->index, agxbuse(xbufs[EMIT_CLABEL])); +#else /* WITH_CGRAPH */ + agxset(cluster_g, xd->g_l_draw, agxbuse(xbufs[EMIT_CLABEL])); +#endif /* WITH_CGRAPH */ } /* @@ -217,36 +261,71 @@ xdot_begin_graph (graph_t *g, int s_arrows, int e_arrows) xd = GNEW(xdot_state_t); if (GD_n_cluster(g)) +#ifndef WITH_CGRAPH xd->g_draw = safe_dcl(g, g, "_draw_", "", agraphattr); +#else + xd->g_draw = safe_dcl(g, AGRAPH, "_draw_", ""); +#endif else xd->g_draw = NULL; if (GD_has_labels(g) & GRAPH_LABEL) +#ifndef WITH_CGRAPH xd->g_l_draw = safe_dcl(g, g, "_ldraw_", "", agraphattr); +#else + xd->g_l_draw = safe_dcl(g, AGRAPH, "_ldraw_", ""); +#endif else xd->g_l_draw = NULL; +#ifndef WITH_CGRAPH xd->n_draw = safe_dcl(g, g->proto->n, "_draw_", "", agnodeattr); xd->n_l_draw = safe_dcl(g, g->proto->n, "_ldraw_", "", agnodeattr); xd->e_draw = safe_dcl(g, g->proto->e, "_draw_", "", agedgeattr); +#else + xd->n_draw = safe_dcl(g, AGNODE, "_draw_", ""); + xd->n_l_draw = safe_dcl(g, AGNODE, "_ldraw_", ""); + + xd->e_draw = safe_dcl(g, AGEDGE, "_draw_", ""); +#endif if (e_arrows) +#ifndef WITH_CGRAPH xd->h_draw = safe_dcl(g, g->proto->e, "_hdraw_", "", agedgeattr); +#else + xd->h_draw = safe_dcl(g, AGEDGE, "_hdraw_", ""); +#endif else xd->h_draw = NULL; if (s_arrows) +#ifndef WITH_CGRAPH xd->t_draw = safe_dcl(g, g->proto->e, "_tdraw_", "", agedgeattr); +#else + xd->t_draw = safe_dcl(g, AGEDGE, "_tdraw_", ""); +#endif else xd->t_draw = NULL; if (GD_has_labels(g) & EDGE_LABEL) +#ifndef WITH_CGRAPH xd->e_l_draw = safe_dcl(g, g->proto->e, "_ldraw_", "", agedgeattr); +#else + xd->e_l_draw = safe_dcl(g, AGEDGE, "_ldraw_", ""); +#endif else xd->e_l_draw = NULL; if (GD_has_labels(g) & HEAD_LABEL) +#ifndef WITH_CGRAPH xd->hl_draw = safe_dcl(g, g->proto->e, "_hldraw_", "", agedgeattr); +#else + xd->hl_draw = safe_dcl(g, AGEDGE, "_hldraw_", ""); +#endif else xd->hl_draw = NULL; if (GD_has_labels(g) & TAIL_LABEL) +#ifndef WITH_CGRAPH xd->tl_draw = safe_dcl(g, g->proto->e, "_tldraw_", "", agedgeattr); +#else + xd->tl_draw = safe_dcl(g, AGEDGE, "_tldraw_", ""); +#endif else xd->tl_draw = NULL; @@ -283,11 +362,20 @@ static void xdot_end_graph(graph_t* g) if (agxblen(xbufs[EMIT_GDRAW])) { if (!xd->g_draw) +#ifndef WITH_CGRAPH xd->g_draw = safe_dcl(g, g, "_draw_", "", agraphattr); agxset(g, xd->g_draw->index, agxbuse(xbufs[EMIT_GDRAW])); +#else /* WITH_CGRAPH */ + xd->g_draw = safe_dcl(g, AGRAPH, "_draw_", ""); + agxset(g, xd->g_draw, agxbuse(xbufs[EMIT_GDRAW])); +#endif /* WITH_CGRAPH */ } if (GD_label(g)) +#ifndef WITH_CGRAPH agxset(g, xd->g_l_draw->index, agxbuse(xbufs[EMIT_GLABEL])); +#else /* WITH_CGRAPH */ + agxset(g, xd->g_l_draw, agxbuse(xbufs[EMIT_GLABEL])); +#endif /* WITH_CGRAPH */ agsafeset (g, "xdotversion", XDOTVERSION, ""); for (i = 0; i < NUMXBUFS; i++) diff --git a/plugin/core/gvrender_core_fig.c b/plugin/core/gvrender_core_fig.c index d57bf2b43..140d1a84c 100644 --- a/plugin/core/gvrender_core_fig.c +++ b/plugin/core/gvrender_core_fig.c @@ -34,7 +34,11 @@ #include "gvplugin_render.h" #include "gvplugin_device.h" #include "gvio.h" +#ifndef WITH_CGRAPH #include "graph.h" +#else +#include "cgraph.h" +#endif #include "agxbuf.h" #include "utils.h" #include "color.h" @@ -204,7 +208,7 @@ static void fig_begin_graph(GVJ_t * job) gvprintf(job, "# Generated by %s version %s (%s)\n", job->common->info[0], job->common->info[1], job->common->info[2]); gvprintf(job, "# For: %s\n", job->common->user); - gvprintf(job, "# Title: %s\n", obj->u.g->name); + gvprintf(job, "# Title: %s\n", agnameof(obj->u.g)); gvprintf(job, "# Pages: %d\n", job->pagesArraySize.x * job->pagesArraySize.y); gvputs(job, "Portrait\n"); /* orientation */ gvputs(job, "Center\n"); /* justification */ diff --git a/plugin/core/gvrender_core_map.c b/plugin/core/gvrender_core_map.c index 033b30658..0fdb2a396 100644 --- a/plugin/core/gvrender_core_map.c +++ b/plugin/core/gvrender_core_map.c @@ -18,12 +18,18 @@ #include "config.h" #endif +#include + #include "gvplugin_render.h" #include "gvplugin_device.h" #include "gvio.h" /* for g->name */ +#ifndef WITH_CGRAPH #include "graph.h" +#else +#include "cgraph.h" +#endif extern char *xml_string(char *str); extern char *xml_url_string(char *str); @@ -172,12 +178,12 @@ static void map_begin_page(GVJ_t * job) gvputs(job, "default "); gvputs(job, xml_string(obj->url)); gvputs(job, " "); - gvputs(job, xml_string(obj->u.g->name)); + gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, "\n"); } break; case FORMAT_CMAPX: - s = xml_string(obj->u.g->name); + s = xml_string(agnameof(obj->u.g)); gvputs(job, "common->viewNum == 0) { - gvprintf(job, "%%%%Title: %s\n", obj->u.g->name); + gvprintf(job, "%%%%Title: %s\n", agnameof(obj->u.g)); if (job->render.id != FORMAT_EPS) gvputs(job, "%%Pages: (atend)\n"); else @@ -176,7 +176,7 @@ static void psgen_begin_cluster(GVJ_t * job) { obj_state_t *obj = job->obj; - gvprintf(job, "%% %s\n", obj->u.sg->name); + gvprintf(job, "%% %s\n", agnameof(obj->u.g)); gvputs(job, "gsave\n"); } diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 0e1cd5931..c6e18491b 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -40,7 +40,6 @@ #include "gvplugin_device.h" #include "gvio.h" #include "gvcint.h" -#include "graph.h" #include "types.h" /* need the SVG font name schemes */ extern char *strdup_and_subst_obj(char *str, void *obj); @@ -172,9 +171,9 @@ static void svg_begin_graph(GVJ_t * job) obj_state_t *obj = job->obj; gvputs(job, "\n", job->pagesArraySize.x * job->pagesArraySize.y); @@ -220,9 +219,9 @@ static void svg_begin_page(GVJ_t * job) job->scale.x, job->scale.y, -job->rotation, job->translation.x, -job->translation.y); /* default style */ - if (obj->u.g->name[0]) { + if (agnameof(obj->u.g)[0]) { gvputs(job, ""); - gvputs(job, xml_string(obj->u.g->name)); + gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, "\n"); } } @@ -240,7 +239,7 @@ static void svg_begin_cluster(GVJ_t * job) gvputs(job, xml_string(obj->id)); gvputs(job, "\" class=\"cluster\">"); gvputs(job, ""); - gvputs(job, xml_string(obj->u.sg->name)); + gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, "\n"); } @@ -257,7 +256,7 @@ static void svg_begin_node(GVJ_t * job) gvputs(job, xml_string(obj->id)); gvputs(job, "\" class=\"node\">"); gvputs(job, ""); - gvputs(job, xml_string(obj->u.n->name)); + gvputs(job, xml_string(agnameof(obj->u.n))); gvputs(job, "\n"); } diff --git a/plugin/core/gvrender_core_tk.c b/plugin/core/gvrender_core_tk.c index 9d355eca6..48497baaa 100644 --- a/plugin/core/gvrender_core_tk.c +++ b/plugin/core/gvrender_core_tk.c @@ -31,7 +31,6 @@ #include "gvplugin_device.h" #include "gvio.h" #include "gvcint.h" -#include "graph.h" #include "types.h" /* need the SVG font name schemes */ typedef enum { FORMAT_TK, } format_type; @@ -68,23 +67,23 @@ static void tkgen_print_tags(GVJ_t *job) switch (obj->emit_state) { case EMIT_NDRAW: ObjType = "node"; - ObjId = obj->u.n->id; + ObjId = AGID(obj->u.n); break; case EMIT_NLABEL: ObjType = "node label"; - ObjId = obj->u.n->id; + ObjId = AGID(obj->u.n); break; case EMIT_EDRAW: case EMIT_TDRAW: case EMIT_HDRAW: ObjType = "edge"; - ObjId = obj->u.e->id; + ObjId = AGID(obj->u.e); break; case EMIT_ELABEL: case EMIT_TLABEL: case EMIT_HLABEL: ObjType = "edge label"; - ObjId = obj->u.e->id; + ObjId = AGID(obj->u.e); break; case EMIT_GDRAW: ObjType = "graph"; @@ -96,11 +95,11 @@ static void tkgen_print_tags(GVJ_t *job) break; case EMIT_CDRAW: ObjType = "cluster"; - ObjId = obj->u.sg->meta_node->id; + ObjId = AGID(obj->u.sg); break; case EMIT_CLABEL: ObjType = "cluster label"; - ObjId = obj->u.sg->meta_node->id; + ObjId = AGID(obj->u.sg); break; default: assert (0); @@ -142,9 +141,9 @@ static void tkgen_begin_graph(GVJ_t * job) obj_state_t *obj = job->obj; gvputs(job, "#"); - if (obj->u.g->name[0]) { + if (agnameof(obj->u.g)[0]) { gvputs(job, " Title: "); - gvputs(job, tkgen_string(obj->u.g->name)); + gvputs(job, tkgen_string(agnameof(obj->u.g))); } gvprintf(job, " Pages: %d\n", job->pagesArraySize.x * job->pagesArraySize.y); } diff --git a/plugin/core/gvrender_core_vml.c b/plugin/core/gvrender_core_vml.c index 9f332331c..24f2c9fbf 100644 --- a/plugin/core/gvrender_core_vml.c +++ b/plugin/core/gvrender_core_vml.c @@ -28,7 +28,6 @@ #include "gvplugin_render.h" #include "gvplugin_device.h" #include "gvio.h" -#include "graph.h" typedef enum { FORMAT_VML, FORMAT_VMLZ, } format_type; @@ -164,9 +163,9 @@ static void vml_begin_graph(GVJ_t * job) obj_state_t *obj = job->obj; gvputs(job, ""); - if (obj->u.g->name[0]) { + if (agnameof(obj->u.g)[0]) { gvputs(job, ""); - gvputs(job, xml_string(obj->u.g->name)); + gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, ""); } gvprintf(job, "\n\n", job->pagesArraySize.x * job->pagesArraySize.y); -- 2.40.0