]> granicus.if.org Git - graphviz/commitdiff
Initial support to allow new edge routing types (line segment, polyline,
authorerg <devnull@localhost>
Mon, 15 Jan 2007 21:03:57 +0000 (21:03 +0000)
committererg <devnull@localhost>
Mon, 15 Jan 2007 21:03:57 +0000 (21:03 +0000)
orthogonal, spline)

lib/dotgen/dotinit.c
lib/dotgen/dotsplines.c
lib/fdpgen/clusteredges.c
lib/fdpgen/layout.c
lib/neatogen/neatoinit.c
lib/neatogen/neatosplines.c
lib/twopigen/twopiinit.c

index f12496c9926fa69b709ab936e6f95b3fbcf4b2d4..dbba40f39ca85332d8cf7f18d94155b440383458 100644 (file)
@@ -222,6 +222,7 @@ dumpRanks (graph_t * g)
 
 void dot_layout(Agraph_t * g)
 {
+    setEdgeType (g, ET_SPLINE);
     dot_init_node_edge(g);
     dot_rank(g);
     dot_mincross(g);
index 17d64bb75073d2b257b3a5c562b75fa43dc0631b..70bfb8ea504b876e7b882a603ace0fc6fd7db544 100644 (file)
@@ -228,9 +228,8 @@ static void _dot_splines(graph_t * g, int normalize)
     edge_t *e, *e0, *e1, *ea, *eb, *le0, *le1, **edges;
     path *P;
     spline_info_t sd;
-    char* s = agget(g, "splines");
 
-    if (s && (*s == '\0')) return; 
+    if (EDGE_TYPE(g->root) == ET_NONE) return; 
 
     mark_lowclusters(g);
     routesplinesinit();
index abb80750a5ca5345ccb3fa2a49ef6642a8e1c64a..97f7596cc83422cb0ab702e760b7050a50ceec38 100644 (file)
@@ -246,7 +246,7 @@ static objlist *objectList(edge_t * ep, double SEP)
  * Returns 0 on success. Failure indicates the obstacle configuration
  * for some edge had overlaps.
  */
-int compoundEdges(graph_t * g, double SEP, int splines)
+int compoundEdges(graph_t * g, double SEP, int edgetype)
 {
     node_t *n;
     node_t *head;
index 332523336f5af680f502219e30f1051c306609ef..d3900857bff0c5e2b7bd337565e2500559ac16fa 100644 (file)
@@ -1037,6 +1037,7 @@ mkClusters (graph_t * g, clist_t* pclist, graph_t* parent)
 
 void fdp_init_graph(Agraph_t * g)
 {
+    setEdgeType (g, ET_LINE);
     GD_alg(g) = (void *) NEW(gdata);   /* freed in cleanup_graph */
     g->u.ndim = late_int(g, agfindattr(g, "dim"), 2, 2);
     Ndim = g->u.ndim = MIN(g->u.ndim, MAXDIM);
@@ -1065,40 +1066,38 @@ void fdpLayout(graph_t * g)
 }
 
 static void
-fdpSplines (graph_t * g, char* str)
+fdpSplines (graph_t * g)
 {
     int trySplines = 0;
+    int et = EDGE_TYPE(g);
 
-    if (str) {
-       if (streq(str, "compound")) {
-           trySplines = splineEdges(g, compoundEdges, 1);
+    if (et != ET_LINE) {
+       if (et == ET_COMPOUND) {
+           trySplines = splineEdges(g, compoundEdges, ET_SPLINE);
            /* When doing the edges again, accept edges done by compoundEdges */
            if (trySplines)
                Nop = 2;
        }
-       if (trySplines || mapbool(str)) {
+       if (trySplines || (et == ET_SPLINE)) {
            if (HAS_CLUST_EDGE(g)) {
                agerr(AGWARN,
                      "splines and cluster edges not supported - using line segments\n");
            } else {
-               spline_edges1(g, 1);
+               spline_edges1(g, ET_SPLINE);
            }
        }
     }
     if (State < GVSPLINES)
-       spline_edges1(g, 0);
+       spline_edges1(g, ET_LINE);
 }
 
 void fdp_layout(graph_t * g)
 {
-    char *str;
-
     fdp_init_graph(g);
     fdpLayout(g);
     neato_set_aspect(g);
 
-    str = agget(g, "splines");
-    if (!str || *str) fdpSplines (g, str); 
+    if (EDGE_TYPE(g) != ET_NONE) fdpSplines (g); 
 
     dotneato_postprocess(g);
 }
index 756b1d48c8dcd742b4d2082764c5843d3624ff06..708e1068361410a1b440c92b40c5022e6302eff3 100644 (file)
@@ -669,6 +669,7 @@ int init_nop(Agraph_t * g, int adjust)
 
 void neato_init_graphn(Agraph_t * g, int dfltdim)
 {
+    setEdgeType (g, ET_LINE);
     GD_ndim(g->root) = late_int(g, agfindattr(g, "dim"), dfltdim, 2);
     Ndim = GD_ndim(g->root) = MIN(GD_ndim(g->root), MAXDIM);
     neato_init_node_edge(g);
index 8147a83ff73d3d4f24b70ef80a838a983626f5b7..a89fe915d79cf38fd2e76be5c6dd54a9ab00b487 100644 (file)
@@ -524,6 +524,36 @@ getPath(edge_t * e, vconfig_t * vconfig, int chkPts, Ppoly_t ** obs,
     return line;
 }
 
+/* makePolyline:
+ */
+static void
+makePolyline(edge_t * e)
+{
+    int i, j;
+    Ppolyline_t line = ED_path(e);
+    int npts = 4 + 3*(line.pn-2);
+    point* ispline = N_GNEW(npts, point);
+    point p;
+
+    j = i = 0;
+    PF2P (line.ps[i], p);
+    ispline[j+1] = ispline[j] = p;
+    j += 2;
+    i++;
+    for (; i < line.pn-1; i++) {
+       PF2P (line.ps[i], p);
+       ispline[j+2] = ispline[j+1] = ispline[j] = p;
+       j += 3;
+    }
+    PF2P (line.ps[i], p);
+    ispline[j+1] = ispline[j] = p;
+
+    if (Verbose > 1)
+       fprintf(stderr, "polyline %s %s\n", e->tail->name, e->head->name);
+    clip_and_install(e, e, ispline, npts, &sinfo);
+    free(ispline);
+}
+
 /* makeSpline:
  * Construct a spline connecting the endpoints of e, avoiding the npoly
  * obstacles obs.
@@ -588,7 +618,7 @@ void makeSpline(edge_t * e, Ppoly_t ** obs, int npoly, boolean chkPts)
  * is not altered to reflect intra-cluster edges.
  * If Nop > 1 and the spline exists, it is just copied.
  */
-static int _spline_edges(graph_t * g, double SEP, int splines)
+static int _spline_edges(graph_t * g, double SEP, int edgetype)
 {
     node_t *n;
     edge_t *e;
@@ -599,7 +629,7 @@ static int _spline_edges(graph_t * g, double SEP, int splines)
     path *P = NULL;
 
     /* build configuration */
-    if (splines) {
+    if ((edgetype == ET_SPLINE) || (edgetype == ET_PLINE)) {
        obs = N_NEW(agnnodes(g), Ppoly_t *);
        for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
            obp = makeObstacle(n, SEP);
@@ -629,7 +659,8 @@ static int _spline_edges(graph_t * g, double SEP, int splines)
     /* route edges  */
     if (Verbose)
        fprintf(stderr, "Creating edges using %s\n",
-               (vconfig ? "splines" : "line segments"));
+           (vconfig ? (edgetype == ET_SPLINE ? "splines" : "polylines") : 
+               "line segments"));
     if (vconfig) {
        /* path-finding pass */
        for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
@@ -656,7 +687,10 @@ static int _spline_edges(graph_t * g, double SEP, int splines)
                }
                makeSelfArcs(P, e, GD_nodesep(g));
            } else if (vconfig) {
-               makeSpline(e, obs, npoly, TRUE);
+               if (edgetype == ET_SPLINE)
+                   makeSpline(e, obs, npoly, TRUE);
+               else
+                   makePolyline(e);
            } else if (ED_count(e)) {
                makeStraightEdge(g, e);
            }
@@ -679,14 +713,13 @@ static int _spline_edges(graph_t * g, double SEP, int splines)
  * Returns 0 on success.
  *
  * The edge function is given the graph, the separation to be added
- * around obstacles, and the type of edge. (At present, this is a boolean,
- * with 1 meaning splines and 0 meaning line segments.) It must guarantee 
+ * around obstacles, and the type of edge. It must guarantee 
  * that all bounding boxes are current; in particular, the bounding box of 
  * g must reflect the addition of the edges.
  */
 int
 splineEdges(graph_t * g, int (*edgefn) (graph_t *, double, int),
-           int splines)
+           int edgetype)
 {
     node_t *n;
     edge_t *e;
@@ -719,7 +752,7 @@ splineEdges(graph_t * g, int (*edgefn) (graph_t *, double, int),
     }
     dtclose(map);
 
-    if (edgefn(g, SEP, splines))
+    if (edgefn(g, SEP, edgetype))
        return 1;
 
     State = GVSPLINES;
@@ -730,9 +763,9 @@ splineEdges(graph_t * g, int (*edgefn) (graph_t *, double, int),
  * Construct edges using default algorithm and given splines value.
  * Return 0 on success.
  */
-int spline_edges1(graph_t * g, int splines)
+int spline_edges1(graph_t * g, int edgetype)
 {
-    return splineEdges(g, _spline_edges, splines);
+    return splineEdges(g, _spline_edges, edgetype);
 }
 
 /* spline_edges0:
@@ -751,11 +784,10 @@ int spline_edges1(graph_t * g, int splines)
  */
 void spline_edges0(graph_t * g)
 {
-    char* s = agget(g, "splines");
-
+    int et = EDGE_TYPE (g->root);
     neato_set_aspect(g);
-    if (s && (*s == '\0')) return; 
-    spline_edges1(g, mapbool(s));
+    if (et == ET_NONE) return;
+    spline_edges1(g, et);
 }
 
 /* spline_edges:
index e9b7159f6e4385879c5eabb2600fde984934c72e..2fadd367f5939ec944d861cc8e9a8107b4e11ba6 100644 (file)
@@ -61,6 +61,7 @@ static void twopi_init_node_edge(graph_t * g)
 
 void twopi_init_graph(graph_t * g)
 {
+    setEdgeType (g, ET_LINE);
     /* GD_ndim(g) = late_int(g,agfindattr(g,"dim"),2,2); */
     Ndim = GD_ndim(g) = 2;     /* The algorithm only makes sense in 2D */
     twopi_init_node_edge(g);