[GRASS-SVN] r52732 - grass/trunk/ps/ps.map

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 19 08:26:49 PDT 2012


Author: mmetz
Date: 2012-08-19 08:26:49 -0700 (Sun, 19 Aug 2012)
New Revision: 52732

Modified:
   grass/trunk/ps/ps.map/border.h
   grass/trunk/ps/ps.map/catval.c
   grass/trunk/ps/ps.map/distance.c
   grass/trunk/ps/ps.map/do_geogrid.c
   grass/trunk/ps/ps.map/do_grid.c
   grass/trunk/ps/ps.map/do_labels.c
   grass/trunk/ps/ps.map/do_plt.c
   grass/trunk/ps/ps.map/do_scalebar.c
   grass/trunk/ps/ps.map/do_vectors.c
   grass/trunk/ps/ps.map/eps.c
   grass/trunk/ps/ps.map/get_scalebar.c
   grass/trunk/ps/ps.map/local_proto.h
   grass/trunk/ps/ps.map/main.c
   grass/trunk/ps/ps.map/map_setup.c
   grass/trunk/ps/ps.map/ps_clrtbl.c
   grass/trunk/ps/ps.map/ps_fclrtbl.c
   grass/trunk/ps/ps.map/ps_map.c
   grass/trunk/ps/ps.map/ps_vareas.c
   grass/trunk/ps/ps.map/ps_vpoints.c
   grass/trunk/ps/ps.map/r_border.c
   grass/trunk/ps/ps.map/r_colortable.c
   grass/trunk/ps/ps.map/r_labels.c
   grass/trunk/ps/ps.map/r_plt.c
   grass/trunk/ps/ps.map/r_vpoints.c
   grass/trunk/ps/ps.map/read_cfg.c
   grass/trunk/ps/ps.map/session.c
   grass/trunk/ps/ps.map/show_scale.c
   grass/trunk/ps/ps.map/textbox.c
Log:
ps.map: major code clean up, part 1

Modified: grass/trunk/ps/ps.map/border.h
===================================================================
--- grass/trunk/ps/ps.map/border.h	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/border.h	2012-08-19 15:26:49 UTC (rev 52732)
@@ -10,7 +10,7 @@
 
 struct border
 {
-    double R, G, B;
+    double r, g, b;
     double width;
 };
 

Modified: grass/trunk/ps/ps.map/catval.c
===================================================================
--- grass/trunk/ps/ps.map/catval.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/catval.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -19,7 +19,6 @@
 #include <grass/vector.h>
 #include <grass/dbmi.h>
 #include <grass/glocale.h>
-
 #include "vector.h"
 
 /**

Modified: grass/trunk/ps/ps.map/distance.c
===================================================================
--- grass/trunk/ps/ps.map/distance.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/distance.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -13,6 +13,7 @@
      * Note, must do lat-lon in 3 pieces, otherwise distance "line" may
      * go the wrong way around the globe
      */
+
     G_begin_distance_calculations();
 
     if (east < west) {
@@ -28,7 +29,8 @@
     e2 = e1 + incr;
 
     meters = G_distance(west, 0.0, e1, 0.0) +
-	G_distance(e1, 0.0, e2, 0.0) + G_distance(e2, 0.0, east, 0.0);
+	     G_distance(e1, 0.0, e2, 0.0) +
+	     G_distance(e2, 0.0, east, 0.0);
 
     return meters;
 }

Modified: grass/trunk/ps/ps.map/do_geogrid.c
===================================================================
--- grass/trunk/ps/ps.map/do_geogrid.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_geogrid.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -144,8 +144,9 @@
     double lat, lon;
     double grid;
     char num_text[50];
-    int vy, vx, hy = 0, hx = 0;
-    int first, x, y, last_bottom, last_right;
+    int vy, vx /*, hy = 0, hx = 0 */;
+    int x, y, last_bottom, last_right;
+    /* int first = 1; */
     int margin;
 
     if (PS.geogrid <= 0 || PS.geogrid_numbers <= 0)
@@ -167,7 +168,6 @@
     set_font_name(PS.geogrid_font);
     set_font_size(PS.geogrid_fontsize);
     set_ps_color(&PS.geogrid_numbers_color);
