Mapper
libraries
common
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];
26
long
xmin
,
xmax
,
ymin
,
ymax
,
lint1
,
lint2
;
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
48
dmult
=
display_set
[
display_flag
].
dmult
[h];
49
xmin
=
display_set
[
display_flag
].
xmin
[h];
50
xmax
=
display_set
[
display_flag
].
xmax
[h];
51
ymin
=
display_set
[
display_flag
].
ymin
[h];
52
ymax
=
display_set
[
display_flag
].
ymax
[h];
53
xcen
=
display_set
[
display_flag
].
xcen
[h];
54
ycen
=
display_set
[
display_flag
].
ycen
[h];
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
73
cmult
=
dmult
*
mult
;
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
topo
struct top * topo
Definition:
build_hrap.c:3
i
static int i
Definition:
get_apps_defaults.c:110
max_height
int max_height
Definition:
display_data.c:5
display
Display * display
Definition:
mapper.c:159
max_width
int max_width
Definition:
mapper.c:99
mult
float mult
Definition:
edit_stations.c:6
printf
printf("fbuf is %s\n", fbuf)
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
image
XImage * image
Definition:
mapper.c:197
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
plot_topo
void plot_topo(Pixmap pixm, int h, int display_flag)
Definition:
plot_topo_new.c:5
prototypes_new.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