static void cloneNode(Agnode_t * old, Agnode_t * new)
{
cloneAttrs(old, new);
- ND_coord_i(new).x = POINTS(ND_pos(old)[0]);
- ND_coord_i(new).y = POINTS(ND_pos(old)[1]);
+ ND_coord(new).x = POINTS(ND_pos(old)[0]);
+ ND_coord(new).y = POINTS(ND_pos(old)[1]);
ND_height(new) = ND_height(old);
ND_ht_i(new) = ND_ht_i(old);
ND_width(new) = ND_width(old);
return rv;
}
+static pointf diaptf(pointf p)
+{
+ pointf rv;
+
+ if (Rot == 0) {
+ rv.x = PB.LL.x + p.x * Scale + Offset.x;
+ rv.y = PB.UR.y - 1 - p.y * Scale - Offset.y;
+ } else {
+ rv.x = PB.UR.x - 1 - p.y * Scale - Offset.x;
+ rv.y = PB.UR.y - 1 - p.x * Scale - Offset.y;
+ }
+ return rv;
+}
+
static void dia_grstyle(context_t * cp)
{
if (strcmp(cp->pencolor, DEFAULT_COLOR)) {
double xsize, ysize, mindist2 = 0.0, dist2;
polygon_t *poly;
pointf P, *vertices;
- static point *A;
+ static pointf *A;
static int A_size;
poly = (polygon_t *) ND_shape_info(n);
if (A_size < sides) {
A_size = sides + 5;
- A = ALLOC(A_size, A, point);
+ A = ALLOC(A_size, A, pointf);
}
- xsize = ((ND_lw_i(n) + ND_rw_i(n)) / POINTS(ND_width(n))) * 16.0;
- ysize = ((ND_ht_i(n)) / POINTS(ND_height(n))) * 16.0;
+ xsize = (ND_lw_i(n) + ND_rw_i(n)) / POINTS(ND_width(n));
+ ysize = (ND_ht_i(n)) / POINTS(ND_height(n));
for (j = 0; j < peripheries; j++) {
for (i = 0; i < sides; i++) {
P = vertices[i + j * sides];
-/* simple rounding produces random results around .5
- * this trick should clip off the random part.
- * (note xsize/ysize prescaled by 16.0 above) */
- A[i].x = ROUND(P.x * xsize) / 16;
- A[i].y = ROUND(P.y * ysize) / 16;
+ A[i].x = P.x * xsize;
+ A[i].y = P.y * ysize;
if (sides > 2) {
- A[i].x += ND_coord_i(n).x;
- A[i].y += ND_coord_i(n).y;
+ A[i].x += ND_coord(n).x;
+ A[i].y += ND_coord(n).y;
}
}
}
z = 0;
while (z < i) {
- dist2 = DIST2(p, diapt(A[z]));
+ dist2 = DIST2(p, diaptf(A[z]));
if (z == 0) {
mindist2 = dist2;
conn = 0;
z = 0;
while (z < i) {
- P.x = (diapt(A[z]).x + diapt(A[z + 1]).x) / 2;
- P.y = (diapt(A[z]).y + diapt(A[z + 1]).y) / 2;
+ P.x = (diaptf(A[z]).x + diaptf(A[z + 1]).x) / 2;
+ P.y = (diaptf(A[z]).y + diaptf(A[z + 1]).y) / 2;
dist2 = DIST2(p, P);
if (dist2 < mindist2) {
mindist2 = dist2;
}
dia_fputs(" <dia:attribute name=\"conn_endpoints\">\n");
- dia_printf(" <dia:point val=\"%g,%g\"/>\n", diapt(A[0]).x,
- diapt(A[0]).y);
- dia_printf(" <dia:point val=\"%g,%g\"/>\n", diapt(A[n - 1]).x,
- diapt(A[n - 1]).y);
+ dia_printf(" <dia:point val=\"%g,%g\"/>\n",
+ diapt(A[0]).x, diapt(A[0]).y);
+ dia_printf(" <dia:point val=\"%g,%g\"/>\n",
+ diapt(A[n - 1]).x, diapt(A[n - 1]).y);
dia_fputs(" </dia:attribute>\n");
dia_fputs(" <dia:connections>\n");
if ((strcmp(shape_t, "ellipse") == 0)
|| (strcmp(shape_t, "circle") == 0)
|| (strcmp(shape_t, "doublecircle") == 0)) {
- cp_h = diapt(ND_coord_i(head));
+ cp_h = diaptf(ND_coord(head));
if (AG_IS_DIRECTED(Rootgraph))
conn_h = ellipse_connection(cp_h, diapt(A[n - 1]));
else
if ((strcmp(shape_t, "ellipse") == 0)
|| (strcmp(shape_t, "circle") == 0)
|| (strcmp(shape_t, "doublecircle") == 0)) {
- cp_t = diapt(ND_coord_i(tail));
+ cp_t = diaptf(ND_coord(tail));
if (AG_IS_DIRECTED(Rootgraph))
conn_t = ellipse_connection(cp_t, diapt(A[0]));
else
int sides, peripheries, i, j, filled = 0, rect = 0, shape, nump = 0;
polygon_t *poly = NULL;
pointf *vertices, ldimen, *p = NULL;
- point coord;
+ pointf coord;
char *s;
obj = push_obj_state(job);
/* checking shape of node */
shape = shapeOf(n);
/* node coordinate */
- coord = ND_coord_i(n);
+ coord = ND_coord(n);
/* checking if filled style has been set for node */
filled = ifFilled(n);
if (rv == 4) {
n = agfindnode(g->root, nodename);
if (n) {
- x = ND_coord_i(n).x;
- y = ND_coord_i(n).y;
+ x = ND_coord(n).x;
+ y = ND_coord(n).y;
}
}
else {
if (rv == 4) {
n = agfindnode(g->root, nodename);
if (n) {
- x = ND_coord_i(n).x;
- y = ND_coord_i(n).y;
+ x = ND_coord(n).x;
+ y = ND_coord(n).y;
}
}
else {
{
edge_t *e;
- ND_bb(n).LL.x = ND_coord_i(n).x - ND_lw_i(n);
- ND_bb(n).LL.y = ND_coord_i(n).y - ND_ht_i(n) / 2.;
- ND_bb(n).UR.x = ND_coord_i(n).x + ND_rw_i(n);
- ND_bb(n).UR.y = ND_coord_i(n).y + ND_ht_i(n) / 2.;
+ ND_bb(n).LL.x = ND_coord(n).x - ND_lw_i(n);
+ ND_bb(n).LL.y = ND_coord(n).y - ND_ht_i(n) / 2.;
+ ND_bb(n).UR.x = ND_coord(n).x + ND_rw_i(n);
+ ND_bb(n).UR.y = ND_coord(n).y + ND_ht_i(n) / 2.;
for (e = agfstout(g, n); e; e = agnxtout(g, e))
init_bb_edge(e);
int Y_off; /* ymin + ymax */
double YF_off; /* Y_off in inches */
-static void printpt(FILE * f, point pt)
-{
- fprintf(f, " %.3g %.3g", PS2INCH(pt.x), PS2INCH(YDIR(pt.y)));
-}
-
static void printptf(FILE * f, pointf pt)
{
fprintf(f, " %.3g %.3g", PS2INCH(pt.x), PS2INCH(YDIR(pt.y)));
if (IS_CLUST_NODE(n))
continue;
fprintf(f, "node %s ", agcanonical(n->name));
- printpt(f, ND_coord_i(n));
+ printptf(f, ND_coord(n));
if (ND_label(n)->html) /* if html, get original text */
lbl = agcanonical (agxget(n, N_label->index));
else
if (f->n_flds == 0) {
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)));
+ f->b.LL.x + ND_coord(n).x,
+ YFDIR(f->b.LL.y + ND_coord(n).y),
+ f->b.UR.x + ND_coord(n).x,
+ YFDIR(f->b.UR.y + ND_coord(n).y));
agxbput(xb, buf);
}
for (i = 0; i < f->n_flds; i++)
safe_dcl(g, g, "bb", "", agraphattr);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
if (dim3) {
- sprintf(buf, "%d,%d,%d", ND_coord_i(n).x, YDIR(ND_coord_i(n).y), POINTS(ND_pos(n)[2]));
+ sprintf(buf, "%.3g,%.3g,%d", ND_coord(n).x, YDIR(ND_coord(n).y), POINTS(ND_pos(n)[2]));
} else {
- sprintf(buf, "%d,%d", ND_coord_i(n).x, YDIR(ND_coord_i(n).y));
+ sprintf(buf, "%.3g,%.3g", ND_coord(n).x, YDIR(ND_coord(n).y));
}
agset(n, "pos", buf);
- sprintf(buf, "%.2f", PS2INCH(ND_ht_i(n)));
+ sprintf(buf, "%.3g", PS2INCH(ND_ht_i(n)));
agxset(n, N_height->index, buf);
- sprintf(buf, "%.2f", PS2INCH(ND_lw_i(n) + ND_rw_i(n)));
+ sprintf(buf, "%.3g", PS2INCH(ND_lw_i(n) + ND_rw_i(n)));
agxset(n, N_width->index, buf);
if (strcmp(ND_shape(n)->name, "record") == 0) {
set_record_rects(n, ND_shape_info(n), &xb);
closepath stroke\n\
} def\n"
-static pointf map_pointf(pointf p)
+static pointf map_point(pointf p)
{
p = ccwrotatepf(p, Rankdir*90);
- p.x -= (double)Offset.x;
- p.y -= (double)Offset.y;
- return p;
-}
-
-static point map_point(point p)
-{
- p = ccwrotatep(p, Rankdir*90);
p.x -= Offset.x;
p.y -= Offset.y;
return p;
for (j = 0; j < ED_spl(e)->size; j++) {
bz = ED_spl(e)->list[j];
for (k = 0; k < bz.size; k++)
- bz.list[k] = map_pointf(bz.list[k]);
+ bz.list[k] = map_point(bz.list[k]);
if (bz.sflag)
- ED_spl(e)->list[j].sp = map_pointf(ED_spl(e)->list[j].sp);
+ ED_spl(e)->list[j].sp = map_point(ED_spl(e)->list[j].sp);
if (bz.eflag)
- ED_spl(e)->list[j].ep = map_pointf(ED_spl(e)->list[j].ep);
+ ED_spl(e)->list[j].ep = map_point(ED_spl(e)->list[j].ep);
}
if (ED_label(e))
- ED_label(e)->pos = map_pointf(ED_label(e)->pos);
+ ED_label(e)->pos = map_point(ED_label(e)->pos);
/* vladimir */
if (ED_head_label(e))
- ED_head_label(e)->pos = map_pointf(ED_head_label(e)->pos);
+ ED_head_label(e)->pos = map_point(ED_head_label(e)->pos);
if (ED_tail_label(e))
- ED_tail_label(e)->pos = map_pointf(ED_tail_label(e)->pos);
+ ED_tail_label(e)->pos = map_point(ED_tail_label(e)->pos);
}
void translate_bb(graph_t * g, int rankdir)
bb = GD_bb(g);
if (rankdir == RANKDIR_LR || rankdir == RANKDIR_BT) {
- new_bb.LL = map_pointf(pointfof(bb.LL.x, bb.UR.y));
- new_bb.UR = map_pointf(pointfof(bb.UR.x, bb.LL.y));
+ new_bb.LL = map_point(pointfof(bb.LL.x, bb.UR.y));
+ new_bb.UR = map_point(pointfof(bb.UR.x, bb.LL.y));
} else {
- new_bb.LL = map_pointf(pointfof(bb.LL.x, bb.LL.y));
- new_bb.UR = map_pointf(pointfof(bb.UR.x, bb.UR.y));
+ new_bb.LL = map_point(pointfof(bb.LL.x, bb.LL.y));
+ new_bb.UR = map_point(pointfof(bb.UR.x, bb.UR.y));
}
GD_bb(g) = new_bb;
if (GD_label(g)) {
- GD_label(g)->pos = map_pointf(GD_label(g)->pos);
+ GD_label(g)->pos = map_point(GD_label(g)->pos);
}
for (c = 1; c <= GD_n_cluster(g); c++)
translate_bb(GD_clust(g)[c], rankdir);
for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
if (Rankdir) dot_nodesize(v, FALSE);
if (shift) {
- ND_coord_i(v) = map_point(ND_coord_i(v));
+ ND_coord(v) = map_point(ND_coord(v));
if (State == GVSPLINES)
for (e = agfstout(g, v); e; e = agnxtout(g, e))
map_edge(e);
static void checkpath(int, boxf*, path*);
static void mkspacep(int size);
static void printpath(path * pp);
-#ifdef OBSOLETE
-static int append(path * path, int bi, point p0, point p1, int);
-#endif
#ifdef DEBUG
static void printboxes(int boxn, box* boxes)
{
}
#endif /* DEBUG */
-#ifdef OBSOLETE
-static point mkpt(int x, int y)
-{
- point rv;
- rv.x = x;
- rv.y = y;
- return rv;
-}
-
-static int pteq(point p, point q)
-{
- return ((p.x == q.x) && (p.y == q.y));
-}
-#endif
-
/* routesplinesinit:
* Data initialized once until matching call to routeplineterm
* Allows recursive calls to dot
routesplinesinit()
{
if (++routeinit > 1) return;
-#ifdef UNUSED
- if (!(bs = N_GNEW(BINC, box))) {
- agerr(AGERR, "cannot allocate bs\n");
- abort();
- }
- maxbn = BINC;
-#endif
if (!(ps = N_GNEW(PINC, pointf))) {
agerr(AGERR, "cannot allocate ps\n");
abort();
Ppoint_t eps[2];
Pvector_t evs[2];
int edgei, prev, next;
- point sp[4];
+ pointf sp[4];
int pi, bi, si;
double t;
boxf *boxes;
if ((boxn > 1) && (boxes[0].LL.y > boxes[1].LL.y)) {
flip = 1;
for (bi = 0; bi < boxn; bi++) {
- int v = boxes[bi].UR.y;
+ double v = boxes[bi].UR.y;
boxes[bi].UR.y = -1*boxes[bi].LL.y;
boxes[bi].LL.y = -v;
}
polypoints[pi++].y = boxes[bi].LL.y;
}
}
- }
+ }
else {
-#ifdef OBSOLETE
- /* new, more generalized approach for self-edges. We do not
- assume any monotonicity about the box path, only that it
- is simply connected. We build up the constraint poly by
- walking the box path from one end to the other and back
- in the recursive function append(). A better approach to all
- of this might be to dispense with the box paths altogether
- and just compute the constraint poly directly, but this
- needs to be done as part of a more thorough overhaul. */
- point p0, p1;
- box b0, b1;
- b0 = pp->boxes[0];
- b1 = pp->boxes[1];
- /* determine 'starting' segment (side of b0) for box path search */
- if (b0.UR.x == b1.LL.x) {
- p0 = b0.LL;
- p1 = mkpt(b0.LL.x, b0.UR.y);
- } else if (b0.LL.y == b1.UR.y) {
- p0 = mkpt(b0.LL.x, b0.UR.y);
- p1 = b0.UR;
- } else if (b0.LL.x == b1.UR.x) {
- p0 = b0.UR;
- p1 = mkpt(b0.UR.x, b0.LL.y);
- } else if (b0.UR.y == b1.LL.y) {
- p0 = mkpt(b0.UR.x, b0.LL.y);
- p1 = b0.LL;
- } else
- abort();
- pi = append(pp, 0, p0, p1, 0);
-#else
abort();
-#endif
}
if (flip) {
boxes[bi].UR.x = INT_MIN;
}
for (splinepi = 0; splinepi < spl.pn; splinepi++) {
- P2PF(spl.ps[splinepi], ps[splinepi]);
+ ps[splinepi] = spl.ps[splinepi];
}
REDO:
for (splinepi = 0; splinepi + 3 < spl.pn; splinepi += 3) {
int num_div = delta * boxn;
for (si = 0; si <= num_div; si++) {
t = si / ((double)num_div);
- PF2P(ps[splinepi], sp[0]);
- PF2P(ps[splinepi + 1], sp[1]);
- PF2P(ps[splinepi + 2], sp[2]);
- PF2P(ps[splinepi + 3], sp[3]);
+ sp[0] = ps[splinepi];
+ sp[1] = ps[splinepi + 1];
+ sp[2] = ps[splinepi + 2];
+ sp[3] = ps[splinepi + 3];
sp[0].x = sp[0].x + t * (sp[1].x - sp[0].x);
sp[0].y = sp[0].y + t * (sp[1].y - sp[0].y);
sp[1].x = sp[1].x + t * (sp[2].x - sp[1].x);
* Therefore, we make the sample finer until all boxes have
* valid values. cf. bug 456. Would making sp[] pointfs help?
*/
- for (bi = 0; bi < boxn; bi++) {
+ for (bi = 0; bi < boxn; bi++) { /* FIXME - fp equality tests */
if ((boxes[bi].LL.x == INT_MAX) || (boxes[bi].UR.x == INT_MIN)) {
delta *= 2;
goto REDO;
/* remove degenerate boxes. */
i = 0;
for (bi = 0; bi < boxn; bi++) {
- if (boxes[bi].LL.y == boxes[bi].UR.y)
+ if (ABS(boxes[bi].LL.y - boxes[bi].UR.y) < .01)
continue;
- if (boxes[bi].LL.x == boxes[bi].UR.x)
+ if (ABS(boxes[bi].LL.x - boxes[bi].UR.x) < .01)
continue;
if (i != bi)
boxes[i] = boxes[bi];
}
}
-#ifdef OBSOLETE
-/* new code to create poly from box list
- * given that we entered the box b on segment p0,p1 (p0==p1 allowed)
- * then add successive points to the constraint poly
- */
-
-#define BOXLEFT 0
-#define BOXTOP 1
-#define BOXRIGHT 2
-#define BOXBOTTOM 3
-static box B;
-
-static int sideofB(point p, box B)
-{
- if (p.x == B.LL.x)
- return BOXLEFT;
- if (p.y == B.UR.y)
- return BOXTOP;
- if (p.x == B.UR.x)
- return BOXRIGHT;
- if (p.y == B.LL.y)
- return BOXBOTTOM;
- abort();
- return 0;
-}
-
-static int appendpt(point p, int polysz)
-{
- polypoints[polysz].x = p.x;
- polypoints[polysz].y = p.y;
- return (polysz+1);
-}
-
-static int cmpf(const void *pp0, const void *pp1)
-{
- point p0, p1;
- int s0, s1;
-
- p0 = *(point *) pp0;
- p1 = *(point *) pp1;
- s0 = sideofB(p0, B);
- s1 = sideofB(p1, B);
-
- if (s0 != s1)
- return s1 - s0;
- switch (s0) {
- case BOXLEFT:
- return p1.y - p0.y;
- case BOXTOP:
- return p1.x - p0.x;
- case BOXRIGHT:
- return p0.y - p1.y;
- case BOXBOTTOM:
- return p0.x - p1.x;
- default:
- abort();
- }
- return 0; /* not reached */
-}
-
-/* append:
- */
-static int
-append(path * path, int bi, point p0, point p1, int polysz)
-{
- point v[8]; /* worst case 4 corners + 2 segs * 2 points each */
- point w[8];
- box b = path->boxes[bi];
- box bb;
- int i, i0, npw, delta;
- point q0 = { 0, 0 }, q1 = { 0, 0}, r;
- int pn;
-
- /* v = 4 corners of b, p0 and p1 */
- pn = 0;
- v[pn++] = b.LL;
- v[pn++] = mkpt(b.UR.x, b.LL.y);
- v[pn++] = b.UR;
- v[pn++] = mkpt(b.LL.x, b.UR.y);
- v[pn++] = p0;
- v[pn++] = p1;
-
- if (bi + 1 < path->nbox) {
- bb = path->boxes[bi + 1];
- /* determine points q0,q1 where b and bb touch and append to v */
- if (b.UR.x == bb.LL.x) {
- q0.x = q1.x = b.UR.x;
- q0.y = MIN(b.UR.y, bb.UR.y);
- q1.y = MAX(b.LL.y, bb.LL.y);
- } else if (b.LL.x == bb.UR.x) {
- q0.x = q1.x = b.LL.x;
- q0.y = MIN(b.UR.y, bb.UR.y);
- q1.y = MAX(b.LL.y, bb.LL.y);
- } else if (b.UR.y == bb.LL.y) {
- q0.y = q1.y = b.UR.y;
- q0.x = MIN(b.UR.x, bb.UR.x);
- q1.x = MAX(b.LL.x, bb.LL.x);
- } else if (b.LL.y == bb.UR.y) {
- q0.y = q1.y = b.LL.y;
- q0.x = MIN(b.UR.x, bb.UR.x);
- q1.x = MAX(b.LL.x, bb.LL.x);
- } else
- abort();
- v[pn++] = q0;
- v[pn++] = q1;
- }
-
- /* sort v so that the cyclic order is p0, all other points, p1 */
- B = b;
- qsort(v, pn, sizeof(v[0]), cmpf);
-
- /* eliminate duplicates and record i0 = index of p0 in w */
- w[0] = v[0];
- npw = 1;
- i0 = -1;
- for (i = 0; i < pn; i++) {
- if (pteq(w[npw - 1], p0))
- i0 = npw - 1;
- if (!pteq(v[i], w[npw - 1]))
- w[npw++] = v[i];
- }
-
- i = i0;
- if (bi == 0)
- polysz = appendpt(p0, polysz);
- if (pteq(p1, w[(i0 + 1) % npw]))
- delta = -1;
- else if (pteq(p1, w[(i0 - 1 + npw) % npw]))
- delta = 1;
- else
- abort();
- do {
- i = (i + delta + npw) % npw; /* go to the next point in order */
- r = w[i]; /* call it r */
-
- /* append r to current poly, except p0 and p1 are special cases */
- if ((bi == 0) || (!pteq(r, p0) && !pteq(r, p1)))
- polysz = appendpt(r, polysz);
- if (pteq(r, p1))
- break;
- if (bi + 1 < path->nbox) { /* recur when we hit the next box */
- if (pteq(r, q0)) {
- polysz = append(path, bi + 1, q0, q1, polysz);
- polysz = appendpt(q1, polysz); /* assumes q1 != p0 and p1 */
- i += delta; /* skip q1 */
- } else if (pteq(r, q1)) {
- polysz = append(path, bi + 1, q1, q0, polysz);
- polysz = appendpt(q0, polysz);
- i += delta;
- }
- }
- } while (i != i0);
- return polysz;
-}
-#endif
-
static void printpath(path * pp)
{
int bi;
static void Mcircle_hack(GVJ_t * job, node_t * n)
{
double x, y;
- pointf AF[2], p, coord;
+ pointf AF[2], p;
y = .7500;
x = .6614; /* x^2 + y^2 = 1.0 */
p.y = y * ND_ht_i(n) / 2.0;
p.x = ND_rw_i(n) * x; /* assume node is symmetric */
- P2PF(ND_coord_i(n), coord);
- AF[0] = add_pointfs(p, coord);
+ AF[0] = add_pointfs(p, ND_coord(n));
AF[1].y = AF[0].y;
AF[1].x = AF[0].x - 2 * p.x;
gvrender_polyline(job, AF, 2);
}
/* nominal label position in the center of the node */
- P2PF(ND_coord_i(n), ND_label(n)->pos);
+ ND_label(n)->pos = ND_coord(n);
xsize = (double)(ND_lw_i(n) + ND_rw_i(n)) / POINTS(ND_width(n));
ysize = (double)ND_ht_i(n) / POINTS(ND_height(n));
/* get coords of innermost periphery */
for (i = 0; i < sides; i++) {
P = vertices[i];
- AF[i].x = P.x * xsize + (double)ND_coord_i(n).x;
- AF[i].y = P.y * ysize + (double)ND_coord_i(n).y;
+ AF[i].x = P.x * xsize + ND_coord(n).x;
+ AF[i].y = P.y * ysize + ND_coord(n).y;
}
/* lay down fill first */
if (filled && pfilled) {
for (j = 0; j < peripheries; j++) {
for (i = 0; i < sides; i++) {
P = vertices[i + j * sides];
- AF[i].x = P.x * xsize + (double)ND_coord_i(n).x;
- AF[i].y = P.y * ysize + (double)ND_coord_i(n).y;
+ AF[i].x = P.x * xsize + ND_coord(n).x;
+ AF[i].y = P.y * ysize + ND_coord(n).y;
}
if (sides <= 2) {
gvrender_ellipse(job, AF, sides, filled);
for (j = 0; j < peripheries; j++) {
for (i = 0; i < sides; i++) {
P = vertices[i + j * sides];
- AF[i].x = P.x + (double)ND_coord_i(n).x;
- AF[i].y = P.y + (double)ND_coord_i(n).y;
+ AF[i].x = P.x + ND_coord(n).x;
+ AF[i].y = P.y + ND_coord(n).y;
}
gvrender_ellipse(job, AF, sides, filled);
/* fill innermost periphery only */
static int record_path(node_t* n, port* prt, int side, boxf rv[], int *kptr)
{
int i, ls, rs;
- pointf p, np;
+ pointf p;
field_t *info;
if (!prt->defined) return 0;
if (BETWEEN(ls, p.x, rs)) {
/* FIXME: I don't understand this code */
if (GD_flip(n->graph)) {
- P2PF(ND_coord_i(n), np);
- rv[0] = flip_rec_boxf(info->fld[i]->b, np);
+ rv[0] = flip_rec_boxf(info->fld[i]->b, ND_coord(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].UR.x = ND_coord_i(n).x + rs;
+ rv[0].LL.x = ND_coord(n).x + ls;
+ rv[0].LL.y = ND_coord(n).y - (ND_ht_i(n) / 2);
+ rv[0].UR.x = ND_coord(n).x + rs;
}
- rv[0].UR.y = ND_coord_i(n).y + ND_ht_i(n) / 2;
+ rv[0].UR.y = ND_coord(n).y + (ND_ht_i(n) / 2);
*kptr = 1;
break;
}
pointf AF[2], coord;
if (f->lp) {
- 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;
+ coord.x = (f->b.LL.x + f->b.UR.x) / 2. + ND_coord(n).x;
+ coord.y = (f->b.LL.y + f->b.UR.y) / 2. + ND_coord(n).y;
f->lp->pos = coord;
emit_label(job, EMIT_NLABEL, f->lp);
pencolor(job, n);
for (i = 0; i < f->n_flds; i++) {
if (i > 0) {
if (f->LR) {
- P2PF(f->fld[i]->b.LL, AF[0]);
+ AF[0] = f->fld[i]->b.LL;
AF[1].x = AF[0].x;
- AF[1].y = (double)(f->fld[i]->b.UR.y);
+ AF[1].y = f->fld[i]->b.UR.y;
} else {
- P2PF(f->fld[i]->b.UR, AF[1]);
- AF[0].x = (double)(f->fld[i]->b.LL.x);
+ AF[1] = f->fld[i]->b.UR;
+ AF[0].x = f->fld[i]->b.LL.x;
AF[0].y = AF[1].y;
}
- P2PF(ND_coord_i(n), coord);
+ coord = ND_coord(n);
AF[0] = add_pointfs(AF[0], coord);
AF[1] = add_pointfs(AF[1], coord);
gvrender_polyline(job, AF, 2);
int doMap = (obj->url || obj->explicit_tooltip);
f = (field_t *) ND_shape_info(n);
- B2BF(f->b, BF);
- BF.LL.x += (double)(ND_coord_i(n).x);
- BF.LL.y += (double)(ND_coord_i(n).y);
- BF.UR.x += (double)(ND_coord_i(n).x);
- BF.UR.y += (double)(ND_coord_i(n).y);
+ BF = f->b;
+ BF.LL.x += ND_coord(n).x;
+ BF.LL.y += ND_coord(n).y;
+ BF.UR.x += ND_coord(n).x;
+ BF.UR.y += ND_coord(n).y;
if (doMap && !(job->flags & EMIT_CLUSTERS_LAST))
gvrender_begin_anchor(job, obj->url, obj->tooltip, obj->target);
gvrender_begin_context(job);
if (desc)
fprintf(job->output_file,
- "%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);
- P2PF(ND_coord_i(n), ND_label(n)->pos);
+ "%.3g %.3g translate newpath user_shape_%d\n",
+ ND_coord(n).x + desc->offset.x,
+ ND_coord(n).y + desc->offset.y, desc->macro_id);
+ ND_label(n)->pos = ND_coord(n);
gvrender_end_context(job);
emit_label(job, EMIT_NLABEL, ND_label(n));
static char* side_port[] = {"s", "e", "n", "w"};
static point
-cvtPt (point p, int rankdir)
+cvtPt (pointf p, int rankdir)
{
- point q = {0, 0};
+ pointf q = {0, 0};
+ point Q;
switch (rankdir) {
case RANKDIR_TB :
q.x = p.y;
break;
}
- return q;
+ PF2P(q, Q);
+ return Q;
}
static char* closestSide (node_t* n, node_t* other, port* oldport)
boxf b;
int rkd = GD_rankdir(n->graph->root);
point p = {0, 0};
- point pt = cvtPt (ND_coord_i(n), rkd);
- point opt = cvtPt (ND_coord_i(other), rkd);
+ point pt = cvtPt (ND_coord(n), rkd);
+ point opt = cvtPt (ND_coord(other), rkd);
int sides = oldport->side;
char* rv = NULL;
int i, d, mind = 0;
save_real_size = ND_rw_i(n);
for (i = 0; i < 4; i++) {
- c[i].x = curve[i].x - ND_coord_i(n).x;
- c[i].y = curve[i].y - ND_coord_i(n).y;
+ c[i].x = curve[i].x - ND_coord(n).x;
+ c[i].y = curve[i].y - ND_coord(n).y;
}
bezier_clip(inside_context, ND_shape(n)->fns->insidefn, c,
left_inside);
for (i = 0; i < 4; i++) {
- curve[i].x = c[i].x + ND_coord_i(n).x;
- curve[i].y = c[i].y + ND_coord_i(n).y;
+ curve[i].x = c[i].x + ND_coord(n).x;
+ curve[i].y = c[i].y + ND_coord(n).y;
}
ND_rw_i(n) = save_real_size;
}
inside_context.s.n = n;
inside_context.s.bp = NULL;
save_real_size = ND_rw_i(n);
- c.x = curve[0].x - ND_coord_i(n).x;
- c.y = curve[0].y - ND_coord_i(n).y;
+ c.x = curve[0].x - ND_coord(n).x;
+ c.y = curve[0].y - ND_coord(n).y;
left_inside = ND_shape(n)->fns->insidefn(&inside_context, c);
ND_rw_i(n) = save_real_size;
shape_clip0(&inside_context, n, curve, left_inside);
inside_context.s.n = tn;
inside_context.s.bp = tbox;
for (start = 0; start < pn - 4; start += 3) {
- p2.x = ps[start + 3].x - ND_coord_i(tn).x;
- p2.y = ps[start + 3].y - ND_coord_i(tn).y;
+ p2.x = ps[start + 3].x - ND_coord(tn).x;
+ p2.y = ps[start + 3].y - ND_coord(tn).y;
if (ND_shape(tn)->fns->insidefn(&inside_context, p2) == FALSE)
break;
}
inside_context.s.n = hn;
inside_context.s.bp = hbox;
for (end = pn - 4; end > 0; end -= 3) {
- p2.x = ps[end].x - ND_coord_i(hn).x;
- p2.y = ps[end].y - ND_coord_i(hn).y;
+ p2.x = ps[end].x - ND_coord(hn).x;
+ p2.y = ps[end].y - ND_coord(hn).y;
if (ND_shape(hn)->fns->insidefn(&inside_context, p2) == FALSE)
break;
}
s_in = s_out = 0.0;
for (cnt_in = 0; (e = ND_in(n).list[cnt_in]); cnt_in++)
- s_in += ND_coord_i(e->tail).x;
+ s_in += ND_coord(e->tail).x;
for (cnt_out = 0; (e = ND_out(n).list[cnt_out]); cnt_out++)
- s_out += ND_coord_i(e->head).x;
- p.x = ND_coord_i(n).x - (s_in / cnt_in);
- p.y = ND_coord_i(n).y - ND_coord_i(ND_in(n).list[0]->tail).y;
+ s_out += ND_coord(e->head).x;
+ p.x = ND_coord(n).x - (s_in / cnt_in);
+ p.y = ND_coord(n).y - ND_coord(ND_in(n).list[0]->tail).y;
m_in = atan2(p.y, p.x);
- p.x = (s_out / cnt_out) - ND_coord_i(n).x;
- p.y = ND_coord_i(ND_out(n).list[0]->head).y - ND_coord_i(n).y;
+ p.x = (s_out / cnt_out) - ND_coord(n).x;
+ p.y = ND_coord(ND_out(n).list[0]->head).y - ND_coord(n).y;
m_out = atan2(p.y, p.x);
return ((m_in + m_out) / 2.0);
}
{
int side, mask;
node_t *n;
- pointf np;
int (*pboxfn) (node_t*, port*, int, boxf*, int*);
n = e->tail;
pboxfn = ND_shape(n)->fns->pboxfn;
else
pboxfn = NULL;
- P2PF(ND_coord_i(n), np);
- P->start.p = add_pointfs(np, ED_tail_port(e).p);
+ P->start.p = add_pointfs(ND_coord(n), ED_tail_port(e).p);
if (merge) {
/*P->start.theta = - M_PI / 2; */
P->start.theta = conc_slope(e->tail);
boxf b0, b = endp->nb;
if (side & TOP) {
endp->sidemask = TOP;
- if (P->start.p.x < ND_coord_i(n).x) { /* go left */
+ if (P->start.p.x < ND_coord(n).x) { /* go left */
b0.LL.x = b.LL.x - 1;
- /* b0.LL.y = ND_coord_i(n).y + ND_ht_i(n)/2; */
+ /* b0.LL.y = ND_coord(n).y + ND_ht_i(n)/2; */
b0.LL.y = P->start.p.y;
b0.UR.x = b.UR.x;
- b0.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2;
- b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - (FUDGE-2);
+ b0.UR.y = ND_coord(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2;
+ b.UR.x = ND_coord(n).x - ND_lw_i(n) - (FUDGE-2);
b.UR.y = b0.LL.y;
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.LL.x -= 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
else {
b0.LL.x = b.LL.x;
b0.LL.y = P->start.p.y;
- /* b0.LL.y = ND_coord_i(n).y + ND_ht_i(n)/2; */
+ /* b0.LL.y = ND_coord(n).y + ND_ht_i(n)/2; */
b0.UR.x = b.UR.x+1;
- b0.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2;
- b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2);
+ b0.UR.y = ND_coord(n).y + ND_ht_i(n)/2 + GD_ranksep(n->graph)/2;
+ b.LL.x = ND_coord(n).x + ND_rw_i(n) + (FUDGE-2);
b.UR.y = b0.LL.y;
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.x += 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
else if (side & LEFT) {
endp->sidemask = LEFT;
b.UR.x = P->start.p.x;
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->start.p.y;
endp->boxes[0] = b;
endp->boxn = 1;
else {
endp->sidemask = RIGHT;
b.LL.x = P->start.p.x;
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->start.p.y;
endp->boxes[0] = b;
endp->boxn = 1;
}
else if (side & BOTTOM) {
if (endp->sidemask == TOP) {
- b0.UR.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b0.UR.y = ND_coord(n).y - ND_ht_i(n)/2;
b0.UR.x = b.UR.x+1;
b0.LL.x = P->start.p.x;
b0.LL.y = b0.UR.y - GD_ranksep(n->graph)/2;
- b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2);
+ b.LL.x = ND_coord(n).x + ND_rw_i(n) + (FUDGE-2);
b.LL.y = b0.UR.y;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.UR.x += 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
else if (side & LEFT) {
b.UR.x = P->start.p.x+1;
if (endp->sidemask == TOP) {
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->start.p.y-1;
}
else {
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->start.p.y+1;
}
endp->boxes[0] = b;
else {
b.LL.x = P->start.p.x;
if (endp->sidemask == TOP) {
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->start.p.y;
}
else {
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->start.p.y+1;
}
endp->boxes[0] = b;
{
int side, mask;
node_t *n;
- pointf np;
int (*pboxfn) (node_t* n, port*, int, boxf*, int*);
n = e->head;
pboxfn = ND_shape(n)->fns->pboxfn;
else
pboxfn = NULL;
- P2PF(ND_coord_i(n), np);
- P->end.p = add_pointfs(np, ED_head_port(e).p);
+ P->end.p = add_pointfs(ND_coord(n), ED_head_port(e).p);
if (merge) {
/*P->end.theta = M_PI / 2; */
P->end.theta = conc_slope(e->head) + M_PI;
}
else if (side & BOTTOM) {
endp->sidemask = BOTTOM;
- if (P->end.p.x < ND_coord_i(n).x) { /* go left */
+ if (P->end.p.x < ND_coord(n).x) { /* go left */
b0.LL.x = b.LL.x-1;
- /* b0.UR.y = ND_coord_i(n).y - ND_ht_i(n)/2; */
+ /* b0.UR.y = ND_coord(n).y - ND_ht_i(n)/2; */
b0.UR.y = P->end.p.y;
b0.UR.x = b.UR.x;
- b0.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2;
- b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - (FUDGE-2);
+ b0.LL.y = ND_coord(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2;
+ b.UR.x = ND_coord(n).x - ND_lw_i(n) - (FUDGE-2);
b.LL.y = b0.UR.y;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.x -= 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
else {
b0.LL.x = b.LL.x;
b0.UR.y = P->end.p.y;
- /* b0.UR.y = ND_coord_i(n).y - ND_ht_i(n)/2; */
+ /* b0.UR.y = ND_coord(n).y - ND_ht_i(n)/2; */
b0.UR.x = b.UR.x+1;
- b0.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2;
- b.LL.x = ND_coord_i(n).x + ND_rw_i(n) + (FUDGE-2);
+ b0.LL.y = ND_coord(n).y - ND_ht_i(n)/2 - GD_ranksep(n->graph)/2;
+ b.LL.x = ND_coord(n).x + ND_rw_i(n) + (FUDGE-2);
b.LL.y = b0.UR.y;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.UR.x += 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
else if (side & LEFT) {
endp->sidemask = LEFT;
b.UR.x = P->end.p.x;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->end.p.y;
endp->boxes[0] = b;
endp->boxn = 1;
else {
endp->sidemask = RIGHT;
b.LL.x = P->end.p.x;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->end.p.y;
endp->boxes[0] = b;
endp->boxn = 1;
case LEFT:
b.UR.x = P->end.p.x;
if (endp->sidemask == TOP) {
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->end.p.y;
}
else {
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->end.p.y;
}
endp->boxes[0] = b;
case RIGHT:
b.LL.x = P->end.p.x-1;
if (endp->sidemask == TOP) {
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.y = P->end.p.y-1;
}
else {
- b.LL.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b.LL.y = ND_coord(n).y - ND_ht_i(n)/2;
b.UR.y = P->end.p.y;
}
endp->boxes[0] = b;
case BOTTOM:
if (endp->sidemask == TOP) {
b0.LL.x = b.LL.x-1;
- b0.UR.y = ND_coord_i(n).y - ND_ht_i(n)/2;
+ b0.UR.y = ND_coord(n).y - ND_ht_i(n)/2;
b0.UR.x = P->end.p.x;
b0.LL.y = b0.UR.y - GD_ranksep(n->graph)/2;
- b.UR.x = ND_coord_i(n).x - ND_lw_i(n) - 2;
+ b.UR.x = ND_coord(n).x - ND_lw_i(n) - 2;
b.LL.y = b0.UR.y;
- b.UR.y = ND_coord_i(n).y + ND_ht_i(n)/2;
+ b.UR.y = ND_coord(n).y + ND_ht_i(n)/2;
b.LL.x -= 1;
endp->boxes[0] = b0;
endp->boxes[1] = b;
stepx = (sizex / 2.) / cnt;
stepx = MAX(stepx,2.);
pointn = 0;
- P2PF(ND_coord_i(n), np);
+ np = ND_coord(n);
tp = ED_tail_port(e).p;
tp.x += np.x;
tp.y += np.y;
width = ED_label(e)->dimen.x;
height = ED_label(e)->dimen.y;
}
- 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)->pos.y = ND_coord(n).y - dy - height / 2.0;
+ ED_label(e)->pos.x = ND_coord(n).x;
ED_label(e)->set = TRUE;
if (height > stepy)
dy += height - stepy;
stepx = (sizex / 2.) / cnt;
stepx = MAX(stepx, 2.);
pointn = 0;
- P2PF(ND_coord_i(n), np);
+ np = ND_coord(n);
tp = ED_tail_port(e).p;
tp.x += np.x;
tp.y += np.y;
width = ED_label(e)->dimen.x;
height = ED_label(e)->dimen.y;
}
- 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)->pos.y = ND_coord(n).y + dy + height / 2.0;
+ ED_label(e)->pos.x = ND_coord(n).x;
ED_label(e)->set = TRUE;
if (height > stepy)
dy += height - stepy;
stepy = (sizey / 2.) / cnt;
stepy = MAX(stepy, 2.);
pointn = 0;
- P2PF(ND_coord_i(n), np);
+ np = ND_coord(n);
tp = ED_tail_port(e).p;
tp.x += np.x;
tp.y += np.y;
width = ED_label(e)->dimen.x;
height = ED_label(e)->dimen.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)->pos.x = ND_coord(n).x + dx + width / 2.0;
+ ED_label(e)->pos.y = ND_coord(n).y;
ED_label(e)->set = TRUE;
if (width > stepx)
dx += width - stepx;
stepy = (sizey / 2.) / cnt;
stepy = MAX(stepy,2.);
pointn = 0;
- P2PF(ND_coord_i(n), np);
+ np = ND_coord(n);
tp = ED_tail_port(e).p;
tp.x += np.x;
tp.y += np.y;
width = ED_label(e)->dimen.x;
height = ED_label(e)->dimen.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)->pos.x = ND_coord(n).x - dx - width / 2.0;
+ ED_label(e)->pos.y = ND_coord(n).y;
ED_label(e)->set = TRUE;
if (width > stepx)
dx += width - stepx;
typedef struct Agnodeinfo_t {
shape_desc *shape;
void *shape_info;
- point coord;
+ pointf coord;
double width, height;
boxf bb;
int ht, lw, rw;
#define ND_alg(n) (n)->u.alg
#define ND_bb(n) (n)->u.bb
#define ND_clust(n) (n)->u.clust
-#define ND_coord_i(n) (n)->u.coord
+#define ND_coord(n) (n)->u.coord
#define ND_dist(n) (n)->u.dist
#define ND_flat_in(n) (n)->u.flat_in
#define ND_flat_out(n) (n)->u.flat_out
if (! OVERLAP(b, bb))
return FALSE;
- P2PF(ND_coord_i(n),p);
+ p = ND_coord(n);
/* FIXME - need to do something better about CLOSEENOUGH */
p.x -= (b.UR.x + b.LL.x) / 2.;
fixed = 0;
if (lh) {
bb = &(GD_bb(lh));
- if (!inBox(ND_coord_i(head), bb)) {
+ if (!inBoxf(ND_coord(head), bb)) {
agerr(AGWARN, "%s -> %s: head not inside head cluster %s\n",
e->tail->name, e->head->name, agget(e, "lhead"));
} else {
* crosses box.
*/
if (inBoxf(bez->list[0], bb)) {
- if (inBox(ND_coord_i(tail), bb)) {
+ if (inBoxf(ND_coord(tail), bb)) {
agerr(AGWARN,
"%s -> %s: tail is inside head cluster %s\n",
e->tail->name, e->head->name, agget(e, "lhead"));
fixed = 0;
if (lt) {
bb = &(GD_bb(lt));
- if (!inBox(ND_coord_i(tail), bb)) {
+ if (!inBoxf(ND_coord(tail), bb)) {
agerr(AGWARN, "%s -> %s: tail not inside tail cluster %s\n",
e->tail->name, head->name, agget(e, "ltail"));
} else {
* arrow head crosses box.
*/
if (inBoxf(bez->list[endi], bb)) {
- if (inBox(ND_coord_i(head), bb)) {
+ if (inBoxf(ND_coord(head), bb)) {
agerr(AGWARN,
"%s -> %s: head is inside tail cluster %s\n",
e->tail->name, e->head->name, agget(e, "ltail"));
ED_to_orig(newp) = old; \
}
-#define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
#define AVG(a, b) ((a + b) / 2)
static boxf boxes[1000];
for (i = GD_minrank(g); i <= GD_maxrank(g); i++) {
n_nodes += GD_rank(g)[i].n;
if ((n = GD_rank(g)[i].v[0]))
- sd.LeftBound = MIN(sd.LeftBound, (ND_coord_i(n).x - ND_lw_i(n)));
+ sd.LeftBound = MIN(sd.LeftBound, (ND_coord(n).x - ND_lw_i(n)));
if (GD_rank(g)[i].n && (n = GD_rank(g)[i].v[GD_rank(g)[i].n - 1]))
- sd.RightBound = MAX(sd.RightBound, (ND_coord_i(n).x + ND_rw_i(n)));
+ sd.RightBound = MAX(sd.RightBound, (ND_coord(n).x + ND_rw_i(n)));
sd.LeftBound -= MINW;
sd.RightBound += MINW;
if (ND_alg(n)) {
edge_t* fe = (edge_t*)ND_alg(n);
assert (ED_label(fe));
- P2PF(ND_coord_i(n), ED_label(fe)->pos);
+ ED_label(fe)->pos = ND_coord(n);
}
if ((ND_node_type(n) != NORMAL) &&
(sinfo.splineMerge(n) == FALSE))
r = ND_rank(n);
if (r == GD_maxrank(g)) {
if (r > 0)
- sizey = ND_coord_i(GD_rank(g)[r-1].v[0]).y - ND_coord_i(n).y;
+ sizey = ND_coord(GD_rank(g)[r-1].v[0]).y - ND_coord(n).y;
else
sizey = ND_ht_i(n);
}
else if (r == GD_minrank(g)) {
- sizey = ND_coord_i(n).y - ND_coord_i(GD_rank(g)[r+1].v[0]).y;
+ sizey = ND_coord(n).y - ND_coord(GD_rank(g)[r+1].v[0]).y;
}
else {
- int upy = ND_coord_i(GD_rank(g)[r-1].v[0]).y - ND_coord_i(n).y;
- int dwny = ND_coord_i(n).y - ND_coord_i(GD_rank(g)[r+1].v[0]).y;
+ int upy = ND_coord(GD_rank(g)[r-1].v[0]).y - ND_coord(n).y;
+ int dwny = ND_coord(n).y - ND_coord(GD_rank(g)[r+1].v[0]).y;
sizey = MIN(upy, dwny);
}
makeSelfEdge(P, edges, ind, cnt, sd.Multisep, sizey/2, &sinfo);
e = ED_to_orig(e));
dimen = ED_label(e)->dimen;
width = GD_flip(n->graph) ? dimen.y : dimen.x;
- ED_label(e)->pos.x = ND_coord_i(n).x + width / 2.0;
- ED_label(e)->pos.y = ND_coord_i(n).y;
+ ED_label(e)->pos.x = ND_coord(n).x + width / 2.0;
+ ED_label(e)->pos.y = ND_coord(n).y;
}
static void
v1 = ND_rank(le1->tail) - ND_rank(le1->head), v1 = ABS(v1);
if (v0 != v1)
return (v0 - v1);
- v0 = ND_coord_i(le0->tail).x - ND_coord_i(le0->head).x, v0 = ABS(v0);
- v1 = ND_coord_i(le1->tail).x - ND_coord_i(le1->head).x, v1 = ABS(v1);
+ v0 = ND_coord(le0->tail).x - ND_coord(le0->head).x, v0 = ABS(v0);
+ v1 = ND_coord(le1->tail).x - ND_coord(le1->head).x, v1 = ABS(v1);
if (v0 != v1)
return (v0 - v1);
/* This provides a cheap test for edges having the same set of endpoints.
makeSimpleFlat (node_t* tn, node_t* hn, edge_t** edges, int ind, int cnt, int et)
{
edge_t* e = edges[ind];
- pointf points[10], np, tp, hp;
+ pointf points[10], tp, hp;
int i, pointn;
double stepy, dy;
- P2PF(ND_coord_i(tn), np);
- tp = add_pointfs(np, ED_tail_port(e).p);
-
- P2PF(ND_coord_i(hn), np);
- hp = add_pointfs(np, ED_head_port(e).p);
+ tp = add_pointfs(ND_coord(tn), ED_tail_port(e).p);
+ hp = add_pointfs(ND_coord(hn), ED_head_port(e).p);
stepy = (cnt > 1) ? ND_ht_i(tn) / (double)(cnt - 1) : 0.;
dy = tp.y - ((cnt > 1) ? ND_ht_i(tn) / 2. : 0.);
auxg = cloneGraph (g);
subg = agsubg (auxg, "xxx");
agset (subg, "rank", "source");
- rightx = ND_coord_i(hn).x;
- leftx = ND_coord_i(tn).x;
+ rightx = ND_coord(hn).x;
+ leftx = ND_coord(tn).x;
if (GD_flip(g)) {
node_t* n;
n = tn;
dot_position(auxg);
/* reposition */
- midx = (ND_coord_i(tn).x - ND_rw_i(tn) + ND_coord_i(hn).x + ND_lw_i(hn))/2;
- midy = (ND_coord_i(auxt).x + ND_coord_i(auxh).x)/2;
+ midx = (ND_coord(tn).x - ND_rw_i(tn) + ND_coord(hn).x + ND_lw_i(hn))/2;
+ midy = (ND_coord(auxt).x + ND_coord(auxh).x)/2;
for (n = GD_nlist(auxg); n; n = ND_next(n)) {
if (n == auxt) {
- ND_coord_i(n).y = rightx;
- ND_coord_i(n).x = midy;
+ ND_coord(n).y = rightx;
+ ND_coord(n).x = midy;
}
else if (n == auxh) {
- ND_coord_i(n).y = leftx;
- ND_coord_i(n).x = midy;
+ ND_coord(n).y = leftx;
+ ND_coord(n).x = midy;
}
- else ND_coord_i(n).y = midx;
+ else ND_coord(n).y = midx;
}
dot_sameports(auxg);
_dot_splines(auxg, 0);
/* copy splines */
if (GD_flip(g)) {
- del.x = ND_coord_i(tn).x - ND_coord_i(auxt).y;
- del.y = ND_coord_i(tn).y + ND_coord_i(auxt).x;
+ del.x = ND_coord(tn).x - ND_coord(auxt).y;
+ del.y = ND_coord(tn).y + ND_coord(auxt).x;
}
else {
- del.x = ND_coord_i(tn).x - ND_coord_i(auxt).x;
- del.y = ND_coord_i(tn).y - ND_coord_i(auxt).y;
+ del.x = ND_coord(tn).x - ND_coord(auxt).x;
+ del.y = ND_coord(tn).y - ND_coord(auxt).y;
}
for (i = 0; i < cnt; i++) {
bezier* auxbz;
else endpath(P, e, FLATEDGE, endp, FALSE);
b.UR.y = endp->boxes[endp->boxn - 1].UR.y;
b.LL.y = endp->boxes[endp->boxn - 1].LL.y;
- b = makeregularend(b, TOP, ND_coord_i(n).y + GD_rank(g)[ND_rank(n)].ht2);
+ b = makeregularend(b, TOP, ND_coord(n).y + GD_rank(g)[ND_rank(n)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
endp->boxes[endp->boxn++] = b;
}
else endpath(P, e, FLATEDGE, endp, FALSE);
b.UR.y = endp->boxes[endp->boxn - 1].UR.y;
b.LL.y = endp->boxes[endp->boxn - 1].LL.y;
- b = makeregularend(b, BOTTOM, ND_coord_i(n).y - GD_rank(g)[ND_rank(n)].ht2);
+ b = makeregularend(b, BOTTOM, ND_coord(n).y - GD_rank(g)[ND_rank(n)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
endp->boxes[endp->boxn++] = b;
}
for (f = ED_to_virt(e); ED_to_virt(f); f = ED_to_virt(f));
ln = f->tail;
- P2PF(ND_coord_i(ln), ED_label(e)->pos);
+ ED_label(e)->pos = ND_coord(ln);
if (et == ET_LINE) {
- pointf np, startp, endp, lp;
-
- P2PF(ND_coord_i(tn), np);
- startp = add_pointfs(np, ED_tail_port(e).p);
+ pointf startp, endp, lp;
- P2PF(ND_coord_i(hn), np);
- endp = add_pointfs(np, ED_head_port(e).p);
+ startp = add_pointfs(ND_coord(tn), ED_tail_port(e).p);
+ endp = add_pointfs(ND_coord(hn), ED_head_port(e).p);
lp = ED_label(e)->pos;
lp.y -= (ED_label(e)->dimen.y)/2.0;
pn = 7;
}
else {
- lb.LL.x = ND_coord_i(ln).x - ND_lw_i(ln);
- lb.UR.x = ND_coord_i(ln).x + ND_rw_i(ln);
- lb.UR.y = ND_coord_i(ln).y + ND_ht_i(ln)/2;
- ydelta = ND_coord_i(ln).y - GD_rank(g)[ND_rank(tn)].ht1 -
- ND_coord_i(tn).y + GD_rank(g)[ND_rank(tn)].ht2;
+ lb.LL.x = ND_coord(ln).x - ND_lw_i(ln);
+ lb.UR.x = ND_coord(ln).x + ND_rw_i(ln);
+ lb.UR.y = ND_coord(ln).y + ND_ht_i(ln)/2;
+ ydelta = ND_coord(ln).y - GD_rank(g)[ND_rank(tn)].ht1 -
+ ND_coord(tn).y + GD_rank(g)[ND_rank(tn)].ht2;
ydelta /= 6.;
lb.LL.y = lb.UR.y - MAX(5.,ydelta);
r = ND_rank(tn);
if (r < GD_maxrank(g)) {
nextr = GD_rank(g) + (r+1);
- vspace = ND_coord_i(tn).y - GD_rank(g)[r].pht1 -
- (ND_coord_i(nextr->v[0]).y + nextr->pht2);
+ vspace = ND_coord(tn).y - GD_rank(g)[r].pht1 -
+ (ND_coord(nextr->v[0]).y + nextr->pht2);
}
else {
vspace = GD_ranksep(g);
prevr = GD_rank(g) + (r-2);
else
prevr = GD_rank(g) + (r-1);
- vspace = ND_coord_i(prevr->v[0]).y - prevr->ht1 - ND_coord_i(tn).y - GD_rank(g)[r].ht2;
+ vspace = ND_coord(prevr->v[0]).y - prevr->ht1 - ND_coord(tn).y - GD_rank(g)[r].ht2;
}
else {
vspace = GD_ranksep(g);
node_t* hn;
node_t* tn;
edge_t* e = fe;
- pointf np, startp, endp, lp;
+ pointf startp, endp, lp;
pointf dimen;
double width, height;
return 0;
if (fe->tail == e->tail) {
*hp = hn;
- P2PF(ND_coord_i(tn), np);
- startp = add_pointfs(np, ED_tail_port(e).p);
- P2PF(ND_coord_i(hn), np);
- endp = add_pointfs(np, ED_head_port(e).p);
+ startp = add_pointfs(ND_coord(tn), ED_tail_port(e).p);
+ endp = add_pointfs(ND_coord(hn), ED_head_port(e).p);
}
else {
*hp = tn;
- P2PF(ND_coord_i(hn), np);
- startp = add_pointfs(np, ED_head_port(e).p);
- P2PF(ND_coord_i(tn), np);
- endp = add_pointfs(np, ED_tail_port(e).p);
+ startp = add_pointfs(ND_coord(hn), ED_head_port(e).p);
+ endp = add_pointfs(ND_coord(tn), ED_tail_port(e).p);
}
if (ED_label(e)) {
b.UR.y = tend.boxes[tend.boxn - 1].UR.y;
b.LL.y = tend.boxes[tend.boxn - 1].LL.y;
b = makeregularend(b, BOTTOM,
- ND_coord_i(tn).y - GD_rank(tn->graph)[ND_rank(tn)].ht1);
+ ND_coord(tn).y - GD_rank(tn->graph)[ND_rank(tn)].ht1);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
tend.boxes[tend.boxn++] = b;
longedge = 0;
hend.nb = maximal_bbox(sp, hn, e, ND_out(hn).list[0]);
endpath(P, e, REGULAREDGE, &hend, spline_merge(e->head));
b = makeregularend(hend.boxes[hend.boxn - 1], TOP,
- ND_coord_i(hn).y + GD_rank(hn->graph)[ND_rank(hn)].ht2);
+ ND_coord(hn).y + GD_rank(hn->graph)[ND_rank(hn)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
hend.boxes[hend.boxn++] = b;
P->end.theta = M_PI / 2, P->end.constrained = TRUE;
tend.nb = maximal_bbox(sp, tn, ND_in(tn).list[0], e);
beginpath(P, e, REGULAREDGE, &tend, spline_merge(e->tail));
b = makeregularend(tend.boxes[tend.boxn - 1], BOTTOM,
- ND_coord_i(tn).y - GD_rank(tn->graph)[ND_rank(tn)].ht1);
+ ND_coord(tn).y - GD_rank(tn->graph)[ND_rank(tn)].ht1);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
tend.boxes[tend.boxn++] = b;
P->start.theta = -M_PI / 2, P->start.constrained = TRUE;
b.UR.y = hend.boxes[hend.boxn - 1].UR.y;
b.LL.y = hend.boxes[hend.boxn - 1].LL.y;
b = makeregularend(b, TOP,
- ND_coord_i(hn).y + GD_rank(hn->graph)[ND_rank(hn)].ht2);
+ ND_coord(hn).y + GD_rank(hn->graph)[ND_rank(hn)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
hend.boxes[hend.boxn++] = b;
completeregularpath(P, segfirst, e, &tend, &hend, boxes, boxn,
left1 = GD_rank(g)[r + 1].v[0];
/* right1 = GD_rank(g)[r + 1].v[GD_rank(g)[r + 1].n - 1]; */
b.LL.x = sp->LeftBound;
- b.LL.y = ND_coord_i(left1).y + GD_rank(g)[r + 1].ht2;
+ b.LL.y = ND_coord(left1).y + GD_rank(g)[r + 1].ht2;
b.UR.x = sp->RightBound;
- b.UR.y = ND_coord_i(left0).y - GD_rank(g)[r].ht1;
+ b.UR.y = ND_coord(left0).y - GD_rank(g)[r].ht1;
sp->Rank_box[r] = b;
}
return b;
break;
if ((ND_out(v).size != 1) || (ND_in(v).size != 1))
break;
- if (ND_coord_i(v).x != ND_coord_i(n).x)
+ if (ND_coord(v).x != ND_coord(n).x)
break;
cnt++;
}
f = ND_out(f->head).list[0];
plist[(*np)++] = plist[n - 1];
plist[(*np)++] = plist[n - 1];
- P2PF(ND_coord_i(f->tail), plist[(*np)]); /* will be overwritten by next spline */
+ plist[(*np)] = ND_coord(f->tail); /* will be overwritten by next spline */
return f;
}
for (vn = e->head;
ND_node_type(vn) == VIRTUAL && !sinfo.splineMerge(vn);
vn = ND_out(vn).list[0]->head) {
- while ((b < p->nbox) && (p->boxes[b].LL.y > ND_coord_i(vn).y))
+ while ((b < p->nbox) && (p->boxes[b].LL.y > ND_coord(vn).y))
b++;
if (b >= p->nbox)
break;
- if (p->boxes[b].UR.y < ND_coord_i(vn).y)
+ if (p->boxes[b].UR.y < ND_coord(vn).y)
continue;
if (ND_label(vn))
resize_vn(vn, p->boxes[b].LL.x, p->boxes[b].UR.x,
node_t *vn;
int lx, cx, rx;
{
- ND_coord_i(vn).x = cx;
+ ND_coord(vn).x = cx;
ND_lw_i(vn) = cx - lx, ND_rw_i(vn) = rx - cx;
}
return ans;
}
-#if 0
-/* not used */
-
-point closest(splines * spl, point p)
-{
- int i, j, k, besti, bestj;
- double bestdist2, d2, dlow2, dhigh2; /* squares of distance */
- double low, high, t;
- pointf c[4], pt2, pt;
- point rv;
- bezier bz;
-
- besti = bestj = -1;
- bestdist2 = 1e+38;
- P2PF(p, pt);
- for (i = 0; i < spl->size; i++) {
- bz = spl->list[i];
- for (j = 0; j < bz.size; j++) {
- pointf b;
-
- b.x = bz.list[j].x;
- b.y = bz.list[j].y;
- d2 = DIST2(b, pt);
- if ((bestj == -1) || (d2 < bestdist2)) {
- besti = i;
- bestj = j;
- bestdist2 = d2;
- }
- }
- }
-
- bz = spl->list[besti];
- j = bestj / 3;
- if (j >= spl->size)
- j--;
- for (k = 0; k < 4; k++) {
- c[k].x = bz.list[j + k].x;
- c[k].y = bz.list[j + k].y;
- }
- low = 0.0;
- high = 1.0;
- dlow2 = DIST2(c[0], pt);
- dhigh2 = DIST2(c[3], pt);
- do {
- t = (low + high) / 2.0;
- pt2 = Bezier(c, 3, t, NULL, NULL);
- if (fabs(dlow2 - dhigh2) < 1.0)
- break;
- if (fabs(high - low) < .00001)
- break;
- if (dlow2 < dhigh2) {
- high = t;
- dhigh2 = DIST2(pt2, pt);
- } else {
- low = t;
- dlow2 = DIST2(pt2, pt);
- }
- } while (1);
- PF2P(pt2, rv);
- return rv;
-}
-#endif
-
/* common routines */
static int cl_vninside(graph_t * cl, node_t * n)
{
- return (BETWEEN(GD_bb(cl).LL.x, (double)(ND_coord_i(n).x), GD_bb(cl).UR.x) &&
- BETWEEN(GD_bb(cl).LL.y, (double)(ND_coord_i(n).y), GD_bb(cl).UR.y));
+ return (BETWEEN(GD_bb(cl).LL.x, (double)(ND_coord(n).x), GD_bb(cl).UR.x) &&
+ BETWEEN(GD_bb(cl).LL.y, (double)(ND_coord(n).y), GD_bb(cl).UR.y));
}
/* returns the cluster of (adj) that interferes with n,
left_cl = right_cl = NULL;
/* give this node all the available space up to its neighbors */
- b = (double)(ND_coord_i(vn).x - ND_lw_i(vn) - FUDGE);
+ b = (double)(ND_coord(vn).x - ND_lw_i(vn) - FUDGE);
if ((left = neighbor(vn, ie, oe, -1))) {
if ((left_cl = cl_bound(vn, left)))
nb = GD_bb(left_cl).UR.x + (double)(sp->Splinesep);
else {
- nb = (double)(ND_coord_i(left).x + ND_mval(left));
+ nb = (double)(ND_coord(left).x + ND_mval(left));
if (ND_node_type(left) == NORMAL)
nb += GD_nodesep(g) / 2.;
else
/* we have to leave room for our own label! */
if ((ND_node_type(vn) == VIRTUAL) && (ND_label(vn)))
- b = (double)(ND_coord_i(vn).x + 10);
+ b = (double)(ND_coord(vn).x + 10);
else
- b = (double)(ND_coord_i(vn).x + ND_rw_i(vn) + FUDGE);
+ b = (double)(ND_coord(vn).x + ND_rw_i(vn) + FUDGE);
if ((right = neighbor(vn, ie, oe, 1))) {
if ((right_cl = cl_bound(vn, right)))
nb = GD_bb(right_cl).LL.x - (double)(sp->Splinesep);
else {
- nb = ND_coord_i(right).x - ND_lw_i(right);
+ nb = ND_coord(right).x - ND_lw_i(right);
if (ND_node_type(right) == NORMAL)
nb -= GD_nodesep(g) / 2.;
else
if ((ND_node_type(vn) == VIRTUAL) && (ND_label(vn)))
rv.UR.x -= ND_rw_i(vn);
- rv.LL.y = ND_coord_i(vn).y - GD_rank(g)[ND_rank(vn)].ht1;
- rv.UR.y = ND_coord_i(vn).y + GD_rank(g)[ND_rank(vn)].ht2;
+ rv.LL.y = ND_coord(vn).y - GD_rank(g)[ND_rank(vn)].ht1;
+ rv.UR.y = ND_coord(vn).y + GD_rank(g)[ND_rank(vn)].ht2;
return rv;
}
place = flat_limits(g, e);
/* grab ypos = LL.y of label box before make_vn_slot() */
if ((n = GD_rank(g)[r - 1].v[0]))
- ypos = ND_coord_i(n).y - GD_rank(g)[r - 1].ht1;
+ ypos = ND_coord(n).y - GD_rank(g)[r - 1].ht1;
else {
n = GD_rank(g)[r].v[0];
- ypos = ND_coord_i(n).y + GD_rank(g)[r].ht2 + GD_ranksep(g);
+ ypos = ND_coord(n).y + GD_rank(g)[r].ht2 + GD_ranksep(g);
}
vn = make_vn_slot(g, r - 1, place);
dimen = ED_label(e)->dimen;
h2 = ND_ht_i(vn) / 2;
ND_lw_i(vn) = ND_rw_i(vn) = dimen.x / 2;
ND_label(vn) = ED_label(e);
- ND_coord_i(vn).y = ypos + h2;
+ ND_coord(vn).y = ypos + h2;
ve = virtual_edge(vn, e->tail, e); /* was NULL? */
ED_tail_port(ve).p.x = -ND_lw_i(vn);
ED_head_port(ve).p.x = ND_rw_i(e->tail);
/*
- * position(g): set ND_coord_i(n) (x and y) for all nodes n of g, using GD_rank(g).
+ * position(g): set ND_coord(n) (x and y) for all nodes n of g, using GD_rank(g).
* (the graph may be modified by merging certain edges with a common endpoint.)
* the coordinates are computed by constructing and ranking an auxiliary graph.
* then leaf nodes are inserted in the fast graph. cluster boundary nodes are
for (i = GD_minrank(g); i <= GD_maxrank(g); i++) {
for (j = 0; j < rank[i].n; j++) {
v = rank[i].v[j];
- ND_coord_i(v).x = ND_rank(v);
+ ND_coord(v).x = ND_rank(v);
ND_rank(v) = i;
}
}
lht = MAX(GD_border(g)[LEFT_IX].y, GD_border(g)[RIGHT_IX].y);
maxr = GD_maxrank(g);
minr = GD_minrank(g);
- rht =
- ND_coord_i(rank[minr].v[0]).y - ND_coord_i(rank[maxr].v[0]).y;
+ rht = ND_coord(rank[minr].v[0]).y - ND_coord(rank[maxr].v[0]).y;
delta = lht - (rht + ht1 + ht2);
if (delta > 0) {
if (equal)
/* copy ycoord assignment from leftmost nodes to others */
for (n = GD_nlist(g); n; n = ND_next(n))
- ND_coord_i(n).y = rank[ND_rank(n)].v[0]->u.coord.y;
+ ND_coord(n).y = rank[ND_rank(n)].v[0]->u.coord.y;
}
/* dot_compute_bb:
for (c = 1; (ND_node_type(v) != NORMAL) && c < rnkn; c++)
v = GD_rank(g)[r].v[c];
if (ND_node_type(v) == NORMAL) {
- x = (double)(ND_coord_i(v).x - ND_lw_i(v));
+ x = ND_coord(v).x - ND_lw_i(v);
LL.x = MIN(LL.x, x);
}
else continue;
v = GD_rank(g)[r].v[rnkn - 1];
for (c = rnkn-2; ND_node_type(v) != NORMAL; c--)
v = GD_rank(g)[r].v[c];
- x = (double)(ND_coord_i(v).x + ND_rw_i(v));
+ x = ND_coord(v).x + ND_rw_i(v);
UR.x = MAX(UR.x, x);
}
offset = CL_OFFSET;
yf = t;
}
for (n = GD_nlist(g); n; n = ND_next(n)) {
- ND_coord_i(n).x = ND_coord_i(n).x * xf;
- ND_coord_i(n).y = ND_coord_i(n).y * yf;
+ ND_coord(n).x = ROUND(ND_coord(n).x * xf);
+ ND_coord(n).y = ROUND(ND_coord(n).y * yf);
}
scale_bb(g, g, xf, yf);
}
static point resize_leaf(node_t * leaf, point lbound)
{
dot_nodesize(leaf, GD_flip(leaf->graph));
- ND_coord_i(leaf).y = lbound.y;
- ND_coord_i(leaf).x = lbound.x + ND_lw_i(leaf);
- lbound.x =
- lbound.x + ND_lw_i(leaf) + ND_rw_i(leaf) + GD_nodesep(leaf->graph);
+ ND_coord(leaf).y = lbound.y;
+ ND_coord(leaf).x = lbound.x + ND_lw_i(leaf);
+ lbound.x = lbound.x + ND_lw_i(leaf) + ND_rw_i(leaf) + GD_nodesep(leaf->graph);
return lbound;
}
if (ND_UF_size(leader) <= 1)
return;
- lbound.x = ND_coord_i(leader).x - ND_lw_i(leader);
- lbound.y = ND_coord_i(leader).y;
+ lbound.x = ND_coord(leader).x - ND_lw_i(leader);
+ lbound.y = ND_coord(leader).y;
lbound = resize_leaf(leader, lbound);
if (ND_out(leader).size > 0) { /* in-edge leaves */
n = ND_out(leader).list[0]->head;
v = e->tail;
else
v = e->head;
- x1 = ND_coord_i(v).x - ND_coord_i(u).x;
- y1 = ND_coord_i(v).y - ND_coord_i(u).y;
+ x1 = ND_coord(v).x - ND_coord(u).x;
+ y1 = ND_coord(v).y - ND_coord(u).y;
r = hypot(x1, y1);
x += x1 / r;
y += y1 / r;
y /= r;
/* (x1,y1),(x2,y2) is a segment that must cross the node boundary */
- x1 = ND_coord_i(u).x;
- y1 = ND_coord_i(u).y; /* center of node */
+ x1 = ND_coord(u).x;
+ y1 = ND_coord(u).y; /* center of node */
r = MAX(ND_lw_i(u) + ND_rw_i(u), ND_ht_i(u) + GD_ranksep(u->graph)); /* far away */
- x2 = x * r + ND_coord_i(u).x;
- y2 = y * r + ND_coord_i(u).y;
+ x2 = x * r + ND_coord(u).x;
+ y2 = y * r + ND_coord(u).y;
{ /* now move (x1,y1) to the node boundary */
pointf curve[4]; /* bezier control points for a straight line */
curve[0].x = x1;
curve[3].y = y2;
shape_clip(u, curve);
- x1 = curve[0].x - ND_coord_i(u).x;
- y1 = curve[0].y - ND_coord_i(u).y;
+ x1 = curve[0].x - ND_coord(u).x;
+ y1 = curve[0].y - ND_coord(u).y;
}
/* compute PORT on the boundary */
node_t *n;
State = GVSPLINES;
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- ND_coord_i(n).x = POINTS(ND_pos(n)[0]);
- ND_coord_i(n).y = POINTS(ND_pos(n)[1]);
+ ND_coord(n).x = POINTS(ND_pos(n)[0]);
+ ND_coord(n).y = POINTS(ND_pos(n)[1]);
}
}
else if (posEdges != AllEdges)
/* genPt:
*/
-static Ppoint_t genPt(double x, double y, point c)
+static Ppoint_t genPt(double x, double y, pointf c)
{
Ppoint_t p;
/* recPt:
*/
-static Ppoint_t recPt(double x, double y, point c, expand_t* m)
+static Ppoint_t recPt(double x, double y, pointf c, expand_t* m)
{
Ppoint_t p;
int i, j, xstep, dx;
double l_perp;
pointf dumber[4];
- pointf p, q, np;
-
- P2PF(ND_coord_i(n), np);
- p = dumb[1] = dumb[0] = add_pointfs(np, ED_tail_port(e).p);
-
- P2PF(ND_coord_i(head), np);
- q = dumb[2] = dumb[3] = add_pointfs(np, ED_head_port(e).p);
+ pointf p, q;
+ p = dumb[1] = dumb[0] = add_pointfs(ND_coord(n), ED_tail_port(e).p);
+ q = dumb[2] = dumb[3] = add_pointfs(ND_coord(head), ED_head_port(e).p);
if (e_cnt == 1) {
clip_and_install(e, e->head, dumb, 4, &sinfo);
addEdgeLabels(e, p, q);
int j, sides;
pointf polyp;
boxf b;
- point pt;
+ pointf pt;
field_t *fld;
epsf_t *desc;
polyp.y = pmargin->y * s * ND_ht_i(n) / 2.0;
}
}
- obs->ps[sides - j - 1].x = polyp.x + ND_coord_i(n).x;
- obs->ps[sides - j - 1].y = polyp.y + ND_coord_i(n).y;
+ obs->ps[sides - j - 1].x = polyp.x + ND_coord(n).x;
+ obs->ps[sides - j - 1].y = polyp.y + ND_coord(n).y;
}
break;
case SH_RECORD:
obs->pn = 4;
obs->ps = N_NEW(4, Ppoint_t);
/* CW order */
- pt = ND_coord_i(n);
+ pt = ND_coord(n);
if (pmargin->doAdd) {
obs->ps[0] = genPt(b.LL.x-pmargin->x, b.LL.y-pmargin->y, pt);
obs->ps[1] = genPt(b.LL.x-pmargin->x, b.UR.y+pmargin->y, pt);
obs->pn = 4;
obs->ps = N_NEW(4, Ppoint_t);
/* CW order */
- pt = ND_coord_i(n);
+ pt = ND_coord(n);
if (pmargin->doAdd) {
obs->ps[0] = genPt(-ND_lw_i(n)-pmargin->x, -ND_ht_i(n)-pmargin->y,pt);
obs->ps[1] = genPt(-ND_lw_i(n)-pmargin->x, ND_ht_i(n)+pmargin->y,pt);
Ppolyline_t line;
int pp, qp;
Ppoint_t p, q;
- pointf tp, hp;
- P2PF(ND_coord_i(e->tail), tp);
- p = add_pointfs(tp, ED_tail_port(e).p);
- P2PF(ND_coord_i(e->head), hp);
- q = add_pointfs(hp, ED_head_port(e).p);
+ p = add_pointfs(ND_coord(e->tail), ED_tail_port(e).p);
+ q = add_pointfs(ND_coord(e->head), ED_head_port(e).p);
/* determine the polygons (if any) that contain the endpoints */
pp = qp = POLYID_NONE;
/* fprintf (stderr, "%s -- %s %d\n", e->tail->name, e->head->name, ED_count(e)); */
node_t *head = e->head;
if (useEdges && ED_spl(e)) {
- pointf np, hp;
- P2PF(ND_coord_i(n), np);
- P2PF(ND_coord_i(head), hp);
addEdgeLabels(e,
- add_pointfs(np, ED_tail_port(e).p),
- add_pointfs(hp, ED_head_port(e).p));
+ add_pointfs(ND_coord(n), ED_tail_port(e).p),
+ add_pointfs(ND_coord(head), ED_head_port(e).p));
}
else if (ED_count(e) == 0) continue; /* only do representative */
else if (n == head) { /* self arc */
/* neato_set_aspect:
* Sets aspect ratio if necessary; real work done in _neato_set_aspect;
* This also copies the internal layout coordinates (ND_pos) to the
- * external ones (ND_coord_i).
+ * external ones (ND_coord).
*/
void neato_set_aspect(graph_t * g)
{
_neato_set_aspect(g);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- ND_coord_i(n).x = POINTS(ND_pos(n)[0]);
- ND_coord_i(n).y = POINTS(ND_pos(n)[1]);
+ ND_coord(n).x = POINTS(ND_pos(n)[0]);
+ ND_coord(n).y = POINTS(ND_pos(n)[1]);
}
}
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
ND_pos(n)[0] += fx;
ND_pos(n)[1] += fy;
- MOVEPT(ND_coord_i(n));
+ MOVEPT(ND_coord(n));
if (doSplines) {
for (e = agfstout(eg, n); e; e = agnxtout(eg, e))
shiftEdge(e, dx, dy);
{
treenode_t *p;
Agnode_t *n;
- point center;
+ pointf center;
rect_t r, rr;
switch(tree->kind) {
center.y = (tree->r.UR.y + tree->r.LL.y) / 2.0;
n = tree->u.n;
- ND_coord_i(n) = center;
+ ND_coord(n) = center;
ND_height(n) = PS2INCH(tree->r.UR.y - tree->r.LL.y);
ND_width(n) = PS2INCH(tree->r.UR.x - tree->r.LL.x);
gv_nodesize(n,GD_flip(n->graph));
finishNode (n);
- /*fprintf(stderr,"%s coord %d %d ht %d width %d\n",
- n->name, ND_coord_i(n).x, ND_coord_i(n).y, ND_ht_i(n),
+ /*fprintf(stderr,"%s coord %.3g %.3g ht %d width %d\n",
+ n->name, ND_coord(n).x, ND_coord(n).y, ND_ht_i(n),
ND_rw_i(n)+ND_lw_i(n));*/
break;
default: abort();
/* make rv relative to PNG canvas */
if (job->rotation) {
- rv.x = ( (p.y - job->pad.y) - ND_coord_i(n).y + ND_lw_i(n) ) * Scale + NODE_PAD;
- rv.y = (-(p.x - job->pad.x) + ND_coord_i(n).x + ND_ht_i(n) / 2.) * Scale + NODE_PAD;
+ rv.x = ( (p.y - job->pad.y) - ND_coord(n).y + ND_lw_i(n) ) * Scale + NODE_PAD;
+ rv.y = (-(p.x - job->pad.x) + ND_coord(n).x + ND_ht_i(n) / 2.) * Scale + NODE_PAD;
} else {
- rv.x = ( (p.x - job->pad.x) - ND_coord_i(n).x + ND_lw_i(n) ) * Scale + NODE_PAD;
- rv.y = (-(p.y - job->pad.y) + ND_coord_i(n).y + ND_ht_i(n) / 2.) * Scale + NODE_PAD;
+ rv.x = ( (p.x - job->pad.x) - ND_coord(n).x + ND_lw_i(n) ) * Scale + NODE_PAD;
+ rv.y = (-(p.y - job->pad.y) + ND_coord(n).y + ND_ht_i(n) / 2.) * Scale + NODE_PAD;
}
return rv;
}
static void
finishSegment (FILE *out, edge_t *e)
{
- point p0 = ND_coord_i(e->tail);
- point p1 = ND_coord_i(e->head);
+ pointf p0 = ND_coord(e->tail);
+ pointf p1 = ND_coord(e->head);
double o_x, o_y, o_z;
double x, y, y0, z, theta;
}
static void
-doSegment (GVJ_t *job, pointf* A, point p0, double z0, point p1, double z1)
+doSegment (GVJ_t *job, pointf* A, pointf p0, double z0, pointf p1, double z1)
{
FILE *out = job->output_file;
obj_state_t *obj = job->obj;
assert(e);
if (straight(A,n)) {
- doSegment (job, A, ND_coord_i(e->tail),Fstz,ND_coord_i(e->head),Sndz);
+ doSegment (job, A, ND_coord(e->tail),Fstz,ND_coord(e->head),Sndz);
return;
}
edge_t *e = obj->u.e;
double rad, ht, y;
pointf p0; /* center of triangle base */
- point tp,hp;
p0.x = (A[0].x + A[2].x)/2.0;
p0.y = (A[0].y + A[2].y)/2.0;
y = (CylHt + ht)/2.0;
- tp = ND_coord_i(e->tail);
- hp = ND_coord_i(e->head);
fprintf(out, "Transform {\n");
- if (DIST2(A[1], tp) < DIST2(A[1], hp)) {
+ if (DIST2(A[1], ND_coord(e->tail)) < DIST2(A[1], ND_coord(e->head))) {
TailHt = ht;
fprintf(out, " translation 0 %.3f 0\n", -y);
fprintf(out, " rotation 0 0 1 %.3f\n", M_PI);
fprintf(out, " geometry Extrusion {\n");
fprintf(out, " crossSection [");
for (i = 0; i < np; i++) {
- p.x = A[i].x - ND_coord_i(n).x;
- p.y = A[i].y - ND_coord_i(n).y;
+ p.x = A[i].x - ND_coord(n).x;
+ p.y = A[i].y - ND_coord(n).y;
fprintf(out, " %.3f %.3f,", p.x, p.y);
}
- p.x = A[0].x - ND_coord_i(n).x;
- p.y = A[0].y - ND_coord_i(n).y;
+ p.x = A[0].x - ND_coord(n).x;
+ p.y = A[0].y - ND_coord(n).y;
fprintf(out, " %.3f %.3f ]\n", p.x, p.y);
- fprintf(out, " spine [ %d %d %.3f, %d %d %.3f ]\n",
- ND_coord_i(n).x, ND_coord_i(n).y, z - .01,
- ND_coord_i(n).x, ND_coord_i(n).y, z + .01);
+ fprintf(out, " spine [ %.3g %.3g %.3g, %.3g %.3g %.3g ]\n",
+ ND_coord(n).x, ND_coord(n).y, z - .01,
+ ND_coord(n).x, ND_coord(n).y, z + .01);
fprintf(out, " }\n");
fprintf(out, "}\n");
break;
(A[0].x + A[2].x) / 2.0 - A[1].x) + M_PI / 2.0;
/* this is gruesome, but how else can we get z coord */
- if (DIST2(p, ND_coord_i(e->tail)) < DIST2(p, ND_coord_i(e->head)))
+ if (DIST2(p, ND_coord(e->tail)) < DIST2(p, ND_coord(e->head)))
z = obj->tail_z;
else
z = obj->head_z;
case EDGE_OBJTYPE:
e = obj->u.e;
/* this is gruesome, but how else can we get z coord */
- if (DIST2(A[0], ND_coord_i(e->tail)) < DIST2(A[0], ND_coord_i(e->head)))
+ if (DIST2(A[0], ND_coord(e->tail)) < DIST2(A[0], ND_coord(e->head)))
z = obj->tail_z;
else
z = obj->head_z;