From be29c10249f899f9441fdf7c72d6467995f703e1 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 11 Aug 2009 21:21:20 +0000 Subject: [PATCH] Use the edge type of the input graph, not its root graph. This allows graphs to be split and laid out separately as connected components; it also allows each component to have a different edge type. --- lib/dotgen/dotsplines.c | 4 ++-- lib/fdpgen/clusteredges.c | 2 +- lib/neatogen/multispline.c | 14 +++++++------- lib/neatogen/multispline.h | 2 +- lib/neatogen/neatoinit.c | 1 + lib/neatogen/neatoprocs.h | 4 ++-- lib/neatogen/neatosplines.c | 26 +++++++++++++------------- lib/twopigen/twopiinit.c | 1 + 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index c4ee13af7..c2e0a1c38 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -224,9 +224,9 @@ static void _dot_splines(graph_t * g, int normalize) path *P; spline_info_t sd; #ifndef WITH_CGRAPH - int et = EDGE_TYPE(g->root); + int et = EDGE_TYPE(g); #else /* WITH_CGRAPH */ - int et = EDGE_TYPE(agroot(g)); + int et = EDGE_TYPE(g); #endif /* WITH_CGRAPH */ if (et == ET_NONE) return; diff --git a/lib/fdpgen/clusteredges.c b/lib/fdpgen/clusteredges.c index 01f44ca92..0bfc2fb54 100644 --- a/lib/fdpgen/clusteredges.c +++ b/lib/fdpgen/clusteredges.c @@ -295,7 +295,7 @@ int compoundEdges(graph_t * g, expand_t* pm, int edgetype) for (e0 = e; e0; e0 = ED_to_virt(e0)) { ED_path(e0) = getPath(e0, vconfig, 0, objl->obs, objl->cnt); - makeSpline(e0, objl->obs, objl->cnt, FALSE); + makeSpline(g, e0, objl->obs, objl->cnt, FALSE); } resetObjlist(objl); } diff --git a/lib/neatogen/multispline.c b/lib/neatogen/multispline.c index 0230d7d7b..e68cc3041 100644 --- a/lib/neatogen/multispline.c +++ b/lib/neatogen/multispline.c @@ -757,7 +757,7 @@ router_t *mkRouter(Ppoly_t** obsp, int npoly) * if necessary, and adding edge labels */ static void -finishEdge (edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q) +finishEdge (graph_t* g, edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q) { int j; pointf *spline = N_GNEW(spl.pn, pointf); @@ -782,7 +782,7 @@ finishEdge (edge_t* e, Ppoly_t spl, int flip, pointf p, pointf q) clip_and_install(e, aghead(e), spline, spl.pn, &sinfo); free(spline); - addEdgeLabels(e, p1, q1); + addEdgeLabels(g, e, p1, q1); } #define EQPT(p,q) (((p).x==(q).x)&&((p).y==(q).y)) @@ -838,7 +838,7 @@ tweakPath (Ppoly_t poly, int s, int t, Ppolyline_t pl) * Return 0 on success. */ static int -genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) +genroute(graph_t* g, tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) { pointf eps[2]; Pvector_t evs[2]; @@ -872,7 +872,7 @@ genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) } tweakPath (poly, s, t, pl); Proutespline(medges, poly.pn, pl, evs, &spl); - finishEdge (e, spl, aghead(e) != head, eps[0], eps[1]); + finishEdge (g, e, spl, aghead(e) != head, eps[0], eps[1]); free(medges); return 0; @@ -915,7 +915,7 @@ genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline) tweakPath (poly, 0, pl.pn-1, mmpl); Proutespline(medges, poly.pn, mmpl, evs, &spl); } - finishEdge (e, spl, aghead(e) != head, eps[0], eps[1]); + finishEdge (g, e, spl, aghead(e) != head, eps[0], eps[1]); e = ED_to_virt(e); } @@ -1296,7 +1296,7 @@ triPath(tgraph * g, int n, int v0, int v1, PQ * pq) * so avoid in neato spline code. * Return 0 on success. */ -int makeMultiSpline(edge_t* e, router_t * rtr, int doPolyline) +int makeMultiSpline(graph_t* g, edge_t* e, router_t * rtr, int doPolyline) { Ppolyline_t line = ED_path(e); node_t *t = agtail(e); @@ -1338,7 +1338,7 @@ int makeMultiSpline(edge_t* e, router_t * rtr, int doPolyline) free(sp); /* Generate multiple splines using polygon */ - ret = genroute(poly, 0, idx, e, doPolyline); + ret = genroute(g, poly, 0, idx, e, doPolyline); freeTripoly (poly); resetGraph(rtr->tg, rtr->tn, ecnt); diff --git a/lib/neatogen/multispline.h b/lib/neatogen/multispline.h index 4462d80af..ba249b36e 100644 --- a/lib/neatogen/multispline.h +++ b/lib/neatogen/multispline.h @@ -24,6 +24,6 @@ typedef struct router_s router_t; extern void freeRouter (router_t* rtr); extern router_t* mkRouter (Ppoly_t** obs, int npoly); -extern int makeMultiSpline(edge_t* e, router_t * rtr, int); +extern int makeMultiSpline(graph_t* g, edge_t* e, router_t * rtr, int); #endif diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index ac3e4ea77..9b9adb814 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -1515,6 +1515,7 @@ void neato_layout(Agraph_t * g) nodeInduce(gc); neatoLayout(g, gc, layoutMode, model, &am); removeOverlapWith(gc, &am); + setEdgeType (gc, ET_LINE); spline_edges(gc); } if (n_cc > 1) { diff --git a/lib/neatogen/neatoprocs.h b/lib/neatogen/neatoprocs.h index e2b636f68..121a107ae 100644 --- a/lib/neatogen/neatoprocs.h +++ b/lib/neatogen/neatoprocs.h @@ -27,7 +27,7 @@ extern "C" { #define extern #endif - extern void addEdgeLabels(edge_t * e, pointf rp, pointf rq); + extern void addEdgeLabels(graph_t* g, edge_t * e, pointf rp, pointf rq); extern int allow_edits(int); extern void avoid_cycling(graph_t *, Agnode_t *, double *); extern int checkStart(graph_t * G, int nG, int); @@ -50,7 +50,7 @@ extern "C" { extern Ppoly_t *makeObstacle(node_t * n, expand_t* ); extern void makeStraightEdge(graph_t * g, edge_t * e, int doPolyline); extern void makeSelfArcs(path * P, edge_t * e, int stepx); - extern void makeSpline(edge_t *, Ppoly_t **, int, boolean); + extern void makeSpline(graph_t*, edge_t *, Ppoly_t **, int, boolean); extern void make_spring(graph_t *, Agnode_t *, Agnode_t *, double); extern void move_node(graph_t *, int, Agnode_t *); extern int init_nop(graph_t * g, int); diff --git a/lib/neatogen/neatosplines.c b/lib/neatogen/neatosplines.c index 151546001..294c0c128 100644 --- a/lib/neatogen/neatosplines.c +++ b/lib/neatogen/neatosplines.c @@ -198,9 +198,9 @@ polylineMidpoint (splines* spl, pointf* pp, pointf* pq) * significantly from rp and rq, but if the spline is degenerate (e.g., * the nodes overlap), we use rp and rq. */ -void addEdgeLabels(edge_t * e, pointf rp, pointf rq) +void addEdgeLabels(graph_t* g, edge_t * e, pointf rp, pointf rq) { - int et = EDGE_TYPE (agroot(agraphof(aghead(e)))); + int et = EDGE_TYPE (g); pointf p, q; pointf d; /* midpoint of segment p-q */ point ld; @@ -430,7 +430,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) q = dumb[2] = dumb[3] = add_pointf(ND_coord(head), ED_head_port(e).p); if ((e_cnt == 1) || Concentrate) { clip_and_install(e, aghead(e), dumb, 4, &sinfo); - addEdgeLabels(e, p, q); + addEdgeLabels(g, e, p, q); return; } @@ -485,7 +485,7 @@ makeStraightEdge(graph_t * g, edge_t * e, int doPolyline) else clip_and_install(e0, aghead(e0), dumber, 4, &sinfo); - addEdgeLabels(e0, p, q); + addEdgeLabels(g, e0, p, q); e0 = ED_to_virt(e0); dumb[1].x += del.x; dumb[1].y += del.y; @@ -672,7 +672,7 @@ getPath(edge_t * e, vconfig_t * vconfig, int chkPts, Ppoly_t ** obs, /* makePolyline: */ static void -makePolyline(edge_t * e) +makePolyline(graph_t* g, edge_t * e) { Ppolyline_t spl, line = ED_path(e); Ppoint_t p0, q0; @@ -683,7 +683,7 @@ makePolyline(edge_t * e) if (Verbose > 1) fprintf(stderr, "polyline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo); - addEdgeLabels(e, p0, q0); + addEdgeLabels(g, e, p0, q0); } /* makeSpline: @@ -696,7 +696,7 @@ makePolyline(edge_t * e) * is on or inside one of the obstacles and, if so, tells the shortest path * computation to ignore them. */ -void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) +void makeSpline(graph_t* g, edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) { Ppolyline_t line, spline; Pvector_t slopes[2]; @@ -728,7 +728,7 @@ void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts) fprintf(stderr, "spline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); clip_and_install(e, aghead(e), spline.ps, spline.pn, &sinfo); free(barriers); - addEdgeLabels(e, p, q); + addEdgeLabels(g, e, p, q); } /* True if either head or tail has a port on its boundary */ @@ -809,7 +809,7 @@ static int _spline_edges(graph_t * g, expand_t* pmargin, int edgetype) /* fprintf (stderr, "%s -- %s %d\n", agnameof(agtail(e)), agnameof(aghead(e)), ED_count(e)); */ node_t *head = aghead(e); if (useEdges && ED_spl(e)) { - addEdgeLabels(e, + addEdgeLabels(g, e, add_pointf(ND_coord(n), ED_tail_port(e).p), add_pointf(ND_coord(head), ED_head_port(e).p)); } @@ -829,7 +829,7 @@ static int _spline_edges(graph_t * g, expand_t* pmargin, int edgetype) makeStraightEdge(g, e, edgetype == ET_PLINE); else { if (!rtr) rtr = mkRouter (obs, npoly); - fail = makeMultiSpline(e, rtr, edgetype == ET_PLINE); + fail = makeMultiSpline(g, e, rtr, edgetype == ET_PLINE); } if (!fail) continue; } @@ -843,9 +843,9 @@ static int _spline_edges(graph_t * g, expand_t* pmargin, int edgetype) e0 = e; for (i = 0; i < cnt; i++) { if (edgetype == ET_SPLINE) - makeSpline(e0, obs, npoly, TRUE); + makeSpline(g, e0, obs, npoly, TRUE); else - makePolyline(e0); + makePolyline(g, e0); e0 = ED_to_virt(e0); } } else { @@ -949,7 +949,7 @@ int spline_edges1(graph_t * g, int edgetype) */ void spline_edges0(graph_t * g) { - int et = EDGE_TYPE (g->root); + int et = EDGE_TYPE (g); neato_set_aspect(g); if (et == ET_NONE) return; #ifndef ORTHO diff --git a/lib/twopigen/twopiinit.c b/lib/twopigen/twopiinit.c index 95075c086..443e65c4e 100644 --- a/lib/twopigen/twopiinit.c +++ b/lib/twopigen/twopiinit.c @@ -105,6 +105,7 @@ void twopi_layout(Agraph_t * g) nodeInduce(sg); circleLayout(sg, c); adjustNodes(sg); + setEdgeType (sg, ET_LINE); spline_edges(sg); } free(ND_alg(agfstnode(g))); -- 2.40.0