[GRASS-SVN] r46382 - grass/branches/releasebranch_6_4/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 23 06:56:13 EDT 2011
Author: hamish
Date: 2011-05-23 03:56:13 -0700 (Mon, 23 May 2011)
New Revision: 46382
Modified:
grass/branches/releasebranch_6_4/ps/ps.map/main.c
grass/branches/releasebranch_6_4/ps/ps.map/map_info.c
grass/branches/releasebranch_6_4/ps/ps.map/map_info.h
grass/branches/releasebranch_6_4/ps/ps.map/ps_vlegend.c
grass/branches/releasebranch_6_4/ps/ps.map/r_info.c
grass/branches/releasebranch_6_4/ps/ps.map/r_vlegend.c
grass/branches/releasebranch_6_4/ps/ps.map/vector.h
Log:
RGB color support for mapinfo and vlegend instructions (#192; backport from 6.5svn)
Modified: grass/branches/releasebranch_6_4/ps/ps.map/main.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/main.c 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/main.c 2011-05-23 10:56:13 UTC (rev 46382)
@@ -179,8 +179,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;
PS.grid_color = BLACK;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/map_info.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/map_info.c 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/map_info.c 2011-05-23 10:56:13 UTC (rev 46382)
@@ -61,14 +61,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");
@@ -76,7 +76,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/releasebranch_6_4/ps/ps.map/map_info.h
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/map_info.h 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/map_info.h 2011-05-23 10:56:13 UTC (rev 46382)
@@ -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/releasebranch_6_4/ps/ps.map/ps_vlegend.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/ps_vlegend.c 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/ps_vlegend.c 2011-05-23 10:56:13 UTC (rev 46382)
@@ -151,8 +151,8 @@
/* } */
/* draw the border, if set */
- if (vector.border != -1) {
- set_rgb_color(vector.border);
+ if (! color_none(&vector.border)) {
+ set_ps_color(&vector.border);
fprintf(PS.fp, "%.1f %.1f w %.1f B\n",
x - margin, y - lc * dy - margin, y);
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_info.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_info.c 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_info.c 2011-05-23 10:56:13 UTC (rev 46382)
@@ -5,8 +5,10 @@
#include <stdlib.h>
#include <string.h>
+#include <grass/glocale.h>
#include "map_info.h"
#include "ps_info.h"
+#include "clr.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
@@ -25,13 +27,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)) {
@@ -41,7 +45,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;
@@ -55,30 +59,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;
}
@@ -87,7 +100,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;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_vlegend.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_vlegend.c 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_vlegend.c 2011-05-23 10:56:13 UTC (rev 46382)
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <string.h>
+#include <grass/glocale.h>
#include "vector.h"
#include "ps_info.h"
#include "local_proto.h"
@@ -26,14 +27,16 @@
{
char buf[1024];
char *key, *data;
- int fontsize, cols, border;
+ int fontsize, cols;
double x, y, width, cseparation;
+ int r, g, b, ret;
+ PSCOLOR border;
fontsize = 0;
x = y = 0.0;
width = -1;
cols = 1;
- border = -1;
+ unset_color(&border);
cseparation = -1;
while (input(2, buf, help)) {
@@ -43,7 +46,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;
@@ -74,12 +77,14 @@
}
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;
}
@@ -89,7 +94,7 @@
continue;
}
- error(key, data, "illegal vlegend sub-request");
+ error(key, data, _("illegal vlegend sub-request"));
}
vector.x = x;
vector.y = y;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/vector.h
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/vector.h 2011-05-23 10:13:13 UTC (rev 46381)
+++ grass/branches/releasebranch_6_4/ps/ps.map/vector.h 2011-05-23 10:56:13 UTC (rev 46382)
@@ -103,7 +103,7 @@
char *font; /* legend font */
double width; /* width of legend symbols */
int cols; /* number of colums */
- int border; /* border color number or -1 for none */
+ PSCOLOR border; /* border color */
double span; /* column separation in inches */
LAYER *layer;
};
More information about the grass-commit
mailing list