[GRASS-SVN] r45586 - grass/branches/develbranch_6/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 6 07:29:19 EST 2011
Author: martinl
Date: 2011-03-06 04:29:19 -0800 (Sun, 06 Mar 2011)
New Revision: 45586
Added:
grass/branches/develbranch_6/ps/ps.map/r_instructions.c
Modified:
grass/branches/develbranch_6/ps/ps.map/box.c
grass/branches/develbranch_6/ps/ps.map/comment.c
grass/branches/develbranch_6/ps/ps.map/distance.h
grass/branches/develbranch_6/ps/ps.map/do_geogrid.c
grass/branches/develbranch_6/ps/ps.map/do_grid.c
grass/branches/develbranch_6/ps/ps.map/do_header.c
grass/branches/develbranch_6/ps/ps.map/do_labels.c
grass/branches/develbranch_6/ps/ps.map/do_plt.c
grass/branches/develbranch_6/ps/ps.map/do_scalebar.c
grass/branches/develbranch_6/ps/ps.map/do_vectors.c
grass/branches/develbranch_6/ps/ps.map/eps.c
grass/branches/develbranch_6/ps/ps.map/get_scalebar.c
grass/branches/develbranch_6/ps/ps.map/getgrid.c
grass/branches/develbranch_6/ps/ps.map/local_proto.h
grass/branches/develbranch_6/ps/ps.map/main.c
grass/branches/develbranch_6/ps/ps.map/map_info.c
grass/branches/develbranch_6/ps/ps.map/map_setup.c
grass/branches/develbranch_6/ps/ps.map/outl_io.c
grass/branches/develbranch_6/ps/ps.map/ps_clrtbl.c
grass/branches/develbranch_6/ps/ps.map/ps_colors.c
grass/branches/develbranch_6/ps/ps.map/ps_fclrtbl.c
grass/branches/develbranch_6/ps/ps.map/ps_map.c
grass/branches/develbranch_6/ps/ps.map/ps_outline.c
grass/branches/develbranch_6/ps/ps.map/ps_raster.c
grass/branches/develbranch_6/ps/ps.map/ps_vareas.c
grass/branches/develbranch_6/ps/ps.map/ps_vlegend.c
grass/branches/develbranch_6/ps/ps.map/ps_vlines.c
grass/branches/develbranch_6/ps/ps.map/ps_vpoints.c
grass/branches/develbranch_6/ps/ps.map/r_border.c
grass/branches/develbranch_6/ps/ps.map/r_cell.c
grass/branches/develbranch_6/ps/ps.map/r_colortable.c
grass/branches/develbranch_6/ps/ps.map/r_group.c
grass/branches/develbranch_6/ps/ps.map/r_header.c
grass/branches/develbranch_6/ps/ps.map/r_info.c
grass/branches/develbranch_6/ps/ps.map/r_paper.c
grass/branches/develbranch_6/ps/ps.map/r_plt.c
grass/branches/develbranch_6/ps/ps.map/r_rgb.c
grass/branches/develbranch_6/ps/ps.map/r_text.c
grass/branches/develbranch_6/ps/ps.map/r_vareas.c
grass/branches/develbranch_6/ps/ps.map/r_vlegend.c
grass/branches/develbranch_6/ps/ps.map/r_vlines.c
grass/branches/develbranch_6/ps/ps.map/r_vpoints.c
grass/branches/develbranch_6/ps/ps.map/r_wind.c
grass/branches/develbranch_6/ps/ps.map/scale.c
grass/branches/develbranch_6/ps/ps.map/symbol.c
Log:
ps.map: `-b` backported from trunk
module sync'ed with trunk
Modified: grass/branches/develbranch_6/ps/ps.map/box.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/box.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/box.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -3,12 +3,12 @@
** Author: Paul W. Carlson March 1992
*/
-#include "ps_info.h"
#include "local_proto.h"
int box_path(double t, double b, double l, double r)
{
- fprintf(PS.fp, "%.1f %.1f %.1f %.1f B ", l, b, r, t);
+ if (PS.fp)
+ fprintf(PS.fp, "%.1f %.1f %.1f %.1f B ", l, b, r, t);
return 0;
}
@@ -16,8 +16,9 @@
int box_clip(double t, double b, double l, double r)
{
box_path(t, b, l, r);
- fprintf(PS.fp, "clip newpath\n");
-
+ if (PS.fp)
+ fprintf(PS.fp, "clip newpath\n");
+
return 0;
}
Modified: grass/branches/develbranch_6/ps/ps.map/comment.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/comment.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/comment.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -8,7 +8,6 @@
#include <stdlib.h>
#include <string.h>
#include "comment.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Property changes on: grass/branches/develbranch_6/ps/ps.map/distance.h
___________________________________________________________________
Added: svn:mime-type
+ text/x-chdr
Added: svn:eol-style
+ native
Modified: grass/branches/develbranch_6/ps/ps.map/do_geogrid.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_geogrid.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_geogrid.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -11,7 +11,6 @@
#include <grass/glocale.h>
#include <grass/gprojects.h>
-#include "ps_info.h"
#include "local_proto.h"
#define LEFT 0
Modified: grass/branches/develbranch_6/ps/ps.map/do_grid.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_grid.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_grid.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,7 @@
*/
#include <string.h>
#include <math.h>
-#include "ps_info.h"
+
#include "local_proto.h"
#define LEFT 0
Modified: grass/branches/develbranch_6/ps/ps.map/do_header.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_header.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_header.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,7 @@
#include <unistd.h>
#include <string.h>
#include "header.h"
-#include "ps_info.h"
+
#include "local_proto.h"
static double x, y, dy, fontsize;
Modified: grass/branches/develbranch_6/ps/ps.map/do_labels.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_labels.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_labels.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <string.h>
#include <grass/glocale.h>
#include "clr.h"
-#include "ps_info.h"
#include "labels.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/do_plt.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_plt.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_plt.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -8,7 +8,6 @@
#include <grass/glocale.h>
#include <grass/symbol.h>
#include "clr.h"
-#include "ps_info.h"
#include "local_proto.h"
int do_plt(int after_masking)
Modified: grass/branches/develbranch_6/ps/ps.map/do_scalebar.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_scalebar.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_scalebar.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -4,8 +4,6 @@
#include <string.h>
#include <math.h>
-#include "ps_info.h"
-#include "decorate.h"
#include "local_proto.h"
#include "distance.h"
Modified: grass/branches/develbranch_6/ps/ps.map/do_vectors.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/do_vectors.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/do_vectors.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -13,7 +13,6 @@
#include <grass/symbol.h>
#include "clr.h"
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
int do_vectors(int after_masking)
Modified: grass/branches/develbranch_6/ps/ps.map/eps.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/eps.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/eps.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -1,6 +1,5 @@
#include <math.h>
#include <string.h>
-#include "ps_info.h"
#include "local_proto.h"
/* test if file is realy EPS file and find bbox
Modified: grass/branches/develbranch_6/ps/ps.map/get_scalebar.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/get_scalebar.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/get_scalebar.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,8 +5,6 @@
#include <stdlib.h>
#include <string.h>
-#include "decorate.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/getgrid.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/getgrid.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/getgrid.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(x,key)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/local_proto.h
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/local_proto.h 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/local_proto.h 2011-03-06 12:29:19 UTC (rev 45586)
@@ -1,3 +1,7 @@
+#include "group.h"
+#include "ps_info.h"
+#include "decorate.h"
+
/* box.c */
int box_path(double, double, double, double);
int box_clip(double, double, double, double);
@@ -188,10 +192,15 @@
int read_cell(char *, char *);
/* read_cfg.c */
-int set_paper(char *pname);
+int set_paper(char *);
void reset_map_location(void);
void print_papers(void);
+/* r_instructions.c */
+void read_instructions(FILE *, struct PS_data *, int, int, int,
+ struct scalebar *, int *, int *,
+ struct PS_group *);
+
/* r_border.c */
int read_border(void);
Modified: grass/branches/develbranch_6/ps/ps.map/main.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/main.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/main.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -2,19 +2,21 @@
/****************************************************************************
*
* MODULE: ps.map
- * AUTHOR(S): Paul W. Carlson 1992 (original contributor)
+ * AUTHOR(S): Paul W. Carlson 1992 (original contributor)
* Radim Blazek <radim.blazek gmail.com>
- * Bob Covill <bcovill tekmap.ns.ca>, Huidae Cho
- * <grass4u gmail.com>, Glynn Clements <glynn
- * gclements.plus.com>, Hamish Bowman <hamish_b yahoo.com>,
- * Markus Neteler <neteler itc.it>,
+ * Bob Covill <bcovill tekmap.ns.ca>
+ * Huidae Cho <grass4u gmail.com>
+ * Glynn Clements <glynn gclements.plus.com>
+ * Hamish Bowman <hamish_b yahoo.com>
+ * Markus Neteler <neteler itc.it>
* Alessandro Frigeri <afrigeri unipg.it>
- * PURPOSE: This is an enhanced PostScript version of the p.map program
- * COPYRIGHT: (C) 2003-2008 by the GRASS Development Team
+ * Martin Landa <landa.martin gmail.com>
+ * PURPOSE: Hardcopy PostScript map output utility (based on p.map program)
+ * COPYRIGHT: (C) 2003-2008, 2011 by the GRASS Development Team
*
- * This program is free software under the GNU General Public
- * License (>=v2). Read the file COPYING that comes with GRASS
- * for details.
+ * This program is free software under the GNU General
+ * Public License (>=v2). Read the file COPYING that
+ * comes with GRASS for details.
*
*****************************************************************************/
@@ -34,38 +36,16 @@
#include "border.h"
#include "comment.h"
#include "colortable.h"
-#include "decorate.h"
-#include "ps_info.h"
-#include "group.h"
#include "local_proto.h"
-#define KEY(x) (strcmp(key,x)==0)
+
FILE *tracefd;
FILE *inputfd;
int do_mapinfo;
int do_vlegend;
char *ps_mask_file;
-static char *help[] = {
- "rast rastermap setcolor val_range(s) color",
- "vpoints vector points map scalebar [f|s]",
- "vlines vector lines map paper [a4|a3|us-letter|...]",
- "vareas vector areas map maploc x y [width height]",
- "labels labelfile text east north text",
- "region regionfile line east north east north",
- "grid spacing point east north",
- "geogrid spacing header",
- "outline mapinfo",
- "colortable [y|n] vlegend",
- "comments [unix-file] psfile PostScript include file",
- "read unix-file eps Encapsulated PostScript file",
- "rectangle east north east north",
- "scale 1:#|# inches|# panels|1 inch = # miles",
- "border [y|n]",
- ""
-};
-
int rotate_plot;
int eps_output;
int ps_copies = 1;
@@ -73,16 +53,13 @@
int main(int argc, char *argv[])
{
char buf[1024];
- char name[GNAME_MAX], mapset[GMAPSET_MAX];
- int i;
- int iflag;
int can_reset_scale;
int copies_set;
struct Option *map_scale;
struct Option *input_file;
struct Option *output_file;
struct Option *copies;
- struct Flag *rflag, *pflag, *eflag;
+ struct Flag *rflag, *pflag, *eflag, *bflag;
struct GModule *module;
static char *def_font = "Helvetica";
@@ -98,37 +75,42 @@
/* Set description */
module = G_define_module();
module->keywords = _("postscript, map, printing");
- module->description = _("Hardcopy PostScript map output utility.");
+ module->description = _("Produces hardcopy PostScript map output.");
rflag = G_define_flag();
rflag->key = 'r';
rflag->description = _("Rotate plot 90 degrees");
+ rflag->guisection = _("Output settings");
pflag = G_define_flag();
pflag->key = 'p';
pflag->description =
- _("List paper formats ( name width height left right top bottom(margin) )");
+ _("List paper formats (name width height left right top bottom(margin))");
+ pflag->guisection = _("Print");
eflag = G_define_flag();
eflag->key = 'e';
eflag->description =
_("Create EPS (Encapsulated PostScript) instead of PostScript file");
+ eflag->guisection = _("Output settings");
- input_file = G_define_option();
- input_file->key = "input";
- input_file->type = TYPE_STRING;
- input_file->description =
- _("File containing mapping instructions (or use input=- to enter from keyboard)");
- input_file->gisprompt = "old_file,file,input";
+ bflag = G_define_flag();
+ bflag->key = 'b';
+ bflag->description =
+ _("Print map-box's position on the page and exit (inches from top-left of paper)");
+ bflag->guisection = _("Print");
+
+ input_file = G_define_standard_option(G_OPT_F_INPUT);
+ input_file->label = _("File containing mapping instructions");
+ input_file->description = _("Use '-' to enter instructions from keyboard)");
input_file->required = NO;
-
- output_file = G_define_option();
- output_file->key = "output";
- output_file->type = TYPE_STRING;
- output_file->gisprompt = "new_file,file,output";
- output_file->description = _("PostScript output file");
- /* output_file->required = YES; Can omit for -p list page size & exit mode */
-
+ input_file->guisection = _("Required");
+
+ output_file = G_define_standard_option(G_OPT_F_OUTPUT);
+ output_file->description = _("Name for PostScript output file");
+ output_file->required = NO;
+ output_file->guisection = _("Required");
+
map_scale = G_define_option();
map_scale->key = "scale";
map_scale->key_desc = "mapscale";
@@ -142,12 +124,15 @@
copies->options = "1-20";
copies->description = _("Number of copies to print");
copies->required = NO;
-
+ copies->guisection = _("Output settings");
+
if (!isatty(0))
G_disable_interactive();
if (G_parser(argc, argv))
usage(0);
-
+
+ G_zero(&PS, sizeof(struct PS_data));
+
/* Print papers */
if (pflag->answer) {
print_papers();
@@ -178,7 +163,6 @@
m_info.bgcolor = WHITE;
hdr.color = BLACK;
cmt.color = BLACK;
- PS.grid_color = BLACK;
m_info.font = G_store(def_font);
vector.font = G_store(def_font);
hdr.font = G_store(def_font);
@@ -191,8 +175,7 @@
ct.fontsize = 10;
ct.cols = 1;
tracefd = NULL;
- inputfd = stdin;
- iflag = 0;
+ inputfd = NULL;
labels.count = 0;
labels.other = NULL;
can_reset_scale = 1;
@@ -200,40 +183,28 @@
grp.do_group = 0;
brd.R = brd.G = brd.B = 0.;
brd.width = 1.;
- PS.grey = 0;
- PS.mask_needed = 0;
- PS.do_header = 0;
+
+ PS.grid_color = BLACK;
PS.min_y = 72.0 * (PS.page_height - PS.top_marg);
PS.set_y = 100.0 * PS.min_y;
- PS.startpanel = 0;
- PS.endpanel = 0;
PS.cell_fd = -1;
- PS.do_outline = 0;
- PS.do_colortable = 0;
PS.do_border = TRUE;
- PS.do_scalebar = 0;
- PS.grid = 0;
- PS.scaletext[0] = 0;
- PS.celltitle[0] = 0;
- PS.commentfile = NULL;
- PS.num_psfiles = 0;
- PS.mask_color = 0;
- /* PS.map_* variables are set to 0 (not defined) and then may be reset by 'maploc'.
- * When script is read, main() should call reset_map_location() to reset map size to fit to paper */
-
- PS.map_width = 0;
- PS.map_height = 0;
- PS.map_x_orig = 0;
- PS.map_y_orig = 0;
- PS.map_y_loc = 0;
-
+ /* PS.map_* variables are set to 0 (not defined) and then may be
+ * reset by 'maploc'. When script is read, main() should call
+ * reset_map_location() to reset map size to fit to paper */
+
/* arguments */
if (input_file->answer && strcmp(input_file->answer, "-")) {
- if (NULL == freopen(input_file->answer, "r", stdin))
- G_fatal_error("%s - %s: %s", G_program_name(),
+ inputfd = fopen(input_file->answer, "r");
+ if (!inputfd)
+ G_fatal_error(_("Unable to open file '%s': %s"),
input_file->answer, strerror(errno));
}
+ else {
+ inputfd = stdin;
+ }
+
if (map_scale->answer) {
G_warning(_("Using <%s> from the command line is depreciated. "
"Please use the <%s> mapping instruction instead. "
@@ -245,26 +216,27 @@
else
error(map_scale->answer, "", "illegal scale request");
}
-
+
if (copies->answer) {
if (sscanf(copies->answer, "%d", &ps_copies) != 1) {
ps_copies = 1;
- error(copies->answer, "", "illegal copies request");
+ error(copies->answer, "", _("illegal copies request"));
}
copies_set = 1;
}
- if (output_file->answer) {
- if ((PS.fp = fopen(output_file->answer, "w")) == NULL)
- G_fatal_error("%s - %s: %s", G_program_name(),
- output_file->answer, strerror(errno));
+ if (!bflag->answer) {
+ if (output_file->answer) {
+ if ((PS.fp = fopen(output_file->answer, "w")) == NULL)
+ G_fatal_error("Unable to create file '%s': %s",
+ output_file->answer, strerror(errno));
+ }
+ else {
+ G_fatal_error(_("Required parameter <%s> not set:\n\t(%s)"),
+ output_file->key, output_file->description);
+ }
}
- else {
- G_message(_("\nERROR: Required parameter <%s> not set:\n (%s).\n"),
- output_file->key, output_file->description);
- usage(1);
- }
-
+
/* get current mapset */
PS.cell_mapset = G_mapset();
@@ -272,458 +244,29 @@
G_get_set_window(&PS.w);
if (G_set_window(&PS.w) == -1)
G_fatal_error(_("Current region cannot be set."));
-
- while (1) {
- char *key;
- char *data;
-
- if (!input(1, buf, help)) {
- if (!iflag) {
- if (G_getl2(buf, 12, inputfd))
- G_warning(_("Data exists after final 'end' instruction!"));
- break;
- }
- iflag = 0;
- continue;
- }
- if (!key_data(buf, &key, &data))
- continue;
-
- if (KEY("read")) {
- if (inputfd != stdin)
- fclose(inputfd);
-
- if (sscanf(data, "%s", name) != 1) {
- error(key, data, "no file specified");
- inputfd = stdin;
- }
- else if ((inputfd = fopen(name, "r")) == NULL) {
- error(key, data, "unable to open");
- inputfd = stdin;
- }
- else
- iflag = 1;
- continue;
- }
-
- /* Please, remove before GRASS 7 released */
- if (KEY("verbose")) {
- int verbose;
-
- if (sscanf(data, "%d", &verbose) != 1)
- verbose = G_verbose_std();
-
- G_warning(_("GRASS environment variable GRASS_VERBOSE "
- "is overwritten by VERBOSE mapping instruction. "
- "This mapping instruction is superseded and "
- "will be removed in future versions of GRASS. "
- "Please use --verbose instead."));
-
- if (!G_set_verbose(verbose))
- G_warning(_("Cannot set GRASS_VERBOSE variable."));
-
- continue;
- }
-
- if (KEY("paper")) {
- if (strlen(data) > 0) {
- set_paper(data);
- }
- read_paper();
-
- continue;
- }
-
- if (KEY("maploc")) {
- int n;
- double x, y, w, h;
-
- n = sscanf(data, "%lf %lf %lf %lf", &x, &y, &w, &h);
- if (n == 2 || n == 4) {
- PS.map_x_orig = x;
- PS.map_y_loc = y;
- if (n == 4) {
- PS.map_width = w;
- PS.map_height = h;
- }
- }
- else {
- error(key, data, "illegal maploc request");
- gobble_input();
- }
- continue;
- }
-
- if (KEY("copies")) {
- int n, copies;
-
- if (copies_set)
- continue;
- n = sscanf(data, "%d", &copies);
- if (n != 1 || copies < 1 || copies > 20) {
- ps_copies = 1;
- error(key, data, "illegal copies request");
- }
- ps_copies = copies;
- continue;
- }
-
- if (KEY("setcolor")) {
- float R, G, B;
- int r, g, b;
- int color;
- int count;
- DCELL *val_list;
- DCELL dmin, dmax;
- char colorbuf[100];
- char catsbuf[100];
-
- if (PS.cell_fd < 0) {
- error(key, data, "no raster map selected yet");
- continue;
- }
- if (sscanf(data, "%s %[^\n]", catsbuf, colorbuf) == 2) {
- color = get_color_number(colorbuf);
- if (color < 0) {
- error(key, data, "illegal color");
- continue;
- }
- get_color_rgb(color, &R, &G, &B);
- r = 255.0 * R;
- g = 255.0 * G;
- b = 255.0 * B;
-
- if (strncmp(catsbuf, "null", 4) == 0) {
- G_set_null_value_color(r, g, b, &PS.colors);
- continue;
- }
- if (strncmp(catsbuf, "default", 7) == 0) {
- G_set_default_color(r, g, b, &PS.colors);
- continue;
- }
- if ((count = parse_val_list(catsbuf, &val_list)) < 0) {
- error(key, data, "illegal value list");
- continue;
- }
- for (i = 0; i < count; i += 2) {
- dmin = val_list[i];
- dmax = val_list[i + 1];
- G_add_d_raster_color_rule(&dmin, r, g, b, &dmax, r, g, b,
- &PS.colors);
- }
- G_free(val_list);
- }
- continue;
- }
-
- if (KEY("colortable")) {
- PS.do_colortable = 0;
- /*
- if (PS.cell_fd < 0)
- error(key, data, "no raster map selected yet");
- else
- */
- PS.do_colortable = yesno(key, data);
- if (PS.do_colortable)
- read_colortable();
- continue;
- }
-
- if (KEY("border")) {
- PS.do_border = yesno(key, data);
- if (PS.do_border)
- read_border();
- continue;
- }
-
- if (KEY("scalebar")) {
- if (G_projection() == PROJECTION_LL) {
- error(key, data,
- "scalebar is not appropriate for this projection");
- gobble_input();
- }
- PS.do_scalebar = 1;
- if (sscanf(data, "%s", sb.type) != 1)
- G_strcpy(sb.type, "f"); /* default to fancy scalebar */
- read_scalebar();
- if (sb.length <= 0.) {
- error(key, data, "Bad scalebar length");
- gobble_input();
- }
- continue;
- }
-
- if (KEY("text")) {
- double e, n;
- char east[50], north[50];
- char text[1024];
-
- if (sscanf(data, "%s %s %[^\n]", east, north, text) == 3
- && (scan_easting(east, &e) && scan_northing(north, &n)))
- read_text(east, north, text);
- else {
- gobble_input();
- error(key, data, "illegal text request");
- }
- continue;
- }
-
- if (KEY("point")) {
- double e, n;
- char east[50], north[50];
-
- if (sscanf(data, "%s %s", east, north) == 2
- && (scan_easting(east, &e) && scan_northing(north, &n)))
- read_point(e, n);
- else {
- gobble_input();
- error(key, data, "illegal point request");
- }
- continue;
- }
-
- if (KEY("eps")) {
- double e, n;
- char east[50], north[50];
-
- if (sscanf(data, "%s %s", east, north) == 2
- && (scan_easting(east, &e) && scan_northing(north, &n)))
- read_eps(e, n);
- else {
- gobble_input();
- error(key, data, "illegal eps request");
- }
- continue;
- }
-
- if (KEY("line")) {
- char east1[50], north1[50];
- char east2[50], north2[50];
- double e1, n1, e2, n2;
-
- if (sscanf(data, "%s %s %s %s", east1, north1, east2, north2) == 4
- && (scan_easting(east1, &e1) && scan_easting(east2, &e2)
- && scan_northing(north1, &n1) &&
- scan_northing(north2, &n2)))
- read_line(e1, n1, e2, n2);
- else {
- gobble_input();
- error(key, data, "illegal line request");
- }
- continue;
- }
-
- if (KEY("rectangle")) {
- char east1[50], north1[50];
- char east2[50], north2[50];
- double e1, n1, e2, n2;
-
- if (sscanf(data, "%s %s %s %s", east1, north1, east2, north2) == 4
- && (scan_easting(east1, &e1) && scan_easting(east2, &e2)
- && scan_northing(north1, &n1) &&
- scan_northing(north2, &n2)))
- read_rectangle(e1, n1, e2, n2);
- else {
- gobble_input();
- error(key, data, "illegal rectangle request");
- }
- continue;
- }
-
- if (KEY("comments")) {
- switch (sscanf(data, "%s %s", name, mapset)) {
- case 1:
- read_comment(name);
- break;
- case 2:
- error(key, data, "illegal comments request");
- break;
- default:
- read_comment("");
- break;
- }
- continue;
- }
-
- if (KEY("scale")) {
- if (!can_reset_scale)
- continue;
- if (check_scale(data))
- strcpy(PS.scaletext, data);
- else {
- PS.scaletext[0] = 0;
- error(key, data, "illegal scale request");
- }
- continue;
- }
-
- if (KEY("labels")) {
- if (scan_gis("paint/labels", "label", key, data, name, mapset, 1))
- read_labels(name, mapset);
- continue;
- }
-
- if (KEY("header")) {
- read_header();
- PS.do_header = 1;
- continue;
- }
-
- if (KEY("mapinfo")) {
- read_info();
- do_mapinfo = 1;
- continue;
- }
-
- if (KEY("vlegend")) {
- read_vlegend();
- do_vlegend = 1;
- continue;
- }
-
- if (KEY("outline")) {
- if (PS.cell_fd < 0) {
- error(key, data, "no raster map selected yet");
- gobble_input();
- }
- else
- read_outline();
- continue;
- }
-
- if (KEY("cell") || KEY("rast") || KEY("raster")) {
- if (scan_gis("cell", "raster", key, data, name, mapset, 0))
- read_cell(name, mapset);
- continue;
- }
-
- if (KEY("greyrast") || KEY("grayrast")) {
- if (scan_gis("cell", "raster", key, data, name, mapset, 0))
- read_cell(name, mapset);
- PS.grey = 1;
- continue;
- }
-
- if (KEY("group")) {
- G_strip(data);
- if (I_find_group(data)) {
- grp.group_name = G_store(data);
- grp.do_group = 1;
- read_group();
- }
- else
- error(key, data, "group not found");
- continue;
- }
-
- if (KEY("rgb")) {
- G_strip(data);
- grp.do_group = 1;
- read_rgb(key, data);
- continue;
- }
-
- if (KEY("vpoints")) {
- if (scan_gis("vector", "vector", key, data, name, mapset, 1))
- read_vpoints(name, mapset);
- continue;
- }
-
- if (KEY("vlines")) {
- if (scan_gis("vector", "vector", key, data, name, mapset, 1))
- read_vlines(name, mapset);
- continue;
- }
-
- if (KEY("vareas")) {
- if (scan_gis("vector", "vector", key, data, name, mapset, 1))
- read_vareas(name, mapset);
- continue;
- }
-
- if (KEY("window") || KEY("region")) {
- if (scan_gis("windows", "region definition", key, data, name,
- mapset, 1))
- read_wind(name, mapset);
- continue;
- }
-
- if (KEY("grid")) {
- PS.grid = -1;
- PS.grid_numbers = 0;
- sscanf(data, "%d", &PS.grid);
- if (PS.grid < 0) {
- PS.grid = 0;
- error(key, data, "illegal grid spacing");
- gobble_input();
- }
- else
- getgrid();
- continue;
- }
-
- if (KEY("geogrid")) {
- if (G_projection() == PROJECTION_XY) {
- error(key, data,
- "geogrid is not available for this projection");
- gobble_input();
- }
- /* if (G_projection() == PROJECTION_LL)
- G_message(_("geogrid referenced to [???] ellipsoid")); */
- PS.geogrid = -1.;
- PS.geogrid_numbers = 0;
- sscanf(data, "%d %s", &PS.geogrid, PS.geogridunit);
- if (PS.geogrid < 0) {
- PS.geogrid = 0;
- error(key, data, "illegal geo-grid spacing");
- gobble_input();
- }
- else
- getgeogrid();
- continue;
- }
-
- if (KEY("psfile")) {
- if (PS.num_psfiles >= MAX_PSFILES)
- continue;
- G_strip(data);
- PS.psfiles[PS.num_psfiles] = G_store(data);
- PS.num_psfiles++;
- continue;
- }
-
- if (KEY("maskcolor")) {
- int ret, r, g, b;
-
- ret = G_str_to_color(data, &r, &g, &b);
- if (ret == 1) {
- PS.mask_r = r / 255.0;
- PS.mask_g = g / 255.0;
- PS.mask_b = b / 255.0;
- PS.mask_color = 1;
- continue;
- }
- else if (ret == 2) { /* none */
- continue;
- }
- else {
- error(key, data, "illegal color request");
- }
- }
-
- if (*key)
- error(key, "", "illegal request");
- }
-
+
+ read_instructions(inputfd, &PS, copies_set, ps_copies, can_reset_scale,
+ &sb, &do_mapinfo, &do_vlegend, &grp);
+
/* reset map location base on 'paper' on 'location' */
reset_map_location();
+
+ if (bflag->answer) {
+ map_setup();
+ fprintf(stdout, "bbox=%.3f,%.3f,%.3f,%.3f\n", PS.map_left / 72.0,
+ PS.page_height - (PS.map_bot / 72.0), PS.map_right / 72.0,
+ PS.page_height - (PS.map_top / 72.0));
+ /* +/- 0.5 ? see ps.map.c brd.* */
+ unlink(output_file->answer); /* fixme: don't open it in the first place */
+ exit(EXIT_SUCCESS);
+ }
/* write the PostScript output file */
ps_mask_file = G_tempfile();
ps_map();
- G_message(_("PostScript file [%s] successfully written."),
- output_file->answer);
+ G_done_msg(_("PostScript file '%s' successfully written."),
+ output_file->answer);
/* cleanup the tempfiles */
unlink(ps_mask_file);
Modified: grass/branches/develbranch_6/ps/ps.map/map_info.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/map_info.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/map_info.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -3,7 +3,6 @@
** Author: Paul W. Carlson April 1992
*/
-#include "ps_info.h"
#include "map_info.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/map_setup.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/map_setup.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/map_setup.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,8 +5,6 @@
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "ps_info.h"
-#include "group.h"
#include "local_proto.h"
#include "distance.h"
@@ -85,7 +83,7 @@
PS.map_pix_wide);
}
- G_message(_("Scale set to %s."), PS.scaletext);
+ G_message(_("Scale set to %s"), PS.scaletext);
/* compute map edges */
PS.map_left = 72.0 * PS.map_x_orig;
@@ -106,8 +104,9 @@
*/
/* save original graphics state */
- fprintf(PS.fp, "gsave ");
-
+ if (PS.fp)
+ fprintf(PS.fp, "gsave ");
+
/* compute conversion factor from meters to PostScript window coordinates */
/*
G_begin_distance_calculations();
Modified: grass/branches/develbranch_6/ps/ps.map/outl_io.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/outl_io.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/outl_io.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "ps_info.h"
#include "local_proto.h"
static int blank_line();
Modified: grass/branches/develbranch_6/ps/ps.map/ps_clrtbl.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_clrtbl.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_clrtbl.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -4,7 +4,6 @@
*/
#include <grass/glocale.h>
-#include "ps_info.h"
#include "colortable.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_colors.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_colors.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_colors.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,7 +5,6 @@
#include <stdio.h>
#include <string.h>
-#include "ps_info.h"
#include "local_proto.h"
#include "clr.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_fclrtbl.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_fclrtbl.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_fclrtbl.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <string.h>
#include <grass/glocale.h>
-#include "ps_info.h"
#include "colortable.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_map.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_map.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_map.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -7,9 +7,7 @@
#include <stdio.h>
#include <unistd.h>
-#include "ps_info.h"
#include "vector.h"
-#include "group.h"
#include "border.h"
#include "colortable.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_outline.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_outline.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_outline.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -8,7 +8,6 @@
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "ps_info.h"
#include "local_proto.h"
static int k, col, row, top, bottom;
Modified: grass/branches/develbranch_6/ps/ps.map/ps_raster.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_raster.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_raster.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -13,8 +13,6 @@
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "ps_info.h"
-#include "group.h"
#include "local_proto.h"
static FILE *ps_mask_fp;
@@ -100,10 +98,11 @@
/* let user know what's happenning */
if (PS.do_raster)
- G_message(_("Reading raster map <%s in %s> ..."),
- PS.cell_name, PS.cell_mapset);
+ G_message(_("Reading raster map <%s>..."),
+ G_fully_qualified_name(PS.cell_name, PS.cell_mapset));
else
- G_message(_("Reading raster maps in group <%s> ..."), grp.group_name);
+ G_message(_("Reading raster maps in group <%s>..."),
+ grp.group_name);
/* build the image RGB string */
if (PS.do_raster) {
Modified: grass/branches/develbranch_6/ps/ps.map/ps_vareas.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_vareas.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_vareas.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <grass/dbmi.h>
#include "vector.h"
-#include "ps_info.h"
#include "clr.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_vlegend.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_vlegend.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_vlegend.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
*/
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
int PS_vlegend(void)
Modified: grass/branches/develbranch_6/ps/ps.map/ps_vlines.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_vlines.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_vlines.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <grass/Vect.h>
#include <grass/dbmi.h>
-#include "ps_info.h"
#include "clr.h"
#include "local_proto.h"
#include "vector.h"
Modified: grass/branches/develbranch_6/ps/ps.map/ps_vpoints.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/ps_vpoints.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/ps_vpoints.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <grass/symbol.h>
#include <grass/glocale.h>
-#include "ps_info.h"
#include "clr.h"
#include "local_proto.h"
#include "vector.h"
Modified: grass/branches/develbranch_6/ps/ps.map/r_border.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_border.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_border.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
#include "border.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_cell.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_cell.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_cell.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,7 +5,6 @@
*/
#include <string.h>
-#include "ps_info.h"
#include "local_proto.h"
int read_cell(char *name, char *mapset)
Modified: grass/branches/develbranch_6/ps/ps.map/r_colortable.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_colortable.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_colortable.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -7,7 +7,6 @@
#include <string.h>
#include <grass/glocale.h>
#include "colortable.h"
-#include "ps_info.h"
#include "clr.h"
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/r_group.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_group.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_group.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,8 +6,6 @@
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
-#include "ps_info.h"
-#include "group.h"
#include "local_proto.h"
int read_group(void)
Modified: grass/branches/develbranch_6/ps/ps.map/r_header.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_header.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_header.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
#include "header.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_info.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_info.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_info.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
#include "map_info.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Copied: grass/branches/develbranch_6/ps/ps.map/r_instructions.c (from rev 45585, grass/trunk/ps/ps.map/r_instructions.c)
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_instructions.c (rev 0)
+++ grass/branches/develbranch_6/ps/ps.map/r_instructions.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -0,0 +1,464 @@
+#include <string.h>
+
+#include <grass/colors.h>
+#include <grass/imagery.h>
+#include <grass/glocale.h>
+
+#include "local_proto.h"
+
+#define KEY(x) (strcmp(key,x)==0)
+
+static char *help[] = {
+ "rast rastermap setcolor val_range(s) color",
+ "vpoints vector points map scalebar [f|s]",
+ "vlines vector lines map paper [a4|a3|us-letter|...]",
+ "vareas vector areas map maploc x y [width height]",
+ "labels labelfile text east north text",
+ "region regionfile line east north east north",
+ "grid spacing point east north",
+ "geogrid spacing header",
+ "outline mapinfo",
+ "colortable [y|n] vlegend",
+ "comments [unix-file] psfile PostScript include file",
+ "read unix-file eps Encapsulated PostScript file",
+ "rectangle east north east north",
+ "scale 1:#|# inches|# panels|1 inch = # miles",
+ "border [y|n]",
+ ""
+};
+
+void read_instructions(FILE *inputfd, struct PS_data *PS,
+ int copies_set, int ps_copies, int can_reset_scale,
+ struct scalebar *sb, int *do_mapinfo, int *do_vlegend,
+ struct PS_group *grp)
+{
+ int i;
+ int iflag;
+ char name[GNAME_MAX], mapset[GMAPSET_MAX];
+ char buf[1024];
+
+ iflag = 0;
+
+ while (1) {
+ char *key;
+ char *data;
+
+ if (!input(1, buf, help)) {
+ if (!iflag) {
+ if (G_getl2(buf, 12, inputfd))
+ G_warning(_("Data exists after final 'end' instruction!"));
+ break;
+ }
+ iflag = 0;
+ continue;
+ }
+ if (!key_data(buf, &key, &data))
+ continue;
+
+ if (KEY("read")) {
+ if (inputfd != stdin)
+ fclose(inputfd);
+
+ if (sscanf(data, "%s", name) != 1) {
+ error(key, data, "no file specified");
+ inputfd = stdin;
+ }
+ else if ((inputfd = fopen(name, "r")) == NULL) {
+ error(key, data, "unable to open");
+ inputfd = stdin;
+ }
+ else
+ iflag = 1;
+ continue;
+ }
+
+ if (KEY("paper")) {
+ if (strlen(data) > 0) {
+ set_paper(data);
+ }
+ read_paper();
+
+ continue;
+ }
+
+ if (KEY("maploc")) {
+ int n;
+ double x, y, w, h;
+
+ n = sscanf(data, "%lf %lf %lf %lf", &x, &y, &w, &h);
+ if (n == 2 || n == 4) {
+ PS->map_x_orig = x;
+ PS->map_y_loc = y;
+ if (n == 4) {
+ PS->map_width = w;
+ PS->map_height = h;
+ }
+ }
+ else {
+ error(key, data, "illegal maploc request");
+ gobble_input();
+ }
+ continue;
+ }
+
+ if (KEY("copies")) {
+ int n, copies;
+
+ if (copies_set)
+ continue;
+ n = sscanf(data, "%d", &copies);
+ if (n != 1 || copies < 1 || copies > 20) {
+ ps_copies = 1;
+ error(key, data, "illegal copies request");
+ }
+ ps_copies = copies;
+ continue;
+ }
+
+ if (KEY("setcolor")) {
+ float R, G, B;
+ int r, g, b;
+ int color;
+ int count;
+ DCELL *val_list;
+ DCELL dmin, dmax;
+ char colorbuf[100];
+ char catsbuf[100];
+
+ if (PS->cell_fd < 0) {
+ error(key, data, "no raster map selected yet");
+ continue;
+ }
+ if (sscanf(data, "%s %[^\n]", catsbuf, colorbuf) == 2) {
+ color = get_color_number(colorbuf);
+ if (color < 0) {
+ error(key, data, "illegal color");
+ continue;
+ }
+ get_color_rgb(color, &R, &G, &B);
+ r = 255.0 * R;
+ g = 255.0 * G;
+ b = 255.0 * B;
+
+ if (strncmp(catsbuf, "null", 4) == 0) {
+ G_set_null_value_color(r, g, b, &(PS->colors));
+ continue;
+ }
+ if (strncmp(catsbuf, "default", 7) == 0) {
+ G_set_default_color(r, g, b, &(PS->colors));
+ continue;
+ }
+ if ((count = parse_val_list(catsbuf, &val_list)) < 0) {
+ error(key, data, "illegal value list");
+ continue;
+ }
+ for (i = 0; i < count; i += 2) {
+ dmin = val_list[i];
+ dmax = val_list[i + 1];
+ G_add_d_raster_color_rule(&dmin, r, g, b, &dmax, r, g, b,
+ &(PS->colors));
+ }
+ G_free(val_list);
+ }
+ continue;
+ }
+
+ if (KEY("colortable")) {
+ PS->do_colortable = 0;
+ /*
+ if (PS->cell_fd < 0)
+ error(key, data, "no raster map selected yet");
+ else
+ */
+ PS->do_colortable = yesno(key, data);
+ if (PS->do_colortable)
+ read_colortable();
+ continue;
+ }
+
+ if (KEY("border")) {
+ PS->do_border = yesno(key, data);
+ if (PS->do_border)
+ read_border();
+ continue;
+ }
+
+ if (KEY("scalebar")) {
+ if (G_projection() == PROJECTION_LL) {
+ error(key, data,
+ "scalebar is not appropriate for this projection");
+ gobble_input();
+ }
+ PS->do_scalebar = 1;
+ if (sscanf(data, "%s", sb->type) != 1)
+ strcpy(sb->type, "f"); /* default to fancy scalebar */
+ read_scalebar();
+ if (sb->length <= 0.) {
+ error(key, data, "Bad scalebar length");
+ gobble_input();
+ }
+ continue;
+ }
+
+ if (KEY("text")) {
+ double e, n;
+ char east[50], north[50];
+ char text[1024];
+
+ if (sscanf(data, "%s %s %[^\n]", east, north, text) == 3
+ && (scan_easting(east, &e) && scan_northing(north, &n)))
+ read_text(east, north, text);
+ else {
+ gobble_input();
+ error(key, data, "illegal text request");
+ }
+ continue;
+ }
+
+ if (KEY("point")) {
+ double e, n;
+ char east[50], north[50];
+
+ if (sscanf(data, "%s %s", east, north) == 2
+ && (scan_easting(east, &e) && scan_northing(north, &n)))
+ read_point(e, n);
+ else {
+ gobble_input();
+ error(key, data, "illegal point request");
+ }
+ continue;
+ }
+
+ if (KEY("eps")) {
+ double e, n;
+ char east[50], north[50];
+
+ if (sscanf(data, "%s %s", east, north) == 2
+ && (scan_easting(east, &e) && scan_northing(north, &n)))
+ read_eps(e, n);
+ else {
+ gobble_input();
+ error(key, data, "illegal eps request");
+ }
+ continue;
+ }
+
+ if (KEY("line")) {
+ char east1[50], north1[50];
+ char east2[50], north2[50];
+ double e1, n1, e2, n2;
+
+ if (sscanf(data, "%s %s %s %s", east1, north1, east2, north2) == 4
+ && (scan_easting(east1, &e1) && scan_easting(east2, &e2)
+ && scan_northing(north1, &n1) &&
+ scan_northing(north2, &n2)))
+ read_line(e1, n1, e2, n2);
+ else {
+ gobble_input();
+ error(key, data, "illegal line request");
+ }
+ continue;
+ }
+
+ if (KEY("rectangle")) {
+ char east1[50], north1[50];
+ char east2[50], north2[50];
+ double e1, n1, e2, n2;
+
+ if (sscanf(data, "%s %s %s %s", east1, north1, east2, north2) == 4
+ && (scan_easting(east1, &e1) && scan_easting(east2, &e2)
+ && scan_northing(north1, &n1) &&
+ scan_northing(north2, &n2)))
+ read_rectangle(e1, n1, e2, n2);
+ else {
+ gobble_input();
+ error(key, data, "illegal rectangle request");
+ }
+ continue;
+ }
+
+ if (KEY("comments")) {
+ switch (sscanf(data, "%s %s", name, mapset)) {
+ case 1:
+ read_comment(name);
+ break;
+ case 2:
+ error(key, data, "illegal comments request");
+ break;
+ default:
+ read_comment("");
+ break;
+ }
+ continue;
+ }
+
+ if (KEY("scale")) {
+ if (!can_reset_scale)
+ continue;
+ if (check_scale(data))
+ strcpy(PS->scaletext, data);
+ else {
+ PS->scaletext[0] = 0;
+ error(key, data, "illegal scale request");
+ }
+ continue;
+ }
+
+ if (KEY("labels")) {
+ if (scan_gis("paint/labels", "label", key, data, name, mapset, 1))
+ read_labels(name, mapset);
+ continue;
+ }
+
+ if (KEY("header")) {
+ read_header();
+ PS->do_header = 1;
+ continue;
+ }
+
+ if (KEY("mapinfo")) {
+ read_info();
+ *do_mapinfo = 1;
+ continue;
+ }
+
+ if (KEY("vlegend")) {
+ read_vlegend();
+ *do_vlegend = 1;
+ continue;
+ }
+
+ if (KEY("outline")) {
+ if (PS->cell_fd < 0) {
+ error(key, data, "no raster map selected yet");
+ gobble_input();
+ }
+ else
+ read_outline();
+ continue;
+ }
+
+ if (KEY("cell") || KEY("rast") || KEY("raster")) {
+ if (scan_gis("cell", "raster", key, data, name, mapset, 0))
+ read_cell(name, mapset);
+ continue;
+ }
+
+ if (KEY("greyrast") || KEY("grayrast")) {
+ if (scan_gis("cell", "raster", key, data, name, mapset, 0))
+ read_cell(name, mapset);
+ PS->grey = 1;
+ continue;
+ }
+
+ if (KEY("group")) {
+ G_strip(data);
+ if (I_find_group(data)) {
+ grp->group_name = G_store(data);
+ grp->do_group = 1;
+ read_group();
+ }
+ else
+ error(key, data, "group not found");
+ continue;
+ }
+
+ if (KEY("rgb")) {
+ G_strip(data);
+ grp->do_group = 1;
+ read_rgb(key, data);
+ continue;
+ }
+
+ if (KEY("vpoints")) {
+ if (scan_gis("vector", "vector", key, data, name, mapset, 1))
+ read_vpoints(name, mapset);
+ continue;
+ }
+
+ if (KEY("vlines")) {
+ if (scan_gis("vector", "vector", key, data, name, mapset, 1))
+ read_vlines(name, mapset);
+ continue;
+ }
+
+ if (KEY("vareas")) {
+ if (scan_gis("vector", "vector", key, data, name, mapset, 1))
+ read_vareas(name, mapset);
+ continue;
+ }
+
+ if (KEY("window") || KEY("region")) {
+ if (scan_gis("windows", "region definition", key, data, name,
+ mapset, 1))
+ read_wind(name, mapset);
+ continue;
+ }
+
+ if (KEY("grid")) {
+ PS->grid = -1;
+ PS->grid_numbers = 0;
+ sscanf(data, "%d", &(PS->grid));
+ if (PS->grid < 0) {
+ PS->grid = 0;
+ error(key, data, "illegal grid spacing");
+ gobble_input();
+ }
+ else
+ getgrid();
+ continue;
+ }
+
+ if (KEY("geogrid")) {
+ if (G_projection() == PROJECTION_XY) {
+ error(key, data,
+ "geogrid is not available for this projection");
+ gobble_input();
+ }
+ /* if (G_projection() == PROJECTION_LL)
+ G_message(_("geogrid referenced to [???] ellipsoid")); */
+ PS->geogrid = -1.;
+ PS->geogrid_numbers = 0;
+ sscanf(data, "%d %s", &(PS->geogrid), PS->geogridunit);
+ if (PS->geogrid < 0) {
+ PS->geogrid = 0;
+ error(key, data, "illegal geo-grid spacing");
+ gobble_input();
+ }
+ else
+ getgeogrid();
+ continue;
+ }
+
+ if (KEY("psfile")) {
+ if (PS->num_psfiles >= MAX_PSFILES)
+ continue;
+ G_strip(data);
+ PS->psfiles[PS->num_psfiles] = G_store(data);
+ PS->num_psfiles++;
+ continue;
+ }
+
+ if (KEY("maskcolor")) {
+ int ret, r, g, b;
+
+ ret = G_str_to_color(data, &r, &g, &b);
+ if (ret == 1) {
+ PS->mask_r = r / 255.0;
+ PS->mask_g = g / 255.0;
+ PS->mask_b = b / 255.0;
+ PS->mask_color = 1;
+ continue;
+ }
+ else if (ret == 2) { /* none */
+ continue;
+ }
+ else {
+ error(key, data, "illegal color request");
+ }
+ }
+
+ if (*key)
+ error(key, "", "illegal request");
+ }
+}
Modified: grass/branches/develbranch_6/ps/ps.map/r_paper.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_paper.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_paper.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
#include "map_info.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_plt.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_plt.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_plt.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -1,5 +1,4 @@
#include <string.h>
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x)(strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_rgb.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_rgb.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_rgb.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -5,8 +5,6 @@
*/
#include <string.h>
-#include "ps_info.h"
-#include "group.h"
#include "local_proto.h"
int read_rgb(char *key, char *data)
Modified: grass/branches/develbranch_6/ps/ps.map/r_text.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_text.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_text.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -8,7 +8,6 @@
#include <string.h>
#include "clr.h"
#include "labels.h"
-#include "ps_info.h"
#include "local_proto.h"
#define EQ(x,y) (strcmp(x,y)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_vareas.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_vareas.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_vareas.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -12,7 +12,6 @@
#include <grass/Vect.h>
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_vlegend.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_vlegend.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_vlegend.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <stdlib.h>
#include <string.h>
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_vlines.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_vlines.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_vlines.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <string.h>
#include <grass/Vect.h>
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_vpoints.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_vpoints.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_vpoints.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -13,7 +13,6 @@
#include <grass/Vect.h>
#include <grass/glocale.h>
#include "vector.h"
-#include "ps_info.h"
#include "local_proto.h"
#define KEY(x) (strcmp(key,x)==0)
Modified: grass/branches/develbranch_6/ps/ps.map/r_wind.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/r_wind.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/r_wind.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -1,5 +1,4 @@
/* parse the "region" instruction */
-#include "ps_info.h"
#include <string.h>
#include "local_proto.h"
Modified: grass/branches/develbranch_6/ps/ps.map/scale.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/scale.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/scale.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -10,7 +10,6 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include "local_proto.h"
-#include "ps_info.h"
#include "distance.h"
#define PWIDTH (PS.page_width-PS.left_marg-PS.right_marg)
Modified: grass/branches/develbranch_6/ps/ps.map/symbol.c
===================================================================
--- grass/branches/develbranch_6/ps/ps.map/symbol.c 2011-03-06 11:57:18 UTC (rev 45585)
+++ grass/branches/develbranch_6/ps/ps.map/symbol.c 2011-03-06 12:29:19 UTC (rev 45586)
@@ -6,7 +6,6 @@
#include <grass/Vect.h>
#include <grass/symbol.h>
#include "clr.h"
-#include "ps_info.h"
#include "local_proto.h"
#include "vector.h"
More information about the grass-commit
mailing list