From d5935d65c0b347a53d34c0be7c130fb33867d7b3 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 22 Jun 2010 19:58:12 +0000 Subject: [PATCH] Provide lwidth and lheight attribute for graph/cluster labels --- doc/info/attrs.html | 10 ++++++++++ doc/infosrc/attrs | 4 ++++ lib/common/output.c | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/doc/info/attrs.html b/doc/info/attrs.html index ea21b6d82..3a095f7ba 100644 --- a/doc/info/attrs.html +++ b/doc/info/attrs.html @@ -268,11 +268,15 @@ This field indicates which graph component uses the attribute. Gdouble0.0neato only lhead Estring""dot only + lheight +GCdoublewrite only lp EGCpoint write only ltail Estring""dot only + lwidth +GCdoublewrite only margin NGdouble
pointf <device-dependent> @@ -1055,6 +1059,9 @@ This field indicates which graph component uses the attribute. the edge is clipped to the boundary of the cluster. See limitation. +
lheight +
Height of graph or cluster label, in inches. +
lp
Label position, in points. The position indicates the center of the label. @@ -1066,6 +1073,9 @@ This field indicates which graph component uses the attribute. the edge is clipped to the boundary of the cluster. See limitation. +
lwidth +
Width of graph or cluster label, in inches. +
margin
For graphs, this sets x and y margins of canvas, in inches. If the margin is a single double, both margins are set equal to the given value. diff --git a/doc/infosrc/attrs b/doc/infosrc/attrs index dd02428d6..89bb81370 100644 --- a/doc/infosrc/attrs +++ b/doc/infosrc/attrs @@ -561,6 +561,8 @@ if lhead is defined and is the name of a cluster containing the real head, the edge is clipped to the boundary of the cluster. See limitation. +:lheight:GC:double; write +Height of graph or cluster label, in inches. :lp:EGC:point; write Label position, in points. The position indicates the center of the label. @@ -570,6 +572,8 @@ if ltail is defined and is the name of a cluster containing the real tail, the edge is clipped to the boundary of the cluster. See limitation. +:lwidth:GC:double; write +Width of graph or cluster label, in inches. :margin:NG:double/pointf:; For graphs, this sets x and y margins of canvas, in inches. If the margin is a single double, both margins are set equal to the given value. diff --git a/lib/common/output.c b/lib/common/output.c index 3d5cc6acd..f3109317c 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -247,6 +247,11 @@ static void rec_attach_bb(graph_t * g, Agsym_t* bbsym) pt = GD_label(g)->pos; sprintf(buf, "%.5g,%.5g", pt.x, YDIR(pt.y)); agset(g, "lp", buf); + pt = GD_label(g)->dimen; + sprintf(buf, "%.2f", PS2INCH(pt.x)); + agset (g, "lwidth", buf); + sprintf(buf, "%.2f", PS2INCH(pt.y)); + agset (g, "lheight", buf); } for (c = 1; c <= GD_n_cluster(g); c++) rec_attach_bb(GD_clust(g)[c], bbsym); @@ -288,10 +293,17 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) safe_dcl(g, g->proto->e, "tail_lp", "", agedgeattr); if (GD_label(g)) { safe_dcl(g, g, "lp", "", agraphattr); + safe_dcl(g, g, "lwidth", "", agraphattr); + safe_dcl(g, g, "lheight", "", agraphattr); if (GD_label(g)->text[0]) { ptf = GD_label(g)->pos; sprintf(buf, "%.5g,%.5g", ptf.x, YDIR(ptf.y)); agset(g, "lp", buf); + ptf = GD_label(g)->dimen; + sprintf(buf, "%.2f", PS2INCH(ptf.x)); + agset(g, "lwidth", buf); + sprintf(buf, "%.2f", PS2INCH(ptf.y)); + agset(g, "lheight", buf); } } bbsym = safe_dcl(g, g, "bb", "", agraphattr); @@ -313,10 +325,17 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) safe_dcl(g, AGEDGE, "tail_lp", ""); if (GD_label(g)) { safe_dcl(g, AGRAPH, "lp", ""); + safe_dcl(g, AGRAPH, "lwidth", ""); + safe_dcl(g, AGRAPH, "lheight", ""); if (GD_label(g)->text[0]) { ptf = GD_label(g)->pos; sprintf(buf, "%.5g,%.5g", ptf.x, YDIR(ptf.y)); agset(g, "lp", buf); + ptf = GD_label(g)->dimen; + sprintf(buf, "%.2f", PS2INCH(ptf.x)); + agset(g, "lwidth", buf); + sprintf(buf, "%.2f", PS2INCH(ptf.y)); + agset(g, "lheight", buf); } } bbsym = safe_dcl(g, AGRAPH, "bb", ""); -- 2.40.0