[GRASS-SVN] r47709 - grass/branches/develbranch_6/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 17 09:41:55 EDT 2011


Author: hamish
Date: 2011-08-17 06:41:55 -0700 (Wed, 17 Aug 2011)
New Revision: 47709

Modified:
   grass/branches/develbranch_6/ps/ps.map/description.html
   grass/branches/develbranch_6/ps/ps.map/r_instructions.c
Log:
full RGB support for the setcolor instruction (#192) & document hidden setcolor functionality; i18n [merge from trunk]

Modified: grass/branches/develbranch_6/ps/ps.map/description.html
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/description.html	2011-08-17 13:34:07 UTC (rev 47708)
+++ grass/branches/develbranch_6/ps/ps.map/description.html	2011-08-17 13:41:55 UTC (rev 47709)
@@ -1181,7 +1181,9 @@
 <EM>setcolor</EM>
 can be requested more than once to override the default color for additional
 categories.  More than one category can be changed for each request by listing
-all the category values separated by commas (but with no spaces).
+all the category values separated by commas (but with no spaces). Also ranges
+can be included, for example "1,2,6-10,12". Colors for "<tt>null</tt>" and the
+"<tt>default</tt>" (i.e. out-of-range) color may also be reassigned.
 <P>
 
 

Modified: grass/branches/develbranch_6/ps/ps.map/r_instructions.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_instructions.c	2011-08-17 13:34:07 UTC (rev 47708)
+++ grass/branches/develbranch_6/ps/ps.map/r_instructions.c	2011-08-17 13:41:55 UTC (rev 47709)
@@ -3,7 +3,6 @@
 #include <grass/colors.h>
 #include <grass/imagery.h>
 #include <grass/glocale.h>
-
 #include "local_proto.h"
 
 #define KEY(x) (strcmp(key,x)==0)
@@ -60,11 +59,11 @@
 		fclose(inputfd);
 
 	    if (sscanf(data, "%s", name) != 1) {
-		error(key, data, "no file specified");
+		error(key, data, _("no file specified"));
 		inputfd = stdin;
 	    }
 	    else if ((inputfd = fopen(name, "r")) == NULL) {
-		error(key, data, "unable to open");
+		error(key, data, _("unable to open"));
 		inputfd = stdin;
 	    }
 	    else
@@ -95,7 +94,7 @@
 		}
 	    }
 	    else {
-		error(key, data, "illegal maploc request");
+		error(key, data, _("illegal maploc request"));
 		gobble_input();
 	    }
 	    continue;
@@ -109,36 +108,27 @@
 	    n = sscanf(data, "%d", &copies);
 	    if (n != 1 || copies < 1 || copies > 20) {
 		ps_copies = 1;
-		error(key, data, "illegal copies request");
+		error(key, data, _("illegal copies request"));
 	    }
 	    ps_copies = copies;
 	    continue;
 	}
 
 	if (KEY("setcolor")) {
-	    float R, G, B;
-	    int r, g, b;
-	    int color;
+	    int ret, r, g, b;
 	    int count;
 	    DCELL *val_list;
 	    DCELL dmin, dmax;
 	    char colorbuf[100];
 	    char catsbuf[100];
 
-	    if (PS->cell_fd < 0) {
-		error(key, data, "no raster map selected yet");
-		continue;
-	    }
+	    if (PS->cell_fd < 0)
+		error(key, data, _("no raster map selected yet"));
+
 	    if (sscanf(data, "%s %[^\n]", catsbuf, colorbuf) == 2) {
-		color = get_color_number(colorbuf);
-		if (color < 0) {
-		    error(key, data, "illegal color");
-		    continue;
-		}
-		get_color_rgb(color, &R, &G, &B);
-		r = 255.0 * R;
-		g = 255.0 * G;
-		b = 255.0 * B;
+		ret = G_str_to_color(colorbuf, &r, &g, &b);
+		if (ret != 1)
+		    error(key, colorbuf, _("illegal color request")); 
 
 		if (strncmp(catsbuf, "null", 4) == 0) {
 		    G_set_null_value_color(r, g, b, &(PS->colors));
@@ -148,15 +138,14 @@
 		    G_set_default_color(r, g, b, &(PS->colors));
 		    continue;
 		}
-		if ((count = parse_val_list(catsbuf, &val_list)) < 0) {
-		    error(key, data, "illegal value list");
-		    continue;
-		}
+		if ((count = parse_val_list(catsbuf, &val_list)) < 0)
+		    error(key, data, _("illegal value list"));
+
 		for (i = 0; i < count; i += 2) {
 		    dmin = val_list[i];
 		    dmax = val_list[i + 1];
-		    G_add_d_raster_color_rule(&dmin, r, g, b, &dmax, r, g, b,
-					      &(PS->colors));
+		    G_add_d_raster_color_rule(&dmin, r, g, b, &dmax,
+					      r, g, b, &(PS->colors));
 		}
 		G_free(val_list);
 	    }
@@ -186,7 +175,7 @@
 	if (KEY("scalebar")) {
 	    if (G_projection() == PROJECTION_LL) {
 		error(key, data,
-		      "scalebar is not appropriate for this projection");
+		      _("scalebar is not appropriate for this projection"));
 		gobble_input();
 	    }
 	    PS->do_scalebar = 1;
@@ -194,7 +183,7 @@
 		strcpy(sb->type, "f");	/* default to fancy scalebar */
 	    read_scalebar();
 	    if (sb->length <= 0.) {
-		error(key, data, "Bad scalebar length");
+		error(key, data, _("Bad scalebar length"));
 		gobble_input();
 	    }
 	    continue;
@@ -210,7 +199,7 @@
 		read_text(east, north, text);
 	    else {
 		gobble_input();
-		error(key, data, "illegal text request");
+		error(key, data, _("illegal text request"));
 	    }
 	    continue;
 	}
