[GRASS-SVN] r52733 - grass/trunk/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 19 09:38:56 PDT 2012


Author: mmetz
Date: 2012-08-19 09:38:56 -0700 (Sun, 19 Aug 2012)
New Revision: 52733

Modified:
   grass/trunk/ps/ps.map/colortable.h
   grass/trunk/ps/ps.map/do_scalebar.c
   grass/trunk/ps/ps.map/get_scalebar.c
   grass/trunk/ps/ps.map/ps_clrtbl.c
   grass/trunk/ps/ps.map/ps_fclrtbl.c
   grass/trunk/ps/ps.map/r_colortable.c
Log:
ps.map: add missing and new options, preserve backwards compatibility

Modified: grass/trunk/ps/ps.map/colortable.h
===================================================================
--- grass/trunk/ps/ps.map/colortable.h	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/colortable.h	2012-08-19 16:38:56 UTC (rev 52733)
@@ -8,15 +8,17 @@
 
 struct colortable
 {
-    double x, y, width;
-    double min, max;
+    double x, y;	/* where */
+    double width;	/* column/table width */
+    double min, max;	/* range */
     double height;	/* fp legend height */
+    double lwidth;	/* line width for columns and tickbars */
     char *font;
     char *name;
     const char *mapset;
     int fontsize;
-    PSCOLOR color;
-    int cols;
+    PSCOLOR color;	/* text color, it seems */
+    int cols;		/* number of columns */
     int nodata;
     int tickbar;
     int discrete;	/* force discrete bands or continuous gradient */

Modified: grass/trunk/ps/ps.map/do_scalebar.c
===================================================================
--- grass/trunk/ps/ps.map/do_scalebar.c	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/do_scalebar.c	2012-08-19 16:38:56 UTC (rev 52733)
@@ -92,7 +92,7 @@
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 		lab = 0;
 	    }
@@ -106,7 +106,7 @@
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 	    }
 
@@ -129,7 +129,7 @@
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
 	}
-	set_rgb_color(BLACK);
+	set_rgb_color(sb.color);
 	fprintf(PS.fp, "TIB\n");
 
 
@@ -152,7 +152,7 @@
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
 	}
-	set_rgb_color(BLACK);
+	set_rgb_color(sb.color);
 	fprintf(PS.fp, "TIB\n");
 
 
@@ -176,7 +176,7 @@
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 		lab = 0;
 	    }
@@ -206,7 +206,7 @@
 	set_rgb_color(WHITE);
 	fprintf(PS.fp, "F ");
     }
-    set_rgb_color(BLACK);
+    set_rgb_color(sb.color);
     fprintf(PS.fp, "TIB\n");
 
 

Modified: grass/trunk/ps/ps.map/get_scalebar.c
===================================================================
--- grass/trunk/ps/ps.map/get_scalebar.c	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/get_scalebar.c	2012-08-19 16:38:56 UTC (rev 52733)
@@ -139,6 +139,17 @@
 		continue;
 	}
 
+	if (KEY("color"))
+	{
+	    sb.color = get_color_number(data);
+	    if (sb.color < 0)
+	    {
+		sb.color = BLACK;
+		error(key, data, "illegal color request");
+	    }
+	    continue;
+	}
+
 	if (KEY("background")) {
 	    sb.bgcolor = yesno(key, data);
 	    continue;

Modified: grass/trunk/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_clrtbl.c	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/ps_clrtbl.c	2012-08-19 16:38:56 UTC (rev 52733)
@@ -199,7 +199,7 @@
 /* grey border	fprintf(PS.fp, "B F .247 .247 .247 C 1 W stroke\n"); */
 		fprintf(PS.fp, "B F ");
 		set_ps_color(&ct.color);
-		fprintf(PS.fp, "1 W stroke\n");
+		fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
 	    }
 	    else {
 		/* split the rectangle into NSTEPS horizontal strips and
@@ -226,7 +226,7 @@
 		    fprintf(PS.fp, "B CF stroke\n");
 		}		/* done filling the box */
 
-		/* outline the box in black */
+		/* outline the box in the specified color, see above */
 		fprintf(PS.fp, "%.1f ", x1);
 		if (center_cols)
 		    fprintf(PS.fp, "mvx ");
@@ -235,7 +235,10 @@
 		if (center_cols)
 		    fprintf(PS.fp, "mvx ");
 		fprintf(PS.fp, "%.1f ", y + fontsize);
-		fprintf(PS.fp, "B BW stroke\n");
+		fprintf(PS.fp, "B ");
+		set_ps_color(&ct.color);
+		fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
+
 	    }	/* done drawing the box */
 
 	    /* do the text */

Modified: grass/trunk/ps/ps.map/ps_fclrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_fclrtbl.c	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/ps_fclrtbl.c	2012-08-19 16:38:56 UTC (rev 52733)
@@ -121,7 +121,7 @@
     cwidth = 0.1;
     ncols = (int)height / cwidth;
     step = (dmax - dmin) / (ncols - 1);
-    lwidth = width > 72 ? 0.02 * 72 : 0.02 * width;
+    lwidth = ct.lwidth;
 
     /* Print color band */
     y = t;

Modified: grass/trunk/ps/ps.map/r_colortable.c
===================================================================
--- grass/trunk/ps/ps.map/r_colortable.c	2012-08-19 15:26:49 UTC (rev 52732)
+++ grass/trunk/ps/ps.map/r_colortable.c	2012-08-19 16:38:56 UTC (rev 52733)
@@ -18,6 +18,7 @@
     "where      x y",
     "width      table_width",
     "height     fptable_height",
+    "lwidth     line_width",
     "raster	raster_name",
     "range	min max",
     "cols       columns",
@@ -36,7 +37,7 @@
     char *key, *data;
     char name[GNAME_MAX], mapset[GMAPSET_MAX];
     int fontsize, cols, nodata, tickbar, discrete;
-    double w, h, x, y;
+    double w, h, x, y, lw;
     int range_override;
     double min, max, tmpD;
     int r, g, b, ret;
@@ -47,6 +48,7 @@
     set_color(&color, 0, 0, 0);
     cols = 1;
     h = w = x = y = 0.0;
+    lw = 1;
     ct.font = G_store("Helvetica");
     ct.nodata = TRUE;
     ct.tickbar = FALSE;
@@ -82,6 +84,14 @@
 		continue;
 	}
 
+	if (KEY("lwidth")) {
+	    if (sscanf(data, "%lf", &lw) != 1 || lw < 0) {
+		error(key, data, _("illegal width request"));
+	    }
+	    else
+		continue;
+	}
+
 	if (KEY("raster")) {
 	    if (scan_gis("cell", "raster", key, data, name, mapset, 0)) {
 		ct.name = G_store(name);
@@ -189,6 +199,7 @@
     ct.range_override = range_override;
     ct.width = w;
     ct.height = h;
+    ct.lwidth = lw;
     ct.color = color;
     ct.cols = cols;
 



More information about the grass-commit mailing list