]> granicus.if.org Git - graphviz/commitdiff
Use explicit _background attribute for specifying background graphics
authorEmden R. Gansner <erg@alum.mit.edu>
Wed, 4 Dec 2013 15:59:22 +0000 (10:59 -0500)
committerEmden R. Gansner <erg@alum.mit.edu>
Wed, 4 Dec 2013 15:59:22 +0000 (10:59 -0500)
in xdot, rather than just using the graph's _draw_ attribute. This
avoids the problem of having the _draw_ attribute growing each time
_draw_ is defined and the graph is rendered.

cmd/dotty/dotty_layout.lefty
cmd/gvmap/make_map.c
cmd/smyrna/topviewfuncs.c
doc/info/attrs.html
doc/infosrc/attrs
lib/common/emit.c

index 8aefac3a683b0ce8eb0d774c7ecbd7dfa0848af6..1bd27bed1c12043f88ec84ec634671651087f76a 100644 (file)
@@ -212,6 +212,8 @@ dotty.protogt.unpackalldraw = function (gt, attr) {
     o = [];
     if (attr._draw_)
         o._draw_ = gt.unpackdraw (gt, attr._draw_);
+    if (attr._background)
+        o._background = gt.unpackdraw (gt, attr._background);
     if (attr._ldraw_)
         o._ldraw_ = gt.unpackdraw (gt, attr._ldraw_);
     if (attr._hdraw_)
index fc1f99cf27e4ba02fac0e7f22157be592db89313..b9d7bcb0f68b2a4c1ff896337959fd530d23fc0a 100644 (file)
@@ -806,7 +806,7 @@ void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, Spa
 
   /*polygons */
   if (plot_polyQ) {
-    if (!gr) fprintf(f,"_draw_ = \"");
+    if (!gr) fprintf(f,"_background = \"");
     plot_dot_polygons(&sbuff, &len, &len_max, -1., NULL, polys, x_poly, polys_groups, r, g, b, opacity);
   }
 
@@ -818,7 +818,7 @@ void plot_dot_map(Agraph_t* gr, int n, int dim, real *x, SparseMatrix polys, Spa
     fprintf(f,"%s",sbuff);
     fprintf(f,"\"\n");/* close polygons/lines */
   } else {
-    agattr(gr, AGRAPH, "_draw_", sbuff);
+    agattr(gr, AGRAPH, "_background", sbuff);
     agwrite(gr, f);
   }
 
index da15b9902b54a7c1910837633dd732be0935fe8b..cc90415e297569db8c9a86d2c0ac7790d8c9ae34 100644 (file)
@@ -29,6 +29,8 @@ static xdot *parseXdotwithattrs(void *e)
     int cnt=0;
     xdot* xDot=NULL;
     xDot=parseXDotFOn (agget(e,"_draw_" ), OpFns,sizeof(sdot_op), xDot);
+    if (agobjkind(e) == AGRAPH)
+       xDot=parseXDotFOn (agget(e,"_background" ), OpFns,sizeof(sdot_op), xDot);
     xDot=parseXDotFOn (agget(e,"_ldraw_" ), OpFns,sizeof(sdot_op), xDot);
     xDot=parseXDotFOn (agget(e,"_hdraw_" ), OpFns,sizeof(sdot_op), xDot);
     xDot=parseXDotFOn (agget(e,"_tdraw_" ), OpFns,sizeof(sdot_op), xDot);
index ca8f629efdc53287c5e04df1c08c151e2ebc4ef3..7938d827dc3ba241b6d43551f886d90b90f7811d 100644 (file)
@@ -86,6 +86,8 @@ This field indicates which graph component uses the attribute.
  <TR><TD><A NAME=a:URL HREF=#d:URL>URL</A>
 </TD><TD>ENGC</TD><TD><A HREF=#k:escString>escString</A>
 </TD><TD ALIGN="CENTER">&#60;none&#62;</TD><TD></TD><TD>svg, postscript, map only</TD> </TR>
+ <TR><TD><A NAME=a:_background HREF=#d:_background>_background</A>
+</TD><TD>G</TD><TD>string</TD><TD ALIGN="CENTER">&#60;none&#62;</TD><TD></TD><TD></TD> </TR>
  <TR><TD><A NAME=a:area HREF=#d:area>area</A>
 </TD><TD>NC</TD><TD>double</TD><TD ALIGN="CENTER">1.0</TD><TD>&#62;0</TD><TD>patchwork only</TD> </TR>
  <TR><TD><A NAME=a:arrowhead HREF=#d:arrowhead>arrowhead</A>
@@ -557,6 +559,13 @@ This field indicates which graph component uses the attribute.
   Also note that, if active areas of two edges overlap, it is unspecified
   which area dominates.
 
+<DT><A NAME=d:_background HREF=#a:_background><STRONG>_background</STRONG></A>
+<DD>  A string in the <A HREF=output.html#d:xdot>xdot format</A> specifying an arbitrary background.  
+  During rendering, the canvas is first filled as described in the
+  <A href=#d:bgcolor>bgcolor attribute</A>. 
+  Then, if <b>_background</b> is defined, the graphics
+  operations described in the string are performed on the canvas.
+
 <DT><A NAME=d:area HREF=#a:area><STRONG>area</STRONG></A>
 <DD>  Indicates the preferred area for a node or empty cluster when laid out by patchwork.
 
@@ -593,12 +602,14 @@ This field indicates which graph component uses the attribute.
   See also the <A HREF=#d:gradientangle>gradientangle</A> attribute
   for setting the gradient angle. 
   <P>
-  If no background color is specified for the root graph, no graphics
-  operation are performed on the background. This works fine for
-  PostScript but for bitmap output, all bits are initialized to something.
-  This means that when the bitmap output is included in some other
+  For certain output formats, such as PostScript, no fill is done for
+  the root graph unless
+  <b>bgcolor</b> is explicitly set. For bitmap formats, however, 
+  the bits need to be
+  initialized to something, so the canvas is filled with white by default.
+  This means that if the bitmap output is included in some other
   document, all of the bits within the bitmap's bounding box will be
-  set, overwriting whatever color or graphics where already on the page.
+  set, overwriting whatever color or graphics were already on the page.
   If this effect is not desired, and you only want to set bits explicitly
   assigned in drawing the graph, set <B>bgcolor</B>="transparent".
 
index 61c2fd0f17b3134c15586daaba772cef233c97bf..2920b3470c9902a6dcf3a46c1ce70bbf4029f9da 100644 (file)
 # the special character '\' can cause problems. When used as a literal, use
 # the HTML encoding &#92; to avoid problems.
 #    
+:_background:G:string:<none>;  
+A string in the <A HREF=output.html#d:xdot>xdot format</A> specifying an arbitrary background.  
+During rendering, the canvas is first filled as described in the
+<A href=#d:bgcolor>bgcolor attribute</A>. 
+Then, if <b>_background</b> is defined, the graphics
+operations described in the string are performed on the canvas.
 :Damping:G:double:0.99:0.0; neato
 Factor damping force motions. On each iteration, a nodes movement
 is limited to this factor of its potential motion. By being less than
@@ -127,12 +133,14 @@ color (after a colon) is missing, the default color is used for it.
 See also the <A HREF=#d:gradientangle>gradientangle</A> attribute
 for setting the gradient angle. 
 <P>
-If no background color is specified for the root graph, no graphics
-operation are performed on the background. This works fine for
-PostScript but for bitmap output, all bits are initialized to something.
-This means that when the bitmap output is included in some other
+For certain output formats, such as PostScript, no fill is done for
+the root graph unless
+<b>bgcolor</b> is explicitly set. For bitmap formats, however, 
+the bits need to be
+initialized to something, so the canvas is filled with white by default.
+This means that if the bitmap output is included in some other
 document, all of the bits within the bitmap's bounding box will be
-set, overwriting whatever color or graphics where already on the page.
+set, overwriting whatever color or graphics were already on the page.
 If this effect is not desired, and you only want to set bits explicitly
 assigned in drawing the graph, set <B>bgcolor</B>="transparent".
 #bottomlabel:N:string:"";
index 610baef8e13768fcebb3a552c358a043e7d0feb5..bf580222537510a6eead00c0f07c8f0c348ed6fa 100644 (file)
@@ -48,7 +48,7 @@ void* init_xdot (Agraph_t* g)
     char* p;
     xdot* xd = NULL;
 
-    if ((p = agget(g, "_draw_")) && p[0]) {
+    if ((p = agget(g, "_background")) && p[0]) {
 #ifdef DEBUG
        if (Verbose) {
            start_timer();
@@ -57,7 +57,7 @@ void* init_xdot (Agraph_t* g)
        xd = parseXDotF (p, NULL, sizeof (exdot_op));
 
        if (!xd) {
-           agerr(AGWARN, "Could not parse \"_draw_\" attribute in graph %s\n", agnameof(g));
+           agerr(AGWARN, "Could not parse \"_background\" attribute in graph %s\n", agnameof(g));
            agerr(AGPREV, "  \"%s\"\n", p);
        }
 #ifdef DEBUG