[GRASS-SVN] r48476 - grass/trunk/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 26 06:22:11 EDT 2011
Author: hamish
Date: 2011-09-26 03:22:10 -0700 (Mon, 26 Sep 2011)
New Revision: 48476
Modified:
grass/trunk/ps/ps.map/do_plt.c
grass/trunk/ps/ps.map/ps.map.html
grass/trunk/ps/ps.map/r_plt.c
Log:
bugfix: (r_plt.c) inch scaling was backwards;
merge in modified version of 'point' width patch from #1453 (thanks mmetz);
r_plt.c: no reason to specify line widths smaller than 1/1000" (%.8f -> %.2f);
pixels -> points in the help page, mention 0.5i capability.
Modified: grass/trunk/ps/ps.map/do_plt.c
===================================================================
--- grass/trunk/ps/ps.map/do_plt.c 2011-09-26 10:13:17 UTC (rev 48475)
+++ grass/trunk/ps/ps.map/do_plt.c 2011-09-26 10:22:10 UTC (rev 48476)
@@ -103,10 +103,11 @@
break;
case 'P':
- i = sscanf(buf, "P %d %lf %lf %d %d %d %d %d %d %lf %lf %s",
+ i = sscanf(buf, "P %d %lf %lf %d %d %d %d %d %d %lf %lf %s %lf",
&masked, &e1, &n1, &color_R, &color_G, &color_B,
- &fcolor_R, &fcolor_G, &fcolor_B, &size, &rotate, symb);
- if (i == 12) {
+ &fcolor_R, &fcolor_G, &fcolor_B, &size, &rotate, symb,
+ &width);
+ if (i == 13) {
if (masked && after_masking)
continue;
if (!masked && !after_masking)
@@ -136,9 +137,9 @@
else
set_color(&pfcolor, fcolor_R, fcolor_G, fcolor_B);
+ if (width < 0) /* default: autoscale relative to size */
+ width = 0.05 * size;
- width = 0.05 * size; /* TODO: Something better */
-
/* Read symbol */
sprintf(sname, "POINTSYMBOL%d", snum);
Symb = S_read(symb);
Modified: grass/trunk/ps/ps.map/ps.map.html
===================================================================
--- grass/trunk/ps/ps.map/ps.map.html 2011-09-26 10:13:17 UTC (rev 48475)
+++ grass/trunk/ps/ps.map/ps.map.html 2011-09-26 10:22:10 UTC (rev 48476)
@@ -649,18 +649,20 @@
The beginning and ending points of the line are entered on the main
instruction. These points can be defined either by map coordinates or
by using percentages of the geographic region.
-The user may also specify line
-<B>color</B>,
-<B>width</B>
-in pixels (accepts decimal points [floating points] as well as integers),
+The user may also specify line <B>color</B>, <B>width</B>
+in points (1/72"; accepts decimal values as well as integers),
and if the line is to be <B>masked</B> by the current mask.
(See manual entry for <EM><A HREF="r.mask.html">r.mask</A>
</EM> for more information on the mask.)
+The line <B>width</B> (if given) is measured in points; an <i>i</i>
+directly following the number indicates that the width is given in
+inches instead.
<P>
This example would draw a yellow line from the point x=10% y=80%
-to the point x=30% y=70%. This line
-would be 2 pixels wide and would appear even if there is a mask.
+to the point x=30% y=70%.
+This line would be 2 points wide (2/72") and would appear even if
+there is a mask.
<PRE>
EXAMPLE:
<B>line</B> 10% 80% 30% 70%
@@ -754,7 +756,7 @@
<PRE>
USAGE: <B>outline</B>
<B>color</B> color
- <B>width</B> width of line in pixels
+ <B>width</B> width of line in points
<B>end</B>
</PRE>
Distinct areas of the raster map will be separated from each other visually
@@ -839,20 +841,24 @@
<B>fcolor</B> color
<B>symbol</B> symbol group/name
<B>size</B> #
+ <B>width</B> #
<B>rotate</B> #
<B>masked</B> [y|n]
<B>end</B>
</PRE>
-The point location is entered in the main instruction line by giving either the map
-coordinates or by using percentages of the geographic region.
+The point location is entered in the main instruction line by giving either
+the map coordinates or by using percentages of the geographic region.
The user may also specify the point <B>color</B>,
the <B>size</B> of symbol in points,
the rotation angle (in degrees CCW),
and whether the point is to be <B>masked</B> by the current mask.
(See manual entry for <EM> <A HREF="r.mask.html">r.mask</A>
</EM> for more information on the mask.)
+The symbol line <B>width</B> (if given) is measured in points; an <i>i</i>
+directly following the number indicates that the width is given in inches
+instead. If a <B>width</B> is not given it will be set proportional to the
+symbol size.
<P>
-
This example would place a purple diamond (from icon file
<EM>diamond</EM>) at the point (E456000 N7890000). This diamond would be the
the size of a 15 points and would not be masked by the current mask.
@@ -978,23 +984,26 @@
by using percentages of the geographic region.
The user may also specify line
<B>color</B>, fill color <B>fcolor</B>, <B>width</B>
-in pixels (accepts decimal points [floating points] as well as integers),
+in points (accepts decimal points [floating points] as well as integers),
and if the rectangle is to be <B>masked</B> by the current mask.
(See manual entry for <EM><A HREF="r.mask.html">r.mask</A></EM>
for more information on the mask.)
+The border line <B>width</B> (if given) is measured in points; an <i>i</i>
+directly following the number indicates that the width is given in inches
+instead.
<BR>
Multiple rectangles may be drawn by using multiple <EM>rectangle</EM> instructions.
<P>
This example would draw a yellow rectangle filled by green from the point x=10% y=80%
-to the point x=30% y=70%. This line
-would be 2 pixels wide and would appear even if there is a mask.
+to the point x=30% y=70%.
+The border line would be 1/16" wide and would appear even if there is a mask.
<PRE>
EXAMPLE:
<B>rectangle</B> 10% 80% 30% 70%
<B>color</B> yellow
<B>fcolor</B> green
- <B>width</B> 2
+ <B>width</B> 0.0625i
<B>masked</B> n
<B>end</B>
</PRE>
@@ -1019,11 +1028,11 @@
on other user-created maps.
<P>
The user can specify the <B>color</B>
-and the <B>width</B> in pixel units (accepts decimal points
+and the <B>width</B> in point units (accepts decimal points
[floating points] as well as integers) of the outline.
-The default is a black border of one pixel width.
+The default is a black border of one point width (1/72").
<P>
-This example would place a white outline, 2 pixels wide, of the
+This example would place a white outline, 2 points wide, of the
geographic region called <EM>fire.zones</EM> onto the output map.
This geographic region would have been created and saved using
<EM><A HREF="g.region.html">g.region</A></EM>.
@@ -1237,11 +1246,12 @@
<P>
<B>yoffset</B>,
which provides finer placement of text by shifting the
-text a vertical distance in pixels from the specified north. The vertical
-offset will shift the location to the south if positive, north if negative;
+text a vertical distance in points (1/72") from the specified north.
+The vertical offset will shift the location to the south if positive,
+north if negative;
<P>
<B>xoffset</B>,
-which shifts the text a horizontal distance in pixels from
+which shifts the text a horizontal distance in points from
the specified east The horizontal offset will shift the location east if
positive, west if negative;
<P>
@@ -1253,7 +1263,7 @@
<BR>
The following example would place the text <EM>SPEARFISH LAND COVER</EM>
at the coordinates E650000 N7365000. The text would be a total of
-3 pixels wide (2 pixels of red text and 1 pixel black highlight), have a white
+3 points wide (2 pixels of red text and 1 pixel black highlight), have a white
background enclosed in a red box, and be 500 meters in size. The lower right
corner of the text would be centered over the coordinates provided. All
vectors on the map would stop at the border of this text.
@@ -1304,7 +1314,7 @@
<P>
<B>rgbcolumn</B> - name of color definition column used for the area fill color;
<P>
-<B>width</B> - width of the vectors lines or area boundaries in pixels
+<B>width</B> - width of the vectors lines or area boundaries in points
(accepts decimal points [floating points] as well as integers);
<P>
<B>masked</B> - whether or not the raster map layer is to be masked
@@ -1404,7 +1414,7 @@
<B>rgbcolumn</B> - name of color definition column used for the vector lines
or area boundaries;
<P>
-<B>width</B> - width of the vectors lines or area boundaries in pixels
+<B>width</B> - width of the vectors lines or area boundaries in points
(accepts decimal points [floating points] as well as integers);
<P>
<B>cwidth</B> - width of the vectors lines. If cwidth is used then
@@ -1413,10 +1423,10 @@
<P>
<B>hcolor</B> - the highlight color for the vector lines;
<P>
-<B>hwidth</B> - the width of the highlight color in pixels;
+<B>hwidth</B> - the width of the highlight color in points;
<P>
-<B>offset</B> (experimental) - offset for the vectors lines in pixels for
-plotting parallel lines in distance equal to offset (accepts positive or
+<B>offset</B> (experimental) - offset for the vectors lines in points (1/72")
+for plotting parallel lines in distance equal to offset (accepts positive or
negative decimal points). Useful to print streets with several parallel lanes;
<P>
<B>coffset</B> (experimental) - offset for the vectors lines. If coffset
Modified: grass/trunk/ps/ps.map/r_plt.c
===================================================================
--- grass/trunk/ps/ps.map/r_plt.c 2011-09-26 10:13:17 UTC (rev 48475)
+++ grass/trunk/ps/ps.map/r_plt.c 2011-09-26 10:22:10 UTC (rev 48476)
@@ -13,8 +13,9 @@
int color_R, color_G, color_B;
int fcolor_R, fcolor_G, fcolor_B;
int ret;
- double size, rotate;
+ double size, width, rotate;
int have_icon;
+ char ch;
char *key, *data;
int masked;
@@ -23,12 +24,14 @@
"fcolor fill color",
"symbol group/symbol",
"size #",
+ "width #",
"rotate #",
"masked [y|n]",
""
};
size = 6.0;
+ width = -1.0; /* default is proportionate to symbol size */
rotate = 0.0;
have_icon = 0;
masked = 0;
@@ -86,6 +89,18 @@
}
continue;
}
+
+ if (KEY("width")) {
+ ch = ' ';
+ if (sscanf(data, "%lf%c", &width, &ch) < 1 || width < 0.) {
+ width = 1.;
+ error(key, data, "illegal width request");
+ }
+ if (ch == 'i')
+ width = width * 72.;
+ continue;
+ }
+
if (KEY("rotate")) {
if (sscanf(data, "%lf", &rotate) != 1) {
rotate = 0.0;
@@ -97,9 +112,9 @@
error(key, data, "illegal point request");
}
- sprintf(buf, "P %d %f %f %d %d %d %d %d %d %f %f %s", masked, e, n,
+ sprintf(buf, "P %d %f %f %d %d %d %d %d %d %f %f %s %.2f", masked, e, n,
color_R, color_G, color_B, fcolor_R, fcolor_G, fcolor_B, size,
- rotate, symb);
+ rotate, symb, width);
add_to_plfile(buf);
@@ -243,14 +258,14 @@
error(key, data, "illegal width request");
}
if (ch == 'i')
- width = width / 72.;
+ width = width * 72.;
continue;
}
error(key, data, "illegal line request");
}
- sprintf(buf, "L %d %f %f %f %f %d %d %d %.8f",
+ sprintf(buf, "L %d %f %f %f %f %d %d %d %.2f",
masked, e1, n1, e2, n2, color_R, color_G, color_B, width);
add_to_plfile(buf);
@@ -280,7 +295,7 @@
width = 1.;
masked = 0;
color_R = color_G = color_B = 0;
- fcolor_R = fcolor_G = fcolor_B = -1; /* not filled by default */
+ fcolor_R = fcolor_G = fcolor_B = -1; /* not filled by default */
while (input(2, buf, help)) {
if (!key_data(buf, &key, &data))
@@ -330,14 +345,14 @@
error(key, data, "illegal width request");
}
if (ch == 'i')
- width = width / 72.;
+ width = width * 72.;
continue;
}
error(key, data, "illegal rectangle request");
}
- sprintf(buf, "R %d %f %f %f %f %d %d %d %d %d %d %.8f",
+ sprintf(buf, "R %d %f %f %f %f %d %d %d %d %d %d %.2f",
masked, e1, n1, e2, n2, color_R, color_G, color_B,
fcolor_R, fcolor_G, fcolor_B, width);
More information about the grass-commit
mailing list