فهرست منبع

ps.map: add missing and new options, preserve backwards compatibility

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52733 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 سال پیش
والد
کامیت
603a460699
6فایلهای تغییر یافته به همراه42 افزوده شده و 15 حذف شده
  1. 6 4
      ps/ps.map/colortable.h
  2. 6 6
      ps/ps.map/do_scalebar.c
  3. 11 0
      ps/ps.map/get_scalebar.c
  4. 6 3
      ps/ps.map/ps_clrtbl.c
  5. 1 1
      ps/ps.map/ps_fclrtbl.c
  6. 12 1
      ps/ps.map/r_colortable.c

+ 6 - 4
ps/ps.map/colortable.h

@@ -8,15 +8,17 @@
 
 struct colortable
 {
-    double x, y, width;
-    double min, max;
+    double x, y;	/* where */
+    double width;	/* column/table width */
+    double min, max;	/* range */
     double height;	/* fp legend height */
+    double lwidth;	/* line width for columns and tickbars */
     char *font;
     char *name;
     const char *mapset;
     int fontsize;
-    PSCOLOR color;
-    int cols;
+    PSCOLOR color;	/* text color, it seems */
+    int cols;		/* number of columns */
     int nodata;
     int tickbar;
     int discrete;	/* force discrete bands or continuous gradient */

+ 6 - 6
ps/ps.map/do_scalebar.c

@@ -92,7 +92,7 @@ int do_scalebar(void)
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 		lab = 0;
 	    }
@@ -106,7 +106,7 @@ int do_scalebar(void)
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 	    }
 
@@ -129,7 +129,7 @@ int do_scalebar(void)
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
 	}
-	set_rgb_color(BLACK);
+	set_rgb_color(sb.color);
 	fprintf(PS.fp, "TIB\n");
 
 
@@ -152,7 +152,7 @@ int do_scalebar(void)
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
 	}
-	set_rgb_color(BLACK);
+	set_rgb_color(sb.color);
 	fprintf(PS.fp, "TIB\n");
 
 
@@ -176,7 +176,7 @@ int do_scalebar(void)
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
 		}
-		set_rgb_color(BLACK);
+		set_rgb_color(sb.color);
 		fprintf(PS.fp, "TIB\n");
 		lab = 0;
 	    }
@@ -206,7 +206,7 @@ int do_scalebar(void)
 	set_rgb_color(WHITE);
 	fprintf(PS.fp, "F ");
     }
-    set_rgb_color(BLACK);
+    set_rgb_color(sb.color);
     fprintf(PS.fp, "TIB\n");
 
 

+ 11 - 0
ps/ps.map/get_scalebar.c

@@ -139,6 +139,17 @@ int read_scalebar(void)
 		continue;
 	}
 
+	if (KEY("color"))
+	{
+	    sb.color = get_color_number(data);
+	    if (sb.color < 0)
+	    {
+		sb.color = BLACK;
+		error(key, data, "illegal color request");
+	    }
+	    continue;
+	}
+
 	if (KEY("background")) {
 	    sb.bgcolor = yesno(key, data);
 	    continue;

+ 6 - 3
ps/ps.map/ps_clrtbl.c

@@ -199,7 +199,7 @@ int PS_colortable(void)
 /* 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");
+		fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
 	    }
 	    else {
 		/* split the rectangle into NSTEPS horizontal strips and
@@ -226,7 +226,7 @@ int PS_colortable(void)
 		    fprintf(PS.fp, "B CF stroke\n");
 		}		/* done filling the box */
 
-		/* outline the box in black */
+		/* outline the box in the specified color, see above */
 		fprintf(PS.fp, "%.1f ", x1);
 		if (center_cols)
 		    fprintf(PS.fp, "mvx ");
@@ -235,7 +235,10 @@ int PS_colortable(void)
 		if (center_cols)
 		    fprintf(PS.fp, "mvx ");
 		fprintf(PS.fp, "%.1f ", y + fontsize);
-		fprintf(PS.fp, "B BW stroke\n");
+		fprintf(PS.fp, "B ");
+		set_ps_color(&ct.color);
+		fprintf(PS.fp, "%.2f W stroke\n", ct.lwidth);
+
 	    }	/* done drawing the box */
 
 	    /* do the text */

+ 1 - 1
ps/ps.map/ps_fclrtbl.c

@@ -121,7 +121,7 @@ int PS_fcolortable(void)
     cwidth = 0.1;
     ncols = (int)height / cwidth;
     step = (dmax - dmin) / (ncols - 1);
-    lwidth = width > 72 ? 0.02 * 72 : 0.02 * width;
+    lwidth = ct.lwidth;
 
     /* Print color band */
     y = t;

+ 12 - 1
ps/ps.map/r_colortable.c

@@ -18,6 +18,7 @@ static char *help[] = {
     "where      x y",
     "width      table_width",
     "height     fptable_height",
+    "lwidth     line_width",
     "raster	raster_name",
     "range	min max",
     "cols       columns",
@@ -36,7 +37,7 @@ int read_colortable(void)
     char *key, *data;
     char name[GNAME_MAX], mapset[GMAPSET_MAX];
     int fontsize, cols, nodata, tickbar, discrete;
-    double w, h, x, y;
+    double w, h, x, y, lw;
     int range_override;
     double min, max, tmpD;
     int r, g, b, ret;
@@ -47,6 +48,7 @@ int read_colortable(void)
     set_color(&color, 0, 0, 0);
     cols = 1;
     h = w = x = y = 0.0;
+    lw = 1;
     ct.font = G_store("Helvetica");
     ct.nodata = TRUE;
     ct.tickbar = FALSE;
@@ -82,6 +84,14 @@ int read_colortable(void)
 		continue;
 	}
 
+	if (KEY("lwidth")) {
+	    if (sscanf(data, "%lf", &lw) != 1 || lw < 0) {
+		error(key, data, _("illegal width request"));
+	    }
+	    else
+		continue;
+	}
+
 	if (KEY("raster")) {
 	    if (scan_gis("cell", "raster", key, data, name, mapset, 0)) {
 		ct.name = G_store(name);
@@ -189,6 +199,7 @@ int read_colortable(void)
     ct.range_override = range_override;
     ct.width = w;
     ct.height = h;
+    ct.lwidth = lw;
     ct.color = color;
     ct.cols = cols;