]> granicus.if.org Git - graphviz/commitdiff
Make sure normalization is checked even in overlap is unspecified.
authorEmden Gansner <erg@research.att.com>
Tue, 19 Mar 2013 21:03:57 +0000 (17:03 -0400)
committerEmden Gansner <erg@research.att.com>
Tue, 19 Mar 2013 21:03:57 +0000 (17:03 -0400)
lib/neatogen/adjust.c
lib/neatogen/adjust.h

index 8c15e2e85a17b7b81bf7b6b2b9f015d87ad1248b..372d1f6fbef4bbe9bfb6cfcb576a53b4a095bb5e 100644 (file)
@@ -899,16 +899,17 @@ vpscAdjust(graph_t* G)
  * rotate graph so that first edge is horizontal.
  * FIX: Generalize to allow rotation determined by graph shape.
  */
-void normalize(graph_t * g)
+int normalize(graph_t * g)
 {
     node_t *v;
     edge_t *e;
 
     double theta;
     pointf p;
+    int ret;
 
     if (!mapbool(agget(g, "normalize")))
-       return;
+       return 0;
 
     v = agfstnode(g);
     p.x = ND_pos(v)[0];
@@ -917,13 +918,15 @@ void normalize(graph_t * g)
        ND_pos(v)[0] -= p.x;
        ND_pos(v)[1] -= p.y;
     }
+    if (p.x || p.y) ret = 1;
+    else ret = 0;
 
     e = NULL;
     for (v = agfstnode(g); v; v = agnxtnode(g, v))
        if ((e = agfstout(g, v)))
            break;
     if (e == NULL)
-       return;
+       return ret;
 
     theta = -atan2(ND_pos(aghead(e))[1] - ND_pos(agtail(e))[1],
                   ND_pos(aghead(e))[0] - ND_pos(agtail(e))[0]);
@@ -934,6 +937,8 @@ void normalize(graph_t * g)
        ND_pos(v)[0] = p.x * cos(theta) - p.y * sin(theta);
        ND_pos(v)[1] = p.x * sin(theta) + p.y * cos(theta);
     }
+    if (theta) return 1;
+    else return ret;
 }
 
 typedef struct {
@@ -1053,8 +1058,6 @@ removeOverlapWith (graph_t * G, adjust_data* am)
     if (agnnodes(G) < 2)
        return 0;
 
-    normalize(G);
-
     if (am->mode == AM_NONE)
        return 0;
 
@@ -1147,14 +1150,17 @@ int
 removeOverlapAs(graph_t * G, char* flag)
 {
     adjust_data am;
+    int ret;
 
     if (agnnodes(G) < 2)
        return 0;
-    if (flag == NULL)
-       return 0;
-
-    getAdjustMode(G, flag, &am);
-    return removeOverlapWith (G, &am);
+    if (flag) {
+       getAdjustMode(G, flag, &am);
+       ret = removeOverlapWith (G, &am);
+    }
+    else
+       ret = 0;
+    return (ret + normalize(G));
 }
 
 /* adjustNodes:
index 31fbbc37bcc03957629f0042b5552a00db7c4bbf..603d9cfb876f41c89158e8c7c51fd261001246ee 100644 (file)
@@ -48,7 +48,7 @@ typedef struct {
     extern expand_t sepFactor(graph_t * G);
     extern expand_t esepFactor(graph_t * G);
     extern int adjustNodes(graph_t * G);
-    extern void normalize(graph_t * g);
+    extern int normalize(graph_t * g);
     extern int removeOverlapAs(graph_t*, char*);
     extern int removeOverlapWith(graph_t*, adjust_data*);
     extern int cAdjust(graph_t *, int);