From 6f1c9013137e5eb8f4ea90080d38dc63bcecce28 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 15 Feb 2011 16:27:53 +0000 Subject: [PATCH] Remove xsize and ysize attributes. These are vestiges of int-based data structures, and are redundant given rw, lw and ht. --- lib/circogen/circularinit.c | 2 ++ lib/common/geom.h | 1 + lib/common/types.h | 9 ++++----- lib/common/utils.c | 14 +++++++------- lib/fdpgen/layout.c | 21 +++++++++++---------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lib/circogen/circularinit.c b/lib/circogen/circularinit.c index 11c3100cc..f1f82f941 100644 --- a/lib/circogen/circularinit.c +++ b/lib/circogen/circularinit.c @@ -89,8 +89,10 @@ static node_t *makeDerivedNode(graph_t * dg, char *name, int isNode, ND_alg(n) = (void *) NEW(cdata); if (isNode) { ND_pos(n) = N_NEW(Ndim, double); +#if 0 ND_xsize(n) = ND_xsize((node_t *) orig); ND_ysize(n) = ND_ysize((node_t *) orig); +#endif ORIGN(n) = (node_t *) orig; } else ORIGG(n) = (graph_t *) orig; diff --git a/lib/common/geom.h b/lib/common/geom.h index 0c214b742..2c8492295 100644 --- a/lib/common/geom.h +++ b/lib/common/geom.h @@ -68,6 +68,7 @@ typedef struct { pointf LL, UR; } boxf; #define POINTS_PER_MM ((double)POINTS_PER_INCH * 0.0393700787) #define POINTS(a_inches) (ROUND((a_inches)*POINTS_PER_INCH)) +#define INCH2PS(a_inches) ((a_inches)*(double)POINTS_PER_INCH) #define PS2INCH(a_points) ((a_points)/(double)POINTS_PER_INCH) #define P2PF(p,pf) ((pf).x = (p).x,(pf).y = (p).y) diff --git a/lib/common/types.h b/lib/common/types.h index f2e790e3f..b09203585 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -481,7 +481,6 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #ifndef DOT_ONLY unsigned char pinned; - short xsize, ysize; int id, heapindex, hops; double *pos, dist; #endif @@ -576,8 +575,8 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #define ND_tree_out(n) (((Agnodeinfo_t*)AGDATA(n))->tree_out) #define ND_weight_class(n) (((Agnodeinfo_t*)AGDATA(n))->weight_class) #define ND_width(n) (((Agnodeinfo_t*)AGDATA(n))->width) -#define ND_xsize(n) (((Agnodeinfo_t*)AGDATA(n))->xsize) -#define ND_ysize(n) (((Agnodeinfo_t*)AGDATA(n))->ysize) +#define ND_xsize(n) (ND_lw(n)+ND_rw(n)) +#define ND_ysize(n) (ND_ht(n)) #else @@ -633,8 +632,8 @@ typedef enum {NATIVEFONTS,PSFONTS,SVGFONTS} fontname_kind; #define ND_tree_out(n) (n)->u.tree_out #define ND_weight_class(n) (n)->u.weight_class #define ND_width(n) (n)->u.width -#define ND_xsize(n) (n)->u.xsize -#define ND_ysize(n) (n)->u.ysize +#define ND_xsize(n) (ND_lw(n)+ND_rw(n)) +#define ND_ysize(n) (ND_ht(n)) #endif typedef struct Agedgeinfo_t { diff --git a/lib/common/utils.c b/lib/common/utils.c index 4b5caeabc..810849d2e 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -852,8 +852,8 @@ void compute_bb(graph_t * g) bb.UR = pointfof(-INT_MAX, -INT_MAX); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { ptf = coord(n); - s2.x = ND_xsize(n) / 2. + 1; - s2.y = ND_ysize(n) / 2. + 1; + s2.x = ND_xsize(n) / 2.0; + s2.y = ND_ysize(n) / 2.0; b.LL = sub_pointf(ptf, s2); b.UR = add_pointf(ptf, s2); @@ -1872,17 +1872,17 @@ void gv_cleanup_node(node_t * n) void gv_nodesize(node_t * n, boolean flip) { - int w; + double w; if (flip) { - w = ND_xsize(n) = POINTS(ND_height(n)); + w = INCH2PS(ND_height(n)); ND_lw(n) = ND_rw(n) = w / 2; - ND_ht(n) = ND_ysize(n) = POINTS(ND_width(n)); + ND_ht(n) = INCH2PS(ND_width(n)); } else { - w = ND_xsize(n) = POINTS(ND_width(n)); + w = INCH2PS(ND_width(n)); ND_lw(n) = ND_rw(n) = w / 2; - ND_ht(n) = ND_ysize(n) = POINTS(ND_height(n)); + ND_ht(n) = INCH2PS(ND_height(n)); } } diff --git a/lib/fdpgen/layout.c b/lib/fdpgen/layout.c index 78c0ca427..6c1e5f226 100644 --- a/lib/fdpgen/layout.c +++ b/lib/fdpgen/layout.c @@ -536,8 +536,9 @@ static graph_t *deriveGraph(graph_t * g, layout_info * infop) ND_id(dn) = id++; ND_width(dn) = ND_width(n); ND_height(dn) = ND_height(n); - ND_xsize(dn) = ND_xsize(n); - ND_ysize(dn) = ND_ysize(n); + ND_lw(dn) = ND_lw(n); + ND_rw(dn) = ND_rw(n); + ND_ht(dn) = ND_ht(n); ND_shape(dn) = ND_shape(n); ND_shape_info(dn) = ND_shape_info(n); if (ND_pinned(n)) { @@ -841,7 +842,7 @@ setClustNodes(graph_t* root) pointf ctr; node_t *n; double w, h; - int h2, w2, h_i; + double h2, w2; pointf *vertices; for (n = agfstnode(root); n; n = agnxtnode(root, n)) { @@ -853,16 +854,16 @@ setClustNodes(graph_t* root) h = bb.UR.y - bb.LL.y; ctr.x = w / 2.0; ctr.y = h / 2.0; - w2 = POINTS(w / 2.0); - h2 = POINTS(h / 2.0); - h_i = POINTS(h); + w2 = INCH2PS(w / 2.0); + h2 = INCH2PS(h / 2.0); + h = INCH2PS(h); ND_pos(n)[0] = ctr.x; ND_pos(n)[1] = ctr.y; ND_width(n) = w; ND_height(n) = h; - ND_xsize(n) = POINTS(w); + /* ND_xsize(n) = POINTS(w); */ ND_lw(n) = ND_rw(n) = w2; - ND_ht(n) = ND_ysize(n) = h_i; + ND_ht(n) = h; vertices = ((polygon_t *) ND_shape_info(n))->vertices; vertices[0].x = ND_rw(n); @@ -945,8 +946,8 @@ setClustNodes(graph_t* root) ND_height(n) = BB(sg).UR.y; pt.x = POINTS_PER_INCH * BB(sg).UR.x; pt.y = POINTS_PER_INCH * BB(sg).UR.y; - ND_xsize(n) = pt.x; - ND_ysize(n) = pt.y; + ND_rw(n) = ND_lw(n) = pt.x/2; + ND_ht(n) = pt.y; } else if (IS_PORT(n)) agdelete(cg, n); /* remove ports from component */ } -- 2.50.1