Mapper
libraries
common
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];
28
long
xmin
,
xmax
,
ymin
,
ymax
,
lint1
,
lint2
;
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
41
dmult
=
display_set
[
display_flag
].
dmult
[h];
42
xmin
=
display_set
[
display_flag
].
xmin
[h];
43
xmax
=
display_set
[
display_flag
].
xmax
[h];
44
ymin
=
display_set
[
display_flag
].
ymin
[h];
45
ymax
=
display_set
[
display_flag
].
ymax
[h];
46
xcen
=
display_set
[
display_flag
].
xcen
[h];
47
ycen
=
display_set
[
display_flag
].
ycen
[h];
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
65
cmult
=
dmult
*
mult
;
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
topo
struct top * topo
Definition:
build_hrap.c:3
i
static int i
Definition:
get_apps_defaults.c:110
display
Display * display
Definition:
mapper.c:159
mult
float mult
Definition:
edit_stations.c:6
plot_topo
void plot_topo(Pixmap pixm, int h, int display_flag)
Definition:
plot_topo.c:5
yy
double yy
Definition:
mapp2h.h:41
j
int j
Definition:
mapp2h.h:48
k
int k
Definition:
mapp2h.h:48
xx
double xx
Definition:
mapp2h.h:41
tmap
unsigned long tmap[50]
Definition:
mapper.c:116
display_flag
int display_flag
Definition:
mapper.c:100
xrat
float xrat
Definition:
plot_qpf_legend.c:20
xmax
long xmax
Definition:
plot_qpf_legend.c:26
dj
int dj[4]
Definition:
plot_qpf_legend.c:28
color
int color
Definition:
plot_qpf_legend.c:19
yrat
float yrat
Definition:
plot_qpf_legend.c:20
ny
long ny[4]
Definition:
plot_qpf_legend.c:21
ymax
long ymax
Definition:
plot_qpf_legend.c:26
dy
int dy
Definition:
plot_qpf_legend.c:28
lint1
long lint1
Definition:
plot_qpf_legend.c:26
gc
GC gc
Definition:
mapper.c:163
dx
int dx
Definition:
plot_qpf_legend.c:28
cmult
float cmult
Definition:
plot_qpf_legend.c:20
xcen
signed long xcen
Definition:
plot_qpf_legend.c:27
height
Dimension height
Definition:
plot_qpf_legend.c:22
ycen
signed long ycen
Definition:
plot_qpf_legend.c:27
width
Dimension width
Definition:
plot_qpf_legend.c:22
lint2
long lint2
Definition:
plot_qpf_legend.c:26
args
Arg args[10]
Definition:
plot_qpf_legend.c:23
xmin
long xmin
Definition:
plot_qpf_legend.c:26
XSIZE
unsigned long XSIZE
Definition:
plot_qpf_legend.c:24
MY
int MY
Definition:
plot_qpf_legend.c:19
zoom
int zoom
Definition:
plot_qpf_legend.c:9
nx
long nx[4]
Definition:
plot_qpf_legend.c:21
dmult
float dmult
Definition:
plot_qpf_legend.c:20
drawing_area
Widget drawing_area
Definition:
mapper.c:185
npoint
int npoint[2]
Definition:
mapper.c:105
ymin
long ymin
Definition:
plot_qpf_legend.c:26
YSIZE
unsigned long YSIZE
Definition:
plot_qpf_legend.c:24
di
int di[4]
Definition:
plot_qpf_legend.c:28
prototypes.h
coord::y
short int y
Definition:
misc.h:498
coord::x
short int x
Definition:
misc.h:497
display_set
Definition:
misc.h:603
display_set::dmult
float dmult[4]
Definition:
misc.h:613
display_set::xmin
long xmin[4]
Definition:
misc.h:607
display_set::xmax
long xmax[4]
Definition:
misc.h:609
display_set::ymax
long ymax[4]
Definition:
misc.h:610
display_set::ymin
long ymin[4]
Definition:
misc.h:608
display_set::ycen
long ycen[4]
Definition:
misc.h:612
display_set::xcen
long xcen[4]
Definition:
misc.h:611
point
Definition:
mapp2h.h:29
point::y
int y
Definition:
mapp2h.h:30
point::x
int x
Definition:
mapp2h.h:30
topo
Definition:
misc.h:523
topo::coord
struct coord ** coord
Definition:
misc.h:525
topo::maxi
int maxi
Definition:
misc.h:527
topo::value
short int ** value
Definition:
misc.h:526
topo::maxj
int maxj
Definition:
misc.h:528
Generated by
1.9.1