From a865bb66aef7e751f2c1a235819c77007b16050f Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 15 Aug 2008 21:37:36 +0000 Subject: [PATCH] convert all label processing to fp clean up h/v alignment code --- lib/common/emit.c | 25 ++++---- lib/common/geom.c | 16 ++++++ lib/common/geomprocs.h | 1 + lib/common/htmltable.c | 111 +++++++++++++++++------------------ lib/common/htmltable.h | 8 +-- lib/common/labels.c | 34 +++++------ lib/common/ns.c | 15 +++-- lib/common/output.c | 58 +++++++++---------- lib/common/postproc.c | 16 +++--- lib/common/render.h | 2 +- lib/common/shapes.c | 127 ++++++++++++++++++----------------------- lib/common/splines.c | 23 ++++---- 12 files changed, 212 insertions(+), 224 deletions(-) diff --git a/lib/common/emit.c b/lib/common/emit.c index 65c2166e4..599f13940 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -174,7 +174,7 @@ static void map_point(GVJ_t *job, point P) } } -void emit_map_rect(GVJ_t *job, point LL, point UR) +void emit_map_rect(GVJ_t *job, boxf b) { obj_state_t *obj = job->obj; int flags = job->flags; @@ -191,8 +191,8 @@ void emit_map_rect(GVJ_t *job, point LL, point UR) } free(obj->url_map_p); obj->url_map_p = p = N_NEW(obj->url_map_n, pointf); - P2PF(LL,p[0]); - P2PF(UR,p[1]); + p[0] = b.LL; + p[1] = b.UR; if (! (flags & GVRENDER_DOES_TRANSFORM)) gvrender_ptf_A(job, p, p, 2); if (! (flags & GVRENDER_DOES_MAP_RECTANGLE)) @@ -217,7 +217,7 @@ static void map_label(GVJ_t *job, textlabel_t *lab) } free(obj->url_map_p); obj->url_map_p = p = N_NEW(obj->url_map_n, pointf); - P2RECT(lab->p, p, lab->dimen.x / 2., lab->dimen.y / 2.); + P2RECT(lab->pos, p, lab->dimen.x / 2., lab->dimen.y / 2.); if (! (flags & GVRENDER_DOES_TRANSFORM)) gvrender_ptf_A(job, p, p, 2); if (! (flags & GVRENDER_DOES_MAP_RECTANGLE)) @@ -1256,7 +1256,6 @@ static pointf computeoffset_qr(pointf p, pointf q, pointf r, pointf s, static void emit_attachment(GVJ_t * job, textlabel_t * lp, splines * spl) { pointf sz, AF[3]; - point p; unsigned char *s; for (s = (unsigned char *) (lp->text); *s; s++) { @@ -1267,10 +1266,9 @@ static void emit_attachment(GVJ_t * job, textlabel_t * lp, splines * spl) return; sz = lp->dimen; - AF[0] = pointfof((double)(lp->p.x) + sz.x / 2., (double)(lp->p.y) - sz.y / 2.); + AF[0] = pointfof(lp->pos.x + sz.x / 2., lp->pos.y - sz.y / 2.); AF[1] = pointfof(AF[0].x - sz.x, AF[0].y); - p = dotneato_closest(spl, lp->p); - P2PF(p,AF[2]); + AF[2] = dotneato_closest(spl, lp->pos); /* Don't use edge style to draw attachment */ gvrender_set_style(job, job->gvc->defaultlinestyle); /* Use font color to draw attachment @@ -2303,7 +2301,6 @@ static void emit_page(GVJ_t * job, graph_t * g) obj_state_t *obj = job->obj; int nump = 0, flags = job->flags; textlabel_t *lab; - point p1, p2; pointf *p = NULL; setColorScheme (agget (g, "colorscheme")); @@ -2342,9 +2339,7 @@ static void emit_page(GVJ_t * job, graph_t * g) * or end_page of renderer. */ if (!(flags & EMIT_CLUSTERS_LAST) && (obj->url || obj->explicit_tooltip)) { - PF2P(job->clip.LL, p1); - PF2P(job->clip.UR, p2); - emit_map_rect(job, p1, p2); + emit_map_rect(job, job->clip); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target); } if (job->numLayers == 1) @@ -2520,6 +2515,7 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) sg = GD_clust(g)[c]; if (clust_in_layer(job, sg) == FALSE) continue; + B2BF(GD_bb(sg), BF); /* when mapping, detect events on clusters after sub_clusters */ if (flags & EMIT_CLUSTERS_LAST) emit_clusters(job, sg, flags); @@ -2529,7 +2525,7 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) setColorScheme (agget (sg, "colorscheme")); gvrender_begin_context(job); if (doAnchor && !(flags & EMIT_CLUSTERS_LAST)) { - emit_map_rect(job, GD_bb(sg).LL, GD_bb(sg).UR); + emit_map_rect(job, BF); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target); } filled = FALSE; @@ -2581,7 +2577,6 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) gvrender_set_penwidth(job, penwidth); } - B2BF(GD_bb(sg), BF); if (istyle & ROUNDED) { if (late_int(sg, G_peripheries, 1, 0) || filled) { AF[0] = BF.LL; @@ -2609,7 +2604,7 @@ void emit_clusters(GVJ_t * job, Agraph_t * g, int flags) if (doAnchor) { if (flags & EMIT_CLUSTERS_LAST) { - emit_map_rect(job, GD_bb(sg).LL, GD_bb(sg).UR); + emit_map_rect(job, BF); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target); } gvrender_end_anchor(job); diff --git a/lib/common/geom.c b/lib/common/geom.c index 7b72bc4db..6a2c1eb42 100644 --- a/lib/common/geom.c +++ b/lib/common/geom.c @@ -519,6 +519,22 @@ box flip_rec_box(box b, point p) return rv; } +boxf flip_rec_boxf(boxf b, pointf p) +{ + boxf rv; + /* flip box */ + rv.UR.x = b.UR.y; + rv.UR.y = b.UR.x; + rv.LL.x = b.LL.y; + rv.LL.y = b.LL.x; + /* move box */ + rv.LL.x += p.x; + rv.LL.y += p.y; + rv.UR.x += p.x; + rv.UR.y += p.y; + return rv; +} + /* ptToLine2: * Return distance from point p to line a-b squared. */ diff --git a/lib/common/geomprocs.h b/lib/common/geomprocs.h index df88bb75d..d083e69f9 100644 --- a/lib/common/geomprocs.h +++ b/lib/common/geomprocs.h @@ -60,6 +60,7 @@ extern int box_contains(box, box); extern int boxf_contains(boxf, boxf); extern box flip_rec_box(box b, point p); +extern boxf flip_rec_boxf(boxf b, pointf p); extern double ptToLine2 (pointf l1, pointf l2, pointf p); diff --git a/lib/common/htmltable.c b/lib/common/htmltable.c index c2cd187cd..e7b0ea094 100644 --- a/lib/common/htmltable.c +++ b/lib/common/htmltable.c @@ -44,7 +44,7 @@ #define DEFAULT_CELLSPACING 2 typedef struct { - point p; + pointf pos; htmlfont_t finfo; void *obj; graph_t *g; @@ -111,10 +111,10 @@ static void popFontInfo(htmlenv_t * env, htmlfont_t * savp) static void emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p, - double halfwidth_x, char* fname, double fsize, char* fcolor, box b) + double halfwidth_x, char* fname, double fsize, char* fcolor, boxf b) { int i,j; - double tmp, center_x, left_x, right_x, fsize_; + double center_x, left_x, right_x, fsize_; char *fname_ , *fcolor_; textpara_t tl; pointf p_ = {0.0, 0.0}; @@ -127,9 +127,7 @@ emit_htextparas(GVJ_t* job, int nparas, htextpara_t* paras, pointf p, /* Initial p is in center of text block; set initial baseline * to top of text block. */ - p_.y = p.y + (double)(b.UR.y-b.LL.y)/2.0; - tmp = ROUND(p_.y); /* align with integer points */ - p_.y = (double)tmp; + p_.y = p.y + (b.UR.y-b.LL.y)/2.0; gvrender_begin_context(job); for(i=0; ifinfo.color; halfwidth_x = ((double) (tp->box.UR.x - tp->box.LL.x)) / 2.0; - p.x = env->p.x + ((double) (tp->box.UR.x + tp->box.LL.x)) / 2.0; - p.y = env->p.y + ((double) (tp->box.UR.y + tp->box.LL.y)) / 2.0; + p.x = env->pos.x + ((double) (tp->box.UR.x + tp->box.LL.x)) / 2.0; + p.y = env->pos.y + ((double) (tp->box.UR.y + tp->box.LL.y)) / 2.0; emit_htextparas(job, tp->nparas, tp->paras, p, halfwidth_x, fname, fsize, fcolor, tp->box); @@ -237,10 +235,9 @@ static void doSide(GVJ_t * job, pointf p, double wd, double ht) * from x to x+border will all pixels from x to x+border, and thus have * width border+1. */ -static void doBorder(GVJ_t * job, char *color, int border, box B) +static void doBorder(GVJ_t * job, char *color, int border, boxf BF) { pointf pt; - boxf BF; double wd, ht; gvrender_begin_context(job); @@ -250,7 +247,6 @@ static void doBorder(GVJ_t * job, char *color, int border, box B) gvrender_set_fillcolor(job, color); gvrender_set_pencolor(job, color); - B2BF(B, BF); if (border == 1) { gvrender_box(job, BF, 0); } else { @@ -270,13 +266,10 @@ static void doBorder(GVJ_t * job, char *color, int border, box B) gvrender_end_context(job); } -static void doFill(GVJ_t * job, char *color, box B) +static void doFill(GVJ_t * job, char *color, boxf BF) { - boxf BF; - gvrender_set_fillcolor(job, color); gvrender_set_pencolor(job, color); - B2BF(B, BF); gvrender_box(job, BF, 1); } @@ -292,7 +285,7 @@ static void doFill(GVJ_t * job, char *color, box B) * for nodes, edges, etc. ? */ static int -initAnchor (GVJ_t* job, htmldata_t* data, box pts, htmlmap_data_t* save, +initAnchor (GVJ_t* job, htmldata_t* data, boxf b, htmlmap_data_t* save, int closePrev) { obj_state_t *obj = job->obj; @@ -308,7 +301,7 @@ initAnchor (GVJ_t* job, htmldata_t* data, box pts, htmlmap_data_t* save, if (closePrev && (save->url || save->explicit_tooltip)) gvrender_end_anchor(job); if (obj->url || obj->explicit_tooltip) { - emit_map_rect(job, pts.LL, pts.UR); + emit_map_rect(job, b); gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target); } } @@ -350,10 +343,10 @@ static void emit_html_cell(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env); static void emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env) { - box pts = tbl->data.box; - point p = env->p; + boxf pts = tbl->data.box; + pointf pos = env->pos; htmlcell_t **cells = tbl->u.n.cells; - htmlfont_t savef; + static htmlfont_t savef; htmlmap_data_t saved; int anchor; /* if true, we need to undo anchor settings. */ int doAnchor = (tbl->data.href || tbl->data.target); @@ -361,10 +354,10 @@ emit_html_tbl(GVJ_t * job, htmltbl_t * tbl, htmlenv_t * env) if (tbl->font) pushFontInfo(env, tbl->font, &savef); - pts.LL.x += p.x; - pts.UR.x += p.x; - pts.LL.y += p.y; - pts.UR.y += p.y; + pts.LL.x += pos.x; + pts.UR.x += pos.x; + pts.LL.y += pos.y; + pts.UR.y += pos.y; if (doAnchor && !(job->flags & EMIT_CLUSTERS_LAST)) anchor = initAnchor(job, &tbl->data, pts, &saved, 1); @@ -403,16 +396,16 @@ static void emit_html_img(GVJ_t * job, htmlimg_t * cp, htmlenv_t * env) { pointf A[4]; - box bb = cp->box; + boxf bb = cp->box; char* scale; - bb.LL.x += env->p.x; - bb.LL.y += env->p.y; - bb.UR.x += env->p.x; - bb.UR.y += env->p.y; + bb.LL.x += env->pos.x; + bb.LL.y += env->pos.y; + bb.UR.x += env->pos.x; + bb.UR.y += env->pos.y; - P2PF(bb.UR, A[0]); - P2PF(bb.LL, A[2]); + A[0] = bb.UR; + A[2] = bb.LL; A[1].x = A[2].x; A[1].y = A[0].y; A[3].x = A[0].x; @@ -429,14 +422,14 @@ static void emit_html_cell(GVJ_t * job, htmlcell_t * cp, htmlenv_t * env) { htmlmap_data_t saved; - box pts = cp->data.box; - point p = env->p; + boxf pts = cp->data.box; + pointf pos = env->pos; int inAnchor, doAnchor = (cp->data.href || cp->data.target); - pts.LL.x += p.x; - pts.UR.x += p.x; - pts.LL.y += p.y; - pts.UR.y += p.y; + pts.LL.x += pos.x; + pts.UR.x += pos.x; + pts.LL.y += pos.y; + pts.UR.y += pos.y; if (doAnchor && !(job->flags & EMIT_CLUSTERS_LAST)) inAnchor = initAnchor(job, &cp->data, pts, &saved, 1); @@ -533,7 +526,7 @@ emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t * tp) htmlenv_t env; allocObj (job); - env.p = tp->p; + env.pos = tp->pos; env.finfo.color = tp->fontcolor; env.finfo.name = tp->fontname; env.finfo.size = tp->fontsize; @@ -709,11 +702,11 @@ portToTbl(htmltbl_t* tp, char* id) * If successful, return pointer to port's box. * Else return NULL. */ -box *html_port(node_t * n, char *pname, int* sides) +boxf *html_port(node_t * n, char *pname, int* sides) { htmldata_t* tp; htmllabel_t* lbl = ND_label(n)->u.html; - box* rv = NULL; + boxf* rv = NULL; if (lbl->kind == HTML_TEXT) return NULL; @@ -872,7 +865,7 @@ static int size_html_img(htmlimg_t * img, htmlenv_t * env) GD_has_images(env->g) = TRUE; } - img->box = b; + B2BF(b, img->box); return rv; } @@ -882,7 +875,7 @@ static int size_html_cell(graph_t *g, htmlcell_t * cp, htmltbl_t * parent, htmlenv_t * env) { int rv; - point sz, child_sz; + pointf sz, child_sz; int margin; cp->parent = parent; @@ -1276,14 +1269,14 @@ void sizeArray(htmltbl_t * tbl) closeGraphs(rowg, colg); } -static void pos_html_tbl(htmltbl_t *, box, int); /* forward declaration */ +static void pos_html_tbl(htmltbl_t *, boxf, int); /* forward declaration */ /* pos_html_img: * Place image in cell * storing allowed space handed by parent cell. * How this space is used is handled in emit_html_img. */ -static void pos_html_img(htmlimg_t * cp, box pos) +static void pos_html_img(htmlimg_t * cp, boxf pos) { cp->box = pos; } @@ -1304,11 +1297,11 @@ pos_html_txt(htmltxt_t* ftxt, char c) /* pos_html_cell: */ -static void pos_html_cell(htmlcell_t * cp, box pos, int sides) +static void pos_html_cell(htmlcell_t * cp, boxf pos, int sides) { - int delx, dely; - point oldsz; - box cbox; + double delx, dely; + pointf oldsz; + boxf cbox; if (!cp->data.pencolor) cp->data.pencolor = cp->parent->data.pencolor; @@ -1426,13 +1419,13 @@ static void pos_html_cell(htmlcell_t * cp, box pos, int sides) * attribute indicating which external sides of the node * are accessible to the table. */ -static void pos_html_tbl(htmltbl_t * tbl, box pos, int sides) +static void pos_html_tbl(htmltbl_t * tbl, boxf pos, int sides) { - int x, y, delx, dely; - int i, plus, extra, oldsz; + double x, y, delx, dely, extra, oldsz; + int i, plus; htmlcell_t **cells = tbl->u.n.cells; htmlcell_t *cp; - box cbox; + boxf cbox; if (tbl->u.n.parent && !tbl->data.pencolor) tbl->data.pencolor = tbl->u.n.parent->data.pencolor; @@ -1483,7 +1476,7 @@ static void pos_html_tbl(htmltbl_t * tbl, box pos, int sides) /* change sizes to start positions and distribute extra space */ x = pos.LL.x + tbl->data.border + tbl->data.space; extra = delx / (tbl->cc); - plus = delx - extra * (tbl->cc); + plus = ROUND(delx - extra * (tbl->cc)); for (i = 0; i <= tbl->cc; i++) { delx = tbl->widths[i] + extra + (i < plus ? 1 : 0); tbl->widths[i] = x; @@ -1491,7 +1484,7 @@ static void pos_html_tbl(htmltbl_t * tbl, box pos, int sides) } y = pos.UR.y - tbl->data.border - tbl->data.space; extra = dely / (tbl->rc); - plus = dely - extra * (tbl->rc); + plus = ROUND(dely - extra * (tbl->rc)); for (i = 0; i <= tbl->rc; i++) { dely = tbl->heights[i] + extra + (i < plus ? 1 : 0); tbl->heights[i] = y; @@ -1526,7 +1519,7 @@ size_html_tbl(graph_t *g, htmltbl_t * tbl, htmlcell_t * parent, htmlenv_t * env) { int i, wd, ht; int rv = 0; - htmlfont_t savef; + static htmlfont_t savef; if (tbl->font) pushFontInfo(env, tbl->font, &savef); @@ -1731,8 +1724,8 @@ static char *getPenColor(void *obj) int make_html_label(graph_t *g, textlabel_t * lp, void *obj) { int rv; - int wd2, ht2; - box box; + double wd2, ht2; + boxf box; htmllabel_t *lbl; htmlenv_t env; @@ -1770,7 +1763,7 @@ int make_html_label(graph_t *g, textlabel_t * lp, void *obj) rv |= size_html_tbl(g, lbl->u.tbl, NULL, &env); wd2 = (lbl->u.tbl->data.box.UR.x + 1) / 2; ht2 = (lbl->u.tbl->data.box.UR.y + 1) / 2; - box = boxof(-wd2, -ht2, wd2, ht2); + box = boxfof(-wd2, -ht2, wd2, ht2); pos_html_tbl(lbl->u.tbl, box, BOTTOM | RIGHT | TOP | LEFT); lp->dimen.x = box.UR.x - box.LL.x; lp->dimen.y = box.UR.y - box.LL.y; @@ -1778,7 +1771,7 @@ int make_html_label(graph_t *g, textlabel_t * lp, void *obj) rv |= size_html_txt(g, lbl->u.txt, &env); wd2 = (lbl->u.txt->box.UR.x + 1) / 2; ht2 = (lbl->u.txt->box.UR.y + 1) / 2; - box = boxof(-wd2, -ht2, wd2, ht2); + box = boxfof(-wd2, -ht2, wd2, ht2); lbl->u.txt->box = box; lp->dimen.x = box.UR.x - box.LL.x; lp->dimen.y = box.UR.y - box.LL.y; diff --git a/lib/common/htmltable.h b/lib/common/htmltable.h index ec7e49a23..d90380048 100644 --- a/lib/common/htmltable.h +++ b/lib/common/htmltable.h @@ -84,11 +84,11 @@ extern "C" { typedef struct { htextpara_t *paras; short nparas; - box box; + boxf box; } htmltxt_t; typedef struct { - box box; + boxf box; char *src; char *scale; } htmlimg_t; @@ -107,7 +107,7 @@ extern "C" { unsigned short flags; unsigned short width; unsigned short height; - box box; /* its geometric placement in points */ + boxf box; /* its geometric placement in points */ } htmldata_t; #define HTML_UNSET 0 @@ -180,7 +180,7 @@ extern "C" { extern void free_html_text(htmltxt_t *); extern void free_html_font(htmlfont_t*); - extern box *html_port(node_t * n, char *pname, int* sides); + extern boxf *html_port(node_t * n, char *pname, int* sides); extern int html_path(node_t * n, port* p, int side, box * rv, int *k); extern int html_inside(node_t * n, pointf p, edge_t * e); diff --git a/lib/common/labels.c b/lib/common/labels.c index 3e39c9262..039a8ba4a 100644 --- a/lib/common/labels.c +++ b/lib/common/labels.c @@ -102,6 +102,7 @@ static pointf label_size(graph_t * g, textlabel_t * lp) storeline(g, lp, line, 'n'); } + lp->space = lp->dimen; return lp->dimen; } @@ -173,7 +174,6 @@ void free_label(textlabel_t * p) void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp) { obj_state_t *obj = job->obj; - double halfwidth_x, center_x, left_x, right_x; int i; pointf p; emit_state_t old_emit_state; @@ -190,34 +190,34 @@ void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t * lp) if (lp->u.txt.nparas < 1) return; - p.x = lp->p.x; - p.y = lp->p.y; - - /* dimensions of box for label, no padding, adjusted for resizing */ - halfwidth_x = MAX(lp->d.x, (lp->dimen.x / 2.0)); - - center_x = p.x; - left_x = center_x - halfwidth_x; - right_x = center_x + halfwidth_x; - - /* position for first para */ - p.y += (lp->dimen.y + lp->d.y) / 2.0 - lp->fontsize; - gvrender_begin_context(job); gvrender_set_pencolor(job, lp->fontcolor); gvrender_set_font(job, lp->fontname, lp->fontsize); + /* position for first para */ + switch (lp->valign) { + case 't': + p.y = lp->pos.y + lp->space.y / 2.0 - lp->fontsize; + break; + case 'b': + p.y = lp->pos.y - lp->space.y / 2.0 + lp->dimen.y - lp->fontsize; + break; + case 'c': + default: + p.y = lp->pos.y + lp->dimen.y / 2.0 - lp->fontsize; + break; + } for (i = 0; i < lp->u.txt.nparas; i++) { switch (lp->u.txt.para[i].just) { case 'l': - p.x = left_x; + p.x = lp->pos.x - lp->space.x / 2.0; break; case 'r': - p.x = right_x; + p.x = lp->pos.x + lp->space.x / 2.0; break; default: case 'n': - p.x = center_x; + p.x = lp->pos.x; break; } gvrender_textpara(job, p, &(lp->u.txt.para[i])); diff --git a/lib/common/ns.c b/lib/common/ns.c index fed98418a..585934f2d 100644 --- a/lib/common/ns.c +++ b/lib/common/ns.c @@ -776,7 +776,7 @@ void tchk(void) for (i = 0; (e = ND_tree_out(n).list[i]); i++) { e_cnt++; if (SLACK(e) > 0) - fprintf(stderr, "not a tight tree %x", e); + fprintf(stderr, "not a tight tree %lx", (unsigned long int)e); } } if ((n_cnt != Tree_node.size) || (e_cnt != Tree_edge.size)) @@ -857,15 +857,22 @@ static node_t *checkdfs(node_t * n) for (i = 0; (e = ND_out(n).list[i]); i++) { w = e->head; if (ND_onstack(w)) { - fprintf(stderr, "cycle: last edge %x %s(%x) %s(%x)\n", - e,n->name,n,w->name,w); + fprintf(stderr, "cycle: last edge %lx %s(%lx) %s(%lx)\n", + (unsigned long int)e, + n->name, + (unsigned long int)n, + w->name, + (unsigned long int)w); return w; } else { if (ND_mark(w) == FALSE) { x = checkdfs(w); if (x) { - fprintf(stderr,"unwind %x %s(%x)\n",e,n->name,n); + fprintf(stderr,"unwind %lx %s(%lx)\n", + (unsigned long int)e, + n->name, + (unsigned long int)n); if (x != n) return x; fprintf(stderr,"unwound to root\n"); fflush(stderr); diff --git a/lib/common/output.c b/lib/common/output.c index 5db76f97e..85027142d 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -25,15 +25,13 @@ double YF_off; /* Y_off in inches */ static void printpt(FILE * f, point pt) { - fprintf(f, " %.3f %.3f", PS2INCH(pt.x), PS2INCH(YDIR(pt.y))); + fprintf(f, " %.3g %.3g", PS2INCH(pt.x), PS2INCH(YDIR(pt.y))); } -#ifdef SPLINESF static void printptf(FILE * f, pointf pt) { - fprintf(f, " %.3f %.3f", PS2INCH(pt.x), PS2INCH(YDIR(pt.y))); + fprintf(f, " %.3g %.3g", PS2INCH(pt.x), PS2INCH(YDIR(pt.y))); } -#endif /* setYInvert: * Set parameters used to flip coordinate system (y=0 at top). @@ -81,7 +79,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) // setup_graph(job, g); setYInvert(g); pt = GD_bb(g).UR; - fprintf(f, "graph %.3f %.3f %.3f\n", job->zoom, PS2INCH(pt.x), PS2INCH(pt.y)); + fprintf(f, "graph %.3g %.3g %.3g\n", job->zoom, PS2INCH(pt.x), PS2INCH(pt.y)); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { if (IS_CLUST_NODE(n)) continue; @@ -91,7 +89,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) lbl = agcanonical (agxget(n, N_label->index)); else lbl = agcanon(ND_label(n)->text); - fprintf(f, " %.3f %.3f %s %s %s %s %s\n", + fprintf(f, " %.3g %.3g %s %s %s %s %s\n", ND_width(n), ND_height(n), lbl, late_nnstring(n, N_style, "solid"), ND_shape(n)->name, @@ -128,7 +126,7 @@ void write_plain(GVJ_t * job, graph_t * g, FILE * f, boolean extend) } if (ED_label(e)) { fprintf(f, " %s", agcanon(ED_label(e)->text)); - printpt(f, ED_label(e)->p); + printptf(f, ED_label(e)->pos); } fprintf(f, " %s %s\n", late_nnstring(e, E_style, "solid"), late_nnstring(e, E_color, DEFAULT_COLOR)); @@ -143,11 +141,11 @@ static void set_record_rects(node_t * n, field_t * f, agxbuf * xb) char buf[BUFSIZ]; if (f->n_flds == 0) { - sprintf(buf, "%d,%d,%d,%d ", - f->b.LL.x + ND_coord_i(n).x, - YDIR(f->b.LL.y + ND_coord_i(n).y), - f->b.UR.x + ND_coord_i(n).x, - YDIR(f->b.UR.y + ND_coord_i(n).y)); + sprintf(buf, "%.3g,%.3g,%.3g,%.3g ", + f->b.LL.x + (double)(ND_coord_i(n).x), + YFDIR(f->b.LL.y + (double)(ND_coord_i(n).y)), + f->b.UR.x + (double)(ND_coord_i(n).x), + YFDIR(f->b.UR.y + (double)(ND_coord_i(n).y))); agxbput(xb, buf); } for (i = 0; i < f->n_flds; i++) @@ -158,14 +156,14 @@ static void rec_attach_bb(graph_t * g) { int c; char buf[BUFSIZ]; - point pt; + pointf pt; sprintf(buf, "%d,%d,%d,%d", GD_bb(g).LL.x, YDIR(GD_bb(g).LL.y), GD_bb(g).UR.x, YDIR(GD_bb(g).UR.y)); agset(g, "bb", buf); if (GD_label(g) && GD_label(g)->text[0]) { - pt = GD_label(g)->p; - sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); + pt = GD_label(g)->pos; + sprintf(buf, "%.3g,%.3g", pt.x, YFDIR(pt.y)); agset(g, "lp", buf); } for (c = 1; c <= GD_n_cluster(g); c++) @@ -183,9 +181,7 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) node_t *n; edge_t *e; point pt; -#ifdef SPLINESF - point ptf; -#endif + pointf ptf; int dim3 = (GD_odim(g) >= 3); e_arrows = s_arrows = 0; @@ -205,8 +201,8 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) if (GD_label(g)) { safe_dcl(g, g, "lp", "", agraphattr); if (GD_label(g)->text[0]) { - pt = GD_label(g)->p; - sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); + ptf = GD_label(g)->pos; + sprintf(buf, "%.3g,%.3g", ptf.x, YFDIR(ptf.y)); agset(g, "lp", buf); } } @@ -245,11 +241,11 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) if (i > 0) agxbputc(&xb, ' '); if (poly->sides >= 3) - sprintf(buf, "%.3f %.3f", + sprintf(buf, "%.3g %.3g", PS2INCH(poly->vertices[i].x), YFDIR(PS2INCH(poly->vertices[i].y))); else - sprintf(buf, "%.3f %.3f", + sprintf(buf, "%.3g %.3g", ND_width(n) / 2.0 * cos(i / (double) sides * M_PI * 2.0), @@ -272,7 +268,7 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) if (ED_spl(e)->list[i].sflag) { s_arrows = 1; #ifdef SPLINESF - sprintf(buf, "s,%.3f,%.3f ", + sprintf(buf, "s,%.3g,%.3g ", ED_spl(e)->list[i].sp.x, YFDIR(ED_spl(e)->list[i].sp.y)); #else @@ -285,7 +281,7 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) if (ED_spl(e)->list[i].eflag) { e_arrows = 1; #ifdef SPLINESF - sprintf(buf, "e,%.3f,%.3f ", + sprintf(buf, "e,%.3g,%.3g ", ED_spl(e)->list[i].ep.x, YFDIR(ED_spl(e)->list[i].ep.y)); #else @@ -300,7 +296,7 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) agxbputc(&xb, ' '); #ifdef SPLINESF ptf = ED_spl(e)->list[i].list[j]; - sprintf(buf, "%.3f,%.3f", ptf.x, YFDIR(ptf.y)); + sprintf(buf, "%.3g,%.3g", ptf.x, YFDIR(ptf.y)); #else pt = ED_spl(e)->list[i].list[j]; sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); @@ -310,18 +306,18 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep) } agset(e, "pos", agxbuse(&xb)); if (ED_label(e)) { - pt = ED_label(e)->p; - sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); + ptf = ED_label(e)->pos; + sprintf(buf, "%.3g,%.3g", ptf.x, YFDIR(ptf.y)); agset(e, "lp", buf); } if (ED_head_label(e)) { - pt = ED_head_label(e)->p; - sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); + ptf = ED_head_label(e)->pos; + sprintf(buf, "%.3g,%.3g", ptf.x, YFDIR(ptf.y)); agset(e, "head_lp", buf); } if (ED_tail_label(e)) { - pt = ED_tail_label(e)->p; - sprintf(buf, "%d,%d", pt.x, YDIR(pt.y)); + ptf = ED_tail_label(e)->pos; + sprintf(buf, "%.3g,%.3g", ptf.x, YDIR(ptf.y)); agset(e, "tail_lp", buf); } } diff --git a/lib/common/postproc.c b/lib/common/postproc.c index 233de925f..5a63bc0fe 100644 --- a/lib/common/postproc.c +++ b/lib/common/postproc.c @@ -81,7 +81,6 @@ static void place_flip_graph_label(graph_t * g); closepath stroke\n\ } def\n" -#ifdef SPLINESF static pointf map_pointf(pointf p) { p = ccwrotatepf(p, Rankdir*90); @@ -89,7 +88,6 @@ static pointf map_pointf(pointf p) p.y -= (double)Offset.y; return p; } -#endif static point map_point(point p) { @@ -129,12 +127,12 @@ static void map_edge(edge_t * e) #endif } if (ED_label(e)) - ED_label(e)->p = map_point(ED_label(e)->p); + ED_label(e)->pos = map_pointf(ED_label(e)->pos); /* vladimir */ if (ED_head_label(e)) - ED_head_label(e)->p = map_point(ED_head_label(e)->p); + ED_head_label(e)->pos = map_pointf(ED_head_label(e)->pos); if (ED_tail_label(e)) - ED_tail_label(e)->p = map_point(ED_tail_label(e)->p); + ED_tail_label(e)->pos = map_pointf(ED_tail_label(e)->pos); } void translate_bb(graph_t * g, int rankdir) @@ -152,7 +150,7 @@ void translate_bb(graph_t * g, int rankdir) } GD_bb(g) = new_bb; if (GD_label(g)) { - GD_label(g)->p = map_point(GD_label(g)->p); + GD_label(g)->pos = map_pointf(GD_label(g)->pos); } for (c = 1; c <= GD_n_cluster(g); c++) translate_bb(GD_clust(g)[c], rankdir); @@ -229,7 +227,7 @@ static void place_root_label(graph_t * g, point d) p.y = GD_bb(g).LL.y + d.y / 2; } - GD_label(g)->p = p; + P2PF(p, GD_label(g)->pos); GD_label(g)->set = TRUE; } @@ -401,7 +399,7 @@ static void place_flip_graph_label(graph_t * g) #endif } - GD_label(g)->p = p; + P2PF(p, GD_label(g)->pos); GD_label(g)->set = TRUE; } @@ -465,7 +463,7 @@ void place_graph_label(graph_t * g) GD_bb(g->root).LL.x = minx; #endif } - GD_label(g)->p = p; + P2PF(p, GD_label(g)->pos); GD_label(g)->set = TRUE; } diff --git a/lib/common/render.h b/lib/common/render.h index 118e27628..7383b1b66 100644 --- a/lib/common/render.h +++ b/lib/common/render.h @@ -100,7 +100,7 @@ extern "C" { extern void emit_label(GVJ_t * job, emit_state_t emit_state, textlabel_t *); extern int emit_once(char *message); extern void emit_jobs_eof(GVC_t * gvc); - extern void emit_map_rect(GVJ_t *job, point LL, point UR); + extern void emit_map_rect(GVJ_t *job, boxf b); extern void enqueue_neighbors(nodequeue *, Agnode_t *, int); extern void endpath(path *, Agedge_t *, int, pathend_t *, boolean); extern void epsf_init(node_t * n); diff --git a/lib/common/shapes.c b/lib/common/shapes.c index c369f6030..f66fae908 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -717,7 +717,7 @@ static void poly_init(node_t * n) double angle, sinx, cosx, xmax, ymax, scalex, scaley; double width, height, marginx, marginy; int regular, peripheries, sides; - int i, j, isBox, outp, labelloc; + int i, j, isBox, outp; polygon_t *poly = NEW(polygon_t); regular = ND_shape(n)->polygon->regular; @@ -761,6 +761,7 @@ static void poly_init(node_t * n) dimen = ND_label(n)->dimen; /* minimal whitespace around label */ +// FIXME - is this an FP safe test? if ((dimen.x > 0.0) || (dimen.y > 0.0)) { /* padding */ if ((p = agget(n, "margin"))) { @@ -834,12 +835,10 @@ static void poly_init(node_t * n) /* extra sizing depends on if label is centered vertically */ p = agget(n, "labelloc"); - if (p && p[0] == 't') - labelloc = +1; - else if (p && p[0] == 'b') - labelloc = -1; - else - labelloc = 0; + if (p && (p[0] == 't' || p[0] == 'b')) + ND_label(n)->valign = p[0]; + else + ND_label(n)->valign = 'c'; isBox = (sides == 4 && (ROUND(orientation) % 90) == 0 && distortion == 0. && skew == 0.); @@ -852,7 +851,7 @@ static void poly_init(node_t * n) */ temp = bb.y * SQRT2; /* if there is height to spare and the label is centered vertically */ - if (height > temp && labelloc == 0) { + if (height > temp && ND_label(n)->valign == 'c') { bb.x *= sqrt(1. / (1. - SQR(bb.y / height))); bb.y = height; } @@ -895,40 +894,21 @@ static void poly_init(node_t * n) bb.x = bb.y = MAX(bb.x, bb.y); } - /* adjust text horizontal justification - * If ND_label(n)->d.x is set, it specifies how far from the - * center are the x positions for left or right justification. - * For simple boxes, this is just half bb.x; - * for other shapes, we calculate where the rectangle dimen - * when shifted to the right, first touches the ellipse enclosed in bb. - * In both cases, we also subtract the horizontal margin about the text. - */ + /* Compute space available for label. Provides the justification borders */ if (!mapbool(late_string(n, N_nojustify, "false"))) { if (isBox) temp = bb.x; else temp = bb.x*sqrt(1.0 - SQR(dimen.y)/SQR(bb.y)); - temp = (temp - (dimen.x - ND_label(n)->dimen.x))/2.0; -#if 0 - if (dimen.x < imagesize.x) - temp += imagesize.x - dimen.x; -#endif - if (temp > 0) - ND_label(n)->d.x = temp; + ND_label(n)->space.x = temp; } + else + ND_label(n)->space.x = dimen.x; - /* adjust text vertical location */ temp = bb.y - min_bb.y; if (dimen.y < imagesize.y) temp += imagesize.y - dimen.y; - if (temp > 0) { - if (labelloc < 0) - ND_label(n)->d.y = -temp; - else if (labelloc > 0) - ND_label(n)->d.y = temp; - else - ND_label(n)->d.y = 0; - } + ND_label(n)->space.y = dimen.y + temp; outp = peripheries; if (peripheries < 1) @@ -1088,14 +1068,14 @@ static boolean poly_inside(inside_t * inside_context, pointf p) int i, i1, j, s; pointf P, Q, R; - box *bp = inside_context->s.bp; + boxf *bp = inside_context->s.bp; node_t *n = inside_context->s.n; P = ccwrotatepf(p, 90*GD_rankdir(n->graph)); /* Quick test if port rectangle is target */ if (bp) { - box bbox = *bp; + boxf bbox = *bp; return INSIDE(P, bbox); } @@ -1280,10 +1260,9 @@ static double invflip_angle (double angle, int rankdir) * return it. * Assumes ictxt and ictxt->n are non-NULL. */ -static point +static pointf compassPoint(inside_t* ictxt, double y, double x) { - point p; pointf curve[4]; /* bezier control points for a straight line */ node_t* n = ictxt->s.n; @@ -1298,10 +1277,7 @@ compassPoint(inside_t* ictxt, double y, double x) bezier_clip(ictxt, ND_shape(n)->fns->insidefn, curve, 1); - p.x = ROUND(curve[0].x); - p.y = ROUND(curve[0].y); - - return p; + return curve[0]; } /* compassPort: @@ -1320,10 +1296,10 @@ compassPoint(inside_t* ictxt, double y, double x) * symmetric, left-right symmetric, and convex. */ static int -compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ictxt) +compassPort(node_t* n, boxf* bp, port* pp, char* compass, int sides, inside_t* ictxt) { - box b; - point p, ctr; + boxf b; + pointf p, ctr; int rv = 0; double theta = 0.0; boolean constrain = FALSE; @@ -1334,17 +1310,17 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic if (bp) { b = *bp; - p = pointof((b.LL.x + b.UR.x) / 2, (b.LL.y + b.UR.y) / 2); + p = pointfof((b.LL.x + b.UR.x) / 2, (b.LL.y + b.UR.y) / 2); defined = TRUE; } else { - p.x = p.y = 0; + p.x = p.y = 0.; if (GD_flip(n->graph)) { - b.UR.x = ND_ht_i(n) / 2; + b.UR.x = ND_ht_i(n) / 2.; b.LL.x = -b.UR.x; b.UR.y = ND_lw_i(n); b.LL.y = -b.UR.y; } else { - b.UR.y = ND_ht_i(n) / 2; + b.UR.y = ND_ht_i(n) / 2.; b.LL.y = -b.UR.y; b.UR.x = ND_lw_i(n); b.LL.x = -b.UR.x; @@ -1445,11 +1421,11 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic break; } } - p = cwrotatep(p, 90*GD_rankdir(n->graph)); + p = cwrotatepf(p, 90*GD_rankdir(n->graph)); if (dyna) pp->side = side; else pp->side = invflip_side(side, GD_rankdir(n->graph)); pp->bp = bp; - pp->p = p; + PF2P(p, pp->p); pp->theta = invflip_angle(theta, GD_rankdir(n->graph)); if ((p.x == 0) && (p.y == 0)) pp->order = MC_SCALE/2; @@ -1469,7 +1445,7 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic static port poly_port(node_t * n, char *portname, char *compass) { port rv; - box *bp; + boxf *bp; int sides; /* bitmap of which sides the port lies along */ if (portname[0] == '\0') @@ -1530,7 +1506,9 @@ static void poly_gencode(GVJ_t * job, node_t * n) AF = ALLOC(A_size, AF, pointf); } - ND_label(n)->p = ND_coord_i(n); + /* nominal label position in the center of the node */ + P2PF(ND_coord_i(n), ND_label(n)->pos); + xsize = (double)(ND_lw_i(n) + ND_rw_i(n)) / POINTS(ND_width(n)); ysize = (double)ND_ht_i(n) / POINTS(ND_height(n)); @@ -2030,7 +2008,8 @@ static void resize_reclbl(field_t * f, point sz, int nojustify_p) { int i, amt; double inc; - point d, newsz; + pointf d; + point newsz; field_t *sf; /* adjust field */ @@ -2038,18 +2017,19 @@ static void resize_reclbl(field_t * f, point sz, int nojustify_p) d.y = sz.y - f->size.y; f->size = sz; - /* adjust text */ + /* adjust text area */ if (f->lp && !nojustify_p) { - P2PF(d, f->lp->d); + f->lp->space.x += d.x; + f->lp->space.y += d.y; } /* adjust children */ if (f->n_flds) { if (f->LR) - inc = (double) d.x / f->n_flds; + inc = d.x / f->n_flds; else - inc = (double) d.y / f->n_flds; + inc = d.y / f->n_flds; for (i = 0; i < f->n_flds; i++) { sf = f->fld[i]; amt = ((int) ((i + 1) * inc)) - ((int) (i * inc)); @@ -2072,8 +2052,8 @@ static void pos_reclbl(field_t * f, point ul, int sides) int i, last, mask; f->sides = sides; - f->b.LL = pointof(ul.x, ul.y - f->size.y); - f->b.UR = pointof(ul.x + f->size.x, ul.y); + f->b.LL = pointfof(ul.x, ul.y - f->size.y); + f->b.UR = pointfof(ul.x + f->size.x, ul.y); last = f->n_flds - 1; for (i = 0; i <= last; i++) { if (sides) { @@ -2234,7 +2214,8 @@ static port record_port(node_t * n, char *portname, char *compass) "node %s, port %s, unrecognized compass point '%s' - ignored\n", n->name, portname, compass); } - } else if (compassPort(n, &f->b, &rv, portname, sides, NULL)) { + } + else if (compassPort(n, &f->b, &rv, portname, sides, NULL)) { unrecognized(n, portname); } @@ -2250,9 +2231,9 @@ record_inside(inside_t * inside_context, pointf p) { field_t *fld0; - box *bp = inside_context->s.bp; + boxf *bp = inside_context->s.bp; node_t *n = inside_context->s.n; - box bbox; + boxf bbox; /* convert point to node coordinate system */ p = ccwrotatepf(p, 90*GD_rankdir(n->graph)); @@ -2275,6 +2256,7 @@ static int record_path(node_t* n, port* prt, int side, box rv[], int *kptr) int i, ls, rs; point p; field_t *info; + box B; if (!prt->defined) return 0; p = prt->p; @@ -2291,10 +2273,11 @@ static int record_path(node_t* n, port* prt, int side, box rv[], int *kptr) if (BETWEEN(ls, p.x, rs)) { /* FIXME: I don't understand this code */ if (GD_flip(n->graph)) { - rv[0] = flip_rec_box(info->fld[i]->b, ND_coord_i(n)); + BF2B(info->fld[i]->b, B); + rv[0] = flip_rec_box(B, ND_coord_i(n)); } else { rv[0].LL.x = ND_coord_i(n).x + ls; - rv[0].LL.y = ND_coord_i(n).y - ND_ht_i(n) / 2; + rv[0].LL.y = ND_coord_i(n).y - ND_ht_i(n) / 2.; rv[0].UR.x = ND_coord_i(n).x + rs; } rv[0].UR.y = ND_coord_i(n).y + ND_ht_i(n) / 2; @@ -2308,13 +2291,12 @@ static int record_path(node_t* n, port* prt, int side, box rv[], int *kptr) static void gen_fields(GVJ_t * job, node_t * n, field_t * f) { int i; - double cx, cy; pointf AF[2], coord; if (f->lp) { - cx = (f->b.LL.x + f->b.UR.x) / 2.0 + ND_coord_i(n).x; - cy = (f->b.LL.y + f->b.UR.y) / 2.0 + ND_coord_i(n).y; - f->lp->p = pointof((int) cx, (int) cy); + coord.x = (f->b.LL.x + f->b.UR.x) / 2.0 + ND_coord_i(n).x; + coord.y = (f->b.LL.y + f->b.UR.y) / 2.0 + ND_coord_i(n).y; + f->lp->pos = coord; emit_label(job, EMIT_NLABEL, f->lp); pencolor(job, n); } @@ -2470,7 +2452,7 @@ static void epsf_gencode(GVJ_t * job, node_t * n) "%d %d translate newpath user_shape_%d\n", ND_coord_i(n).x + desc->offset.x, ND_coord_i(n).y + desc->offset.y, desc->macro_id); - ND_label(n)->p = ND_coord_i(n); + P2PF(ND_coord_i(n), ND_label(n)->pos); gvrender_end_context(job); emit_label(job, EMIT_NLABEL, ND_label(n)); @@ -2486,7 +2468,7 @@ static char* side_port[] = {"s", "e", "n", "w"}; static point cvtPt (point p, int rankdir) { - point q; + point q = {0, 0}; switch (rankdir) { case RANKDIR_TB : @@ -2510,13 +2492,14 @@ cvtPt (point p, int rankdir) static char* closestSide (node_t* n, node_t* other, port* oldport) { - box b; + boxf b; int rkd = GD_rankdir(n->graph->root); - point p, pt = cvtPt (ND_coord_i(n), rkd); + point p = {0, 0}; + point pt = cvtPt (ND_coord_i(n), rkd); point opt = cvtPt (ND_coord_i(other), rkd); int sides = oldport->side; char* rv = NULL; - int i, d, mind; + int i, d, mind = 0; if (sides == 0) return rv; /* use center */ diff --git a/lib/common/splines.c b/lib/common/splines.c index 6c262b4c9..d39118e2f 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -240,8 +240,7 @@ clip_and_install(edge_t * fe, node_t * hn, point * ps, int pn, int start, end, i, clipTail, clipHead; graph_t *g; edge_t *orig; - box *tbox, *hbox; - boxf bb; + boxf *tbox, *hbox, bb; inside_t inside_context; tn = fe->tail; @@ -1001,8 +1000,8 @@ selfBottom (edge_t* edges[], int ind, int cnt, int sizex, int stepy, width = ED_label(e)->dimen.x; height = ED_label(e)->dimen.y; } - ED_label(e)->p.y = ND_coord_i(n).y - dy - height / 2.0; - ED_label(e)->p.x = ND_coord_i(n).x; + ED_label(e)->pos.y = ND_coord_i(n).y - dy - height / 2.0; + ED_label(e)->pos.x = ND_coord_i(n).x; ED_label(e)->set = TRUE; if (height > stepy) dy += height - stepy; @@ -1069,8 +1068,8 @@ selfTop (edge_t* edges[], int ind, int cnt, int sizex, int stepy, width = ED_label(e)->dimen.x; height = ED_label(e)->dimen.y; } - ED_label(e)->p.y = ND_coord_i(n).y + dy + height / 2.0; - ED_label(e)->p.x = ND_coord_i(n).x; + ED_label(e)->pos.y = ND_coord_i(n).y + dy + height / 2.0; + ED_label(e)->pos.x = ND_coord_i(n).x; ED_label(e)->set = TRUE; if (height > stepy) dy += height - stepy; @@ -1137,8 +1136,8 @@ selfRight (edge_t* edges[], int ind, int cnt, int stepx, int sizey, width = ED_label(e)->dimen.x; height = ED_label(e)->dimen.y; } - ED_label(e)->p.x = ND_coord_i(n).x + dx + width / 2.0; - ED_label(e)->p.y = ND_coord_i(n).y; + ED_label(e)->pos.x = ND_coord_i(n).x + dx + width / 2.0; + ED_label(e)->pos.y = ND_coord_i(n).y; ED_label(e)->set = TRUE; if (width > stepx) dx += width - stepx; @@ -1205,8 +1204,8 @@ selfLeft (edge_t* edges[], int ind, int cnt, int stepx, int sizey, width = ED_label(e)->dimen.x; height = ED_label(e)->dimen.y; } - ED_label(e)->p.x = ND_coord_i(n).x - dx - width / 2.0; - ED_label(e)->p.y = ND_coord_i(n).y; + ED_label(e)->pos.x = ND_coord_i(n).x - dx - width / 2.0; + ED_label(e)->pos.y = ND_coord_i(n).y; ED_label(e)->set = TRUE; if (width > stepx) dx += width - stepx; @@ -1399,8 +1398,8 @@ void place_portlabel(edge_t * e, boolean head_p) angle = atan2(pf.y - p.y, pf.x - p.x) + RADIANS(late_double(e, E_labelangle, PORT_LABEL_ANGLE, -180.0)); dist = PORT_LABEL_DISTANCE * late_double(e, E_labeldistance, 1.0, 0.0); - l->p.x = p.x + ROUND(dist * cos(angle)); - l->p.y = p.y + ROUND(dist * sin(angle)); + l->pos.x = p.x + dist * cos(angle); + l->pos.y = p.y + dist * sin(angle); l->set = TRUE; } -- 2.50.0