[GRASS-SVN] r39106 - grass/branches/develbranch_6/display/d.colortable

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 10 04:23:36 EDT 2009


Author: hamish
Date: 2009-09-10 04:23:35 -0400 (Thu, 10 Sep 2009)
New Revision: 39106

Modified:
   grass/branches/develbranch_6/display/d.colortable/main.c
Log:
add flag to skip showing NULL color for FP maps, ie fill the box

Modified: grass/branches/develbranch_6/display/d.colortable/main.c
===================================================================
--- grass/branches/develbranch_6/display/d.colortable/main.c	2009-09-10 08:10:32 UTC (rev 39105)
+++ grass/branches/develbranch_6/display/d.colortable/main.c	2009-09-10 08:23:35 UTC (rev 39106)
@@ -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