Mapper
contour_topo.c
Go to the documentation of this file.
1 
2 #include "prototypes_new.h"
3 
4 void contour_topo(Pixmap pixm,int h, int display_flag)
5 
6 {
7 
8 extern float topo_scale;
9 extern Font font[10];
10 extern Display *display;
11 extern int npoint[2],zoom;
12 extern GC gc;
13 extern unsigned long tmap[50];
14 extern Widget drawing_area;
15 extern struct display_set display_set[4];
16 extern struct topo *topo;
17 int i,j,k,m,l;
18 int color,MY=10;
19 float xrat,yrat,mult,dmult,cmult;
20 long nx[4],ny[4];
21 Dimension width,height;
22 Arg args[10];
23 unsigned long XSIZE,YSIZE;
24 XPoint point[5];
26 signed long xcen,ycen;
27 int di[5],dj[5],dy,dx,pnum,kk,mm;
28 float value[5];
29 float x[5],y[5],xx[5],yy[5];
30 int line_style,cap_style,join_style;
31 unsigned line_width;
32 int xint,yint,dup_flag[5];
33 float telim[10];
34 int maxtop,mintop;
35 
36 telim[1]=80;
37 telim[2]=160;
38 telim[3]=240;
39 telim[4]=320;
40 telim[5]=400;
41 
42 for(i=0;i<6;i++)
43  telim[i]=telim[i]*topo_scale;
44 
45 dx=1;dy=1;
46 
47 di[0]=0;dj[0]=0;
48 di[1]=1;dj[1]=0;
49 di[2]=1;dj[2]=1;
50 di[3]=0;dj[3]=1;
51 di[4]=0;dj[4]=0;
52 
53 XSetFont(display,gc,font[0]);
54 
62 
63 XtSetArg(args[0],XtNwidth,&width);
64 XtSetArg(args[1],XtNheight,&height);
65 XtGetValues(drawing_area,args,2);
66 
67 XSIZE=(long)width*10L;
68 YSIZE=(long)height*10L;
69 
70 xrat=(float)XSIZE/(float)12800;
71 yrat=(float)YSIZE/(float)9600;
72 
73 if(xrat < yrat)
74  mult=xrat;
75 
76 else
77  mult=yrat;
78 
80 lint1=(long)npoint[0]*(long)MY;
81 lint2=(long)npoint[1]*(long)MY;
82 
83 line_width=0;
84 line_style=LineSolid;
85 cap_style=CapButt;
86 join_style=JoinMiter;
87 
88 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
89 
90 for(i=0;i<topo->maxi-1;i++) {
91 
92 for(j=0;j<topo->maxj-1;j++) {
93 
94  value[0]=(float)topo->value[i][j];
95  value[1]=(float)topo->value[i+1][j];
96  value[2]=(float)topo->value[i+1][j+1];
97  value[3]=(float)topo->value[i][j+1];
98 
99  maxtop=0;
100  mintop=9999;
101  for(mm=0;mm<4;mm++) {
102 
103  if(value[mm] < mintop)
104  mintop=value[mm];
105 
106  if(value[mm] > maxtop)
107  maxtop=value[mm];
108 
109  }
110 
111  value[4]=value[0];
112 
113  for(l=1;l<6;l++) {
114  if(tmap[3+7*l]==0)
115  continue;
116 
117 
118  if(telim[l] < mintop || telim[l] > maxtop)
119  continue;
120 
121  pnum=0;
122 
123  for(m=0;m<4;m++) {
124 
125  if((telim[l] >= value[m] &&
126  telim[l] < value[m+1]) ||
127  (telim[l] < value[m] &&
128  telim[l] >= value[m+1])) {
129 
130  if(value[m]==value[m+1])
131  continue;
132 
133  x[pnum]=(float)topo->coord[i+di[m+1]][j+dj[m+1]].x +
134  (float)(topo->coord[i+di[m]][j+dj[m]].x-
135  topo->coord[i+di[m+1]][j+dj[m+1]].x)/
136  (value[m]-value[m+1])*
137  (telim[l]-value[m+1]);
138 
139  y[pnum]=(float)topo->coord[i+di[m+1]][j+dj[m+1]].y +
140  (float)(topo->coord[i+di[m]][j+dj[m]].y-
141  topo->coord[i+di[m+1]][j+dj[m+1]].y)/
142  (value[m]-value[m+1])*
143  (telim[l]-value[m+1]);
144 
145  for(h=0;h<pnum;h++){
146 
147  if(x[h]==x[pnum] && y[h]==y[pnum])
148  goto hop;
149 
150  }
151 
152  if(pnum==2) {
153 
154  for(kk=0;kk<3;kk++) {
155 
156  dup_flag[kk]=0;
157 
158  for(mm=0;mm<4;mm++) {
159 
160  xint=(int)x[kk];
161  yint=(int)y[kk];
162 
163  if(xint/10==topo->coord[i+di[mm]][j+dj[mm]].x/10 &&
164  yint/10==topo->coord[i+di[mm]][j+dj[mm]].y/10)
165  dup_flag[kk]=1;
166 
167 
168  }
169  }
170  }
171  pnum++;
172 
173  hop:
174 
175  pnum=pnum;
176 
177  }
178 
179  }
180 
181 if(pnum==3) {
182 
183  mm=0;
184  for(kk=0;kk<3;kk++){
185 
186  if(dup_flag[kk]==0) {
187  xx[mm]=x[kk];
188  yy[mm++]=y[kk];
189 
190 
191  }
192 
193  }
194 
195  for(kk=0;kk<2;kk++){
196 
197  x[kk]=xx[kk];
198  y[kk]=yy[kk];
199 
200  }
201  pnum=mm;
202 
203  }
204 
205 if(pnum != 2 && pnum != 4)
206  continue;
207 
208  color=tmap[6+7*l];
209  XSetForeground(display,gc,color);
210 
211  if(zoom <= 1) {
212 
213  for(k=0;k<pnum;k++) {
214 
215  nx[k]=xmin+x[k]*cmult;
216  ny[k]=ymin+y[k]*cmult;
217 
218  }
219  }
220 
221  else {
222 
223  for(k=0;k<pnum;k++) {
224 
225  nx[k]=(xmin+x[k]*cmult-lint1)*zoom + xcen;
226  ny[k]=(ymin+y[k]*cmult-lint2)*zoom + ycen;
227 
228  }
229 
230 }
231  for(k=0;k<pnum;k++) {
232 
233  point[k].x=(nx[k]+5)/MY;
234  point[k].y=(ny[k]+5)/MY;
235 
236 
237  }
238 
239 
240 
241  if(pnum==2)
242  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
243 
244  else {
245 
246  if(telim[l] < value[1]) {
247 
248  XDrawLine(display,pixm,gc,point[1].x,point[1].y,point[2].x,point[2].y);
249  XDrawLine(display,pixm,gc,point[3].x,point[3].y,point[0].x,point[0].y);
250 
251  }
252 
253  else {
254 
255  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
256  XDrawLine(display,pixm,gc,point[2].x,point[2].y,point[3].x,point[3].y);
257 
258  }
259 
260  }
261  }
262 
263  }
264 }
265 
266 
267 line_width=0;
268 line_style=LineSolid;
269 cap_style=CapButt;
270 join_style=JoinMiter;
271 
272 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
273 
274 
275 return;
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 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329 
330 
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 
341 
struct top * topo
Definition: build_hrap.c:3
static int i
void contour_topo(Pixmap pixm, int h, int display_flag)
Definition: contour_topo.c:4
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
float mult
Definition: edit_stations.c:6
double yy
Definition: mapp2h.h:41
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
double xx
Definition: mapp2h.h:41
unsigned long tmap[50]
Definition: mapper.c:116
int display_flag
Definition: mapper.c:100
float xrat
long xmax
int dj[4]
int color
float value
float yrat
long ny[4]
long ymax
int dy
long lint1
GC gc
Definition: mapper.c:163
int dx
float cmult
signed long xcen
Dimension height
signed long ycen
Dimension width
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
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 di[4]
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
Definition: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30
Definition: misc.h:523
struct coord ** coord
Definition: misc.h:525
int maxi
Definition: misc.h:527
short int ** value
Definition: misc.h:526
int maxj
Definition: misc.h:528