24 #define DATE_FORMAT "%c" 28 static double width, height;
35 double left, right, bot, top;
38 static const struct paper papers[] = {
40 {
"a4", 8.268, 11.693, 0.5, 0.5, 1.0, 1.0},
41 {
"a3", 11.693, 16.535, 0.5, 0.5, 1.0, 1.0},
42 {
"a2", 16.54, 23.39, 1.0, 1.0, 1.0, 1.0},
43 {
"a1", 23.39, 33.07, 1.0, 1.0, 1.0, 1.0},
44 {
"a0", 33.07, 46.77, 1.0, 1.0, 1.0, 1.0},
45 {
"us-legal", 8.5, 14.0, 1.0, 1.0, 1.0, 1.0},
46 {
"us-letter", 8.5, 11.0, 1.0, 1.0, 1.0, 1.0},
47 {
"us-tabloid", 11.0, 17.0, 1.0, 1.0, 1.0, 1.0},
48 {
NULL, 0, 0, 0, 0, 0, 0}
51 static void write_prolog(
void)
56 time_t
t = time(
NULL);
59 strftime(date_str,
sizeof(date_str),
DATE_FORMAT, tm);
61 sprintf(prolog_file,
"%s/etc/psdriver.ps",
G_gisbase());
63 prolog_fp = fopen(prolog_file,
"r");
68 output(
"%%!PS-Adobe-3.0 EPSF-3.0\n");
70 output(
"%%!PS-Adobe-3.0\n");
72 output(
"%%%%LanguageLevel: %d\n", 3);
73 output(
"%%%%Creator: GRASS PS Driver\n");
76 output(
"%%%%Orientation: %s\n", landscape ?
"Landscape" :
"Portrait");
77 output(
"%%%%BoundingBox: %d %d %d %d\n",
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");
104 output(
"90 rotate 0 1 -1 scale\n");
106 output(
"0 %.1f translate 1 -1 scale\n", height);
108 output(
"%.1f %.1f BEGIN\n", width, height);
111 output(
"%%%%Page: 1 1\n");
114 static double in2pt(
double x)
119 static void swap(
double *x,
double *y)
127 static void get_paper(
void)
129 const char *
name =
getenv(
"GRASS_RENDER_PS_PAPER");
130 const struct paper *paper;
157 ps.
left = in2pt(paper->left);
158 ps.
right = in2pt(paper->width) - in2pt(paper->right);
159 ps.
bot = in2pt(paper->bot);
160 ps.
top = in2pt(paper->height) - in2pt(paper->top);
163 height = in2pt(paper->height) - in2pt(paper->top) - in2pt(paper->bot);
166 swap(&width, &height);
178 p =
getenv(
"GRASS_RENDER_FILE");
179 if (!p || strlen(p) == 0)
186 p =
getenv(
"GRASS_RENDER_TRUECOLOR");
189 p =
getenv(
"GRASS_RENDER_PS_LANDSCAPE");
190 landscape = p && strcmp(p,
"TRUE") == 0;
192 p =
getenv(
"GRASS_RENDER_PS_HEADER");
195 p =
getenv(
"GRASS_RENDER_PS_TRAILER");
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
const char * G_whoami(void)
Gets user's name.
const char * PS_Graph_get_file(void)
Get render file.
int G_rename_file(const char *, const char *)
Rename a file or a directory in the filesystem.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
char * G_tempfile(void)
Returns a temporary file name.
void output(const char *fmt,...)
const char * G_gisbase(void)
Get full path name of the top level module directory.
void void G_verbose_message(const char *,...) __attribute__((format(printf