File: ps_map.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (151 lines) | stat: -rw-r--r-- 3,420 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* Function: ps_map
**
** This function writes the PostScript output file.
**
** Author: Paul W. Carlson	March 1992
*/

#include <stdio.h>
#include <unistd.h>
#include "ps_info.h"
#include "vector.h"
#include "group.h"
#include "colortable.h"
#include "local_proto.h"

extern int verbose;
extern int do_mapinfo;
extern int do_vlegend;
extern int eps_output;
extern int rotate_plot;
extern int ps_copies;

int ps_map (void)
{
    long current_offset;
    char *date;
    int urx, ury;

    /* get date */
    date = G_date();

    /* write the PostScript header */
    write_PS_header();

    /* create the PostScript procs */
    make_procs();

    /* set number of copies */
    if (ps_copies > 1) fprintf(PS.fp, "/#copies %d def\n", ps_copies);

    /* Set page size */
    if ( !eps_output ) {
	if(!rotate_plot) {
	    urx = (int) 72.0 * PS.page_width;
	    ury = (int) 72.0 * PS.page_height;
	} else {
	    urx = (int) 72.0 * PS.page_height;
	    ury = (int) 72.0 * PS.page_width;
	}
	fprintf(PS.fp, "<< /PageSize [  %d %d ] >> setpagedevice\n", urx, ury);
    }
    
    /* rotate map? */
    if (rotate_plot)
    {
    	fprintf(PS.fp, "%.2f 0.0 TR\n", 72.0 * PS.page_height);
    	fprintf(PS.fp, "90 rotate\n");
    }

    /* do the map header */
    if (PS.do_header) do_map_header(date);

    /* size the map */
    map_setup();

    /* do the raster stuff, if any */
    if (PS.do_raster || grp.do_group) PS_raster_plot();

    /* do the outline, if requested */
    if (PS.do_outline) ps_outline();

    /* do the masked vector plots, if any */
    if (vector.count) do_vectors(0);

    /* do the masked ponts/lines, if any */
    do_plt(0);

    /* do masking, if required */
    PS_make_mask();
    if (PS.mask_needed) 
        do_masking();

    /* do the unmasked vector plots, if any */
    if (vector.count) do_vectors(1);

    /* do the grid, if any */
    if (PS.grid_cross)
	    do_grid_cross();
    else
	    do_grid();

    /* do geo-grid, if any */
    do_geogrid();

    /* do the grid numbers, if any */
    if (PS.grid_numbers > 0) do_grid_numbers();
    if (PS.geogrid_numbers > 0) do_geogrid_numbers();

    /* do the labels from paint/labels, if any */
    do_labels(0);

    /* restore the unclipped graphics state */
    fprintf(PS.fp, "grestore ");

    /* do the unmasked points, lines and eps if any */
    do_plt(1);

    /* do the labels specified in script file */
    do_labels(1);

    /* show the map info */
    if (do_mapinfo) map_info();

    /* show the vector legend */
    if (do_vlegend && vector.count) PS_vlegend();
   
   /* Make scalebar */ 
    if (PS.do_scalebar) do_scalebar();

    /* put border around map */
    fprintf(PS.fp, "BW\n");
    box_draw(PS.map_top  - 0.5, PS.map_bot   + 0.5, 
	     PS.map_left + 0.5, PS.map_right - 0.5);

    /* do the colortable, if requested */
    if (PS.do_colortable) {
	if ( G_raster_map_is_fp(ct.name, ct.mapset) ) 
       	    PS_fcolortable();
	else
            PS_colortable();
    }

    /* do comments, if any */
    if (PS.commentfile != NULL) do_comment();

    /* do any PostScript include files */
    if (PS.num_psfiles) do_psfiles();

    /* write the bounding box */
    current_offset = ftell(PS.fp);
    write_bounding_box();
    fseek(PS.fp, current_offset, SEEK_SET);

    fprintf(PS.fp, "showpage\n");
    fprintf(PS.fp, "%%%%Trailer\n");
    fprintf(PS.fp, "%%%%EOF\n");
    fclose(PS.fp);

    return 0;
}