18 #include <grass/gis.h>
21 #define DATE_FORMAT "%c"
31 static int left, right, bot, top;
40 static const struct paper papers[] = {
42 {
"a4", 8.268, 11.693, 0.5, 0.5, 1.0, 1.0},
43 {
"a3", 11.693, 16.535, 0.5, 0.5, 1.0, 1.0},
44 {
"a2", 16.54, 23.39, 1.0, 1.0, 1.0, 1.0},
45 {
"a1", 23.39, 33.07, 1.0, 1.0, 1.0, 1.0},
46 {
"a0", 33.07, 46.77, 1.0, 1.0, 1.0, 1.0},
47 {
"us-legal", 8.5, 14.0, 1.0, 1.0, 1.0, 1.0},
48 {
"us-letter", 8.5, 11.0, 1.0, 1.0, 1.0, 1.0},
49 {
"us-tabloid", 11.0, 17.0, 1.0, 1.0, 1.0, 1.0},
50 {
NULL, 0, 0, 0, 0, 0, 0}
53 static void write_prolog(
void)
55 char prolog_file[GPATH_MAX];
58 time_t t = time(
NULL);
61 strftime(date_str,
sizeof(date_str),
DATE_FORMAT, tm);
65 prolog_fp = fopen(prolog_file,
"r");
70 output(
"%%!PS-Adobe-3.0 EPSF-3.0\n");
72 output(
"%%!PS-Adobe-3.0\n");
74 output(
"%%%%LanguageLevel: %d\n", 3);
75 output(
"%%%%Creator: GRASS PS Driver\n");
78 output(
"%%%%Orientation: %s\n", landscape ?
"Landscape" :
"Portrait");
79 output(
"%%%%BoundingBox: %d %d %d %d\n", left, bot, right, top);
80 output(
"%%%%CreationDate: %s\n", date_str);
81 output(
"%%%%EndComments\n");
83 output(
"%%%%BeginProlog\n");
84 while (!feof(prolog_fp)) {
87 if (!fgets(buf,
sizeof(buf), prolog_fp))
99 output(
"%%%%BeginSetup\n");
101 output(
"%d %d translate\n", left, bot);
104 output(
"90 rotate 0 1 -1 scale\n");
111 output(
"%%%%Page: 1 1\n");
114 static int in2pt(
double x)
116 return (
int)(x * 72);
119 static void swap(
int *x,
int *
y)
127 static void get_paper(
void)
176 G_gisinit(
"PS driver");
178 p =
getenv(
"GRASS_PSFILE");
179 if (!p || strlen(p) == 0)
186 p =
getenv(
"GRASS_TRUECOLOR");
189 p =
getenv(
"GRASS_LANDSCAPE");
190 landscape = p && strcmp(p,
"TRUE") == 0;
192 p =
getenv(
"GRASS_PS_HEADER");
193 no_header = p && strcmp(p,
"FALSE") == 0;
195 p =
getenv(
"GRASS_PS_TRAILER");
198 G_message(
"PS: GRASS_TRUECOLOR status: %s",
216 (
"PS: collecting to file: %s,\n GRASS_WIDTH=%d, GRASS_HEIGHT=%d",
229 vfprintf(
outfp, fmt, va);
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void init_color_table(void)
void G_message(const char *msg,...)
Print a message to stderr.
int PS_Graph_set(int argc, char **argv)
char * G_whoami(void)
Gets user's name.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
char * G_gisbase(void)
top level module directory
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void output(const char *fmt,...)