Browse Source

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 years ago
parent
commit
3a7b8ed631
2 changed files with 21 additions and 7 deletions
  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.
 the map, starting <EM>x</EM> inches from the left edge of the page.
 
 
 <P>
 <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 
 <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 
 column. The maximum number of colums is 10, or equal to the number of legend entries 
 if there are less than 10 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;
 	x = 72.0 * vector.x;
     else
     else
 	x = PS.map_left;
 	x = PS.map_left;
+
     if (vector.y > 0.0)
     if (vector.y > 0.0)
 	y = 72.0 * (PS.page_height - vector.y);
 	y = 72.0 * (PS.page_height - vector.y);
     else if (vector.x <= 0.0)
     else if (vector.x <= 0.0)
 	y = PS.min_y;
 	y = PS.min_y;
     else
     else
 	y = PS.map_bot;
 	y = PS.map_bot;
+
     margin = 0.4 * fontsize;
     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)
     if (lcount < vector.cols)
 	vector.cols = lcount;
 	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.map_right - x) / vector.cols;
+/*    dx = ((PS.page_width-PS.right_marg)*72 - x) / vector.cols; */
+
     xs = x;			/*save x and y */
     xs = x;			/*save x and y */
     ys = y;
     ys = y;
     lc = (int)lcount / vector.cols;	/* lines per column */
     lc = (int)lcount / vector.cols;	/* lines per column */
+
     if (lcount % vector.cols)
     if (lcount % vector.cols)
 	lc++;
 	lc++;
 
 
@@ -181,6 +192,7 @@ int PS_vlegend(void)
 			    eps_bbox(vector.layer[i].pat, &llx, &lly, &urx,
 			    eps_bbox(vector.layer[i].pat, &llx, &lly, &urx,
 				     &ury);
 				     &ury);
 			    sprintf(pat, "APATTEPS%d", i);
 			    sprintf(pat, "APATTEPS%d", i);
+			    pat_save(PS.fp, vector.layer[i].pat, pat);
 
 
 			    fprintf(PS.fp,
 			    fprintf(PS.fp,
 				    "<<  /PatternType 1\n    /PaintType 1\n    /TilingType 1\n");
 				    "<<  /PatternType 1\n    /PaintType 1\n    /TilingType 1\n");
@@ -254,10 +266,11 @@ int PS_vlegend(void)
 
 
 	    /* plot the text */
 	    /* plot the text */
 	    set_rgb_color(BLACK);
 	    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;
     x = xs;
     y = ys - lc * dy;
     y = ys - lc * dy;