From: Emden R. Gansner Date: Mon, 28 Jul 2014 20:57:39 +0000 (-0400) Subject: Change neato behavior to original vis-a-vis final translation; X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a892236b199849f8558b1806304b6df9153b3e5f;p=graphviz Change neato behavior to original vis-a-vis final translation; add attribute notranslate to allow the user to avoid a translation. --- diff --git a/doc/info/attrs.html b/doc/info/attrs.html index f1d00a895..08d4f4e07 100644 --- a/doc/info/attrs.html +++ b/doc/info/attrs.html @@ -334,6 +334,9 @@ of the layout programs. normalize Gdouble
bool falsenot dot + notranslate +Gbool +falseneato only nslimit
nslimit1 Gdoubledot only @@ -1343,6 +1346,11 @@ of the layout programs. corresponding to 0 degrees. NOTE: Since the attribute is evaluated first as a number, 0 and 1 cannot be used for false and true. +
notranslate +
By default, the final layout is translated so that the lower-left corner of the bounding box is + at the origin. This can be annoying if some nodes are pinned or if the user runs neato -n. + To avoid this translation, set notranslate to true. +
nslimit ,
nslimit1
Used to set number of iterations in @@ -1561,7 +1569,8 @@ of the layout programs. difference between the old and new coordinates will give the translation, which can then be subtracted from all of the appropriate coordinates.

- After 27 Feb 2014, this translation is no longer done. However, if the graph + After 27 Feb 2014, this translation can be avoided in neato by setting the + notranslate to TRUE. However, if the graph specifies node overlap removal or a change in aspect ratio, node coordinates may still change. diff --git a/doc/infosrc/attrs b/doc/infosrc/attrs index ee2cacb33..d4b9ea790 100644 --- a/doc/infosrc/attrs +++ b/doc/infosrc/attrs @@ -788,6 +788,10 @@ layout so that the angle of the first edge is specified by the value of norm If normalize is not a number, it is evaluated as a bool, with true corresponding to 0 degrees. NOTE: Since the attribute is evaluated first as a number, 0 and 1 cannot be used for false and true. +:notranslate:G:bool:false; neato +By default, the final layout is translated so that the lower-left corner of the bounding box is +at the origin. This can be annoying if some nodes are pinned or if the user runs neato -n. +To avoid this translation, set notranslate to true. :nslimit/nslimit1:G:double; dot Used to set number of iterations in network simplex applications. nslimit is used in @@ -989,7 +993,8 @@ simple workaround is to maintain the coordinates of a pinned node. The vector difference between the old and new coordinates will give the translation, which can then be subtracted from all of the appropriate coordinates.

