Mapper
plot_map_rsel.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+100]!=-1 && pcp_in_use[num+100-i1]!=-1) {
64 
65  read_file(file,num+100,spf);
66  read_file(file,num+100-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+100]==1) {
85 
86  read_file(file,num+100,spf);
87 
88 
89  }
90 
91  else if(pcp_in_use[num+100-i1]==1) {
92 
93  read_file(file,num+100-i1,spf);
94 
95 
96  }
97 
98 
99 
100 
101 
102  }
103 
104 minx=hrap_grid->hrap_minx;
105 miny=hrap_grid->hrap_miny;
106 maxx=hrap_grid->maxi;
107 maxy=hrap_grid->maxj;
108 
109 dx=1;dy=1;
110 
111 di[0]=0;dj[0]=0;
112 di[1]=1;dj[1]=0;
113 di[2]=1;dj[2]=1;
114 di[3]=0;dj[3]=1;
115 
123 
124 XtSetArg(args[0],XtNwidth,&width);
125 XtSetArg(args[1],XtNheight,&height);
126 XtGetValues(drawing_area,args,2);
127 
128 XSIZE=(long)width*10L;
129 YSIZE=(long)height*10L;
130 
131 xrat=(float)XSIZE/(float)12800;
132 yrat=(float)YSIZE/(float)9600;
133 
134 if(xrat < yrat)
135  mult=xrat;
136 
137 else
138  mult=yrat;
139 
141 lint1=(long)npoint[0]*(long)MY;
142 lint2=(long)npoint[1]*(long)MY;
143 XSetFillRule(display,gc,WindingRule);
144 
145 for(ib=0;map[ib].hb5[0]!=0;ib++) {
146 
147  if(map[ib].maps_done[num] <=0)
148  continue;
149 
150  if(wfo_all!=1) {
151 
152  for(hh=0;hh<20;hh++) {
153 
154  if(wfo_in_use[hh] == -1)
155  break;
156 
157  if(map[ib].owner==wfo_in_use[hh])
158  break;
159 
160  }
161 
162  if(wfo_in_use[hh]==-1)
163  continue;
164 
165  }
166 
167  for(l=0;l<map[ib].basin_points;l++) {
168 
169  r=map[ib].basin[l].x;
170  s=map[ib].basin[l].y;
171 
172  if(zoom<=1) {
173 
174  point[l].x=(xmin+(float)r * cmult)/MY;
175  point[l].y=(ymin+(float)s * cmult)/MY;
176 
177  }
178  else {
179 
180  fx =((((xmin+(float)r*cmult)-lint1)*zoom+xcen)/MY);
181  fy=((((ymin+(float)s*cmult)-lint2)*zoom+ycen)/MY);
182 
183 
184  if(fx < 0)
185  fx=0;
186  if(fy < 0)
187  fy=0;
188  if(fx > width)
189  fx=width;
190  if(fy>height)
191  fy=height;
192 
193  point[l].x=(short int)fx;
194  point[l].y=(short int)fy;
195 
196  }
197 
198  }
199 
200 
201  lz=map[ib].lz[num];
202  mz=map[ib].mz[num];
203  uz=map[ib].uz[num];
204  gz=map[ib].gz[num];
205 
206  if( map[ib].zones[1] !=1 &&
207  map[ib].zones[2] !=1 &&
208  map[ib].zones[3] !=1 && rsmode==1) {
209 
210  XSetClipMask(display,gc,None);
211 
212  mapvalue=lz;
213 
214  for(k=0;k<15;k++) {
215 
216  if(mapvalue >= delim[kscale][k] &&
217  mapvalue < delim[kscale][k+1]) {
218 
219  color=xmap[k];
220  break;
221 
222  }
223 
224  }
225 
226  if(mapvalue > .01 || mapvalue < -.01) {
227 
228 
229  if(k==15)
230  color=xmap[15];
231 
232  XSetForeground(display,gc,color);
233 
234  XFillPolygon(display,pixm,gc,point,map[ib].basin_points,Complex,CoordModeOrigin);
235 
236  }
237 
238  line_width=2;
239  line_style=LineSolid;
240  cap_style=CapButt;
241  join_style=JoinMiter;
242 
243  XSetLineAttributes(display,gc,line_width,line_style,cap_style,
244  join_style);
245 
246  XSetForeground(display,gc,qmap[15]);
247 
248  XDrawLines(display,pixm,gc,point,map[ib].basin_points,CoordModeOrigin);
249 
250  continue;
251 
252  }
253 
254  region=XPolygonRegion(point,map[ib].basin_points,WindingRule);
255 
256  XSetRegion(display,gc,region);
257  XDestroyRegion(region);
258  for(l=0;l<map[ib].hrap_points;l++) {
259 
260  x=map[ib].hrap_data[l].x;
261  y=map[ib].hrap_data[l].y;
262 
263  /* search for highest zone number is hrap block */
264 
265  ip=1;
266 
267  if(map[ib].hrap_data[l].zone[1] >= 0)
268  ip=2;
269 
270  if(map[ib].hrap_data[l].zone[2] >= 0)
271  ip=3;
272 
273  if(map[ib].hrap_data[l].zone[3] >= 0)
274  ip=4;
275 
276  if(ip==4)
277  mapvalue=gz;
278 
279  else if(ip==3)
280  mapvalue=uz;
281 
282  else if(ip==2)
283  mapvalue=mz;
284 
285  else
286  mapvalue=lz;
287 
288 
289  ix=x-minx;
290  iy=y-miny;
291 
292  if(ix < 0 || iy < 0 || ix >= maxx-1 || iy >= maxy-1) {
293 
294  continue;
295 
296  }
297 
298 
299  if(zoom <= 1) {
300 
301  for(k=0;k<4;k++) {
302 
303  nx[k]=xmin+(float)hrap_grid->coord[ix+di[k]][iy+dj[k]].x*
304  cmult;
305  ny[k]=ymin+(float)hrap_grid->coord[ix+di[k]][iy+dj[k]].y*
306  cmult;
307 
308  }
309  }
310 
311  else {
312 
313  for(k=0;k<4;k++) {
314 
315  nx[k]=(xmin+((float)hrap_grid->coord[ix+di[k]][iy+dj[k]].x*
316  cmult-lint1))*zoom + xcen;
317  ny[k]=(ymin+((float)hrap_grid->coord[ix+di[k]][iy+dj[k]].y*
318  cmult-lint2))*zoom + ycen;
319 
320 
321  }
322 
323  }
324 
325  for(k=0;k<4;k++) {
326 
327  mpoint[k].x=(nx[k]+5)/MY;
328  mpoint[k].y=(ny[k]+5)/MY;
329 
330  }
331 
332  mpoint[4].x=mpoint[0].x;
333  mpoint[4].y=mpoint[0].y;
334 
335  if(rsmode==1) {
336 
337  for(k=0;k<15;k++) {
338 
339  if(mapvalue >= delim[kscale][k] &&
340  mapvalue < delim[kscale][k+1]) {
341 
342  color=xmap[k];
343  break;
344 
345  }
346 
347  }
348 
349  if(mapvalue <= 0.01 && mapvalue >= -0.01)
350  continue;
351 
352  else if(k==15)
353  color=xmap[15];
354 
355  }
356 
357 
358  else{
359 
360  for(k=0;k<4;k++) {
361 
362  if(mapvalue >= delim[kscale][k] &&
363  mapvalue < delim[kscale][k+1]) {
364 
365  color=xmap[k];
366  break;
367 
368  }
369 
370  }
371 
372  if(mapvalue <= 0.01 && mapvalue >= -0.01)
373  continue;
374 
375  if(k==4)
376  color=xmap[4];
377 
378  if(mapvalue < -99.98)
379  color=xmap[7];
380 
381  if(color==0)
382  continue;
383 
384 
385  }
386 
387  if(rsmode != 1 &&
388  (pcp_in_use[100+num] == 1 ||
389  pcp_in_use[100+num-i1] == 1)) {
390 
391  if((spf->value[ix][iy] * 10 - dmvalue <
392  hrap_grid->elev[ix][iy]) && spf->value[ix][iy] >= 0)
393  color=xmap[k+5];
394 
395 
396 
397  }
398 
399 
400  XSetForeground(display,gc,color);
401 
402  XFillPolygon(display,pixm,gc,mpoint,5,Convex,CoordModeOrigin);
403 
404  }
405 
406  line_width=2;
407  line_style=LineSolid;
408  cap_style=CapButt;
409  join_style=JoinMiter;
410 
411  XSetLineAttributes(display,gc,line_width,line_style,cap_style,
412  join_style);
413 
414  XSetForeground(display,gc,qmap[15]);
415 
416  XDrawLines(display,pixm,gc,point,map[ib].basin_points,CoordModeOrigin);
417 
418  }
419 
420 XSetClipMask(display,gc,None);
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 
484 
485 
486 
487 
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_rsel.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