[GRASS-SVN] r47690 - grass/trunk/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 17 06:33:02 EDT 2011
Author: hamish
Date: 2011-08-17 03:33:02 -0700 (Wed, 17 Aug 2011)
New Revision: 47690
Modified:
grass/trunk/ps/ps.map/do_geogrid.c
grass/trunk/ps/ps.map/do_grid.c
grass/trunk/ps/ps.map/getgrid.c
grass/trunk/ps/ps.map/main.c
grass/trunk/ps/ps.map/ps_info.h
Log:
full RGB support for grid lines (#192, merge from devbr6)
Modified: grass/trunk/ps/ps.map/do_geogrid.c
===================================================================
--- grass/trunk/ps/ps.map/do_geogrid.c 2011-08-17 10:28:27 UTC (rev 47689)
+++ grass/trunk/ps/ps.map/do_geogrid.c 2011-08-17 10:33:02 UTC (rev 47690)
@@ -54,7 +54,7 @@
/* set color and set line width */
- set_rgb_color(PS.geogrid_color);
+ set_ps_color(&PS.geogrid_color);
set_line_width(PS.geogrid_width);
/* draw horizontal lines in 3 pieces -- lat-lon lines must not
@@ -166,7 +166,7 @@
/* initialize */
set_font_name(PS.geogrid_font);
set_font_size(PS.geogrid_fontsize);
- set_rgb_color(PS.geogrid_numbers_color);
+ set_ps_color(&PS.geogrid_numbers_color);
first = 1;
/* vertical grid numbers
@@ -204,7 +204,7 @@
text_box_path(x, y, RIGHT, CENTER, num_text, PS.geogrid_fontsize, 0);
set_rgb_color(WHITE);
fprintf(PS.fp, "F ");
- set_rgb_color(PS.geogrid_numbers_color);
+ set_ps_color(&PS.geogrid_numbers_color);
fprintf(PS.fp, "TIB\n");
last_bottom = y - PS.geogrid_fontsize;
if (first) {
@@ -248,7 +248,7 @@
fprintf(PS.fp, "%d bt bb sub D2 add mg sub neg TR TB\n", x);
set_rgb_color(WHITE);
fprintf(PS.fp, "F ");
- set_rgb_color(PS.geogrid_numbers_color);
+ set_ps_color(&PS.geogrid_numbers_color);
fprintf(PS.fp, "TIB\n");
last_right = x + PS.geogrid_fontsize;
}
Modified: grass/trunk/ps/ps.map/do_grid.c
===================================================================
--- grass/trunk/ps/ps.map/do_grid.c 2011-08-17 10:28:27 UTC (rev 47689)
+++ grass/trunk/ps/ps.map/do_grid.c 2011-08-17 10:33:02 UTC (rev 47690)
@@ -27,7 +27,7 @@
return 1;
/* set color and set line width to 1 */
- set_rgb_color(PS.grid_color);
+ set_ps_color(&PS.grid_color);
set_line_width(PS.grid_width);
/* draw horizontal lines in 3 pieces -- lat-lon lines must not
@@ -85,7 +85,7 @@
return 1;
/* set color and set line width to 1 */
- set_rgb_color(PS.grid_color);
+ set_ps_color(&PS.grid_color);
set_line_width(PS.grid_width);
g_north = floor(PS.w.north / PS.grid) * PS.grid;
@@ -139,7 +139,7 @@
/* initialize */
set_font_name(PS.grid_font);
set_font_size(PS.grid_fontsize);
- set_rgb_color(PS.grid_numbers_color);
+ set_ps_color(&PS.grid_numbers_color);
first = 1;
/* horizontal grid numbers
@@ -172,7 +172,7 @@
text_box_path(x, y, LEFT, CENTER, num_text, PS.grid_fontsize, 0);
set_rgb_color(WHITE);
fprintf(PS.fp, "F ");
- set_rgb_color(PS.grid_numbers_color);
+ set_ps_color(&PS.grid_numbers_color);
fprintf(PS.fp, "TIB\n");
last_bottom = y - PS.grid_fontsize;
if (first) {
@@ -211,7 +211,7 @@
fprintf(PS.fp, "%d bt bb sub D2 add mg sub neg TR TB\n", x);
set_rgb_color(WHITE);
fprintf(PS.fp, "F ");
- set_rgb_color(PS.grid_numbers_color);
+ set_ps_color(&PS.grid_numbers_color);
fprintf(PS.fp, "TIB\n");
last_right = x + PS.grid_fontsize;
}
Modified: grass/trunk/ps/ps.map/getgrid.c
===================================================================
--- grass/trunk/ps/ps.map/getgrid.c 2011-08-17 10:28:27 UTC (rev 47689)
+++ grass/trunk/ps/ps.map/getgrid.c 2011-08-17 10:33:02 UTC (rev 47690)
@@ -5,6 +5,9 @@
#include <stdlib.h>
#include <string.h>
+#include <grass/colors.h>
+#include <grass/glocale.h>
+#include "clr.h"
#include "local_proto.h"
#define KEY(x) (strcmp(x,key)==0)
@@ -29,28 +32,35 @@
int getgrid(void)
{
int spacing;
- int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
+ int fontsize = PS_FONT_DEFAULT_SIZE;
+ int ret, r, g, b;
char temp[30];
char buf[1024];
char ch, *key, *data;
+ PSCOLOR color, text_color;
PS.grid_font = G_store("Helvetica");
PS.grid_fontsize = 0;
- PS.grid_color = BLACK;
PS.grid_numbers = 0;
PS.grid_cross = 0.;
PS.grid_width = 0.25;
+ set_color(&color, 0, 0, 0);
+ set_color(&text_color, 0, 0, 0);
while (input(2, buf, help)) {
if (!key_data(buf, &key, &data))
continue;
if (KEY("color")) {
- color = get_color_number(data);
- if (color < 0)
- error(key, data, "illegal color request");
+ ret = G_str_to_color(data, &r, &g, &b);
+ if (ret == 1)
+ set_color(&color, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ /* unset_color(&color); */
+ error(key, data, _("Unsupported color request"));
else
- PS.grid_color = color;
+ error(key, data, _("illegal color request"));
+
continue;
}
@@ -59,24 +69,32 @@
if (strlen(data) == 0) {
spacing = 1;
- color = BLACK;
+ set_color(&text_color, 0, 0, 0);
}
switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
case 1:
- color = BLACK;
+ set_color(&text_color, 0, 0, 0);
break;
case 2:
- color = get_color_number(temp);
- if (color < 0)
+ ret = G_str_to_color(temp, &r, &g, &b);
+ if (ret == 1)
+ set_color(&text_color, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ error(key, data, _("Unsupported color request"));
+ else
+ error(key, data, _("illegal color request"));
+
+ if (ret < 1)
spacing = -1;
+
break;
}
if (spacing < 0)
- error(key, data, "illegal numbers request");
+ error(key, data, _("illegal numbers request"));
else {
PS.grid_numbers = spacing;
- PS.grid_numbers_color = color;
+ PS.grid_numbers_color = text_color;
}
continue;
}
@@ -104,16 +122,17 @@
if ((sscanf(data, "%lf%c", &PS.grid_width, &ch) < 1) ||
(PS.grid_width < 0.)) {
PS.grid_width = 1.;
- error(key, data, "illegal grid width request");
+ error(key, data, _("illegal grid width request"));
}
if (ch == 'i')
PS.grid_width = PS.grid_width / 72.0;
continue;
}
- error(key, data, "illegal request (getgrid)");
+ error(key, data, _("illegal request (grid)"));
}
PS.grid_fontsize = fontsize;
+ PS.grid_color = color;
return 0;
}
@@ -124,27 +143,34 @@
int getgeogrid(void)
{
int spacing;
- int color = 0, fontsize = PS_FONT_DEFAULT_SIZE;
+ int fontsize = PS_FONT_DEFAULT_SIZE;
+ int ret, r, g, b;
char temp[30];
char buf[1024];
char ch, *key, *data;
+ PSCOLOR color, text_color;
PS.geogrid_font = G_store("Helvetica");
PS.geogrid_fontsize = 0;
- PS.geogrid_color = BLACK;
PS.geogrid_numbers = 0;
PS.geogrid_width = 0.25;
+ set_color(&color, 0, 0, 0);
+ set_color(&text_color, 0, 0, 0);
while (input(2, buf, help2)) {
if (!key_data(buf, &key, &data))
continue;
if (KEY("color")) {
- color = get_color_number(data);
- if (color < 0)
- error(key, data, "illegal color request");
+ ret = G_str_to_color(data, &r, &g, &b);
+ if (ret == 1)
+ set_color(&color, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ /* unset_color(&color); */
+ error(key, data, _("Unsupported color request"));
else
- PS.geogrid_color = color;
+ error(key, data, _("illegal color request"));
+
continue;
}
@@ -153,25 +179,33 @@
if (strlen(data) == 0) {
spacing = 1;
- color = BLACK;
+ set_color(&text_color, 0, 0, 0);
}
switch (sscanf(data, "%d %[^\n]", &spacing, temp)) {
case 1:
- color = BLACK;
+ set_color(&text_color, 0, 0, 0);
break;
case 2:
- color = get_color_number(temp);
- if (color < 0)
+ ret = G_str_to_color(temp, &r, &g, &b);
+ if (ret == 1)
+ set_color(&text_color, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ error(key, data, _("Unsupported color request"));
+ else
+ error(key, data, _("illegal color request"));
+
+ if (ret < 1)
spacing = -1;
+
break;
}
if (spacing < 0)
- error(key, data, "illegal numbers request");
+ error(key, data, _("illegal numbers request"));
else {
PS.geogrid_numbers = spacing;
- PS.geogrid_numbers_color = color;
+ PS.geogrid_numbers_color = text_color;
}
continue;
@@ -196,16 +230,17 @@
if ((sscanf(data, "%lf%c", &PS.geogrid_width, &ch) < 1) ||
(PS.geogrid_width < 0.)) {
PS.geogrid_width = 1.;
- error(key, data, "illegal grid width request");
+ error(key, data, _("illegal grid width request"));
}
if (ch == 'i')
PS.geogrid_width = PS.geogrid_width / 72.0;
continue;
}
- error(key, data, "illegal request (getgrid)");
+ error(key, data, _("illegal request (geogrid)"));
}
PS.geogrid_fontsize = fontsize;
+ PS.geogrid_color = color;
return 0;
}
Modified: grass/trunk/ps/ps.map/main.c
===================================================================
--- grass/trunk/ps/ps.map/main.c 2011-08-17 10:28:27 UTC (rev 47689)
+++ grass/trunk/ps/ps.map/main.c 2011-08-17 10:33:02 UTC (rev 47690)
@@ -188,8 +188,7 @@
grp.do_group = 0;
brd.R = brd.G = brd.B = 0.;
brd.width = 1.;
-
- PS.grid_color = BLACK;
+
PS.min_y = 72.0 * (PS.page_height - PS.top_marg);
PS.set_y = 100.0 * PS.min_y;
PS.cell_fd = -1;
Modified: grass/trunk/ps/ps.map/ps_info.h
===================================================================
--- grass/trunk/ps/ps.map/ps_info.h 2011-08-17 10:28:27 UTC (rev 47689)
+++ grass/trunk/ps/ps.map/ps_info.h 2011-08-17 10:33:02 UTC (rev 47690)
@@ -1,4 +1,5 @@
#include <grass/raster.h>
+#include "clr.h"
/* Font sizes */
#define PS_FONT_MAX_SIZE 50
@@ -42,11 +43,12 @@
int do_border;
int do_scalebar;
int num_psfiles;
- int grid, grid_color, grid_numbers, grid_numbers_color, grid_fontsize;
+ int grid, grid_numbers, grid_fontsize;
+ PSCOLOR grid_color, grid_numbers_color;
float grid_cross;
char geogridunit[64];
- int geogrid, geogrid_color, geogrid_numbers;
- int geogrid_numbers_color, geogrid_fontsize;
+ int geogrid, geogrid_numbers, geogrid_fontsize;
+ PSCOLOR geogrid_color, geogrid_numbers_color;
double grid_width, geogrid_width;
int do_outline, outline_color;
int cell_fd;
More information about the grass-commit
mailing list