Mapper
plot_map_new.c
Go to the documentation of this file.
1 
2 
3 #include "prototypes_new.h"
4 
5 void plot_map(Pixmap pixm,int h, int display_flag,int num)
6 
7 {
8 extern int dmvalue;
9 extern int pcpn_time_step;
10 extern int rsmode;
11 extern int pcp_in_use[500];
12 extern struct pcp *spf;
13 extern struct pcp *pcp;
14 extern int wfo_all;
15 extern int wfo_in_use[20];
16 extern struct map map[1500];
17 extern int kscale;
18 extern struct hrap_grid *hrap_grid;
19 extern Font font[10];
20 extern Display *display;
21 extern int npoint[2],zoom;
22 extern int kscale;
23 extern GC gc;
24 extern unsigned long xmap[16];
25 extern unsigned long qmap[16];
26 extern Widget drawing_area;
27 extern float delim[][16];
28 extern struct display_set display_set[4];
29 int hh;
30 int k;
31 int x,y,ip,ib;
32 int color,MY=10;
33 float xrat,yrat,mult,dmult,cmult;
34 Dimension width,height;
35 Arg args[10];
36 unsigned long XSIZE,YSIZE;
37 signed long xmin,xmax,ymin,ymax,lint1,lint2;
38 signed long xcen,ycen;
39 int di[4],dj[4],dy,dx;
40 XPoint point[10000];
41 XPoint mpoint[6];
42 int l,line_width,line_style,cap_style,join_style;
43 double mapvalue;
44 signed long r,s;
45 int nx[6],ny[6];
46 int minx,miny,ix,iy,maxx,maxy;
47 extern Region region;
48 float uz,mz,lz,gz,fx,fy;
49 int i1;
50 int i,j;
51 char file[100];
52 
53 strcpy(file,"pcp");
54 
55 if(pcpn_time_step==0 && rsmode != 1) {
56 
57  i1=1;
58 
59  if(num==0)
60  i1=0;
61 
62 
63  if(pcp_in_use[num+200]!=-1 && pcp_in_use[num+200-i1]!=-1) {
64 
65  read_file(file,num+200,spf);
66  read_file(file,num+200-i1,pcp);
67 
68  for(i=0;i<hrap_grid->maxi-1;i++) {
69 
70  for(j=0;j<hrap_grid->maxj-1;j++) {
71 
72  spf->value[i][j]=(spf->value[i][j] +
73  pcp->value[i][j])/2;
74 
75 
76 
77  }
78 
79  }
80 
81 
82  }
83 
84  else if(pcp_in_use[num+200]==1) {
85 
86  read_file(file,num+200,spf);
87 
88 
89  }
90 
91  else if(pcp_in_use[num+200-i1]==1) {
92 
93  read_file(file,num+200-i1,spf);
94 
95 
96  }
97 
98 
99  }
100 
101 minx=hrap_grid->hrap_minx;
102 miny=hrap_grid->hrap_miny;
103 maxx=hrap_grid->maxi;
104 maxy=hrap_grid->maxj;
105 
106 dx=1;dy=1;
107 
108 di[0]=0;dj[0]=0;
109 di[1]=1;dj[1]=0;
110 di[2]=1;dj[2]=1;
111 di[3]=0;dj[3]=1;
112 
120 
121 XtSetArg(args[0],XtNwidth,&width);
122 XtSetArg(args[1],XtNheight,&height);
123 XtGetValues(drawing_area,args,2);
124 
125 XSIZE=(long)width*10L;
126 YSIZE=(long)height*10L;
127 
128 xrat=(float)XSIZE/(float)12800;
129 yrat=(float)YSIZE/(float)9600;
130 
131 if(xrat < yrat)
132  mult=xrat;
133 
134 else
135  mult=yrat;
136 
138 lint1=(long)npoint[0]*(long)MY;
139 lint2=(long)npoint[1]*(long)MY;
140 XSetFillRule(display,gc,WindingRule);
141 
142 for(ib=0;map[ib].hb5[0]!=0;ib++) {
143 
144  if(map[ib].maps_done[num] <=0)
145  continue;
146 
147  if(wfo_all!=1) {
148 
149  for(hh=0;hh<20;hh++) {
150 
151  if(wfo_in_use[hh] == -1)
152  break;
153 
154  if(map[ib].owner==wfo_in_use[hh])
155  break;
156 
157  }
158 
159  if(wfo_in_use[hh]==-1)
160  continue;
161 
162  }
163 
164  for(l=0;l<map[ib].basin_points;l++) {
165 
166  r=map[ib].basin[l].x;
167  s=map[ib].basin[l].y;
168 
169  if(zoom<=1) {
170 
171  point[l].x=(xmin+(float)r * cmult)/MY;
172  point[l].y=(ymin+(float)s * cmult)/MY;
173 
174  }
175  else {
176 
177  fx =((((xmin+(float)r*cmult)-lint1)*zoom+xcen)/MY);
178  fy=((((ymin+(float)s*cmult)-lint2)*zoom+ycen)/MY);
179 
180 
181  if(fx < 0)
182  fx=0;
183  if(fy < 0)
184  fy=0;
185  if(fx > width)
186  fx=width;
187  if(fy>height)
188  fy=height;
189 
190  point[l].x=(short int)fx;
191  point[l].y=(short int)fy;
192 
193  }
194 
195  }
196 
197 
198  lz=map[ib].lz[num];
199  mz=map[ib].mz[num];
200  uz=map[ib].uz[num];
201  gz=map[ib].gz[num];
202 
203  if( map[ib].zones[1] !=1 &&
204  map[ib].zones[2] !=1 &&
205  map[ib].zones[3] !=1 && rsmode==1) {
206 
207  XSetClipMask(display,gc,None);
208 
209  mapvalue=lz;
210 
211  for(k=0;k<15;k++) {
212 
213  if(mapvalue >= delim[kscale][k] &&
214  mapvalue < delim[kscale][k+1]) {
215 
216  color=xmap[k];
217  break;
218 
219  }
220 
221  }
222 
223  if(mapvalue > .01 || mapvalue < -.01) {
224 
225 
226  if(k==15)
227  color=xmap[15];
228 
229  XSetForeground(display,gc,color);
230 
231  XFillPolygon(display,pixm,gc,point,map[ib].basin_points,Complex,CoordModeOrigin);
232 
233  }
234 
235  line_width=2;
236  line_style=LineSolid;
237  cap_style=CapButt;
238  join_style=JoinMiter;
239 
240  XSetLineAttributes(display,gc,line_width,line_style,cap_style,
241  join_style);
242 
243  XSetForeground(display,gc,qmap[15]);
244 
245  XDrawLines(display,pixm,gc,point,map[ib].basin_points,CoordModeOrigin);
246 
247  continue;
248 
249  }
250 
251  region=XPolygonRegion(point,map[ib].basin_points,WindingRule);
252 
253  XSetRegion(display,gc,region);
254  XDestroyRegion(region);
255  for(l=0;l<map[ib].hrap_points;l++) {
256 
257  x=map[ib].hrap_data[l].x;
258  y=map[ib].hrap_data[l].y;
259 
260  /* search for highest zone number is hrap block */
261 
262  ip=1;
263 
264  if(map[ib].hrap_data[l].zone[1] >= 0)
265  ip=2;
266 
267  if(map[ib].hrap_data[l].zone[2] >= 0)
268  ip=3;
269 
270  if(map[ib].hrap_data[l].zone[3] >= 0)
271  ip=4;
272 
273  if(ip==4)
274  mapvalue=gz;
275 
276  else if(ip==3)
277  mapvalue=uz;
278 
279  else if(ip==2)
280  mapvalue=mz;
281 
282  else
283  mapvalue=lz;
284 
285 
286  ix=x-minx;
287  iy=y-miny;
288 
289  if(ix < 0 || iy < 0 || ix >= maxx-1 || iy >= maxy-1) {
290 
291  continue;
292 
293  }
294 
295  if(zoom <= 1) {
296 
297  for(k=0;k<4;k++) {
298 
299  nx[k]=xmin+(float)hrap_grid->coord[ix+di[k]][iy+dj[k]].x*
300  cmult;
301  ny[k]=ymin+(float)hrap_grid->coord[ix+di[k]][iy+dj[k]].y*
302  cmult;
303 
304  }
305  }
306 
307  else {
308 
309  for(k=0;k<4;k++) {
310 
311  nx[k]=(xmin+((float)hrap_grid->coord[ix+di[k]][iy+dj[k]].x*
312  cmult-lint1))*zoom + xcen;
313  ny[k]=(ymin+((float)hrap_grid->coord[ix+di[k]][iy+dj[k]].y*
314  cmult-lint2))*zoom + ycen;
315 
316 
317  }
318 
319  }
320 
321  for(k=0;k<4;k++) {
322 
323  mpoint[k].x=(nx[k]+5)/MY;
324  mpoint[k].y=(ny[k]+5)/MY;
325 
326  }
327 
328  mpoint[4].x=mpoint[0].x;
329  mpoint[4].y=mpoint[0].y;
330 
331 
332  if(rsmode==1) {
333 
334 
335  for(k=0;k<15;k++) {
336 
337  if(mapvalue >= delim[kscale][k] &&
338  mapvalue < delim[kscale][k+1]) {
339 
340  color=xmap[k];
341  break;
342 
343  }
344 
345  }
346 
347  if(mapvalue <= 0.01 && mapvalue >= -0.01)
348  continue;
349 
350  else if(k==15)
351  color=xmap[15];
352 
353  }
354 
355  else {
356 
357  for(k=0;k<4;k++) {
358 
359  if(mapvalue >= delim[kscale][k] &&
360  mapvalue < delim[kscale][k+1]) {
361 
362  color=xmap[k];
363  break;
364 
365  }
366 
367  }
368 
369  if(mapvalue <= 0.01 && mapvalue >= -0.01)
370  continue;
371 
372  if(k==4)
373  color=xmap[4];
374 
375  if(mapvalue < -99.98)
376  color=xmap[7];
377 
378  if(color==0)
379  continue;
380 
381 
382  }
383 
384  if(rsmode != 1 &&
385  (pcp_in_use[200+num] == 1 ||
386  pcp_in_use[200+num-i1] == 1)) {
387 
388  if(spf->value[ix][iy] * 10 - dmvalue <
389  hrap_grid->elev[ix][iy])
390  color=xmap[k+5];
391 
392 
393 
394  }
395 
396  XSetForeground(display,gc,color);
397 
398  XFillPolygon(display,pixm,gc,mpoint,5,Convex,CoordModeOrigin);
399 
400  }
401 
402  line_width=2;
403  line_style=LineSolid;
404  cap_style=CapButt;
405  join_style=JoinMiter;
406 
407  XSetLineAttributes(display,gc,line_width,line_style,cap_style,
408  join_style);
409 
410  XSetForeground(display,gc,qmap[15]);
411 
412  XDrawLines(display,pixm,gc,point,map[ib].basin_points,CoordModeOrigin);
413 
414  }
415 
416 XSetClipMask(display,gc,None);
417 
418 }
419 
420 
421 
422 
423 
424 
425 
426 
427 
428 
429 
430 
431 
432 
433 
434 
435 
436 
437 
438 
439 
440 
441 
442 
443 
444 
445 
446 
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 
464 
465 
466 
467 
468 
469 
470 
471 
472 
473 
474 
475 
476 
477 
478 
479 
480 
481 
482 
483 
static int i
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
float mult
Definition: edit_stations.c:6
void read_file(char *, int, struct pcp *)
Definition: read_file.c:5
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
int pcpn_time_step
Definition: mapper.c:75
unsigned long qmap[16]
Definition: mapper.c:116
struct pcp * spf
Definition: mapper.c:141
Region region
Definition: mapper.c:170
int display_flag
Definition: mapper.c:100
void plot_map(Pixmap pixm, int h, int display_flag, int num)
Definition: plot_map_new.c:5
float xrat
long xmax
int dj[4]
int color
float yrat
long ny[4]
long ymax
struct pcp * pcp
Definition: mapper.c:140
int dy
int pcp_in_use[50]
Definition: mapper.c:78
long lint1
GC gc
Definition: mapper.c:163
int dx
struct hrap_grid * hrap_grid
Definition: mapper.c:142
float cmult
unsigned long xmap[16]
Definition: mapper.c:116
signed long xcen
Dimension height
signed long ycen
Dimension width
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
float delim[][16]
Definition: mapper.c:30
long nx[4]
float dmult
Widget drawing_area
Definition: mapper.c:185
int npoint[2]
Definition: mapper.c:105
long ymin
unsigned long YSIZE
int kscale
Definition: mapper.c:101
int di[4]
ib
Definition: shleap.cc:46
short int y
Definition: misc.h:498
short int x
Definition: misc.h:497
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
int x
Definition: misc.h:230
int y
Definition: misc.h:231
short int hrap_miny
Definition: misc.h:583
short int hrap_minx
Definition: misc.h:582
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
struct coord ** coord
Definition: misc.h:584
short int ** elev
Definition: misc_new.h:815
Definition: misc.h:236
char hb5[10]
Definition: misc.h:238
float lz[200]
Definition: misc.h:250
float uz[200]
Definition: misc.h:248
struct hrap_data * hrap_data
Definition: misc.h:245
int basin_points
Definition: misc.h:240
int hrap_points
Definition: misc.h:244
float gz[200]
Definition: misc.h:247
float mz[200]
Definition: misc.h:249
XPoint * basin
Definition: misc.h:243
Definition: misc.h:596
short int ** value
Definition: misc.h:599
Definition: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30