@@ -224,7 +213,7 @@
 		read_point(e, n);
 	    else {
 		gobble_input();
-		error(key, data, "illegal point request");
+		error(key, data, _("illegal point request"));
 	    }
 	    continue;
 	}
@@ -238,7 +227,7 @@
 		read_eps(e, n);
 	    else {
 		gobble_input();
-		error(key, data, "illegal eps request");
+		error(key, data, _("illegal eps request"));
 	    }
 	    continue;
 	}
@@ -255,7 +244,7 @@
 		read_line(e1, n1, e2, n2);
 	    else {
 		gobble_input();
-		error(key, data, "illegal line request");
+		error(key, data, _("illegal line request"));
 	    }
 	    continue;
 	}
@@ -272,7 +261,7 @@
 		read_rectangle(e1, n1, e2, n2);
 	    else {
 		gobble_input();
-		error(key, data, "illegal rectangle request");
+		error(key, data, _("illegal rectangle request"));
 	    }
 	    continue;
 	}
@@ -283,7 +272,7 @@
 		read_comment(name);
 		break;
 	    case 2:
-		error(key, data, "illegal comments request");
+		error(key, data, _("illegal comments request"));
 		break;
 	    default:
 		read_comment("");
@@ -299,7 +288,7 @@
 		strcpy(PS->scaletext, data);
 	    else {
 		PS->scaletext[0] = 0;
-		error(key, data, "illegal scale request");
+		error(key, data, _("illegal scale request"));
 	    }
 	    continue;
 	}
@@ -330,7 +319,7 @@
 
 	if (KEY("outline")) {
 	    if (PS->cell_fd < 0) {
-		error(key, data, "no raster map selected yet");
+		error(key, data, _("no raster map selected yet"));
 		gobble_input();
 	    }
 	    else
@@ -359,7 +348,7 @@
 		read_group();
 	    }
 	    else
-		error(key, data, "group not found");
+		error(key, data, _("group not found"));
 	    continue;
 	}
 
@@ -401,7 +390,7 @@
 	    sscanf(data, "%d", &(PS->grid));
 	    if (PS->grid < 0) {
 		PS->grid = 0;
-		error(key, data, "illegal grid spacing");
+		error(key, data, _("illegal grid spacing"));
 		gobble_input();
 	    }
 	    else
@@ -412,7 +401,7 @@
 	if (KEY("geogrid")) {
 	    if (G_projection() == PROJECTION_XY) {
 		error(key, data,
-		      "geogrid is not available for this projection");
+		      _("geogrid is not available for this projection"));
 		gobble_input();
 	    }
 	    /*          if (G_projection() == PROJECTION_LL)
@@ -422,7 +411,7 @@
 	    sscanf(data, "%d %s", &(PS->geogrid), PS->geogridunit);
 	    if (PS->geogrid < 0) {
 		PS->geogrid = 0;
-		error(key, data, "illegal geo-grid spacing");
+		error(key, data, _("illegal geo-grid spacing"));
 		gobble_input();
 	    }
 	    else
@@ -454,11 +443,11 @@
 		continue;
 	    }
 	    else {
-		error(key, data, "illegal color request");
+		error(key, data, _("illegal color request"));
 	    }
 	}
 
 	if (*key)
-	    error(key, "", "illegal request");
+	    error(key, "", _("illegal request"));
     }
 }



More information about the grass-commit mailing list