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