-    first = 1;
 
     /* vertical grid numbers
      * these numbers only appear on the right edge
@@ -181,7 +181,6 @@
     fprintf(PS.fp, "/mg %d def\n", margin);
     g = floor(north / grid) * grid;
     last_bottom = (int)PS.map_top;
-    first = 1;
 
     for (; g > south; g -= grid) {
 	e1 = east;		/* draw at east boundary */
@@ -201,18 +200,20 @@
 	if (y - PS.grid_fontsize < (int)PS.map_bot)
 	    continue;
 	G_format_northing(g, num_text, PROJECTION_LL);
-	text_box_path(x, y, RIGHT, CENTER, num_text, PS.geogrid_fontsize, 0);
+	text_box_path(x, y, RIGHT, CENTER, num_text, 0);
 	set_rgb_color(WHITE);
 	fprintf(PS.fp, "F ");
 	set_ps_color(&PS.geogrid_numbers_color);
 	fprintf(PS.fp, "TIB\n");
 	last_bottom = y - PS.geogrid_fontsize;
+	/*
 	if (first) {
 	    first = 0;
 	    hy = y + (int)(0.5 * (double)PS.geogrid_fontsize + 0.5) + margin;
 	    hx = x + 0.7 * strlen(num_text) * PS.geogrid_fontsize +
 		2 * margin;
 	}
+	*/
     }
 
     /* horizontal grid numbers along the bottom

Modified: grass/trunk/ps/ps.map/do_grid.c
===================================================================
--- grass/trunk/ps/ps.map/do_grid.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_grid.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -169,7 +169,7 @@
 	if (y - PS.grid_fontsize < (int)PS.map_bot)
 	    continue;
 	sprintf(num_text, "%s", format_northing(g, rounded_grid));
-	text_box_path(x, y, LEFT, CENTER, num_text, PS.grid_fontsize, 0);
+	text_box_path(x, y, LEFT, CENTER, num_text, 0);
 	set_rgb_color(WHITE);
 	fprintf(PS.fp, "F ");
 	set_ps_color(&PS.grid_numbers_color);

Modified: grass/trunk/ps/ps.map/do_labels.c
===================================================================
--- grass/trunk/ps/ps.map/do_labels.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_labels.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -190,12 +190,12 @@
 	    multi_text = multi_lines(value);
 	    if (multi_text) {
 		/* multiple lines - text is in PostScript array "ta" */
