Mapper
draw_map.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 
5 void draw_map(Drawable pix,int h,int display_flag)
6 
7 {
8 extern struct maplayer *smaplayer[100];
9 extern int off[100],npoint[2],zoom;
10 extern GC gc;
11 extern unsigned long cmap[16];
12 extern Widget drawing_area;
13 extern Display *display;
14 extern Font font[10];
15 extern XFontStruct *info_font[10];
16 struct maplayer *maplayer;
17 int i,mapno,ind,xc,yc,text_width,length,no;
18 int x1,y1,xadd,yadd,color,izoom,MY=10;
19 float xrat,yrat,mult,dmult,cmult;
20 long xmin,xmax,ymin,ymax;
21 signed long xcen,ycen,lint1,lint2;
22 Dimension width,height;
23 Arg args[10];
24 signed long XSIZE,YSIZE;
25 extern struct display_set display_set[4];
26 XPoint point[10000];
27 int line_width,line_style,cap_style,join_style;
28 int yheight;
29 int offset;
30 
31 XSetFont(display,gc,font[0]);
32 
33 yheight=info_font[0]->ascent/2;
34 line_width=0;
35 line_style=LineSolid;
36 cap_style=CapButt;
37 join_style=JoinMiter;
38 
39 XSetFillRule(display,gc,WindingRule);
40 XSetLineAttributes(display,gc,line_width,line_style,cap_style,
41  join_style);
42 
43 XtSetArg(args[0],XtNwidth,&width);
44 XtSetArg(args[1],XtNheight,&height);
45 XtGetValues(drawing_area,args,2);
46 
47 XSIZE=(long)width*10L;
48 YSIZE=(long)height*10L;
49 
50 xrat=(float)XSIZE/(float)12800;
51 yrat=(float)YSIZE/(float)9600;
52 
53 if(xrat < yrat)
54  mult=xrat;
55 
56 else
57  mult=yrat;
58 
66 
67 for(mapno=0;mapno < 100;mapno++) {
68 
69 if(smaplayer[mapno]==NULL)
70  break;
71 
72 if(off[mapno] ==-1)
73  continue;
74 
75 maplayer=smaplayer[mapno]; /*beginning of map buffer #mapno */
76 
77 ind=0;
78 
79 lint1=(long)npoint[0]*(long)MY;
80 lint2=(long)npoint[1]*(long)MY;
81 
83 
84 while( maplayer!=NULL) {
85 
86  if(maplayer->type==0 || maplayer->type==1) {
87 
89  izoom=maplayer->zoom;
90  no=maplayer->number;
91 
92  if(izoom > zoom) {
93 
95 
96  if(maplayer==NULL)
97  break;
98 
99  continue;
100 
101  }
102 
103  if(zoom==1 && izoom==1) {
104 
105  for(i=0;i<no;i++) {
106 
107  point[i].x=(xmin+(float)maplayer->points[i].x * cmult)/MY;
108  point[i].y=(ymin+(float)maplayer->points[i].y * cmult)/MY;
109 
110  }
111 
112  XSetForeground(display,gc,color);
113  if(maplayer->type==0)
114  XDrawLines(display,pix,gc,point,no,CoordModeOrigin);
115 
116  else
117  XFillPolygon(display,pix,gc,point,no,Complex,CoordModeOrigin);
118 
119  }
120  else {
121 
122  /* recalc all vectors */
123 
124  for(i=0;i<no;i++) {
125 
126  point[i].x=(((xmin+(float)maplayer->points[i].x*cmult)-
127  lint1)*zoom+xcen)/MY;
128  point[i].y=(((ymin+(float)maplayer->points[i].y*cmult)-
129  lint2)*zoom+ycen)/MY;
130 
131  }
132 
133  XSetForeground(display,gc,color);
134  if(maplayer->type==0)
135  XDrawLines(display,pix,gc,point,no,CoordModeOrigin);
136  else
137  XFillPolygon(display,pix,gc,point,no,Complex,CoordModeOrigin);
138 
139  }
140 
142 
143  if(maplayer==NULL)
144  break;
145 
146 
147 
148  }
149 
150  /* ascii symbol and/or text string */
151 
152  else {
153 
154  xadd=maplayer->xmax;
155  yadd=maplayer->ymax;
156 
158  izoom=maplayer->zoom;
159 
160  if(izoom > zoom) {
161 
163 
164  if(maplayer==NULL)
165  break;
166 
167  continue;
168 
169  }
170 
171  if(zoom==1 && izoom==1) {
172 
173  x1=(xmin+(float)maplayer->points[0].x * cmult)/MY;
174  y1=(ymin+(float)maplayer->points[0].y * cmult)/MY;
175 
176  }
177 
178  else {
179 
180  x1=(((xmin+(float)maplayer->points[0].x*cmult)-
181  lint1)*zoom+xcen)/MY;
182  y1=(((ymin+(float)maplayer->points[0].y*cmult)-
183  lint2)*zoom+ycen)/MY;
184 
185  }
186 
187  XSetForeground(display,gc,color);
188 
189  if(maplayer->number==0) {
190 
191  if(strlen(maplayer->name) > 0) {
192 
193  XDrawLine(display,pix,gc,x1+1,y1+1,x1+1,y1-1);
194  XDrawLine(display,pix,gc,x1+1,y1-1,x1-1,y1-1);
195  XDrawLine(display,pix,gc,x1-1,y1-1,x1-1,y1+1);
196  XDrawLine(display,pix,gc,x1-1,y1+1,x1+1,y1-1);
197 
198  }
199 
200  else {
201 
202 
203  offset=4;
204  XDrawLine(display,pix,gc,x1,y1-offset,x1-offset,y1+offset);
205  XDrawLine(display,pix,gc,x1,y1-offset,x1+offset,y1+offset);
206  XDrawLine(display,pix,gc,x1-offset,y1+offset,x1+offset,y1+offset);
207 
208 
209 
210  }
211 
212 
213  }
214 
215  length=strlen(maplayer->name);
216  text_width=XTextWidth(info_font[0],maplayer->name,length);
217 
218  if(maplayer->number==1) {
219 
220  xc=x1-text_width/2;
221  yc=y1+yheight;
222 
223  }
224 
225  else {
226 
227  if(xadd < 0)
228  xc=x1 - text_width;
229 
230  else
231  xc=x1+3;
232 
233 
234  yc=y1+yadd;
235 
236  }
237 
238  XDrawString(display,pix,gc,xc,yc,maplayer->name,length);
239 
241 
242  if(maplayer==NULL)
243  break;
244 
245  }
246 
247 
248 }
249 
250 }
251 
252 return;
253 }
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 
304 
305 
306 
307 
308 
309 
310 
311 
312 
313 
314 
315 
316 
317 
static int i
XFontStruct * info_font[10]
Definition: mapper.c:195
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
void draw_map(Drawable pix, int h, int display_flag)
Definition: draw_map.c:5
float mult
Definition: edit_stations.c:6
int off[100]
Definition: mapper.c:105
unsigned long cmap[16]
Definition: mapper.c:117
struct maplayer * smaplayer[100]
Definition: mapper.c:145
int display_flag
Definition: mapper.c:100
float xrat
long xmax
int color
float yrat
long ymax
long lint1
GC gc
Definition: mapper.c:163
float cmult
signed long xcen
Dimension height
signed long ycen
Dimension width
int yheight
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
float dmult
Widget drawing_area
Definition: mapper.c:185
int npoint[2]
Definition: mapper.c:105
long ymin
unsigned long YSIZE
float dmult[4]
Definition: misc.h:613
long xmin[4]
Definition: misc.h:607
long xmax[4]
Definition: misc.h:609
long ymax[4]
Definition: misc.h:610
long ymin[4]
Definition: misc.h:608
long ycen[4]
Definition: misc.h:612
long xcen[4]
Definition: misc.h:611
Definition: misc.h:443
short int xmax
Definition: misc.h:448
short int number
Definition: misc.h:447
int type
Definition: misc.h:452
char * name
Definition: misc.h:453
struct maplayer * nextseg
Definition: misc.h:455
short int color
Definition: misc.h:445
short int zoom
Definition: misc.h:446
short int ymax
Definition: misc.h:449
struct mappoints * points
Definition: misc.h:454
int x
Definition: misc.h:438
int y
Definition: misc.h:439
Definition: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30