]> granicus.if.org Git - graphviz/commitdiff
Add most of the implementation allowing fixed shapes. That is, the label has no effec...
authorEmden R. Gansner <erg@alum.mit.edu>
Sun, 2 Feb 2014 22:49:45 +0000 (17:49 -0500)
committerEmden R. Gansner <erg@alum.mit.edu>
Sun, 2 Feb 2014 22:49:45 +0000 (17:49 -0500)
lib/common/const.h
lib/common/shapes.c
lib/neatogen/neatosplines.c

index 14a3136a5b4dfba1f0470c311c3ba25b613c8c60..b38bee17660164fd32b75252c25d652970436ab9 100644 (file)
 #define DASHED         (1 << 8)
 #define WEDGED         (1 << 9)
 #define UNDERLINE      (1 << 10)
+#define FIXEDSHAPE     (1 << 11)
 
 #define SHAPE_MASK     (127 << 24)
 
index 3623d41821cba40a418bde5ab13370a432eab9dc..27baaecfc6513882239c8a98051c870cfd764e88 100644 (file)
@@ -1822,7 +1822,7 @@ static void poly_init(node_t * n)
     point imagesize;
     pointf P, Q, R;
     pointf *vertices;
-    char *p, *sfile;
+    char *p, *sfile, *fxd;
     double temp, alpha, beta, gamma;
     double orientation, distortion, skew;
     double sectorangle, sidelength, skewdist, gdistortion, gskew;
@@ -1989,7 +1989,12 @@ static void poly_init(node_t * n)
     min_bb = bb;
 
     /* increase node size to width/height if needed */
-    if (mapbool(late_string(n, N_fixed, "false"))) {
+    fxd = late_string(n, N_fixed, "false");
+    if ((*fxd == 's') && streq(fxd,"shape")) {
+       bb.x = width;
+       bb.y = height;
+       poly->option |= FIXEDSHAPE;
+    } else if (mapbool(fxd)) {
        /* check only label, as images we can scale to fit */
        if ((width < ND_label(n)->dimen.x) || (height < ND_label(n)->dimen.y))
            agerr(AGWARN,
@@ -2024,11 +2029,12 @@ static void poly_init(node_t * n)
        ND_label(n)->space.x = dimen.x - spacex;
     }
 
-
-    temp = bb.y - min_bb.y;
-    if (dimen.y < imagesize.y)
-       temp += imagesize.y - dimen.y;
-    ND_label(n)->space.y = dimen.y + temp;
+    if ((poly->option & FIXEDSHAPE) == 0) {
+       temp = bb.y - min_bb.y;
+       if (dimen.y < imagesize.y)
+           temp += imagesize.y - dimen.y;
+       ND_label(n)->space.y = dimen.y + temp;
+    }
 
     outp = peripheries;
     if (peripheries < 1)
@@ -2190,8 +2196,14 @@ static void poly_init(node_t * n)
     poly->distortion = distortion;
     poly->vertices = vertices;
 
-    ND_width(n) = PS2INCH(bb.x);
-    ND_height(n) = PS2INCH(bb.y);
+    if (poly->option & FIXEDSHAPE) {
+       /* set width and height to reflect label and shape */
+       ND_width(n) = PS2INCH(MAX(dimen.x,bb.x));
+       ND_height(n) = PS2INCH(MAX(dimen.y,bb.y));
+    } else {
+       ND_width(n) = PS2INCH(bb.x);
+       ND_height(n) = PS2INCH(bb.y);
+    }
     ND_shape_info(n) = (void *) poly;
 }
 
index cb24a1d39ab1fce6311aec03a8d88010d84c1899..1ca59a1bcdb999a9cacda1cc4cc2235971a15d4a 100644 (file)
@@ -291,18 +291,23 @@ Ppoly_t *makeObstacle(node_t * n, expand_t* pmargin, boolean isOrtho)
        if (isOrtho) {
            isPoly = 1;
            sides = 4;
-           p.x = -ND_lw(n); 
-           p.y = -ND_ht(n)/2.0; 
-           vs[0] = p;
-           p.x = ND_lw(n);
-           vs[1] = p;
-           p.y = ND_ht(n)/2.0; 
-           vs[2] = p;
-           p.x = -ND_lw(n); 
-           vs[3] = p;
-           verts = vs;
-           margin.x = 0;
-           margin.y = 0;
+           margin.x = margin.y = 0;
+               /* For fixedshape, we can't use the width and height, as this includes
+                * the label. We only want to use the actual node shape.
+                */
+           if (poly->option & FIXEDSHAPE) {
+           } else {
+               p.x = -ND_lw(n);
+               p.y = -ND_ht(n)/2.0;
+               vs[0] = p;
+               p.x = ND_lw(n);
+               vs[1] = p;
+               p.y = ND_ht(n)/2.0;
+               vs[2] = p;
+               p.x = -ND_lw(n);
+               vs[3] = p;
+               verts = vs;
+           }
        }
        else if (poly->sides >= 3) {
            isPoly = 1;