[GRASS-SVN] r45774 - grass/branches/develbranch_6/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Mar 26 22:06:37 EDT 2011
Author: hamish
Date: 2011-03-26 19:06:36 -0700 (Sat, 26 Mar 2011)
New Revision: 45774
Modified:
grass/branches/develbranch_6/ps/ps.map/main.c
grass/branches/develbranch_6/ps/ps.map/map_info.c
grass/branches/develbranch_6/ps/ps.map/map_info.h
grass/branches/develbranch_6/ps/ps.map/r_info.c
Log:
RGB color support for mapinfo instruction (#192)
Modified: grass/branches/develbranch_6/ps/ps.map/main.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/main.c 2011-03-26 22:12:30 UTC (rev 45773)
+++ grass/branches/develbranch_6/ps/ps.map/main.c 2011-03-27 02:06:36 UTC (rev 45774)
@@ -160,8 +160,6 @@
vector.x = vector.y = -1.0;
ct.x = ct.y = -1.0;
ct.width = -1.0;
- m_info.color = BLACK;
- m_info.bgcolor = WHITE;
hdr.color = BLACK;
cmt.color = BLACK;
m_info.font = G_store(def_font);
Modified: grass/branches/develbranch_6/ps/ps.map/map_info.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/map_info.c 2011-03-26 22:12:30 UTC (rev 45773)
+++ grass/branches/develbranch_6/ps/ps.map/map_info.c 2011-03-27 02:06:36 UTC (rev 45774)
@@ -60,14 +60,14 @@
fprintf(PS.fp, "/t1 t1 sx mg add add def\n");
/* draw the background box */
- if (m_info.bgcolor != -999) { /* skip if "none" */
- set_rgb_color(m_info.bgcolor);
+ if (! color_none(&m_info.bgcolor)) {
+ set_ps_color(&m_info.bgcolor);
fprintf(PS.fp, "%.1f %.1f t1 %.1f B fill \n",
x - margin, y - k * dy - margin, y);
}
/* draw the border, if set */
- if (m_info.border != -1) {
- set_rgb_color(m_info.border);
+ if (! color_none(&m_info.border)) {
+ set_ps_color(&m_info.border);
fprintf(PS.fp, "%.1f %.1f t1 %.1f B\n",
x - margin, y - k * dy - margin, y);
fprintf(PS.fp, "D\n");
@@ -75,7 +75,7 @@
}
/* set text color */
- set_rgb_color(m_info.color);
+ set_ps_color(&m_info.color);
/* show map scale */
show_text(x, y - dy, "SCALE:");
Modified: grass/branches/develbranch_6/ps/ps.map/map_info.h
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/map_info.h 2011-03-26 22:12:30 UTC (rev 45773)
+++ grass/branches/develbranch_6/ps/ps.map/map_info.h 2011-03-27 02:06:36 UTC (rev 45774)
@@ -3,12 +3,14 @@
** Author: Paul W. Carlson April 1992
*/
+#include "clr.h"
+
struct map_info
{
double x, y;
char *font;
int fontsize;
- int color, bgcolor, border;
+ PSCOLOR color, bgcolor, border;
};
#ifdef MAIN
Modified: grass/branches/develbranch_6/ps/ps.map/r_info.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_info.c 2011-03-26 22:12:30 UTC (rev 45773)
+++ grass/branches/develbranch_6/ps/ps.map/r_info.c 2011-03-27 02:06:36 UTC (rev 45774)
@@ -5,7 +5,9 @@
#include <stdlib.h>
#include <string.h>
+#include <grass/glocale.h>
#include "map_info.h"
+#include "clr.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
@@ -24,13 +26,15 @@
{
char buf[1024];
char *key, *data;
- int color, bgcolor, border, fontsize;
+ int fontsize;
double x, y;
+ int r, g, b, ret;
+ PSCOLOR color, bgcolor, border;
fontsize = 0;
- color = BLACK;
- bgcolor = WHITE;
- border = -1;
+ set_color(&color, 0, 0, 0);
+ set_color(&bgcolor, 255, 255, 255);
+ unset_color(&border);
x = y = 0.0;
while (input(2, buf, help)) {
@@ -40,7 +44,7 @@
if (KEY("where")) {
if (sscanf(data, "%lf %lf", &x, &y) != 2) {
x = y = 0.0;
- error(key, data, "illegal where request");
+ error(key, data, _("illegal where request"));
}
else
continue;
@@ -54,30 +58,39 @@
}
if (KEY("color")) {
- color = get_color_number(data);
- if (color < 0) {
- color = BLACK;
- 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
+ error(key, data, _("illegal color request"));
+
continue;
}
if (KEY("background")) {
- bgcolor = get_color_number(data);
- if ((bgcolor != -999) && (bgcolor < 0)) { /* -999 is "none" */
- bgcolor = WHITE;
- error(key, data, "illegal color request");
- }
+ ret = G_str_to_color(data, &r, &g, &b);
+ if (ret == 1)
+ set_color(&bgcolor, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ unset_color(&bgcolor);
+ else
+ error(key, data, _("illegal bgcolor request"));
+
continue;
}
if (KEY("border")) {
- border = get_color_number(data);
- if (border < 0) {
- if (border != -999) /* here -999 is "none" */
- error(key, data, "illegal border request");
- border = -1;
- }
+ ret = G_str_to_color(data, &r, &g, &b);
+ if (ret == 1)
+ set_color(&border, r, g, b);
+ else if (ret == 2) /* i.e. "none" */
+ unset_color(&border);
+ else
+ error(key, data, _("illegal border color request"));
+
continue;
}
@@ -86,7 +99,7 @@
m_info.font = G_store(data);
continue;
}
- error(key, data, "illegal mapinfo sub-request");
+ error(key, data, _("illegal mapinfo sub-request"));
}
m_info.x = x;
m_info.y = y;
More information about the grass-commit
mailing list