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