[GRASS-SVN] r55728 - grass/branches/releasebranch_6_4/display/d.colortable

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 13 02:58:33 PDT 2013


Author: hamish
Date: 2013-04-13 02:58:32 -0700 (Sat, 13 Apr 2013)
New Revision: 55728

Modified:
   grass/branches/releasebranch_6_4/display/d.colortable/main.c
Log:
add flag to skip showing NULL color for FP maps, ie fill the box (merge r39106 from devbr6)

Modified: grass/branches/releasebranch_6_4/display/d.colortable/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.colortable/main.c	2013-04-13 09:50:36 UTC (rev 55727)
+++ grass/branches/releasebranch_6_4/display/d.colortable/main.c	2013-04-13 09:58:32 UTC (rev 55728)
@@ -46,12 +46,14 @@
     int atcat;
     int white, black;
     int atcol, atline;
-    int count;
+    int count, offset;
     int t, b, l, r;
     int fp, new_colr;
     int x_box[5], y_box[5];
+
     struct GModule *module;
     struct Option *opt1, *opt2, *opt3, *opt4;
+    struct Flag *skip_null;
 
     /* Initialize the GIS calls */
     G_gisinit(argv[0]);
@@ -85,6 +87,11 @@
     opt4->options = "1-1000";
     opt4->description = _("Number of columns to appear in the color table");
 
+    skip_null = G_define_flag();
+    skip_null->key = 'n';
+    skip_null->description =
+	_("Don't draw a collar showing the NULL color in FP maps");
+
     /* Check command line */
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -255,14 +262,21 @@
 	x_box[2] = (dots_per_col - 6);
 	x_box[4] = (6 - dots_per_col);
 
-	G_debug(1, "dots_per_line: %d", dots_per_line);
+	G_debug(1, "dots_per_line: %d  dmin=%.2f dmax=%.2f",
+		dots_per_line, dmin, dmax);
 
+	if (skip_null->answer)
+	    offset = 1;
+	else
+	    offset = 4;
+
 	for (r = 0; r < dots_per_line - 6; r++) {
-	    if (r <= 4)
+	    if ((r <= 4) && !skip_null->answer)
 		G_set_d_null_value(&dval, 1);
 	    else
 		dval =
-		    dmin + (r - 1) * (dmax - dmin) / (dots_per_line - 6 - 5);
+		    dmin +  r*(dmax - dmin) / (dots_per_line - 6 - offset);
+
 	    D_d_color(dval, &colors);
 	    R_move_abs(cur_dot_col + 3, (cur_dot_row - 3) - r);
 	    R_polygon_rel(x_box, y_box, 5);



More information about the grass-commit mailing list