[GRASS-SVN] r39098 -
grass/branches/releasebranch_6_4/display/d.colortable
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Sep 10 02:20:12 EDT 2009
Author: hamish
Date: 2009-09-10 02:20:11 -0400 (Thu, 10 Sep 2009)
New Revision: 39098
Modified:
grass/branches/releasebranch_6_4/display/d.colortable/description.html
grass/branches/releasebranch_6_4/display/d.colortable/main.c
Log:
cleanup, fix box rendering, i18n, html bugs and modernization (merge from devbr6)
Modified: grass/branches/releasebranch_6_4/display/d.colortable/description.html
===================================================================
--- grass/branches/releasebranch_6_4/display/d.colortable/description.html 2009-09-10 06:10:04 UTC (rev 39097)
+++ grass/branches/releasebranch_6_4/display/d.colortable/description.html 2009-09-10 06:20:11 UTC (rev 39098)
@@ -1,89 +1,52 @@
<H2>DESCRIPTION</H2>
-
The GRASS program <EM>d.colortable</EM>
is used to display the color table associated with a raster map layer in the
-active frame on the graphics monitor. The map <EM>name</EM> should be
+active frame on the graphics monitor. The <EM>map</EM> name should be
an available raster map layer in the user's current mapset search path
and location.
<P>
-
-<H3>Parameters:</H3>
-
-<DL>
-<DT><B>map=</B><EM>name</EM>
-<DD>Name of a raster map layer in the user's current mapset search path
-whose color table is to be displayed.
-<DT><B>color=</B><EM>name</EM>
-<DD>Color of the lines separating the colors of the color table.
-<BR>
-Options: red, orange, yellow, green, blue,
-indigo, violet, gray, white</B>, and black.
-<BR>
-Default: <EM>white</EM>
-<DT><B>lines=</B><EM>value</EM>
-<DD>Number of lines to appear in the color table.
-<BR>
-Options: 1 - 1000
-<DT><B>cols=</B><EM>value</EM>
-<DD>Number of columns to appear in the color table.
-<BR>
-Options: 1 - 1000
-
-If the <EM>value</B>s</EM> of both <EM>lines</EM> and <EM>cols</EM> are not specified by
-the user, <EM>d.colortable</EM>
+If the values of both <EM>lines</EM> and <EM>cols</EM> are
+not specified by the user, <EM>d.colortable</EM>
divides the active frame equally among the number of categories
present in the named raster map layer. If one option is specified,
the other is automatically set to accommodate all categories.
If both are specified, as many categories as possible are displayed.
-</DL>
<P>
-The user can specify all needed parameters on the command line using the
-form:
-
-<P>
-<DL>
-<DD>
-<B>d.colortable map=</B><EM>name</EM>
-[<B>color=</B><EM>name</EM>]
-[<B>lines=</B><EM>value</EM>]
-[<B>cols=</B><EM>value</EM>]
-</DL>
-
-<P>
If the user specifies the name of a map on the command line but does not
specify the values of other parameters, parameter default values will be used.
-Alternately, if the user types simply <B>d.colortable</B> on the command line
+Alternately, if the user types simply <em>d.colortable</em> on the command line
without any program arguments, the program will prompt the user for parameter
-settings using the standard GRASS <A HREF="parser.html">parser</A> interface described in the manual
-entry for <EM><A HREF="parser.html">parser</A></B>.</EM>
+settings using the standard GRASS parser interface.
+
<H2>EXAMPLE</H2>
The user running the command:
<DL>
<DD>
<B>d.colortable map=</B><EM>soils</EM>
-[<B>color=</B><EM>red</EM>]
-[<B>lines=</B><EM>1</EM>]
-[<B>cols=</B><EM>3</EM>]
+ <B>color=</B><EM>red</EM>
+ <B>lines=</B><EM>1</EM>
+ <B>cols=</B><EM>3</EM>
</DL>
would see the active graphics frame divided into three columns
extending the full frame height. The lines dividing the color table
associated with the <EM>soils</EM> map would be displayed in red.
The user would see, at most, only three of the colors from the <EM>soils</EM>
color table displayed in the active frame (because the user requested
-that this frame be divided into three sections).
+that this frame be divided into three sections).
+
<H2>NOTES</H2>
If the user wishes to display the entire color table associated with
a map, the user should either stipulate a number of lines (rows) and
columns (cols) sufficient to accommodate the number of categories
in the map's color table, or fail to assign values to one or both of
-<EM>lines</EM> and/or <EM>cols</B>.</EM>
+<EM>lines</EM> and/or <EM>cols</EM>.
If the user runs <EM>d.colortable</EM> using the default number of
lines and columns (the full graphics frame), all categories from the
map's color table will be displayed. However, if the user requests
@@ -97,15 +60,20 @@
<EM><A HREF="d.erase.html">d.erase</A></EM> between
runs of <EM>d.colortable</EM> to avoid confusion.
+
<H2>SEE ALSO</H2>
-<EM><A HREF="d.colors.html">d.colors</A></EM><br>
-<EM><A HREF="d.erase.html">d.erase</A></EM><br>
-<EM><A HREF="d.rast.html">d.rast</A></EM><br>
-<EM><A HREF="parser.html">parser</A></EM>
+<EM>
+<A HREF="d.colors.html">d.colors</A><br>
+<A HREF="d.erase.html">d.erase</A><br>
+<A HREF="d.legend.html">d.legend</A><br>
+<A HREF="d.rast.html">d.rast</A><br>
+</EM>
+
<H2>AUTHOR</H2>
James Westervelt, U.S. Army Construction Engineering Research Laboratory
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/branches/releasebranch_6_4/display/d.colortable/main.c
===================================================================
--- grass/branches/releasebranch_6_4/display/d.colortable/main.c 2009-09-10 06:10:04 UTC (rev 39097)
+++ grass/branches/releasebranch_6_4/display/d.colortable/main.c 2009-09-10 06:20:11 UTC (rev 39098)
@@ -7,11 +7,11 @@
* Bernhard Reiter <bernhard intevation.de>,
* Eric G. Miller <egm2 jps.net>,
* Glynn Clements <glynn gclements.plus.com>,
- * Hamish Bowman <hamish_nospam yahoo.com>,
+ * Hamish Bowman <hamish_b yahoo.com>,
* Jan-Oliver Wagner <jan intevation.de>
* PURPOSE: display the color table associated with a raster map layer in
* the active frame on the graphics monitor
- * COPYRIGHT: (C) 1999-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2009 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
@@ -34,7 +34,6 @@
int lines;
int cols;
- char buff[256];
char window_name[64];
char *mapset;
struct FPRange fp_range;
@@ -42,20 +41,15 @@
double ratio;
DCELL dmin, dmax, dval;
int cats_num;
- int cur_dot_row;
- int cur_dot_col;
- int dots_per_line;
- int dots_per_col;
+ int cur_dot_row, cur_dot_col;
+ int dots_per_line, dots_per_col;
int atcat;
- int white;
- int black;
- int atcol;
- int atline;
+ int white, black;
+ int atcol, atline;
int count;
int t, b, l, r;
int fp, new_colr;
- int x_box[5];
- int y_box[5];
+ int x_box[5], y_box[5];
struct GModule *module;
struct Option *opt1, *opt2, *opt3, *opt4;
@@ -63,36 +57,33 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("display, setup");
+ module->keywords = _("display, raster");
module->description =
_("Displays the color table associated with a raster map layer.");
- opt1 = G_define_option();
- opt1->key = "map";
- opt1->type = TYPE_STRING;
- opt1->required = YES;
- opt1->gisprompt = "old,cell,raster";
- opt1->description = "Name of existing raster map";
+ opt1 = G_define_standard_option(G_OPT_R_MAP);
+ opt1->description =
+ _("Name of raster map whose color table is to be displayed");
opt2 = G_define_option();
opt2->key = "color";
opt2->type = TYPE_STRING;
- opt2->answer = DEFAULT_FG_COLOR;
+ opt2->answer = DEFAULT_BG_COLOR;
opt2->options = D_color_list();
opt2->description =
- "Color of lines separating the colors of the color table";
+ _("Color of lines separating the colors of the color table");
opt3 = G_define_option();
opt3->key = "lines";
opt3->type = TYPE_INTEGER;
opt3->options = "1-1000";
- opt3->description = "Number of lines";
+ opt3->description = _("Number of lines to appear in the color table");
opt4 = G_define_option();
opt4->key = "cols";
opt4->type = TYPE_INTEGER;
opt4->options = "1-1000";
- opt4->description = "Number of columns";
+ opt4->description = _("Number of columns to appear in the color table");
/* Check command line */
if (G_parser(argc, argv))
@@ -102,6 +93,7 @@
mapset = G_find_cell2(map_name, "");
if (mapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), map_name);
+
fp = G_raster_map_is_fp(map_name, mapset);
if (opt2->answer != NULL) {
@@ -113,13 +105,12 @@
lines = 1;
else
lines = 0;
+
if (opt3->answer != NULL) {
- if (fp) {
- sprintf(buff,
- "%s is fp map. Ignoring lines and drawing continuous color ramp",
- map_name);
- G_warning(buff);
- }
+ if (fp)
+ G_warning(_("<%s> is a floating point map. "
+ "Ignoring [lines] and drawing continuous color ramp"),
+ map_name);
else
sscanf(opt3->answer, "%d", &lines);
}
@@ -128,37 +119,37 @@
cols = 1;
else
cols = 0;
+
if (opt4->answer != NULL) {
- if (fp) {
- sprintf(buff,
- "%s is fp map. Ignoring cols and drawing continuous color ramp",
- map_name);
- G_warning(buff);
- }
+ if (fp)
+ G_warning(_("<%s> is a floating point map. "
+ "Ignoring [cols] and drawing continuous color ramp"),
+ map_name);
else
sscanf(opt4->answer, "%d", &cols);
}
/* Make sure map is available */
if (G_read_colors(map_name, mapset, &colors) == -1)
- G_fatal_error("R_color file for [%s] not available", map_name);
+ G_fatal_error(_("R_color file for [%s] not available"), map_name);
if (G_read_fp_range(map_name, mapset, &fp_range) == -1)
- G_fatal_error("Range file for [%s] not available", map_name);
+ G_fatal_error(_("Range file for [%s] not available"), map_name);
if (R_open_driver() != 0)
- G_fatal_error("No graphics device selected");
-
+ G_fatal_error(_("No graphics device selected"));
if (D_get_cur_wind(window_name))
- G_fatal_error("No current frame");
+ G_fatal_error(_("No current frame"));
if (D_set_cur_wind(window_name))
- G_fatal_error("Current frame not available");
+ G_fatal_error(_("Current frame not available"));
/* Figure out where to put boxes */
D_get_screen_window(&t, &b, &l, &r);
G_get_fp_range_min_max(&fp_range, &dmin, &dmax);
if (G_is_d_null_value(&dmin) || G_is_d_null_value(&dmax))
- G_fatal_error("Data range is empty");
+ G_fatal_error(_("Data range is empty"));
+
cats_num = (int)dmax - (int)dmin + 1;
+
if (lines <= 0 && cols <= 0) {
double dx, dy;
@@ -185,17 +176,18 @@
x_box[0] = 0;
y_box[0] = 0;
x_box[1] = 0;
- y_box[1] = (6 - dots_per_line);
- x_box[2] = (dots_per_col - 6);
+ y_box[1] = (5 - dots_per_line);
+ x_box[2] = (dots_per_col - 5);
y_box[2] = 0;
x_box[3] = 0;
- y_box[3] = (dots_per_line - 6);
- x_box[4] = (6 - dots_per_col);
+ y_box[3] = (dots_per_line - 5);
+ x_box[4] = (5 - dots_per_col);
y_box[4] = 0;
white = D_translate_color("white");
black = D_translate_color("black");
G_set_c_null_value(&atcat, 1);
+
if (!fp) {
for (atcol = 0; atcol < cols; atcol++) {
cur_dot_row = t;
@@ -203,7 +195,7 @@
count = 0;
for (atline = 0; atline < lines; atline++) {
cur_dot_row += dots_per_line;
- /* Draw white box */
+ /* Draw outer border box */
R_standard_color(color);
R_move_abs(cur_dot_col + 2, (cur_dot_row - 1));
R_cont_rel(0, (2 - dots_per_line));
@@ -219,7 +211,7 @@
R_cont_rel((4 - dots_per_col), 0);
/* Color box */
D_color((CELL) atcat, &colors);
- R_move_abs(cur_dot_col + 4, (cur_dot_row - 3));
+ R_move_abs(cur_dot_col + 4, (cur_dot_row - 2));
R_polygon_rel(x_box, y_box, 5);
count++;
@@ -231,33 +223,40 @@
}
if (atcat > (int)dmax)
break;
- } /* col loop */
- } /* int map */
- else { /* draw continuous color ramp for fp map */
+ } /* col loop */
+ } /* int map */
+ else {
+ /*** draw continuous color ramp for fp map ***/
+
cur_dot_row = t + dots_per_line;
cur_dot_col = l;
- /* Draw white box */
+
+ /* Draw outer border box */
R_standard_color(color);
- R_move_abs(cur_dot_col + 2, (cur_dot_row - 1));
- R_cont_rel(0, (2 - dots_per_line));
- R_cont_rel((dots_per_col - 2), 0);
- R_cont_rel(0, (dots_per_line - 2));
- R_cont_rel((2 - dots_per_col), 0);
+ R_move_abs(cur_dot_col + 1, (cur_dot_row - 3));
+ R_cont_rel(0, (4 - dots_per_line));
+ R_cont_rel((dots_per_col - 3), 0);
+ R_cont_rel(0, (dots_per_line - 3));
+ R_cont_rel((3 - dots_per_col), 0);
/* Draw black box */
R_standard_color(black);
- R_move_abs(cur_dot_col + 3, (cur_dot_row - 2));
- R_cont_rel(0, (4 - dots_per_line));
- R_cont_rel((dots_per_col - 4), 0);
- R_cont_rel(0, (dots_per_line - 4));
- R_cont_rel((4 - dots_per_col), 0);
- /* Color ramp box */
+ R_move_abs(cur_dot_col + 2, (cur_dot_row - 3));
+ R_cont_rel(0, (5 - dots_per_line));
+ R_cont_rel((dots_per_col - 5), 0);
+ R_cont_rel(0, (dots_per_line - 5));
+ R_cont_rel((5 - dots_per_col), 0);
- /* get separate color for each pixel */
- /* fisrt 5 pixels draw null color */
+ /* Color ramp box */
+ /* get separate color for each pixel */
+ /* fisrt 5 pixels draw null color */
y_box[1] = -1;
y_box[3] = 1;
- fprintf(stdout, "dots_per_line: %d\n", dots_per_line);
+ x_box[2] = (dots_per_col - 6);
+ x_box[4] = (6 - dots_per_col);
+
+ G_debug(1, "dots_per_line: %d", dots_per_line);
+
for (r = 0; r < dots_per_line - 6; r++) {
if (r <= 4)
G_set_d_null_value(&dval, 1);
@@ -265,7 +264,7 @@
dval =
dmin + (r - 1) * (dmax - dmin) / (dots_per_line - 6 - 5);
D_d_color(dval, &colors);
- R_move_abs(cur_dot_col + 4, (cur_dot_row - 3) - r);
+ R_move_abs(cur_dot_col + 3, (cur_dot_row - 3) - r);
R_polygon_rel(x_box, y_box, 5);
}
}
@@ -274,5 +273,5 @@
R_close_driver();
- return 0;
+ exit(EXIT_SUCCESS);
}
More information about the grass-commit
mailing list