Mapper
plot_isoh_new.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 < 0)
120  continue;
121 
122  if(iflag==1 && nlong < YSIZE)
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;i++) {
148 
149 for(j=minj;j<maxj;j++) {
150 
151  if(isoh->value[isom][i+di[0]][j+dj[0]] < 0 )
152  continue;
153 
154  ddi=(float)(isoh->value[isom][i+di[0]][j+dj[0]]+)/(4*25.3);
155 
156  if(ddi <= 0)
157  continue;
158 
159  for(h=1;h <= 16;h++) {
160 
161  if(ddi < fm*h ) {
162 
163  color=h;
164  break;
165 
166  }
167 
168  }
169 
170  if(color > 16)
171  color=16;
172 
173  color=imap[color-1];
174 
175  if(color==0)
176  continue;
177 
178  XSetForeground(display,gc,color);
179 
180  if(zoom <= 1) {
181 
182 /* fix for wider gaps */
183 
184  for(k=0;k<4;k++) {
185 
186  nx[k]=xmin+(float)isoh->coord[i+di[k]][j+dj[k]].x*cmult;
187  ny[k]=ymin+(float)isoh->coord[i+di[k]][j+dj[k]].y*cmult;
188 
189  }
190  }
191 
192  else {
193 
194  for(k=0;k<4;k++) {
195 
196  nx[k]=(xmin+((float)isoh->coord[i+di[k]][j+dj[k]].x*cmult-
197  lint1))*zoom + xcen;
198  ny[k]=(ymin+((float)isoh->coord[i+di[k]][j+dj[k]].y*cmult-
199  lint2))*zoom + ycen;
200 
201  }
202 
203  }
204  for(k=0;k<4;k++) {
205 
206  point[k].x=(nx[k]+5)/MY;
207  point[k].y=(ny[k]+5)/MY;
208 
209 
210  }
211 
212  point[4].x=point[0].x;
213  point[4].y=point[0].y;
214 
215  XFillPolygon(display,pixm,gc,point,5,Convex,CoordModeOrigin);
216 
217  }
218 
219 
220 }
221 
222 return;
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 
279 
280 
281 
282 
283 
284 
285 
286 
287 
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_new.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