24 #define DATE_FORMAT "%c"
28 static double width, height;
34 double left, right, bot, top;
37 static const struct paper papers[] = {
39 {
"a4", 8.268, 11.693, 0.5, 0.5, 1.0, 1.0},
40 {
"a3", 11.693, 16.535, 0.5, 0.5, 1.0, 1.0},
41 {
"a2", 16.54, 23.39, 1.0, 1.0, 1.0, 1.0},
42 {
"a1", 23.39, 33.07, 1.0, 1.0, 1.0, 1.0},
43 {
"a0", 33.07, 46.77, 1.0, 1.0, 1.0, 1.0},
44 {
"us-legal", 8.5, 14.0, 1.0, 1.0, 1.0, 1.0},
45 {
"us-letter", 8.5, 11.0, 1.0, 1.0, 1.0, 1.0},
46 {
"us-tabloid", 11.0, 17.0, 1.0, 1.0, 1.0, 1.0},
47 {
NULL, 0, 0, 0, 0, 0, 0}};
49 static void write_prolog(
void)
54 time_t
t = time(
NULL);
55 struct tm *tm = localtime(&
t);
57 strftime(date_str,
sizeof(date_str),
DATE_FORMAT, tm);
59 snprintf(prolog_file,
sizeof(prolog_file),
"%s/etc/psdriver.ps",
62 prolog_fp = fopen(prolog_file,
"r");
67 output(
"%%!PS-Adobe-3.0 EPSF-3.0\n");
69 output(
"%%!PS-Adobe-3.0\n");
71 output(
"%%%%LanguageLevel: %d\n", 3);
72 output(
"%%%%Creator: GRASS PS Driver\n");
75 output(
"%%%%Orientation: %s\n", landscape ?
"Landscape" :
"Portrait");
76 output(
"%%%%BoundingBox: %d %d %d %d\n", (
int)floor(
ps.
left),
78 output(
"%%%%CreationDate: %s\n", date_str);
79 output(
"%%%%EndComments\n");
81 output(
"%%%%BeginProlog\n");
82 while (!feof(prolog_fp)) {
85 if (!fgets(buf,
sizeof(buf), prolog_fp))
97 output(
"%%%%BeginSetup\n");
102 output(
"90 rotate 0 1 -1 scale\n");
104 output(
"0 %.1f translate 1 -1 scale\n", height);
106 output(
"%.1f %.1f BEGIN\n", width, height);
109 output(
"%%%%Page: 1 1\n");
112 static double in2pt(
double x)
117 static void swap(
double *
x,
double *y)
125 static void get_paper(
void)
127 const char *
name = getenv(
"GRASS_RENDER_PS_PAPER");
128 const struct paper *paper;
155 ps.
left = in2pt(paper->left);
156 ps.
right = in2pt(paper->width) - in2pt(paper->right);
157 ps.
bot = in2pt(paper->bot);
158 ps.
top = in2pt(paper->height) - in2pt(paper->top);
161 height = in2pt(paper->height) - in2pt(paper->top) - in2pt(paper->bot);
164 swap(&width, &height);
176 p = getenv(
"GRASS_RENDER_FILE");
177 if (!p || strlen(p) == 0)
184 p = getenv(
"GRASS_RENDER_TRUECOLOR");
187 p = getenv(
"GRASS_RENDER_PS_LANDSCAPE");
188 landscape = p && strcmp(p,
"TRUE") == 0;
190 p = getenv(
"GRASS_RENDER_PS_HEADER");
193 p = getenv(
"GRASS_RENDER_PS_TRAILER");
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int G_rename_file(const char *, const char *)
Rename a file or a directory in the filesystem.
void void G_verbose_message(const char *,...) __attribute__((format(printf
const char * G_whoami(void)
Gets user's name.
char * G_tempfile(void)
Returns a temporary file name.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
const char * G_gisbase(void)
Get full path name of the top level module directory.
GRASS_DRIVER_EXPORT int screen_height
GRASS_DRIVER_EXPORT int screen_width
const char * PS_Graph_get_file(void)
Get render file.
void output(const char *fmt,...)