void driver_plot_icon(double x, double y, const char *icon) { char buf[1024]; int xi, yi; G_plot_where_xy(x, y, &xi, &yi); sprintf(buf, ".screen.canvas create bitmap %d %d -bitmap @$iconpath/%s.xbm -foreground %s -anchor center", xi, yi, icon, color); if (Tcl_Eval(Toolbox, buf) != TCL_OK) G_warning("driver_plot_icon: %s", Tcl_GetStringResult(Toolbox)); }
int do_grid_numbers(void) { double g; char num_text[50]; int grid, vy, vx, hy = 0, hx = 0; int first, len, x, y, last_bottom, last_right; int rounded_grid, margin; if (PS.grid <= 0 || PS.grid_numbers <= 0) return 1; grid = PS.grid * PS.grid_numbers; /* round grid to multiple of 10 */ rounded_grid = 1; if (PS.w.proj != PROJECTION_LL) { sprintf(num_text, "%d", PS.grid); len = strlen(num_text); while (len-- && num_text[len] == '0') rounded_grid *= 10; if (rounded_grid == 10) rounded_grid = 1; } /* initialize */ set_font_name(PS.grid_font); set_font_size(PS.grid_fontsize); set_ps_color(&PS.grid_numbers_color); first = 1; /* horizontal grid numbers * these numbers only appear on the left edge of the first panel. * center the numbers on each grid line. * suppress number if it falls off the map or would overlay the previous * label */ margin = (int)(0.2 * (double)PS.grid_fontsize + 0.5); if (margin < 2) margin = 2; fprintf(PS.fp, "/mg %d def\n", margin); g = floor(PS.w.north / grid) * grid; last_bottom = (int)PS.map_top; first = 1; /* x = XCONV(PS.w.west); */ for (; g > PS.w.south; g -= grid) { /*y = YCONV(g); */ G_plot_where_xy(PS.w.west, g, &vx, &vy); x = (double)vx / 10.; y = (double)vy / 10.; if (y + PS.grid_fontsize > last_bottom) continue; 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); set_rgb_color(WHITE); fprintf(PS.fp, "F "); set_ps_color(&PS.grid_numbers_color); fprintf(PS.fp, "TIB\n"); last_bottom = y - PS.grid_fontsize; if (first) { first = 0; hy = y + (int)(0.5 * (double)PS.grid_fontsize + 0.5) + margin; hx = x + 0.7 * strlen(num_text) * PS.grid_fontsize + 2 * margin; } } /* vertical grid numbers * center the numbers on each grid line. * suppress number if it falls of the map or would overlay the previous * label */ g = floor(PS.w.west / grid) * grid; last_right = (int)PS.map_left; /* y = YCONV(PS.w.north); */ for (; g < PS.w.east; g += grid) { /* x = XCONV(g); */ G_plot_where_xy(g, PS.w.north, &vx, &vy); x = (double)vx / 10.; y = (double)vy / 10.; if (x - PS.grid_fontsize < last_right) continue; if (x + PS.grid_fontsize > (int)PS.map_right) continue; sprintf(num_text, "%s", format_easting(g, rounded_grid)); vy = y - 0.7 * strlen(num_text) * PS.grid_fontsize - 2 * margin; vx = x - (int)(0.5 * (double)PS.grid_fontsize + 0.5) - margin; if (vx < hx && vy < hy) continue; fprintf(PS.fp, "ZB (%s) PB 90 rotate\n", num_text); fprintf(PS.fp, "%d br sub bl add mg add\n", y); fprintf(PS.fp, "%d bt bb sub D2 add mg sub neg TR TB\n", x); set_rgb_color(WHITE); fprintf(PS.fp, "F "); set_ps_color(&PS.grid_numbers_color); fprintf(PS.fp, "TIB\n"); last_right = x + PS.grid_fontsize; } return 0; }