Selaa lähdekoodia

merge fixes from devbr6 (trac https://trac.osgeo.org/grass/ticket/355):
- allow placement of vector legend left of the map
- patch from Bob Covill to save pattern file for legend even if pattern is never used within the map region


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34739 15284696-431f-4ddb-bdfa-cd5b030d7da7

Hamish Bowman 16 vuotta sitten
vanhempi
commit
3a7b8ed631
2 muutettua tiedostoa jossa 21 lisäystä ja 7 poistoa
  1. 3 2
      ps/ps.map/ps.map.html
  2. 18 5
      ps/ps.map/ps_vlegend.c

+ 3 - 2
ps/ps.map/ps.map.html

@@ -1476,8 +1476,9 @@ equal to zero, the vector legend will be positioned immediately below
 the map, starting <EM>x</EM> inches from the left edge of the page.
 
 <P>
-<EM>width</EM> is the width in inches of the color symbol (for areas) in front of the 
-legend text. The default is 1/24 * fontsize inches.
+<EM>width</EM> is the width in inches of the color symbol (for lines)
+in front of the  legend text. The default is 1/24 * fontsize inches.
+<P>
 <EM>cols</EM> is the number of columns to split the legend into. The default is one 
 column. The maximum number of colums is 10, or equal to the number of legend entries 
 if there are less than 10 entries.

+ 18 - 5
ps/ps.map/ps_vlegend.c

@@ -74,22 +74,33 @@ int PS_vlegend(void)
 	x = 72.0 * vector.x;
     else
 	x = PS.map_left;
+
     if (vector.y > 0.0)
 	y = 72.0 * (PS.page_height - vector.y);
     else if (vector.x <= 0.0)
 	y = PS.min_y;
     else
 	y = PS.map_bot;
+
     margin = 0.4 * fontsize;
-    if (x < PS.map_left + margin)
-	x = PS.map_left + margin;
+
+    if (x < PS.left_marg*72 + margin)
+	x = PS.left_marg*72 + margin;
 
     if (lcount < vector.cols)
 	vector.cols = lcount;
+
+/* FIXME (somehow): allow multi column to draw to the right margin would 
+    be nice, but for normal use locking to the right side of the map box
+    looks better. What's the correct compromise if the right side is always
+    automatically chosen? */
     dx = (PS.map_right - x) / vector.cols;
+/*    dx = ((PS.page_width-PS.right_marg)*72 - x) / vector.cols; */
+
     xs = x;			/*save x and y */
     ys = y;
     lc = (int)lcount / vector.cols;	/* lines per column */
+
     if (lcount % vector.cols)
 	lc++;
 
@@ -181,6 +192,7 @@ int PS_vlegend(void)
 			    eps_bbox(vector.layer[i].pat, &llx, &lly, &urx,
 				     &ury);
 			    sprintf(pat, "APATTEPS%d", i);
+			    pat_save(PS.fp, vector.layer[i].pat, pat);
 
 			    fprintf(PS.fp,
 				    "<<  /PatternType 1\n    /PaintType 1\n    /TilingType 1\n");
@@ -254,10 +266,11 @@ int PS_vlegend(void)
 
 	    /* plot the text */
 	    set_rgb_color(BLACK);
-	    fprintf(PS.fp, "a %d get %.1f %.1f MS\n", j - h * lc, x + width,
-		    y);
+	    fprintf(PS.fp, "a %d get %.1f %.1f MS\n",
+			j - h * lc, x + width, y);
 	}
-    }				/*h */
+    }	/* h */
+
     x = xs;
     y = ys - lc * dy;