[GRASS-SVN] r34744 - grass/trunk/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 5 21:05:47 EST 2008
Author: hamish
Date: 2008-12-05 21:05:47 -0500 (Fri, 05 Dec 2008)
New Revision: 34744
Modified:
grass/trunk/ps/ps.map/ps.map.html
grass/trunk/ps/ps.map/ps_vlegend.c
grass/trunk/ps/ps.map/r_vlegend.c
grass/trunk/ps/ps.map/vector.h
Log:
add vlegend column separation control (see trac #355; merge from devbr6)
Modified: grass/trunk/ps/ps.map/ps.map.html
===================================================================
--- grass/trunk/ps/ps.map/ps.map.html 2008-12-06 02:00:50 UTC (rev 34743)
+++ grass/trunk/ps/ps.map/ps.map.html 2008-12-06 02:05:47 UTC (rev 34744)
@@ -1466,6 +1466,7 @@
<B>fontsize</B> font size
<B>width</B> width of color symbol
<B>cols</B> number of columns to print
+ <B>span</B> column separation
<B>border</B> color|none
<B>end</B>
</PRE>
@@ -1474,15 +1475,19 @@
If the <EM>where</EM> instruction is present and <EM>y</EM> is less than or
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 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.
+<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.
<P>
+<EM>span</EM> is the column separation distance between the left edges of
+two columns in a multicolumn legend. It is given in inches.
+The default is automatic scaling based on the left margin and the right
+hand side of the map box.
+<P>
<EM>border</EM> will draw a border around the legend using the specified color.
(see <a href="#NAMED_COLORS">NAMED COLORS</a>)
<P>
Modified: grass/trunk/ps/ps.map/ps_vlegend.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vlegend.c 2008-12-06 02:00:50 UTC (rev 34743)
+++ grass/trunk/ps/ps.map/ps_vlegend.c 2008-12-06 02:05:47 UTC (rev 34744)
@@ -70,6 +70,7 @@
/* get text location */
dy = 1.5 * fontsize;
+
if (vector.x > 0.0)
x = 72.0 * vector.x;
else
@@ -90,12 +91,11 @@
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; */
+ if(vector.span < 0)
+ dx = (PS.map_right - x) / vector.cols;
+ /* dx = ((PS.page_width-PS.right_marg)*72 - x) / vector.cols; */
+ else
+ dx = vector.span*72;
xs = x; /*save x and y */
ys = y;
Modified: grass/trunk/ps/ps.map/r_vlegend.c
===================================================================
--- grass/trunk/ps/ps.map/r_vlegend.c 2008-12-06 02:00:50 UTC (rev 34743)
+++ grass/trunk/ps/ps.map/r_vlegend.c 2008-12-06 02:05:47 UTC (rev 34744)
@@ -18,6 +18,7 @@
"width sample box width",
"cols number of columns",
"border color|none",
+ "span column separation",
""
};
@@ -26,13 +27,14 @@
char buf[1024];
char *key, *data;
int fontsize, cols, border;
- double x, y, width;
+ double x, y, width, cseparation;
fontsize = 0;
x = y = 0.0;
width = -1;
cols = 1;
border = -1;
+ cseparation = -1;
while (input(2, buf, help)) {
if (!key_data(buf, &key, &data))
@@ -81,6 +83,12 @@
continue;
}
+ if (KEY("span")) {
+ G_strip(data);
+ cseparation = atof(data);
+ continue;
+ }
+
error(key, data, "illegal vlegend sub-request");
}
vector.x = x;
@@ -95,6 +103,7 @@
vector.cols = cols;
vector.border = border;
+ vector.span = cseparation;
return 0;
}
Modified: grass/trunk/ps/ps.map/vector.h
===================================================================
--- grass/trunk/ps/ps.map/vector.h 2008-12-06 02:00:50 UTC (rev 34743)
+++ grass/trunk/ps/ps.map/vector.h 2008-12-06 02:05:47 UTC (rev 34744)
@@ -8,6 +8,7 @@
#include "clr.h"
#define PI M_PI
+
/* #define MAXVECTORS 20 */
/* layer type */
@@ -103,6 +104,7 @@
double width; /* width of legend symbols */
int cols; /* number of colums */
int border; /* border color number or -1 for none */
+ double span; /* column separation in inches */
LAYER *layer;
};
More information about the grass-commit
mailing list