]> granicus.if.org Git - graphviz/commitdiff
Add user control over pad values.
authorerg <devnull@localhost>
Sat, 3 Mar 2007 21:55:23 +0000 (21:55 +0000)
committererg <devnull@localhost>
Sat, 3 Mar 2007 21:55:23 +0000 (21:55 +0000)
lib/common/emit.c
lib/gvc/gvcint.h

index a355d55c417ec2f8ef91521bd56d471e561997c5..739df17f3b84dd9e422a1b6a50b42f385c59dae8 100644 (file)
@@ -1724,6 +1724,18 @@ static void init_gvc(GVC_t * gvc, graph_t * g)
         }
     }
 
+    /* pad */
+    gvc->graph_sets_pad = FALSE;
+    if ((p = agget(g, "pad"))) {
+        i = sscanf(p, "%lf,%lf", &xf, &yf);
+        if (i > 0) {
+            gvc->pad.x = gvc->pad.y = xf * POINTS_PER_INCH;
+            if (i > 1)
+                gvc->pad.y = yf * POINTS_PER_INCH;
+            gvc->graph_sets_pad = TRUE;
+        }
+    }
+
     /* pagesize */
     gvc->graph_sets_pageSize = FALSE;
     P2PF(GD_drawing(g)->page, gvc->pageSize);
@@ -1767,13 +1779,20 @@ static void init_gvc(GVC_t * gvc, graph_t * g)
 
 static void init_job_pad(GVJ_t *job)
 {
-    switch (job->output_lang) {
-    case GVRENDER_PLUGIN:
-       job->pad.x = job->pad.y = job->render.features->default_pad;
-       break;
-    default:
-       job->pad.x = job->pad.y = DEFAULT_GRAPH_PAD;
-       break;
+    GVC_t *gvc = job->gvc;
+    
+    if (gvc->graph_sets_pad) {
+       job->pad = gvc->pad;
+    }
+    else {
+       switch (job->output_lang) {
+       case GVRENDER_PLUGIN:
+           job->pad.x = job->pad.y = job->render.features->default_pad;
+           break;
+       default:
+           job->pad.x = job->pad.y = DEFAULT_GRAPH_PAD;
+           break;
+       }
     }
 }
 
index 12f00ae2f933387ac7bbbd9ba6bf06760ccd0d49..a5fef9d3b2f4e08aa948b420cbb19a1e3fcea49a 100644 (file)
@@ -111,11 +111,12 @@ extern "C" {
        /* pagination */
        char *pagedir;          /* pagination order */
        pointf margin;          /* margins in graph units */
+       pointf pad;             /* pad in graph units */
        pointf pageSize;        /* pageSize in graph units, not including margins */
        point pb;               /* page size - including margins (inches) */
        boxf bb;                /* graph bb in graph units, not including margins */
        int rotation;           /* rotation - 0 = portrait, 90 = landscape */
-       boolean graph_sets_margin, graph_sets_pageSize, graph_sets_rotation;
+       boolean graph_sets_pad, graph_sets_margin, graph_sets_pageSize, graph_sets_rotation;
 
        /* layers */
        char *layerDelims;      /* delimiters in layer names */