From: Emden R. Gansner Date: Tue, 9 Sep 2014 21:27:07 +0000 (-0400) Subject: Add new shape=plain as shorthand for shape=none width=height=margin=0. X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~164 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd4a89ce572b0a426026dccb676bab7476df90c3;p=graphviz Add new shape=plain as shorthand for shape=none width=height=margin=0. This is useful for HTML-like labels. --- diff --git a/doc/info/shapes.html b/doc/info/shapes.html index 2906a526c..a1725077a 100644 --- a/doc/info/shapes.html +++ b/doc/info/shapes.html @@ -58,157 +58,162 @@ The possible polygon-based shapes are displayed below. + - plaintext + plain diamond trapezium - parallelogram + - + parallelogram house pentagon hexagon - septagon + - + septagon octagon doublecircle doubleoctagon - tripleoctagon + - + tripleoctagon invtriangle invtrapezium invhouse - Mdiamond + - + Mdiamond Msquare Mcircle rect - rectangle + - + rectangle square star none - underline + - + underline note tab folder - box3d + - + box3d component promoter cds - terminator + - + terminator utr primersite restrictionsite - fivepoverhang + - + fivepoverhang threepoverhang noverhang assembly - signature + - + signature insulator ribosite rnastab - proteasesite + - + proteasesite proteinstab rpromoter rarrow - larrow + + larrow lpromoter As the figures suggest, the shapes rect and rectangle are synonyms for box, and none is a synonym for plaintext. -Also, unlike the rest, we have shown these last two +The shape plain is similar to these two, except that it also enforces +width=0 height=0 margin=0, which guarantees that the actual size of the node is entirely determined by the label. +This is useful, for example, when using HTML-like labels. +Also, unlike the rest, we have shown these three, as well as underline, without style=filled to indicate the normal use. If fill were turned on, the label text would appear in a filled rectangle. @@ -453,6 +458,11 @@ The horizontal and vertical rules (<HR> and <VR>

+NOTE:For releases later than 9 September 2014, one can use shape=plain so that the size +of the node is totally determined by the label. Otherwise, the node's margin, width and height values may cause the +node to be larger, so that edges are clipped away from the label. In effect, shape=plain is shorthand +for shape=none width=0 height=0 margin=0. +

If the value of a label attribute (label for nodes, edges, clusters, and graphs, and the @@ -550,11 +560,6 @@ Note that, as in HTML, element and attribute names are case-insensitive. | <U> text </U> - - - | - <O> text </O> - | @@ -741,17 +746,11 @@ Attribute values must appear in double quotes. >

- <!-- Underline text --> + <!-- Underlined text -->

<U
   <!-- No attributes -->
 >
 
-

- <!-- Overline text --> -

<O
-  <!-- No attributes -->
->
-

<!-- Subscript text -->

<SUB
diff --git a/doc/infosrc/mkshapes.sh b/doc/infosrc/mkshapes.sh
index 69bbd5984..be0c5ed10 100755
--- a/doc/infosrc/mkshapes.sh
+++ b/doc/infosrc/mkshapes.sh
@@ -7,7 +7,7 @@ do
   F=$s.dot
   exec 3> $F
   echo "digraph G {" >&3
-  if [[ $s == "plaintext" || $s == "none" || $s == "underline" ]]
+  if [[ $s == "plaintext" || $s == "none" || $s == "underline" || $s == "plain" ]]
   then
     echo " node [shape=$s];" >&3
   else
diff --git a/doc/infosrc/shapelist b/doc/infosrc/shapelist
index 54a62f433..26294c242 100644
--- a/doc/infosrc/shapelist
+++ b/doc/infosrc/shapelist
@@ -7,6 +7,7 @@ point
 egg
 triangle
 plaintext
+plain
 diamond
 trapezium
 parallelogram
diff --git a/doc/infosrc/shapes.2 b/doc/infosrc/shapes.2
index 7ec431877..aa46f8a63 100644
--- a/doc/infosrc/shapes.2
+++ b/doc/infosrc/shapes.2
@@ -1,6 +1,9 @@
 
 As the figures suggest, the shapes rect and rectangle are synonyms for box, and none is a synonym for plaintext.
-Also, unlike the rest, we have shown these last two 
+The shape plain is similar to these two, except that it also enforces 
+width=0 height=0 margin=0, which guarantees that the actual size of the node is entirely determined by the label.
+This is useful, for example, when using HTML-like labels.
+Also, unlike the rest, we have shown these three, as well as underline,
 without style=filled
 to indicate the normal use. If fill were turned on, the label text would
 appear in a filled rectangle.
diff --git a/lib/common/shapes.c b/lib/common/shapes.c
index 000734f29..e0c484f53 100644
--- a/lib/common/shapes.c
+++ b/lib/common/shapes.c
@@ -83,6 +83,7 @@ static polygon_t p_triangle = { FALSE, 1, 3, 0., 0., 0. };
 static polygon_t p_box = { FALSE, 1, 4, 0., 0., 0. };
 static polygon_t p_square = { TRUE, 1, 4, 0., 0., 0. };
 static polygon_t p_plaintext = { FALSE, 0, 4, 0., 0., 0. };
+static polygon_t p_plain = { FALSE, 0, 4, 0., 0., 0. };
 static polygon_t p_diamond = { FALSE, 1, 4, 45., 0., 0. };
 static polygon_t p_trapezium = { FALSE, 1, 4, 0., -.4, 0. };
 static polygon_t p_parallelogram = { FALSE, 1, 4, 0., 0., .6 };
@@ -139,6 +140,7 @@ static polygon_t p_larrow = { FALSE, 1, 4, 0., 0., 0., LARROW};
 static polygon_t p_lpromoter = { FALSE, 1, 4, 0., 0., 0., LPROMOTER};
 
 #define IS_BOX(n) (ND_shape(n)->polygon == &p_box)
+#define IS_PLAIN(n) (ND_shape(n)->polygon == &p_plain)
 
 /* True if style requires processing through round_corners. */
 #define SPECIAL_CORNERS(style) ((style) & (ROUNDED | DIAGONALS | SHAPE_MASK))
@@ -221,6 +223,7 @@ static shape_desc Shapes[] = {	/* first entry is default for no such shape */
     {"triangle", &poly_fns, &p_triangle},
     {"none", &poly_fns, &p_plaintext},
     {"plaintext", &poly_fns, &p_plaintext},
+    {"plain", &poly_fns, &p_plain},
     {"diamond", &poly_fns, &p_diamond},
     {"trapezium", &poly_fns, &p_trapezium},
     {"parallelogram", &poly_fns, &p_parallelogram},
@@ -1831,6 +1834,7 @@ static void poly_init(node_t * n)
     int regular, peripheries, sides;
     int i, j, isBox, outp;
     polygon_t *poly = NEW(polygon_t);
+    boolean isPlain = IS_PLAIN(n);
 
     regular = ND_shape(n)->polygon->regular;
     peripheries = ND_shape(n)->polygon->peripheries;
@@ -1847,7 +1851,10 @@ static void poly_init(node_t * n)
      *   Else use minimum default value.
      * If node is not regular, use the current width and height.
      */
-    if (regular) {
+    if (isPlain) {
+	width = height = 0;
+    }
+    else if (regular) {
 	double sz = userSize(n);
 	if (sz > 0.0)
 	    width = height = sz;
@@ -1875,23 +1882,25 @@ static void poly_init(node_t * n)
     /* minimal whitespace around label */
     if ((dimen.x > 0) || (dimen.y > 0)) {
 	/* padding */
-	if ((p = agget(n, "margin"))) {
-	    marginx = marginy = 0;
-	    i = sscanf(p, "%lf,%lf", &marginx, &marginy);
-	    if (marginx < 0)
-		marginx = 0;
-	    if (marginy < 0)
-		marginy = 0;
-	    if (i > 0) {
-		dimen.x += 2 * POINTS(marginx);
-		if (i > 1)
-		    dimen.y += 2 * POINTS(marginy);
-		else
-		    dimen.y += 2 * POINTS(marginx);
+	if (!isPlain) {
+	    if ((p = agget(n, "margin"))) {
+		marginx = marginy = 0;
+		i = sscanf(p, "%lf,%lf", &marginx, &marginy);
+		if (marginx < 0)
+		    marginx = 0;
+		if (marginy < 0)
+		    marginy = 0;
+		if (i > 0) {
+		    dimen.x += 2 * POINTS(marginx);
+		    if (i > 1)
+			dimen.y += 2 * POINTS(marginy);
+		    else
+			dimen.y += 2 * POINTS(marginx);
+		} else
+		    PAD(dimen);
 	    } else
 		PAD(dimen);
-	} else
-	    PAD(dimen);
+	}
     }
     spacex = dimen.x - ND_label(n)->dimen.x;