-After 27 Feb 2014, this translation is no longer done. However, if the graph +After 27 Feb 2014, this translation can be avoided in neato by setting the +notranslate to TRUE. However, if the graph specifies node overlap removal or a change in aspect ratio, node coordinates may still change. :pos:EN:point/splineType; diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index f2bbb29ec..792e95580 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -534,6 +534,7 @@ int init_nop(Agraph_t * g, int adjust) attrsym_t *G_bb = agfindgraphattr(g, "bb"); int didAdjust = 0; /* Have nodes been moved? */ int haveBackground; + boolean translate = !mapBool(agget(g, "notranslate"), FALSE); /* If G_bb not defined, define it */ if (!G_bb) @@ -587,7 +588,10 @@ int init_nop(Agraph_t * g, int adjust) } } else { - boolean didShift = neato_set_aspect(g); + boolean didShift; + if (translate && !haveBackground && ((GD_bb(g).LL.x != 0)||(GD_bb(g).LL.y != 0))) + neato_translate (g); + didShift = neato_set_aspect(g); /* if we have some edge positions and we either shifted or adjusted, free edge positions */ if ((posEdges != NoEdges) && (didShift || didAdjust)) { freeEdgeInfo (g); @@ -1421,6 +1425,7 @@ void neato_layout(Agraph_t * g) } else gv_postprocess(g, 0); } else { + boolean noTranslate = mapBool(agget(g, "notranslate"), FALSE); PSinputscale = get_inputscale (g); neato_init_graph(g); layoutMode = neatoMode(g); @@ -1455,7 +1460,8 @@ void neato_layout(Agraph_t * g) neatoLayout(g, gc, layoutMode, model, &am); removeOverlapWith(gc, &am); setEdgeType (gc, ET_LINE); - doEdges(gc); + if (noTranslate) doEdges(g); + else spline_edges(g); } if (pin) { bp = N_NEW(n_cc, boolean); @@ -1472,7 +1478,8 @@ void neato_layout(Agraph_t * g) else { neatoLayout(g, g, layoutMode, model, &am); removeOverlapWith(g, &am); - doEdges(g); + if (noTranslate) doEdges(g); + else spline_edges(g); } compute_bb(g); addZ (g); @@ -1492,7 +1499,8 @@ void neato_layout(Agraph_t * g) neatoLayout(g, g, layoutMode, model, &am); removeOverlapWith(g, &am); addZ (g); - doEdges(g); + if (noTranslate) doEdges(g); + else spline_edges(g); } gv_postprocess(g, 0); } diff --git a/lib/neatogen/neatoprocs.h b/lib/neatogen/neatoprocs.h index 2339a25e8..63173c189 100644 --- a/lib/neatogen/neatoprocs.h +++ b/lib/neatogen/neatoprocs.h @@ -64,6 +64,7 @@ extern "C" { extern int spline_edges1(graph_t * g, int); extern int splineEdges(graph_t *, int (*edgefn) (graph_t *, expand_t*, int), int); + extern void neato_translate(Agraph_t * g); extern boolean neato_set_aspect(graph_t * g); extern void toggle(int); extern int user_pos(Agsym_t *, Agsym_t *, Agnode_t *, int); diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index 02155f621..83419762f 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -962,9 +962,9 @@ static void translateG(Agraph_t * g, pointf offset) translateG(GD_clust(g)[i], offset); } -/* translate: +/* neato_translate: */ -static void translate(Agraph_t * g) +void neato_translate(Agraph_t * g) { node_t *n; edge_t *e; @@ -1000,14 +1000,17 @@ static boolean _neato_set_aspect(graph_t * g) { double xf, yf, actual, desired; node_t *n; + boolean translated = FALSE; if (g->root != g) return FALSE; /* compute_bb(g); */ if (GD_drawing(g)->ratio_kind) { - if (ROUND(abs(GD_bb(g).LL.x)) || ROUND(abs(GD_bb(g).LL.y))) - translate (g); + if ((abs(GD_bb(g).LL.x)) || (abs(GD_bb(g).LL.y))) { + translated = TRUE; + neato_translate (g); + } /* normalize */ if (GD_flip(g)) { double t = GD_bb(g).UR.x; @@ -1017,7 +1020,7 @@ static boolean _neato_set_aspect(graph_t * g) if (GD_drawing(g)->ratio_kind == R_FILL) { /* fill is weird because both X and Y can stretch */ if (GD_drawing(g)->size.x <= 0) - return FALSE; + return (translated || FALSE); xf = (double) GD_drawing(g)->size.x / GD_bb(g).UR.x; yf = (double) GD_drawing(g)->size.y / GD_bb(g).UR.y; /* handle case where one or more dimensions is too big */ @@ -1032,14 +1035,14 @@ static boolean _neato_set_aspect(graph_t * g) } } else if (GD_drawing(g)->ratio_kind == R_EXPAND) { if (GD_drawing(g)->size.x <= 0) - return FALSE; + return (translated || FALSE); xf = (double) GD_drawing(g)->size.x / GD_bb(g).UR.x; yf = (double) GD_drawing(g)->size.y / GD_bb(g).UR.y; if ((xf > 1.0) && (yf > 1.0)) { double scale = MIN(xf, yf); xf = yf = scale; } else - return FALSE; + return (translated || FALSE); } else if (GD_drawing(g)->ratio_kind == R_VALUE) { desired = GD_drawing(g)->ratio; actual = (GD_bb(g).UR.y) / (GD_bb(g).UR.x); @@ -1051,7 +1054,7 @@ static boolean _neato_set_aspect(graph_t * g) yf = 1.0; } } else - return FALSE; + return (translated || FALSE); if (GD_flip(g)) { double t = xf; xf = yf;