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