Mapper
plot_topo.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 
5 void plot_topo(Pixmap pixm,int h, int display_flag)
6 
7 {
8 
9 extern float topo_scale;
10 /*
11 extern XImage *image;
12 */
13 extern Display *display;
14 extern int npoint[2],zoom;
15 extern GC gc;
16 extern struct topo *topo;
17 extern unsigned long tmap[50];
18 extern Widget drawing_area;
19 extern struct display_set display_set[4];
20 int i,j,k;
21 int color,MY=10;
22 float xrat,yrat,mult,dmult,cmult;
23 long nx[4],ny[4];
24 Dimension width,height;
25 Arg args[10];
26 unsigned long XSIZE,YSIZE;
27 XPoint point[5];
29 signed long xcen,ycen;
30 int iflag,maxi,maxj,mini,minj,nlong,dx,dy,di[4],dj[4];
31 int tdi,ceni,cenj;
32 int xx,yy;
33 
34  dx=1;dy=1;
35 
36  di[0]=0;dj[0]=0;
37  di[1]=1;dj[1]=0;
38  di[2]=1;dj[2]=1;
39  di[3]=0;dj[3]=1;
40 
48 
49 XtSetArg(args[0],XtNwidth,&width);
50 XtSetArg(args[1],XtNheight,&height);
51 XtGetValues(drawing_area,args,2);
52 
53 XSIZE=(long)width*10L;
54 YSIZE=(long)height*10L;
55 
56 xrat=(float)XSIZE/(float)12800;
57 yrat=(float)YSIZE/(float)9600;
58 
59 if(xrat < yrat)
60  mult=xrat;
61 
62 else
63  mult=yrat;
64 
66 lint1=(long)npoint[0]*(long)MY;
67 lint2=(long)npoint[1]*(long)MY;
68 
69 XSetFillRule(display,gc,WindingRule);
70 
71 mini=minj=0;
72 maxi=topo->maxi;
73 maxj=topo->maxj;
74 ceni=maxi/2;
75 cenj=maxj/2;
76 
77 if(zoom > 1) {
78 
79  iflag=0;
80 
81  for(i=0;i<maxi-dx;i++) {
82 
83  nlong=(xmin+((float)topo->coord[i][cenj].x*cmult-lint1))*zoom + xcen;
84 
85 
86  if(iflag==0 && nlong < xmin)
87  continue;
88 
89  if(iflag==1 && nlong < xmax)
90  continue;
91 
92  if(iflag==0)
93  mini=i;
94 
95  if(iflag==1)
96  maxi=i;
97 
98  iflag++;
99 
100 
101  }
102 
103  iflag=0;
104 
105  for(j=0;j<maxj-dy;j++) {
106 
107 
108  nlong=(ymin+((float)topo->coord[ceni][j].y*cmult-lint2))*zoom + ycen;
109 
110 
111  if(iflag==0 && nlong < 0)
112  continue;
113 
114  if(iflag==1 && nlong < YSIZE)
115  continue;
116 
117  if(iflag==0)
118  minj=j;
119 
120 
121  if(iflag==1)
122  maxj=j;
123 
124  iflag++;
125 
126  }
127 
128  }
129 
130 
131 for(i=mini;i<maxi-dx;i=i+dx) {
132 for(j=minj;j<maxj-dy;j=j+dy) {
133 
134  if(topo->value[i][j]==0)
135  continue;
136 
137  if(topo->value[i][j] < 80*topo_scale)
138  color=3;
139 
140  else if(topo->value[i][j] < 160*topo_scale)
141  color=10;
142 
143  else if(topo->value[i][j] < 240*topo_scale)
144  color=17;
145 
146  else if(topo->value[i][j] < 320*topo_scale)
147  color=24;
148 
149  else
150  color=31;
151 
152  tdi=-topo->value[i][j+1]/3+topo->value[i+1][j]/3;
153  if(tdi > 3)
154  tdi=3;
155 
156  if(tdi < -3)
157  tdi=-3;
158 
159  color=color+tdi;
160 
161  color=tmap[color];
162 /*
163  if(color==0)
164  continue;
165 */
166  XSetForeground(display,gc,color);
167 
168  if(zoom <= 1) {
169 
170 /* fix for wider gaps */
171 
172  for(k=0;k<4;k++) {
173 
174  nx[k]=xmin+(float)topo->coord[i+di[k]][j+dj[k]].x*cmult;
175  ny[k]=ymin+(float)topo->coord[i+di[k]][j+dj[k]].y*cmult;
176 
177  }
178 /*
179 
180  nx[0]=xmin+(float)topo->coord[i][j].x*cmult;
181  ny[0]=ymin+(float)topo->coord[i][j].y*cmult;
182 
183  nx[1]=xmin+(float)topo->coord[i+1][j].x*cmult;
184  ny[1]=ymin+(float)topo->coord[i+1][j].y*cmult;
185 
186  nx[2]=xmin+(float)topo->coord[i+1][j+1].x*cmult;
187  ny[2]=ymin+(float)topo->coord[i+1][j+1].y*cmult;
188 
189  nx[3]=xmin+(float)topo->coord[i][j+1].x*cmult;
190  ny[3]=ymin+(float)topo->coord[i][j+1].y*cmult;
191 
192 
193 */
194 
195  }
196 
197  else {
198 
199  for(k=0;k<4;k++) {
200 
201  nx[k]=(xmin+((float)topo->coord[i+di[k]][j+dj[k]].x*cmult-
202  lint1))*zoom + xcen;
203  ny[k]=(ymin+((float)topo->coord[i+di[k]][j+dj[k]].y*cmult-
204  lint2))*zoom + ycen;
205  }
206 
207 
208 
209  }
210 
211  if(zoom>=1) {
212 
213  for(k=0;k<4;k++) {
214 
215  point[k].x=(nx[k]+5)/MY;
216  point[k].y=(ny[k]+5)/MY;
217 
218 
219  }
220 
221  point[4].x=point[0].x;
222  point[4].y=point[0].y;
223 /*
224  for(xx=point[0].x;xx<=point[1].x;xx++){
225 
226  for(yy=point[0].y;yy<=point[3].y;yy++){
227 
228  XPutPixel(image,xx,yy,color);
229 
230  }
231  }
232 */
233 
234 
235  XFillPolygon(display,pixm,gc,point,5,Convex,CoordModeOrigin);
236 
237  }
238 
239 
240  else {
241 
242 
243 
244 
245 
246  }
247 
248 
249  }
250 
251 
252 }
253 
254 return;
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 
318 
319 
320 
struct top * topo
Definition: build_hrap.c:3
static int i
Display * display
Definition: mapper.c:159
float mult
Definition: edit_stations.c:6
void plot_topo(Pixmap pixm, int h, int display_flag)
Definition: plot_topo.c:5
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 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