[GRASS-SVN] r46383 - grass/branches/releasebranch_6_4/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 23 07:30:47 EDT 2011
Author: hamish
Date: 2011-05-23 04:30:47 -0700 (Mon, 23 May 2011)
New Revision: 46383
Modified:
grass/branches/releasebranch_6_4/ps/ps.map/colortable.h
grass/branches/releasebranch_6_4/ps/ps.map/ps_clrtbl.c
grass/branches/releasebranch_6_4/ps/ps.map/ps_fclrtbl.c
grass/branches/releasebranch_6_4/ps/ps.map/r_colortable.c
Log:
bugfix for number of columns hangover;
RGB color for colortables
(merge from devbr6 r45314-8)
Modified: grass/branches/releasebranch_6_4/ps/ps.map/colortable.h
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/colortable.h 2011-05-23 10:56:13 UTC (rev 46382)
+++ grass/branches/releasebranch_6_4/ps/ps.map/colortable.h 2011-05-23 11:30:47 UTC (rev 46383)
@@ -4,6 +4,7 @@
*/
#include <stdio.h>
+#include "clr.h"
struct colortable
{
@@ -14,7 +15,7 @@
char *name;
char *mapset;
int fontsize;
- int color;
+ PSCOLOR color;
int cols;
int nodata;
int tickbar;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/ps_clrtbl.c 2011-05-23 10:56:13 UTC (rev 46382)
+++ grass/branches/releasebranch_6_4/ps/ps.map/ps_clrtbl.c 2011-05-23 11:30:47 UTC (rev 46383)
@@ -4,13 +4,17 @@
*/
#include <grass/glocale.h>
-
#include "ps_info.h"
#include "colortable.h"
+#include "local_proto.h"
-#define NSTEPS 5 /* number of steps to divide color box when showing color for
- category data range */
+#define NSTEPS 5 /* number of steps to divide color box when
+ showing color for category data range */
+#define FONTFIT_FACT 4.0 /* how agressive to be with shrinking the font size
+ to get it to fit in the column (normal range: 2-4) */
+#define PRETEXT_MULT 2.0 /* space between box and text (this*fontsize) */
+
int PS_colortable(void)
{
char *label;
@@ -79,8 +83,8 @@
r = l + 72.0 * ct.width;
col_width = ct.width / (double)ct.cols;
- G_debug(3, "clrtbl: adjusted ct.x=[%.3f] ct.y=[%.3f] ct.width=[%.3f]",
- ct.x, ct.y, ct.width);
+ G_debug(3, "clrtbl: adjusted ct.x=[%.3f] ct.y=[%.3f] ct.width=[%.3f] "
+ "col_width=[%.3f]", ct.x, ct.y, ct.width, col_width);
/* read cats into PostScript array "a" */
fprintf(PS.fp, "/a [\n");
@@ -106,7 +110,8 @@
if (ct.cols == 1)
tl = 72.0 * col_width - 2.0 * fontsize;
else
- tl = 72.0 * col_width - 4.0 * fontsize;
+ tl = 72.0 * col_width - FONTFIT_FACT * fontsize;
+ G_debug(5, "clrtbl: fontsize=%.1f adjusted tl=%.1f", fontsize, tl);
fprintf(PS.fp, "/s %.1f def\n", fontsize);
fprintf(PS.fp, "mw %.1f gt {/s s %.1f mul mw div def } if\n", tl, tl);
fprintf(PS.fp, "(%s) FN s SF\n", ct.font);
@@ -127,7 +132,7 @@
k = 0;
for (i = 0; i <= num_cats;) {
if (!i && !ct.nodata)
- i++; /* step over 'no data' */
+ i++; /* step over 'no data' */
/* test for bottom of page */
y -= dy;
@@ -190,10 +195,14 @@
if (center_cols)
fprintf(PS.fp, "mvx ");
fprintf(PS.fp, "%.1f ", y + fontsize);
- fprintf(PS.fp, "B F BW stroke\n");
+/* no border fprintf(PS.fp, "B CF stroke\n"); */
+/* grey border fprintf(PS.fp, "B F .247 .247 .247 C 1 W stroke\n"); */
+ fprintf(PS.fp, "B F ");
+ set_ps_color(&ct.color);
+ fprintf(PS.fp, "1 W stroke\n");
}
else
- /* split the rectangle into NSTEPS horisontal strips and
+ /* split the rectangle into NSTEPS horizontal strips and
draw each with the corresponding value's color */
{
for (jj = 0; jj < NSTEPS; jj++) {
@@ -227,15 +236,17 @@
fprintf(PS.fp, "mvx ");
fprintf(PS.fp, "%.1f ", y + fontsize);
fprintf(PS.fp, "B BW stroke\n");
- } /* done drawing the box */
+ } /* done drawing the box */
/* do the text */
- fprintf(PS.fp, "a %d get %.1f ", k++, x1 + 2.0 * fontsize);
+ set_ps_color(&ct.color);
+ fprintf(PS.fp, "a %d get %.1f ", k++, x1 + PRETEXT_MULT * fontsize);
if (center_cols)
fprintf(PS.fp, "mvx ");
fprintf(PS.fp, "%.1f MS\n", y);
+
i++;
- if (i >= num_cats)
+ if (i > num_cats)
j = ct.cols + 1;
}
}
Modified: grass/branches/releasebranch_6_4/ps/ps.map/ps_fclrtbl.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/ps_fclrtbl.c 2011-05-23 10:56:13 UTC (rev 46382)
+++ grass/branches/releasebranch_6_4/ps/ps.map/ps_fclrtbl.c 2011-05-23 11:30:47 UTC (rev 46383)
@@ -152,7 +152,7 @@
/* Frame around */
fprintf(PS.fp, "NP\n");
- set_rgb_color(ct.color);
+ set_ps_color(&ct.color);
fprintf(PS.fp, "%.8f W\n", lwidth);
fprintf(PS.fp, "%f %f %f %f B\n", x1,
t - (ncols - 1) * cwidth - (cwidth + lwidth) / 2, x2,
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_colortable.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_colortable.c 2011-05-23 10:56:13 UTC (rev 46382)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_colortable.c 2011-05-23 11:30:47 UTC (rev 46383)
@@ -5,8 +5,10 @@
#include <stdlib.h>
#include <string.h>
+#include <grass/glocale.h>
#include "colortable.h"
#include "ps_info.h"
+#include "clr.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
@@ -32,14 +34,16 @@
char buf[1024];
char *key, *data;
char name[GNAME_MAX], mapset[GMAPSET_MAX];
- int color, fontsize, cols, nodata, tickbar, discrete;
+ int fontsize, cols, nodata, tickbar, discrete;
double w, h, x, y;
int range_override;
double min, max, tmpD;
+ int r, g, b, ret;
+ PSCOLOR color;
fontsize = 0;
- color = BLACK;
+ set_color(&color, 0, 0, 0);
cols = 1;
h = w = x = y = 0.0;
ct.nodata = TRUE;
@@ -54,7 +58,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;
@@ -62,7 +66,7 @@
if (KEY("width")) {
if (sscanf(data, "%lf", &w) != 1 || w <= 0) {
- error(key, data, "illegal width request");
+ error(key, data, _("illegal width request"));
}
else
continue;
@@ -70,7 +74,7 @@
if (KEY("height")) {
if (sscanf(data, "%lf", &h) != 1 || h <= 0) {
- error(key, data, "illegal height request");
+ error(key, data, _("illegal height request"));
}
else
continue;
@@ -87,7 +91,7 @@
if (KEY("range")) {
if (sscanf(data, "%lf %lf", &min, &max) != 2) {
range_override = FALSE;
- error(key, data, "illegal range request");
+ error(key, data, _("illegal range request"));
}
else {
range_override = TRUE;
@@ -103,7 +107,7 @@
if (KEY("cols")) {
if (sscanf(data, "%d", &cols) != 1) {
cols = 1;
- error(key, data, "illegal columns request");
+ error(key, data, _("illegal columns request"));
}
else
continue;
@@ -117,11 +121,15 @@
}
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 (colortable)"));
+ else
+ error(key, data, _("illegal color request (colortable)"));
+
continue;
}
@@ -147,7 +155,7 @@
continue;
}
- error(key, data, "illegal colortabe sub-request");
+ error(key, data, _("illegal colortabe sub-request"));
}
ct.x = x;
@@ -158,7 +166,7 @@
/* Check for Raster */
if (!ct.name) {
if (!PS.cell_name) {
- error(key, data, "No raster selected for colortable !");
+ error(key, data, _("No raster selected for colortable!"));
}
else {
ct.name = PS.cell_name;
More information about the grass-commit
mailing list