Mapper
plot_isoh.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 
5 void plot_isoh(Pixmap pixm,int h, int display_flag)
6 
7 {
8 
9 extern int isom;
10 extern int iscale;
11 extern Display *display;
12 extern int npoint[2],zoom;
13 extern GC gc;
14 extern struct isoh *isoh;
15 extern unsigned long imap[16];
16 extern Widget drawing_area;
17 extern struct display_set display_set[4];
18 int i,j,k,m;
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 ceni,cenj;
30 float ddi;
31 float fm;
32 
33  dx=1;dy=1;
34 
35  di[0]=0;dj[0]=0;
36  di[1]=1;dj[1]=0;
37  di[2]=1;dj[2]=1;
38  di[3]=0;dj[3]=1;
39 
40  if(zoom==1 && (isoh->maxi > 500 || isoh->maxj > 500)){
41 
42  dx=2;dy=2;
43  di[0]=0;dj[0]=0;
44  di[1]=2;dj[1]=0;
45  di[2]=2;dj[2]=2;
46  di[3]=0;dj[3]=2;
47 
48  }
49 
57 
58 XtSetArg(args[0],XtNwidth,&width);
59 XtSetArg(args[1],XtNheight,&height);
60 XtGetValues(drawing_area,args,2);
61 
62 XSIZE=(long)width*10L;
63 YSIZE=(long)height*10L;
64 
65 xrat=(float)XSIZE/(float)12800;
66 yrat=(float)YSIZE/(float)9600;
67 
68 if(xrat < yrat)
69  mult=xrat;
70 
71 else
72  mult=yrat;
73 
75 lint1=(long)npoint[0]*(long)MY;
76 lint2=(long)npoint[1]*(long)MY;
77 
78 XSetFillRule(display,gc,WindingRule);
79 
80 mini=minj=0;
81 maxi=isoh->maxi;
82 maxj=isoh->maxj;
83 ceni=maxi/2;
84 cenj=maxj/2;
85 
86 if(zoom > 1) {
87 
88  iflag=0;
89 
90  for(i=0;i<maxi-dx;i++) {
91 
92  nlong=(xmin+((float)isoh->coord[i][cenj].x*cmult-lint1))*zoom + xcen;
93 
94 
95  if(iflag==0 && nlong < xmin)
96  continue;
97 
98  if(iflag==1 && nlong < xmax)
99  continue;
100 
101  if(iflag==0)
102  mini=i;
103 
104  if(iflag==1)
105  maxi=i;
106 
107  iflag++;
108 
109 
110  }
111 
112  iflag=0;
113 
114  for(j=0;j<maxj-dy;j++) {
115 
116  nlong=(ymin+((float)isoh->coord[ceni][j].y*cmult-lint2))*zoom + ycen;
117 
118 
119  if(iflag==0 && nlong < ymin)
120  continue;
121 
122  if(iflag==1 && nlong < ymax)
123  continue;
124 
125  if(iflag==0)
126  minj=j;
127 
128 
129  if(iflag==1)
130  maxj=j;
131 
132  iflag++;
133 
134  }
135 
136  }
137 
138 
139 if(iscale==0)
140  fm=.5;
141 else
142  fm=pow(2,(double)(iscale-1));
143 
144 
145 printf("isoh %d %d %f\n",xmin,ymin,cmult);
146 
147 for(i=mini;i<maxi-dx;i=i+dx) {
148 
149 for(j=minj;j<maxj-dy;j=j+dy) {
150 
151  if(isoh->value[isom][i+di[0]][j+dj[0]] < 0 ||
152  isoh->value[isom][i+di[1]][j+dj[1]] < 0 ||
153  isoh->value[isom][i+di[2]][j+dj[2]] < 0 ||
154  isoh->value[isom][i+di[3]][j+dj[3]] < 0)
155  continue;
156 
157  ddi=(float)(isoh->value[isom][i+di[0]][j+dj[0]]+
158  isoh->value[isom][i+di[1]][j+dj[1]] +
159  isoh->value[isom][i+di[2]][j+dj[2]]+
160  isoh->value[isom][i+di[3]][j+dj[3]])/(4*25.3);
161 
162  if(ddi <= 0)
163  continue;
164 
165  for(h=1;h <= 16;h++) {
166 
167  if(ddi < fm*h ) {
168 
169  color=h;
170  break;
171 
172  }
173 
174  }
175 
176  if(color > 16)
177  color=16;
178 
179  color=imap[color-1];
180 
181  if(color==0)
182  continue;
183 
184  XSetForeground(display,gc,color);
185 
186  if(zoom <= 1) {
187 
188 /* fix for wider gaps */
189 
190  for(k=0;k<4;k++) {
191 
192  nx[k]=xmin+(float)isoh->coord[i+di[k]][j+dj[k]].x*cmult;
193  ny[k]=ymin+(float)isoh->coord[i+di[k]][j+dj[k]].y*cmult;
194 
195  }
196  }
197 
198  else {
199 
200  for(k=0;k<4;k++) {
201 
202  nx[k]=(xmin+((float)isoh->coord[i+di[k]][j+dj[k]].x*cmult-
203  lint1))*zoom + xcen;
204  ny[k]=(ymin+((float)isoh->coord[i+di[k]][j+dj[k]].y*cmult-
205  lint2))*zoom + ycen;
206 
207  }
208 
209  }
210  for(k=0;k<4;k++) {
211 
212  point[k].x=(nx[k]+5)/MY;
213  point[k].y=(ny[k]+5)/MY;
214 
215 
216  }
217 
218  point[4].x=point[0].x;
219  point[4].y=point[0].y;
220 
221  XFillPolygon(display,pixm,gc,point,5,Convex,CoordModeOrigin);
222 
223  }
224 
225 
226 }
227 
228 return;
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 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 
static int i
Display * display
Definition: mapper.c:159
float mult
Definition: edit_stations.c:6
printf("fbuf is %s\n", fbuf)
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
int iscale
Definition: mapper.c:101
struct isoh * isoh
Definition: mapper.c:144
unsigned long imap[16]
Definition: mapper.c:116
int display_flag
Definition: mapper.c:100
void plot_isoh(Pixmap pixm, int h, int display_flag)
Definition: plot_isoh.c:5
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: misc.h:538
struct coord ** coord
Definition: misc.h:540
int maxi
Definition: misc.h:542
short int *** value
Definition: misc.h:541
int maxj
Definition: misc.h:543
Definition: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30