]> 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/circogen/circularinit.c
lib/common/utils.c

index 6aa254d534164b9aa9b649a4e4a0ad4e46a9c574..110857f9186a49341e5c3fc8886536668e51c430 100644 (file)
@@ -72,6 +72,7 @@ static void circular_init_node_edge(graph_t * g)
 
 void circo_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 */
     circular_init_node_edge(g);
index 87d3ce70d9b0644b10d5f8c33f338cac662b945d..26719c59fd854bb3f68f9f4fb2a78702aef546d2 100644 (file)
@@ -1598,4 +1598,92 @@ boolean overlap_edge(edge_t *e, boxf b)
     return FALSE;
 }
 
+/* setEdgeType:
+ * Sets graph's edge type based on the "splines" attribute.
+ * If the attribute is not defined, use default.
+ * If the attribute is "", use NONE.
+ * If attribute value matches (case indepedent), use match.
+ *   ortho => ET_ORTHO
+ *   none => ET_NONE
+ *   line => ET_LINE
+ *   polyline => ET_PLINE
+ *   spline => ET_SPLINE
+ * If attribute is boolean, true means ET_SPLINE, false means ET_LINE.
+ * Else warn and use default.
+ */
+void setEdgeType (graph_t* g, int dflt)
+{
+    char* s = agget(g, "splines");
+    int et;
+
+    if (!s) {
+       GD_flags(g) |= dflt;
+       return;
+    }
+    if (*s == '\0') {
+       et = ET_NONE;
+       return;
+    }
+    et = 0;
+    switch (*s) {
+    case '0' :    /* false */
+       et = ET_LINE;
+       break;
+    case '1' :    /* true */
+    case '2' :
+    case '3' :
+    case '4' :
+    case '5' :
+    case '6' :
+    case '7' :
+    case '8' :
+    case '9' :
+       et = ET_SPLINE;
+       break;
+    case 'c' :
+    case 'C' :
+       if (!strcasecmp (s+1, "ompound"))
+           et = ET_COMPOUND;
+       break;
+    case 'f' :
+    case 'F' :
+       if (!strcasecmp (s+1, "alse"))
+           et = ET_LINE;
+       break;
+    case 'l' :
+    case 'L' :
+       if (!strcasecmp (s+1, "ine"))
+           et = ET_LINE;
+       break;
+    case 'n' :
+    case 'N' :
+       if (!strcasecmp (s+1, "one")) return;
+       break;
+    case 'o' :
+    case 'O' :
+       if (!strcasecmp (s+1, "rtho"))
+           et = ET_ORTHO;
+       break;
+    case 'p' :
+    case 'P' :
+       if (!strcasecmp (s+1, "olyline"))
+           et = ET_PLINE;
+       break;
+    case 's' :
+    case 'S' :
+       if (!strcasecmp (s+1, "pline"))
+           et = ET_SPLINE;
+       break;
+    case 't' :
+    case 'T' :
+       if (!strcasecmp (s+1, "rue"))
+           et = ET_SPLINE;
+       break;
+    }
+    if (!et) {
+       agerr(AGWARN, "Unknown \"splines\" value: \"%s\" - ignored\n", s);
+       et = dflt;
+    }
+    GD_flags(g) |= et;
+}