-		multi_text_box_path(x, y, xref, yref, value, fontsize,
-				    rotate);
+		multi_text_box_path(x, y, xref, yref, value, fontsize, 
+		                    rotate);
 	    }
 	    else {
 		/* single line - text is left on stack */
-		text_box_path(x, y, xref, yref, value, fontsize, rotate);
+		text_box_path(x, y, xref, yref, value, rotate);
 	    }
 
 	    if (opaque && !color_none(&background)) {

Modified: grass/trunk/ps/ps.map/do_plt.c
===================================================================
--- grass/trunk/ps/ps.map/do_plt.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_plt.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -14,7 +14,7 @@
 {
     FILE *fp;
     char buf[1024], symb[1024], sname[100];
-    char name[1024], prev_name[50];
+    char name[1024] /*, prev_name[50] */;
     double e1, n1, e2, n2, llx, lly, urx, ury;
     int color_R, color_G, color_B;
     int fcolor_R, fcolor_G, fcolor_B;
@@ -27,8 +27,6 @@
     SYMBOL *Symb;
     static int snum = 0;
 
-    prev_name[0] = 0;
-
     if (PS.plfile == NULL)
 	return 1;
     fp = fopen(PS.plfile, "r");

Modified: grass/trunk/ps/ps.map/do_scalebar.c
===================================================================
--- grass/trunk/ps/ps.map/do_scalebar.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_scalebar.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -53,6 +53,7 @@
 	margin = 2;
     fprintf(PS.fp, "/mg %d def\n", margin);
     x = sb.x - (length / 2.);
+    set_font_name(sb.font);
     set_font_size(sb.fontsize);
     set_line_width(sb.width);
 
@@ -86,8 +87,7 @@
 	    /* do text */
 	    if (i == 0 || lab == sb.numbers) {
 		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));
-		text_box_path(x1, y2 + margin, CENTER, LOWER, num,
-			      sb.fontsize, 0);
+		text_box_path(x1, y2 + margin, CENTER, LOWER, num, 0);
 		if (sb.bgcolor) {	/* TODO: take bg color, not just [white|none] */
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
@@ -101,8 +101,7 @@
 		(sb.numbers == 1 && i == seg - 1)) {
 		/* special case for last label */
 		sprintf(num, "%s", nice_number(sb.length));
-		text_box_path(x2, y2 + margin, CENTER, LOWER, num,
-			      sb.fontsize, 0);
+		text_box_path(x2, y2 + margin, CENTER, LOWER, num, 0);
 		if (sb.bgcolor) {
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
@@ -125,7 +124,7 @@
 	fprintf(PS.fp, "%.1f %.1f %.1f %.1f L D\n", x1, y1, x2, y2);
 
 	/* draw label */
-	text_box_path(x1, y1 + margin, CENTER, LOWER, "0", sb.fontsize, 0);
+	text_box_path(x1, y1 + margin, CENTER, LOWER, "0", 0);
 	if (sb.bgcolor) {
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
@@ -148,7 +147,7 @@
 
 	/* draw label */
 	sprintf(num, "%s", nice_number(sb.length));
-	text_box_path(x1, y2 + margin, CENTER, LOWER, num, sb.fontsize, 0);
+	text_box_path(x1, y2 + margin, CENTER, LOWER, num, 0);
 	if (sb.bgcolor) {
 	    set_rgb_color(WHITE);
 	    fprintf(PS.fp, "F ");
@@ -172,8 +171,7 @@
 	    if (lab == sb.numbers) {
 		sprintf(num, "%s", nice_number((sb.length / sb.segment) * i));
 
-		text_box_path(x1, y3 + margin, CENTER, LOWER, num,
-			      sb.fontsize, 0);
+		text_box_path(x1, y3 + margin, CENTER, LOWER, num, 0);
 		if (sb.bgcolor) {
 		    set_rgb_color(WHITE);
 		    fprintf(PS.fp, "F ");
@@ -202,7 +200,7 @@
 	strcpy(num, _("nautical miles"));
     
     text_box_path(72.0 * (x + length/2), 72.0 * (PS.page_height - (sb.y + 0.075)),
-	CENTER, UPPER, num, sb.fontsize, 0);
+	CENTER, UPPER, num, 0);
 
     if (sb.bgcolor) {
 	set_rgb_color(WHITE);

Modified: grass/trunk/ps/ps.map/do_vectors.c
===================================================================
--- grass/trunk/ps/ps.map/do_vectors.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/do_vectors.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -149,7 +149,7 @@
 	    continue;
 	}
 
-	PS_vpoints_plot(&Map, n, LINE_DRAW_LINE);
+	PS_vpoints_plot(&Map, n);
 
 	Vect_close(&Map);
 	fprintf(PS.fp, "[] 0 setdash\n");

Modified: grass/trunk/ps/ps.map/eps.c
===================================================================
--- grass/trunk/ps/ps.map/eps.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/eps.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -77,7 +77,7 @@
 }
 
 /* draw EPS file saved by eps_save */
-int eps_draw_saved(FILE * fp, char *name, double x, double y, double scale,
+int eps_draw_saved(char *name, double x, double y, double scale,
 		   double rotate)
 {
     fprintf(PS.fp, "\nBeginEPSF\n");

Modified: grass/trunk/ps/ps.map/get_scalebar.c
===================================================================
--- grass/trunk/ps/ps.map/get_scalebar.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/get_scalebar.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -16,7 +16,10 @@
     "height	height",
     "segment	no_segemnts",
     "numbers	no_labels",
+    "font   	fontname",
     "fontsize   fontsize",
+    "color   	fontcolor",
+    "bgcolor   	backgroundcolor",
     "background [Y|n]",
     "width      #",
     ""
@@ -31,13 +34,15 @@
     /* struct defined in decorate.h */
     sb.segment = 4;		/* four segments */
     sb.numbers = 1;		/* label each segment */
+    sb.font = G_store("Helvetica");
     sb.fontsize = 8;
+    sb.color = BLACK;		/* TODO: multi-color */
     sb.width = 1.;
     sb.length = -1.;
     sb.height = 0.1;		/* default height in inches */
     sb.x = PS.page_width / 2.;
     sb.y = 2.;
-    sb.bgcolor = 1;		/* default is "on" [white|none] (TODO: multi-color) */
+    sb.bgcolor = 1;		/* TODO: multi-color */
     sb.units = SB_UNITS_AUTO;   /* default to automatic based on value in PROJ_UNITS */
 
 
@@ -119,6 +124,13 @@
 		continue;
 	}
 
+	if (KEY("font")) {
+	    get_font(data);
+	    G_free(sb.font);
+	    sb.font = G_store(data);
+	    continue;
+	}
+
 	if (KEY("fontsize")) {
 	    if (sscanf(data, "%d", &sb.fontsize) != 1 || sb.fontsize <= 0) {
 		error(key, data, "illegal fontsize request");

Modified: grass/trunk/ps/ps.map/local_proto.h
===================================================================
--- grass/trunk/ps/ps.map/local_proto.h	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/local_proto.h	2012-08-19 15:26:49 UTC (rev 52732)
@@ -176,7 +176,7 @@
 
 #ifdef GRASS_VECTOR_H
 /* ps_vpoints.c */
-int PS_vpoints_plot(struct Map_info *, int, int);
+int PS_vpoints_plot(struct Map_info *, int);
 
 /* ps_vlines.c */
 int PS_vlines_plot(struct Map_info *, int, int);
@@ -198,9 +198,6 @@
 void reset_map_location(void);
 void print_papers(void);
 
-/* r_instructions.c */
-void read_instructions(int, int);
-
 /* r_border.c */
 int read_border(void);
 
@@ -216,6 +213,9 @@
 /* r_info.c */
 int read_info(void);
 
+/* r_instructions.c */
+void read_instructions(int, int);
+
 /* r_labels.c */
 int read_labels(char *, char *);
 
@@ -286,7 +286,7 @@
 #endif
 #endif
 /* textbox.c */
-int text_box_path(double, double, int, int, char *, int, float);
+int text_box_path(double, double, int, int, char *, float);
 
 /* vector.c */
 void vector_init(void);
@@ -301,7 +301,7 @@
 	      double *, double *);
 #ifdef _STDIO_H
 int eps_save(FILE *, char *, char *);
-int eps_draw_saved(FILE *, char *, double, double, double, double);
+int eps_draw_saved(char *, double, double, double, double);
 int eps_draw(FILE *, char *, double, double, double, double);
 int pat_save(FILE *, char *, char *);
 #endif

Modified: grass/trunk/ps/ps.map/main.c
===================================================================
--- grass/trunk/ps/ps.map/main.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/main.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -189,7 +189,7 @@
     can_reset_scale = 1;
     hdr.fp = NULL;
     grp.do_group = 0;
-    brd.R = brd.G = brd.B = 0.;
+    brd.r = brd.g = brd.b = 0.;
     brd.width = 1.;
 
     PS.min_y = 72.0 * (PS.page_height - PS.top_marg);
@@ -239,9 +239,8 @@
     /* get current mapset */
     PS.cell_mapset = G_mapset();
 
-    /* set current window */
-    G_get_set_window(&PS.w);
-    Rast_set_window(&PS.w);
+    /* get current window */
+    Rast_get_window(&PS.w);
 
     read_instructions(copies_set, can_reset_scale);
     

Modified: grass/trunk/ps/ps.map/map_setup.c
===================================================================
--- grass/trunk/ps/ps.map/map_setup.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/map_setup.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -30,9 +30,7 @@
 		PS.map_pix_wide = 72.0 * PS.map_width;
 		PS.map_pix_high = 72.0 * PS.map_height;
 	    }
-
-	    /* else, kill the scale */
-	    else
+	    else    /* kill the scale */
 		PS.scaletext[0] = 0;
 	}
 
@@ -52,9 +50,7 @@
 		PS.map_pix_wide = 72.0 * PS.map_width;
 		PS.map_pix_high = 72.0 * PS.map_height;
 	    }
-
-	    /* else, kill the scale */
-	    else
+	    else    /* kill the scale */
 		PS.scaletext[0] = 0;
 	}
 

Modified: grass/trunk/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_clrtbl.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/ps_clrtbl.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -24,7 +24,7 @@
     int center_cols;
     DCELL dmin, dmax, val;
     struct Colors colors;
-    double t, l, r;
+    double t, l /*, r */;
     double x1, x2, y, dy, fontsize, tl;
     double col_width;
     int do_color;
@@ -80,7 +80,7 @@
     if (ct.width <= 0.0 || ct.width > PS.page_width - PS.right_marg - ct.x)
 	ct.width = PS.page_width - PS.right_marg - ct.x;
 
-    r = l + 72.0 * ct.width;
+    /* r = l + 72.0 * ct.width; */ /* unused */
     col_width = ct.width / (double)ct.cols;
 
     G_debug(3, "clrtbl: adjusted ct.x=[%.3f] ct.y=[%.3f] ct.width=[%.3f] "
@@ -154,9 +154,9 @@
 
 	    x2 = x1 + fontsize;
 
-	    if (!i || dmax == dmin)
+	    if (!i || dmax == dmin) {
 		/* draw a 1-color rectangle */
-	    {
+
 		/* set box fill color */
 		if (!i)
 		    Rast_get_null_value_color(&R, &G, &B, &colors);
@@ -201,10 +201,10 @@
 		set_ps_color(&ct.color);
 		fprintf(PS.fp, "1 W stroke\n");
 	    }
-	    else
+	    else {
 		/* split the rectangle into NSTEPS horizontal strips and
 		   draw each with the corresponding value's color */
-	    {
+
 		for (jj = 0; jj < NSTEPS; jj++) {
 		    /* set box fill color */
 		    val = dmin + (double)jj *(dmax - dmin) / NSTEPS;

Modified: grass/trunk/ps/ps.map/ps_fclrtbl.c
===================================================================
--- grass/trunk/ps/ps.map/ps_fclrtbl.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/ps_fclrtbl.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -25,9 +25,8 @@
     int i, k;
     int R, G, B;
     DCELL dmin, dmax, val;
-    double t, l, r;		/* legend top, left, right */
-    double x1, x2, y, dy, fontsize, xu, yu;
-    double col_width;
+    double t, l;		/* legend top, left, right */
+    double x1, x2, y, dy, xu, yu;
     double width;		/* width of legend in map units */
     double height;		/* width of legend in map units */
     double cwidth;		/* width of one color line */
@@ -40,7 +39,8 @@
     double ex, cur_d, cur_ex;
     int do_color;
     double grey_color_val, margin;
-    int max_label_length = 0, label_posn, label_xref, label_yref;
+    unsigned int max_label_length = 0;
+    int label_posn, label_xref, label_yref;
 
     /* let user know what's happenning */
     G_message(_("Creating color table for <%s in %s>..."),
@@ -70,9 +70,10 @@
 
     do_color = (PS.grey == 0 && PS.level == 2);
 
-    /* set font */
-    fontsize = (double)ct.fontsize;
-    fprintf(PS.fp, "(%s) FN %.1f SF\n", ct.font, fontsize);
+    /* set font name, size, and color */
+    set_font_name(ct.font);
+    set_font_size(ct.fontsize);
+    set_ps_color(&ct.color);
 
     /* set colortable location,  */
     /* if height and width are not given, calculate defaults */
@@ -81,7 +82,7 @@
     if (ct.height <= 0)
 	ct.height = 10 * ct.fontsize / 72.0;
 
-    dy = 1.5 * fontsize;
+    dy = 1.5 * ct.fontsize;
 
     G_debug(3, "pwidth = %f pheight = %f", PS.page_width, PS.page_height);
     G_debug(3, "ct.width = %f ct.height = %f", ct.width, ct.height);
@@ -112,8 +113,7 @@
 
     G_debug(3, "corrected ct.x = %f ct.y = %f", ct.x, ct.y);
 
-    r = l + 72.0 * ct.width;
-    col_width = ct.width / (double)ct.cols;
+    /* r = l + 72.0 * ct.width; */ /* unused */
 
     /* Calc number of colors to print */
     width = 72.0 * ct.width;
@@ -237,11 +237,11 @@
 	*ch = '\0';
 
 	if (ct.tickbar)		/* switch to draw tic all the way through bar */
-	    fprintf(PS.fp, "(%s) %f %f MS\n", buf, x1 + 0.2 * fontsize,
-		    y - 0.35 * fontsize);
+	    fprintf(PS.fp, "(%s) %f %f MS\n", buf, x1 + 0.2 * ct.fontsize,
+		    y - 0.35 * ct.fontsize);
 	else
-	    fprintf(PS.fp, "(%s) %f %f MS\n", buf, x2 + 0.2 * fontsize,
-		    y - 0.35 * fontsize);
+	    fprintf(PS.fp, "(%s) %f %f MS\n", buf, x2 + 0.2 * ct.fontsize,
+		    y - 0.35 * ct.fontsize);
 
 	if(strlen(buf) > max_label_length)
 	    max_label_length = strlen(buf);
@@ -256,7 +256,7 @@
         units = "";
 
     if(strlen(units)) {
-	margin = 0.2 * fontsize;
+	margin = 0.2 * ct.fontsize;
 	if (margin < 2)
 	    margin = 2;
 	fprintf(PS.fp, "/mg %.1f def\n", margin);
@@ -284,16 +284,16 @@
 	case 2:
 	    /* directly above the tick numbers */
 	    if (ct.tickbar)
-		xu = x1 + 0.2 * fontsize;
+		xu = x1 + 0.2 * ct.fontsize;
 	    else
-		xu = x2 + 0.2 * fontsize;
+		xu = x2 + 0.2 * ct.fontsize;
 	    yu = t + 0.05*72;
 	    label_xref = LEFT;
 	    label_yref = LOWER;
 	    break;
 	case 3:
 	    /* to the right of the tick numbers */
-	    xu = 0.15*72 + max_label_length*fontsize*0.5;
+	    xu = 0.15*72 + max_label_length * ct.fontsize * 0.5;
 	    if (ct.tickbar)
 		xu += x1;
 	    else
@@ -305,9 +305,9 @@
 	case 4:
 	    /* directly below the tick numbers */
 	    if (ct.tickbar)
-		xu = x1 + 0.2 * fontsize;
+		xu = x1 + 0.2 * ct.fontsize;
 	    else
-		xu = x2 + 0.2 * fontsize;
+		xu = x2 + 0.2 * ct.fontsize;
 	    yu = t - height - 0.05*72;
 	    label_xref = LEFT;
 	    label_yref = UPPER;
@@ -321,7 +321,7 @@
 	    break;
 	}
 
-	text_box_path( xu, yu, label_xref, label_yref, units, fontsize, 0);
+	text_box_path( xu, yu, label_xref, label_yref, units, 0);
 	fprintf(PS.fp, "TIB\n");
 	set_rgb_color(BLACK);
     }

Modified: grass/trunk/ps/ps.map/ps_map.c
===================================================================
--- grass/trunk/ps/ps.map/ps_map.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/ps_map.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -134,8 +134,8 @@
 	do_scalebar();
 
     /* put border around map */
-    if (PS.do_border && brd.R >= 0.) {	/* if color wasn't "none" */
-	fprintf(PS.fp, "%.3f %.3f %.3f C\n", brd.R, brd.G, brd.B);
+    if (PS.do_border && brd.r >= 0.) {	/* if color wasn't "none" */
+	fprintf(PS.fp, "%.3f %.3f %.3f C\n", brd.r, brd.g, brd.b);
 	fprintf(PS.fp, "%.8f W\n", brd.width);
 	box_draw(PS.map_top - 0.5, PS.map_bot + 0.5,
 		 PS.map_left + 0.5, PS.map_right - 0.5);

Modified: grass/trunk/ps/ps.map/ps_vareas.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vareas.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/ps_vareas.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -131,7 +131,6 @@
     double e, w, n, s, aw, shift;
     double llx, lly, urx, ury, sc;
     char pat[50];
-    struct line_cats *Cats;
     struct bound_box box;
     struct varray *Varray = NULL;
     PSCOLOR color;
@@ -142,8 +141,6 @@
 
     fprintf(PS.fp, "1 setlinejoin\n");	/* set line join to round */
 
-    Cats = Vect_new_cats_struct();
-
     /* Create vector array if required */
     if (vector.layer[vec].cats != NULL || vector.layer[vec].where != NULL) {
 	Varray = Vect_new_varray(Vect_get_num_areas(P_map));

Modified: grass/trunk/ps/ps.map/ps_vpoints.c
===================================================================
--- grass/trunk/ps/ps.map/ps_vpoints.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/ps_vpoints.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -16,10 +16,10 @@
 #include "local_proto.h"
 #include "vector.h"
 
-int PS_vpoints_plot(struct Map_info *P_map, int vec, int type)
+int PS_vpoints_plot(struct Map_info *P_map, int vec)
 {
-    struct line_pnts *Points, *nPoints, *pPoints;
-    int k, line, cat, nlines, ret;
+    struct line_pnts *Points;
+    int line, ltype, cat, nlines, ret;
     struct line_cats *Cats;
 
     char eps[50], epsfile[1024], sname[100];
@@ -49,8 +49,6 @@
 
     cv_rgb = NULL;
 
-
-
     /* Create vector array if required */
     if (vector.layer[vec].cats != NULL || vector.layer[vec].where != NULL) {
 	Varray = Vect_new_varray(Vect_get_num_lines(P_map));
@@ -120,24 +118,20 @@
 
 
     /* read and plot vectors */
-    k = 0;
     nlines = Vect_get_num_lines(P_map);
     for (line = 1; line <= nlines; line++) {
-	if (0 > (ret = Vect_read_line(P_map, Points, Cats, line))) {
-	    if (ret == -1)
-		G_warning(_("Read error in vector map"));
-	    break;
-	}
-	if (!(ret & GV_POINTS))
+	if (!Vect_line_alive(P_map, line))
 	    continue;
-	if (!(ret & vector.layer[vec].ltype))
+	ltype = Vect_read_line(P_map, Points, Cats, line);
+
+	if (!(ltype & GV_POINTS))
 	    continue;
+	if (!(ltype & vector.layer[vec].ltype))
+	    continue;
 
 	if (Varray != NULL && Varray->c[line] == 0)
 	    continue;		/* is not in array */
 
-	pPoints = Points;
-	nPoints = 0;
 	Vect_cat_get(Cats, 1, &cat);
 
 	nn = Points->y[0];
@@ -260,7 +254,7 @@
 	if (vector.layer[vec].epstype == 1) {	/* draw common eps */
 	    /* calculate translation */
 	    eps_trans(llx, lly, urx, ury, x, y, size, rotate, &xt, &yt);
-	    eps_draw_saved(PS.fp, eps, xt, yt, size, rotate);
+	    eps_draw_saved(eps, xt, yt, size, rotate);
 	}
 	else if (vector.layer[vec].epstype == 2) {	/* draw epses */
 	    sprintf(epsfile, "%s%d%s", vector.layer[vec].epspre, cat,

Modified: grass/trunk/ps/ps.map/r_border.c
===================================================================
--- grass/trunk/ps/ps.map/r_border.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/r_border.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -25,7 +25,7 @@
     double width;
     char ch;
     int r, g, b;
-    double color_R, color_G, color_B;
+    double color_r, color_g, color_b;
     int ret;
 
     static char *help[] = {
@@ -37,7 +37,7 @@
     G_debug(1, "Reading border settings ..");
 
     width = 1.;
-    color_R = color_G = color_B = 0.;
+    color_r = color_g = color_b = 0.;
 
     while (input(2, buf, help)) {
 	if (!key_data(buf, &key, &data))
@@ -46,12 +46,12 @@
 	if (KEY("color")) {
 	    ret = G_str_to_color(data, &r, &g, &b);
 	    if (ret == 1) {
-		color_R = r / 255.;
-		color_G = g / 255.;
-		color_B = b / 255.;
+		color_r = r / 255.;
+		color_g = g / 255.;
+		color_b = b / 255.;
 	    }
 	    else if (ret == 2)	/* i.e. "none" */
-		color_R = color_G = color_B = -1.;
+		color_r = color_g = color_b = -1.;
 	    else
 		error(key, data, "illegal border color request");
 
@@ -74,9 +74,9 @@
 	error(key, data, "illegal border sub-request");
     }
 
-    brd.R = color_R;
-    brd.G = color_G;
-    brd.B = color_B;
+    brd.r = color_r;
+    brd.g = color_g;
+    brd.b = color_b;
     brd.width = width;
 
     return 0;

Modified: grass/trunk/ps/ps.map/r_colortable.c
===================================================================
--- grass/trunk/ps/ps.map/r_colortable.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/r_colortable.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -43,10 +43,11 @@
     PSCOLOR color;
 
 
-    fontsize = 0;
+    fontsize = 10;
     set_color(&color, 0, 0, 0);
     cols = 1;
     h = w = x = y = 0.0;
+    ct.font = G_store("Helvetica");
     ct.nodata = TRUE;
     ct.tickbar = FALSE;
     ct.discrete = -1;	    /* default: TRUE for CELL map, FALSE for FP maps */

Modified: grass/trunk/ps/ps.map/r_labels.c
===================================================================
--- grass/trunk/ps/ps.map/r_labels.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/r_labels.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -12,7 +12,7 @@
 
 int read_labels(char *name, char *mapset)
 {
-    char fullname[GNAME_MAX+GMAPSET_MAX+5];
+    char fullname[GNAME_MAX + 2 * GMAPSET_MAX + 4];
     char buf[1024];
     char *key, *data;
 

Modified: grass/trunk/ps/ps.map/r_plt.c
===================================================================
--- grass/trunk/ps/ps.map/r_plt.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/r_plt.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -14,7 +14,7 @@
     int fcolor_R, fcolor_G, fcolor_B;
     int ret;
     double size, width, rotate;
-    int have_icon;
+    /* int have_icon; */ /* unused */
     char ch;
     char *key, *data;
     int masked;
@@ -33,7 +33,6 @@
     size = 6.0;
     width = -1.0;  /* default is proportionate to symbol size */
     rotate = 0.0;
-    have_icon = 0;
     masked = 0;
     color_R = color_G = color_B = 0;
     fcolor_R = fcolor_G = fcolor_B = 128;

Modified: grass/trunk/ps/ps.map/r_vpoints.c
===================================================================
--- grass/trunk/ps/ps.map/r_vpoints.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/r_vpoints.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -236,15 +236,6 @@
 	    continue;
 	}
 
-	/* 
-	   GRASS 6.3: sizecol renamed to sizecolumn
-	   remove sizecol test and the warning in GRASS7
-	 */
-	if (KEY("sizecol")) {
-	    G_warning(_("The mapping instruction <%s> will be renamed to <%s> "
-		       "in future versions of GRASS. Please use <%s> instead."),
-		      "sizecol", "sizecolumn", "sizecolumn");
-	}
 	if (KEY("sizecol") || KEY("sizecolumn")) {
 	    G_strip(data);
 	    vector.layer[vec].sizecol = G_store(data);

Modified: grass/trunk/ps/ps.map/read_cfg.c
===================================================================
--- grass/trunk/ps/ps.map/read_cfg.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/read_cfg.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -82,7 +82,8 @@
     w = PS.page_width - PS.map_x_orig - PS.right_marg;
     h = PS.page_height - PS.map_y_loc - PS.bot_marg;
 
-    if (PS.map_width <= 0 || PS.map_width > w)	/* not specified or greater than available space */
+    if (PS.map_width <= 0 || PS.map_width > w)
+	/* not specified or greater than available space */
 	PS.map_width = w;
 
     if (PS.map_height <= 0 || PS.map_height > h)

Modified: grass/trunk/ps/ps.map/session.c
===================================================================
--- grass/trunk/ps/ps.map/session.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/session.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -2,6 +2,9 @@
 #include <grass/gis.h>
 #include "local_proto.h"
 
+/* TODO: when done, 
+ * remove session file or save it to a user-specified location */
+
 static char cur[2000];
 static char *sessionfile = NULL;
 static FILE *fd;

Modified: grass/trunk/ps/ps.map/show_scale.c
===================================================================
--- grass/trunk/ps/ps.map/show_scale.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/show_scale.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -11,6 +11,7 @@
 {
     double fontsize;
 
+    /* TODO: add font name, size, color options */
     fontsize = FONTSIZE;
     fprintf(PS.fp, "(Helvetica) FN %.1lf SF\n", fontsize);
     fprintf(PS.fp, "(SCALE:   %s)\n", PS.scaletext);

Modified: grass/trunk/ps/ps.map/textbox.c
===================================================================
--- grass/trunk/ps/ps.map/textbox.c	2012-08-19 14:02:45 UTC (rev 52731)
+++ grass/trunk/ps/ps.map/textbox.c	2012-08-19 15:26:49 UTC (rev 52732)
@@ -11,9 +11,12 @@
 #define UPPER 1
 #define CENTER 2
 
+/* font name, size, and color must be set first, outside text_box_path()
+ * because text_box_path() is called repeatedly with identical 
+ * font name, size, and color */
 int
 text_box_path(double x, double y, int xref, int yref, char *text,
-	      int fontsize, float rotate)
+	      float rotate)
 {
     /* get relative box coordinates */
     fprintf(PS.fp, "ZB (%s) PB\n", text);



More information about the grass-commit mailing list