Mapper
redraw_rpcpn_legend.c
Go to the documentation of this file.
1 
2 #include "prototypes_new.h"
3 void redraw_rpcpn_legend(Drawable pixm)
4 
5 {
6 extern Font font[10];
7 extern XFontStruct *info_font[10];
8 extern int qlegend_save;
9 extern Display *display;
10 extern GC gc;
11 extern float delim[][16];
12 extern int maxkscale;
13 extern unsigned long qmap[16];
14 extern unsigned long xmap[16];
15 extern int kscale;
16 extern Widget drawing_area;
17 extern int rs;
18 extern int legendysize,legendxsize;
19 extern Pixmap logo[4];
20 char buf[50];
21 int k,text_width;
22 Dimension width,height;
23 Arg args[10];
24 int legendystart;
25 int i;
26 
28 
29 XtSetArg(args[0],XtNwidth,&width);
30 XtSetArg(args[1],XtNheight,&height);
31 XtGetValues(drawing_area,args,2);
32 
33 XSetForeground(display,gc,0);
34 XSetBackground(display,gc,0);
35 
36 XSetFunction(display,gc,GXcopy);
37 
38 XFillRectangle(display,pixm,gc,width-legendxsize+1,0,width,height);
39 
40 XSetFont(display,gc,font[3]);
41 strcpy(buf,"Rain/Snow(in)");
42 XSetForeground(display,gc,qmap[15]);
43 text_width=XTextWidth(info_font[3],buf,strlen(buf));
44 XDrawString(display,pixm,gc,width-5-text_width,legendystart+5,buf,strlen(buf));
45 XSetFont(display,gc,font[1]);
46 
47 for(k=0;k<5;k++) {
48 
49  XSetForeground(display,gc,xmap[k]);
50 
51  XFillRectangle(display,pixm,gc,width-rs-5,legendystart+(k+1)*rs,rs/2,rs);
52  XSetForeground(display,gc,xmap[k+5]);
53 
54  XFillRectangle(display,pixm,gc,width-rs/2-5,legendystart+(k+1)*rs,rs/2,rs);
55 
56  if(qlegend_save==k) {
57 
58  XSetForeground(display,gc,qmap[15]);
59  XDrawRectangle(display,pixm,gc,width-rs-5,legendystart+(k+1)*rs,rs-1,rs-1);
60 
61  }
62 
63  if(k==4)
64  sprintf(buf,"> %4.1f",delim[kscale][k]);
65  else
66  sprintf(buf,"%4.1f to %4.1f",delim[kscale][k],
67  delim[kscale][k+1]);
68 
69 
70  XSetForeground(display,gc,qmap[15]);
71  text_width=XTextWidth(info_font[1],buf,strlen(buf));
72  XDrawString(display,pixm,gc,width-rs-10-text_width,legendystart+(k+1)*rs+rs/2+3,buf,strlen(buf));
73 
74  }
75 
76 XSetForeground(display,gc,qmap[15]);
77 
78 XSetFillStyle(display,gc,FillStippled);
79 XSetStipple(display,gc,logo[0]);
80 XFillRectangle(display,pixm,gc,width-rs-5,legendystart+6*rs,rs,rs);
81 strcpy(buf,"filter down");
82 text_width=XTextWidth(info_font[1],buf,strlen(buf));
83 XSetFillStyle(display,gc,FillSolid);
84 XDrawString(display,pixm,gc,width-rs-10-text_width,legendystart+6*rs+rs/2+3,buf,strlen(buf));
85 
86 XSetStipple(display,gc,logo[2]);
87 XSetFillStyle(display,gc,FillStippled);
88 XFillRectangle(display,pixm,gc,width-rs-5,legendystart+7*rs,rs,rs);
89 strcpy(buf,"filter up");
90 text_width=XTextWidth(info_font[1],buf,strlen(buf));
91 XSetFillStyle(display,gc,FillSolid);
92 XDrawString(display,pixm,gc,width-rs-10-text_width,legendystart+7*rs+rs/2+3,buf,strlen(buf));
93 
94 XSetStipple(display,gc,logo[0]);
95 XSetFillStyle(display,gc,FillStippled);
96 XFillRectangle(display,pixm,gc,width-rs-5,legendystart+8*rs,rs,rs);
97 strcpy(buf,"filter off");
98 text_width=XTextWidth(info_font[1],buf,strlen(buf));
99 XSetFillStyle(display,gc,FillSolid);
100 XDrawString(display,pixm,gc,width-rs-10-text_width,legendystart+8*rs+rs/2+3,buf,strlen(buf));
101 
102 for(i=0;i<maxkscale;i++) {
103 
104  if((i/2)*2==i)
105  XSetStipple(display,gc,logo[2]);
106 
107  else
108  XSetStipple(display,gc,logo[0]);
109 
110  XSetFillStyle(display,gc,FillStippled);
111  XFillRectangle(display,pixm,gc,width-rs-5,legendystart+(9+i)*rs,rs,rs);
112  /* fix here */
113 
114  sprintf(buf,"%4.1f - %4.1f",delim[i][0],delim[i][4]);
115 
116  text_width=XTextWidth(info_font[1],buf,strlen(buf));
117  XSetFillStyle(display,gc,FillSolid);
118  XDrawString(display,pixm,gc,width-rs-10-text_width,legendystart+(9+i)*rs+rs/2+3,buf,strlen(buf));
119 
120  }
121 
122 XSetStipple(display,gc,logo[0]);
123 XSetFillStyle(display,gc,FillStippled);
124 XFillRectangle(display,pixm,gc,width-rs-5,
126 strcpy(buf,"raster");
127 text_width=XTextWidth(info_font[1],buf,strlen(buf));
128 XSetFillStyle(display,gc,FillSolid);
129 XDrawString(display,pixm,gc,width-rs-10-text_width,
130  legendystart+(9+maxkscale)*rs+rs/2+3,buf,strlen(buf));
131 
132 XSetStipple(display,gc,logo[2]);
133 XSetFillStyle(display,gc,FillStippled);
134 XFillRectangle(display,pixm,gc,width-rs-5,
135  legendystart+(10+maxkscale)*rs,rs,rs);
136 strcpy(buf,"contour");
137 text_width=XTextWidth(info_font[1],buf,strlen(buf));
138 XSetFillStyle(display,gc,FillSolid);
139 XDrawString(display,pixm,gc,width-rs-10-text_width,
140  legendystart+(10+maxkscale)*rs+rs/2+3,buf,strlen(buf));
141 
142 XSetStipple(display,gc,logo[0]);
143 XSetFillStyle(display,gc,FillStippled);
144 XFillRectangle(display,pixm,gc,width-rs-5,
145  legendystart+(11+maxkscale)*rs,rs,rs);
146 strcpy(buf,"close");
147 text_width=XTextWidth(info_font[1],buf,strlen(buf));
148 XSetFillStyle(display,gc,FillSolid);
149 XDrawString(display,pixm,gc,width-rs-10-text_width,
150  legendystart+(11+maxkscale)*rs+rs/2+3,buf,strlen(buf));
151 
152 }
153 
static int i
XFontStruct * info_font[10]
Definition: mapper.c:195
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
struct stat buf
Definition: is_file_closed.c:8
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
int k
Definition: mapp2h.h:48
int rs
Definition: mapper.c:103
int legendysize
Definition: mapper.c:103
int maxkscale
Definition: mapper.c:102
unsigned long qmap[16]
Definition: mapper.c:116
Pixmap logo[4]
Definition: mapper.c:167
int legendxsize
Definition: mapper.c:103
int qlegend_save
Definition: mapper.c:95
int legendystart
Definition: mapper.c:103
GC gc
Definition: mapper.c:163
unsigned long xmap[16]
Definition: mapper.c:116
Dimension height
Dimension width
Arg args[10]
float delim[][16]
Definition: mapper.c:30
Widget drawing_area
Definition: mapper.c:185
int kscale
Definition: mapper.c:101
void redraw_rpcpn_legend(Drawable pixm)