From: north Date: Wed, 31 Jan 2007 19:09:13 +0000 (+0000) Subject: Add penwidth edge attribute. X-Git-Tag: LAST_LIBGRAPH~32^2~5688 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50fab589a80fc6bac8f6e8b3c466dc6dd5a9944c;p=graphviz Add penwidth edge attribute. --- diff --git a/lib/common/emit.c b/lib/common/emit.c index 7c15cd2e3..9a8ff0b5c 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -1271,6 +1271,7 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e) splinesf offspl, tmpspl; pointf pf0, pf1, pf2 = { 0, 0 }, pf3, *offlist, *tmplist; double scale, numc2; + double penwidth; char *p; #define SEP 2.0 @@ -1293,10 +1294,8 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e) scale = late_double(e, E_arrowsz, 1.0, 0.0); color = late_string(e, E_color, ""); - if (color[0] || styles) { - if (styles) - gvrender_set_style(job, styles); - } + if (styles) gvrender_set_style(job, styles); + /* need to know how many colors separated by ':' */ for (p = color; *p; p++) if (*p == ':') @@ -1323,6 +1322,10 @@ static void emit_edge_graphics(GVJ_t * job, edge_t * e) default_pencolor(pencolor, DEFAULT_VISITEDPENCOLOR)); fillcolor = late_nnstring(e, E_visitedfillcolor, DEFAULT_VISITEDFILLCOLOR); } + if (E_penwidth && agxget(e,E_penwidth->index)) { + penwidth = late_double(e, E_penwidth, 1.0, 0.0); + gvrender_set_penwidth(job, penwidth); + } if (pencolor != color) gvrender_set_pencolor(job, pencolor); if (fillcolor != color) diff --git a/lib/common/globals.h b/lib/common/globals.h index be887a4d8..78b62d789 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -116,7 +116,8 @@ extern "C" { *E_headlabel, *E_taillabel, *E_labelfontsize, *E_labelfontname, *E_labelfontcolor, *E_labeldistance, *E_labelangle, - *E_tailclip, *E_headclip; + *E_tailclip, *E_headclip, + *E_penwidth; EXTERN fdpParms_t fdp_parms; diff --git a/lib/common/input.c b/lib/common/input.c index 207ddf425..ca3d195be 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -712,6 +712,7 @@ void graph_init(graph_t * g, boolean use_rankdir) E_comment = agfindattr(g->proto->e, "comment"); E_tailclip = agfindattr(g->proto->e, "tailclip"); E_headclip = agfindattr(g->proto->e, "headclip"); + E_penwidth = agfindattr(g->proto->e, "penwidth"); } void graph_cleanup(graph_t *g) diff --git a/lib/common/types.h b/lib/common/types.h index 4ba0dda8d..7fb9f83fb 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -228,6 +228,7 @@ extern "C" { boolean bezier_has_arrows; void (*comment) (char *str); void (*usershape) (usershape_t *us, boxf b, point * A, int sides, boolean filled); + void (*set_penwidth) (double penwidth); }; struct codegen_info_s { diff --git a/lib/gvc/gvrender.c b/lib/gvc/gvrender.c index 17a0a0755..048d918cc 100644 --- a/lib/gvc/gvrender.c +++ b/lib/gvc/gvrender.c @@ -700,7 +700,7 @@ void gvrender_set_style(GVJ_t * job, char **s) obj->rawstyle = s; if (gvre) { - while ((p = line = *s++)) { + if (s) while ((p = line = *s++)) { if (streq(line, "solid")) obj->pen = PEN_SOLID; else if (streq(line, "dashed")) @@ -990,3 +990,21 @@ void gvrender_usershape(GVJ_t * job, char *name, pointf * a, int n, boolean fill } #endif } + +void gvrender_set_penwidth(GVJ_t * job, double penwidth) +{ + gvrender_engine_t *gvre = job->render.engine; + + if (gvre) { + job->obj->penwidth = penwidth; + /*if (gvre->set_penwidth) gvre->set_penwidth(job, penwidth);*/ + } +#ifdef WITH_CODEGENS + else { + codegen_t *cg = job->codegen; + + if (cg && cg->set_penwidth) + cg->set_penwidth(penwidth); + } +#endif +}