1 | ;------------------------------------------------ |
---|
2 | PRO xxxmenubar_event, event |
---|
3 | ; |
---|
4 | compile_opt idl2, strictarrsubs |
---|
5 | ; |
---|
6 | @common |
---|
7 | |
---|
8 | |
---|
9 | case event.value of |
---|
10 | 'Open' :begin |
---|
11 | oldmeshparams = ccmeshparameters |
---|
12 | newfile = selectfile() |
---|
13 | if size(newfile, /type) NE 8 then return |
---|
14 | widget_control, event.top, /hourglass |
---|
15 | widget_control, event.top, update = 0 |
---|
16 | widget_control, event.top, get_uvalue = top_uvalue |
---|
17 | ; on s''occupe de filelist |
---|
18 | filelist = extractatt(top_uvalue, 'filelist') |
---|
19 | filelist = [filelist, newfile.fileparameters.filename] |
---|
20 | currentfile = n_elements(filelist)-1 |
---|
21 | ; on update le widget |
---|
22 | filelistid = widget_info(event.top, find_by_uname = 'filelist') |
---|
23 | widget_control, filelistid, combobox_additem = file_basename(newfile.fileparameters.filename) |
---|
24 | widget_control, filelistid, set_combobox_select = currentfile |
---|
25 | ; on update les elements filelist et currentfile de la top_uvalue |
---|
26 | *top_uvalue[1, findline(top_uvalue, 'filelist')] = filelist |
---|
27 | oldfile = *top_uvalue[1, findline(top_uvalue, 'currentfile')] |
---|
28 | *top_uvalue[1, findline(top_uvalue, 'currentfile')] = currentfile |
---|
29 | ; on s''occupe du nom de la variable |
---|
30 | vlstid = widget_info(event.top, find_by_uname = 'varlist') |
---|
31 | ; quel etait le champ selectionne ? on le reselectionne ? |
---|
32 | fieldname = widget_info(vlstid, /combobox_gettext) |
---|
33 | index = where(newfile.fileparameters.listvar EQ fieldname) |
---|
34 | widget_control, vlstid, set_value = newfile.fileparameters.listvar |
---|
35 | widget_control, vlstid, set_combobox_select = 0 > index[0] |
---|
36 | ; on s''occupe du calendrier |
---|
37 | key_caltype = newfile.fileparameters.caltype |
---|
38 | date1id = widget_info(event.top, find_by_uname = 'calendar1') |
---|
39 | widget_control, date1id, get_value = date1 |
---|
40 | widget_control, date1id, /destroy |
---|
41 | jdate1 = jul2date(date1) |
---|
42 | if (where(newfile.fileparameters.time_counter EQ jdate1))[0] EQ -1 $ |
---|
43 | then jdate1 = newfile.fileparameters.time_counter[0] |
---|
44 | date2id = widget_info(event.top, find_by_uname = 'calendar2') |
---|
45 | widget_control, date2id, get_value = date2 |
---|
46 | widget_control, date2id, /destroy |
---|
47 | jdate2 = jul2date(date2) |
---|
48 | if (where(newfile.fileparameters.time_counter EQ jdate2))[0] EQ -1 then jdate2 = jdate1 |
---|
49 | basecal = widget_info(event.top, find_by_uname = 'basecal') |
---|
50 | fakecal = newfile.fileparameters.fakecal |
---|
51 | rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate1, uname = 'calendar1' $ |
---|
52 | , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame) |
---|
53 | rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate2, uname = 'calendar2' $ |
---|
54 | , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame) |
---|
55 | ; on update les elements fileparameters, readparameters et meshparameters de la top_uvalue |
---|
56 | newfileparameters = ptrarr(currentfile+1, /allocate_heap) |
---|
57 | FOR i = 0, currentfile-1 DO $ |
---|
58 | *newfileparameters[i] = *(extractatt(top_uvalue, 'fileparameters'))[i] |
---|
59 | *newfileparameters[currentfile] = newfile.fileparameters |
---|
60 | ptr_free, extractatt(top_uvalue, 'fileparameters') |
---|
61 | *top_uvalue[1, findline(top_uvalue, 'fileparameters')] = newfileparameters |
---|
62 | ; |
---|
63 | newreadparameters = ptrarr(currentfile+1, /allocate_heap) |
---|
64 | FOR i = 0, currentfile-1 DO $ |
---|
65 | *newreadparameters[i] = *(extractatt(top_uvalue, 'readparameters'))[i] |
---|
66 | *newreadparameters[currentfile] = newfile.readparameters |
---|
67 | ptr_free, extractatt(top_uvalue, 'readparameters') |
---|
68 | *top_uvalue[1, findline(top_uvalue, 'readparameters')] = newreadparameters |
---|
69 | ; |
---|
70 | newmeshparameters = ptrarr(currentfile+1, /allocate_heap) |
---|
71 | FOR i = 0, currentfile-1 DO $ |
---|
72 | *newmeshparameters[i] = *(extractatt(top_uvalue, 'meshparameters'))[i] |
---|
73 | *newmeshparameters[currentfile] = newfile.meshparameters |
---|
74 | ptr_free, extractatt(top_uvalue, 'meshparameters') |
---|
75 | *top_uvalue[1, findline(top_uvalue, 'meshparameters')] = newmeshparameters |
---|
76 | ; on actualise le widget! |
---|
77 | if cmpgrid(oldmeshparams) then BEGIN |
---|
78 | domainid = widget_info(event.top, find_by_uname = 'domain') |
---|
79 | widget_control, domainid, set_value = -1 |
---|
80 | endif |
---|
81 | widget_control, event.top, update = 1 |
---|
82 | end |
---|
83 | 'New xxx' :BEGIN |
---|
84 | widget_control, event.top, get_uvalue = top_uvalue |
---|
85 | extra = extractatt(top_uvalue, 'extra') |
---|
86 | xxx, CALLERWIDID = event.top, _extra = extra |
---|
87 | end |
---|
88 | 'Quit':begin |
---|
89 | widget_control, event.top, get_uvalue = top_uvalue |
---|
90 | ptr_free, extractatt(top_uvalue, 'exextra') |
---|
91 | ptr_free, extractatt(top_uvalue, 'fileparameters') |
---|
92 | ptr_free, extractatt(top_uvalue, 'readparameters') |
---|
93 | ptr_free, extractatt(top_uvalue, 'meshparameters') |
---|
94 | ptr_free, top_uvalue |
---|
95 | widget_control, event.top, /destroy ;on ferme le widget |
---|
96 | end |
---|
97 | 'PostScript' :BEGIN |
---|
98 | IF lmgr(/demo) EQ 1 THEN BEGIN |
---|
99 | dummy = report('impossible to save as postscript in demo mode') |
---|
100 | return |
---|
101 | ENDIF |
---|
102 | widget_control, event.top, get_uvalue = top_uvalue |
---|
103 | ; on recupere la liste des instructions |
---|
104 | globalcommand = extractatt(top_uvalue, 'globalcommand') |
---|
105 | ; for i = 0, n_elements(globalcommand)-1 do print, globalcommand[i] |
---|
106 | ; on complete par le premiere et les dernieres lignes du programme |
---|
107 | createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ |
---|
108 | , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $ |
---|
109 | +', PORTRAIT = portrait, LANDSCAPE = landscape' $ |
---|
110 | +', DATE1IN = date1in, DATE2IN = date2in' $ |
---|
111 | , /POSTSCRIPT |
---|
112 | END |
---|
113 | 'Animated gif' :begin |
---|
114 | IF float(strmid(!version.release,0,3)) GE 6.2 THEN xcreateanim, event.top |
---|
115 | end |
---|
116 | 'Gif' :BEGIN |
---|
117 | IF lmgr(/demo) EQ 1 THEN BEGIN |
---|
118 | dummy = report('impossible to save as an image in demo mode') |
---|
119 | return |
---|
120 | ENDIF |
---|
121 | widget_control, event.top, get_uvalue = top_uvalue |
---|
122 | smallin = extractatt(top_uvalue, 'smallin') |
---|
123 | numdessinin = smallin[2]-1 |
---|
124 | smallout = extractatt(top_uvalue, 'smallout') |
---|
125 | numdessinout = smallout[2]-1 |
---|
126 | tracecadre, smallin, /erase |
---|
127 | tracecadre, smallout, /erase |
---|
128 | filename = xquestion('dans quelle fichier gif voulez vous sauver !C l''ecran de xxx?', 'xxx_image.gif') |
---|
129 | if rstrpos(filename, '.gif') NE strlen(filename)-4 then filename = filename+'.gif' |
---|
130 | filename = isafile(file = filename, io = imagedir, /new) |
---|
131 | saveimage, filename, /quiet |
---|
132 | end |
---|
133 | 'IDL procedure':BEGIN |
---|
134 | IF lmgr(/demo) EQ 1 THEN BEGIN |
---|
135 | dummy = report('impossible to save as a idl program file in demo mode') |
---|
136 | return |
---|
137 | ENDIF |
---|
138 | ; on recupere le nom du fichier |
---|
139 | filename = xquestion('dans quelle procedure IDL voulez vous sauver !C la realisation de ce graph?', 'xxx_figure.pro') |
---|
140 | ; on le complete par un .pro |
---|
141 | if rstrpos(filename, '.pro') NE strlen(filename)-4 then filename = filename+'.pro' |
---|
142 | filename = isafile(file = filename, io = homedir, /new) |
---|
143 | widget_control, event.top, get_uvalue = top_uvalue |
---|
144 | ; portrait ou landscape ??? |
---|
145 | options = extractatt(top_uvalue, 'options') |
---|
146 | optionsflag = extractatt(top_uvalue, 'optionsflag') |
---|
147 | portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] |
---|
148 | ; on lit les commandes pour faire un plot |
---|
149 | globalcommand = extractatt(top_uvalue, 'globalcommand') |
---|
150 | ; on complete par le premiere et les dernieres lignes du programme |
---|
151 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
152 | CASE thisOS of |
---|
153 | 'MAC':sep = ':' |
---|
154 | 'WIN':sep = '\' |
---|
155 | ELSE:sep = '/' |
---|
156 | ENDCASE |
---|
157 | poslastsep = rstrpos(filename, sep) |
---|
158 | proname = strmid(filename, poslastsep+1, strlen(filename)-poslastsep-1-4) |
---|
159 | globalcommand = ['pro '+proname+', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ |
---|
160 | , ' ' $ |
---|
161 | , ' '+globalcommand $ |
---|
162 | , ' ' $ |
---|
163 | , 'return' $ |
---|
164 | , 'end'] |
---|
165 | ; on les ecrit dans un programme |
---|
166 | putfile, filename, globalcommand |
---|
167 | END |
---|
168 | 'RESTORE kwd of xxx':BEGIN |
---|
169 | IF lmgr(/demo) EQ 1 THEN BEGIN |
---|
170 | dummy = report('impossible to save the widget in demo mode') |
---|
171 | return |
---|
172 | ENDIF |
---|
173 | ; on recupere le nom du fichier |
---|
174 | filename = xquestion('dans quel fichier bianire voulez vous sauver le widget ?', 'xxx_widget.dat') |
---|
175 | ; on le complete par un .dat |
---|
176 | if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat' |
---|
177 | filename = isafile(file = filename, io = homedir, /new) |
---|
178 | ; |
---|
179 | widget_control, event.top, get_uvalue = uvalue |
---|
180 | widget_control, extractatt(uvalue, 'graphid'), get_value = win |
---|
181 | wshow, win |
---|
182 | wset, win |
---|
183 | image = tvrd(/true) |
---|
184 | save, uvalue, image, filename = filename |
---|
185 | END |
---|
186 | 'Print to prompt':BEGIN |
---|
187 | commande = getfile(myuniquetmpdir + 'xxx_oneplot.pro') |
---|
188 | for i = 0, n_elements(commande)-1 do print, commande[i] |
---|
189 | end |
---|
190 | 'Portrait/Landscape' :begin |
---|
191 | widget_control, event.top, get_uvalue = top_uvalue |
---|
192 | options = extractatt(top_uvalue, 'options') |
---|
193 | index = where(options EQ 'Portrait/Landscape') & index = index[0] |
---|
194 | optionsflag = extractatt(top_uvalue, 'optionsflag') |
---|
195 | key_portrait = 1-optionsflag[index, 0] |
---|
196 | (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = key_portrait |
---|
197 | ; fenetre separee ou fenetre collee au widget ? |
---|
198 | if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN |
---|
199 | ; on tue la fenetre |
---|
200 | graphid = extractatt(top_uvalue, 'graphid') |
---|
201 | widget_control, widget_info(graphid, /parent), /destroy |
---|
202 | ; on la recree |
---|
203 | basegraph = widget_base(title = 'xxx window', group_leader = event.top, uvalue = event.top, uname = 'basegraph') |
---|
204 | windsize = givewindowsize() |
---|
205 | graphid = widget_draw(basegraph, uname = 'graph' $ |
---|
206 | , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ |
---|
207 | , /button_events, retain = 2 $ |
---|
208 | , xsize = windsize[0], ysize = windsize[1]) |
---|
209 | widget_control, basegraph, /realize |
---|
210 | xmanager, 'xxx', basegraph, /no_block |
---|
211 | ; on redessine ce qu''il y avait dedans |
---|
212 | ; on recupere la liste des instructions |
---|
213 | globalcommand = extractatt(top_uvalue, 'globalcommand') |
---|
214 | ; on complete par le premiere et les dernieres lignes du programme |
---|
215 | createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ |
---|
216 | , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ |
---|
217 | , KWDUSED = ', /noerase, PORTRAIT = portrait' |
---|
218 | ; on reattribue l''element graphid de la top_uvalue |
---|
219 | *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid |
---|
220 | ENDIF ELSE BEGIN |
---|
221 | extra = extractatt(top_uvalue, 'extra') |
---|
222 | xxx, CALLERWIDID = event.top, /redraw, _extra = extra |
---|
223 | widget_control, event.top, /destroy ;on ferme le widget |
---|
224 | ENDELSE |
---|
225 | end |
---|
226 | 'Overlay' :begin |
---|
227 | widget_control, event.top, get_uvalue = top_uvalue |
---|
228 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
229 | options = extractatt(top_uvalue, 'options') |
---|
230 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
231 | index = where(options EQ 'Overlay') |
---|
232 | ; on change le flag sur Longitude / x index |
---|
233 | flag = 1-flags[index, numdessinin] & flag = flag[0] |
---|
234 | ; on le reeatribue |
---|
235 | (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag |
---|
236 | end |
---|
237 | 'Vecteur':BEGIN |
---|
238 | widget_control, event.top, get_uvalue = top_uvalue |
---|
239 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
240 | options = extractatt(top_uvalue, 'options') |
---|
241 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
242 | index = where(options EQ 'Vecteur') |
---|
243 | ; on change le flag sur Longitude / x index |
---|
244 | flag = 1-flags[index, numdessinin] & flag = flag[0] |
---|
245 | ; on le reeatribue |
---|
246 | (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag |
---|
247 | end |
---|
248 | 'Longitude / x index':BEGIN |
---|
249 | widget_control, event.top, get_uvalue = top_uvalue |
---|
250 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
251 | options = extractatt(top_uvalue, 'options') |
---|
252 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
253 | index = where(options EQ 'Longitude / x index') |
---|
254 | ; on change le flag sur Longitude / x index |
---|
255 | flag = 1-flags[index, numdessinin] & flag = flag[0] |
---|
256 | ; on le reeatribue |
---|
257 | (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag |
---|
258 | ; maintenant on va changer les sliders definissant la boxzoom |
---|
259 | domainid = widget_info(event.top, find_by_uname = 'domain') |
---|
260 | boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] |
---|
261 | ; on veut retrouver le type de grille qui est utilisee |
---|
262 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
263 | listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid |
---|
264 | listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar |
---|
265 | vlstid = widget_info(event.top, find_by_uname = 'varlist') |
---|
266 | namevar = widget_info(vlstid, /combobox_gettext) |
---|
267 | indexvar = where(listvar EQ namevar) |
---|
268 | vargrid = strupcase(listgrid[indexvar]) |
---|
269 | if flag EQ 0 then BEGIN ; longitudes |
---|
270 | ; on fait un domdef pour retrouver le lon1 lon2 correspondant a la |
---|
271 | ; boxzoom definie sur le widget... |
---|
272 | domdef, boxzoom, gridtype = vargrid, /xindex $ |
---|
273 | , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] |
---|
274 | widget_control, domainid, set_value = [lon1, lon2, boxzoom[2:3]] |
---|
275 | ENDIF ELSE BEGIN ; xindex |
---|
276 | ; maintenant ion veut retrouver firstx, lastx correspondant a la |
---|
277 | ; boxzoom definie sur le widget... |
---|
278 | domdef, boxzoom, gridtype = vargrid $ |
---|
279 | , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] |
---|
280 | grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz |
---|
281 | widget_control, domainid, set_value = [firstx, lastx, boxzoom[2:3]] |
---|
282 | ENDELSE |
---|
283 | ; on met a jour la top_uvalue |
---|
284 | widget_control, domainid, get_value = boxzoom |
---|
285 | (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom |
---|
286 | end |
---|
287 | 'Latitude / y index':begin |
---|
288 | widget_control, event.top, get_uvalue = top_uvalue |
---|
289 | numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
290 | options = extractatt(top_uvalue, 'options') |
---|
291 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
292 | index = where(options EQ 'Latitude / y index') |
---|
293 | ; on change le flag sur Latitude / y index |
---|
294 | flag = 1-flags[index, numdessinin] & flag = flag[0] |
---|
295 | ; on le reeatribue |
---|
296 | (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag |
---|
297 | ; maintenant on va changer les sliders definissant la boxzoom |
---|
298 | domainid = widget_info(event.top, find_by_uname = 'domain') |
---|
299 | boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] |
---|
300 | ; on veut retrouver le type de grille qui est utilisee |
---|
301 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
302 | listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid |
---|
303 | listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar |
---|
304 | vlstid = widget_info(event.top, find_by_uname = 'varlist') |
---|
305 | namevar = widget_info(vlstid, /combobox_gettext) |
---|
306 | indexvar = where(listvar EQ namevar) |
---|
307 | vargrid = strupcase(listgrid[indexvar]) |
---|
308 | if flag EQ 0 then BEGIN ; latitudes |
---|
309 | ; on fait un domdef pour retrouver le lat1 lat2 correspondant a la |
---|
310 | ; boxzoom definie sur le widget... |
---|
311 | domdef, boxzoom, gridtype = vargrid, /yindex $ |
---|
312 | , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] |
---|
313 | widget_control, domainid, set_value = [boxzoom[0:1], lat1, lat2] |
---|
314 | ENDIF ELSE BEGIN ; yindex |
---|
315 | ; maintenant ion veut retrouver firsty, lasty correspondant a la |
---|
316 | ; boxzoom definie sur le widget... |
---|
317 | domdef, boxzoom, gridtype = vargrid $ |
---|
318 | , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] |
---|
319 | grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz |
---|
320 | widget_control, domainid, set_value = [boxzoom[0:1], firsty, lasty] |
---|
321 | ENDELSE |
---|
322 | ; on met a jour la top_uvalue |
---|
323 | widget_control, domainid, get_value = boxzoom |
---|
324 | (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom |
---|
325 | END |
---|
326 | endcase |
---|
327 | return |
---|
328 | end |
---|