;------------------------------------------------ PRO xxxmenubar_event, event @common case event.value of 'Open' :begin oldmeshparams = ccmeshparameters newfile = selectfile() if size(newfile, /type) NE 8 then return widget_control, event.top, /hourglass widget_control, event.top, update = 0 widget_control, event.top, get_uvalue = top_uvalue ; on s''occupe de filelist filelist = extractatt(top_uvalue, 'filelist') filelist = [filelist, newfile.fileparameters.filename] currentfile = n_elements(filelist)-1 ; on update le widget filelistid = widget_info(event.top, find_by_uname = 'filelist') widget_control, filelistid, combobox_additem = file_basename(newfile.fileparameters.filename) widget_control, filelistid, set_combobox_select = currentfile ; on update les elements filelist et currentfile de la top_uvalue *top_uvalue[1, findline(top_uvalue, 'filelist')] = filelist oldfile = *top_uvalue[1, findline(top_uvalue, 'currentfile')] *top_uvalue[1, findline(top_uvalue, 'currentfile')] = currentfile ; on s''occupe du nom de la variable vlstid = widget_info(event.top, find_by_uname = 'varlist') ; quel etait le champ selectionne ? on le reselectionne ? fieldname = widget_info(vlstid, /combobox_gettext) index = where(newfile.fileparameters.listvar EQ fieldname) widget_control, vlstid, set_value = newfile.fileparameters.listvar widget_control, vlstid, set_combobox_select = 0 > index[0] ; on s''occupe du calendrier key_caltype = newfile.fileparameters.caltype date1id = widget_info(event.top, find_by_uname = 'calendar1') widget_control, date1id, get_value = date1 widget_control, date1id, /destroy jdate1 = jul2date(date1) if (where(newfile.fileparameters.time_counter EQ jdate1))[0] EQ -1 $ then jdate1 = newfile.fileparameters.time_counter[0] date2id = widget_info(event.top, find_by_uname = 'calendar2') widget_control, date2id, get_value = date2 widget_control, date2id, /destroy jdate2 = jul2date(date2) if (where(newfile.fileparameters.time_counter EQ jdate2))[0] EQ -1 then jdate2 = jdate1 basecal = widget_info(event.top, find_by_uname = 'basecal') fakecal = newfile.fileparameters.fakecal rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate1, uname = 'calendar1' $ , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame) rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate2, uname = 'calendar2' $ , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame) ; on update les elements fileparameters, readparameters et meshparameters de la top_uvalue newfileparameters = ptrarr(currentfile+1, /allocate_heap) FOR i = 0, currentfile-1 DO $ *newfileparameters[i] = *(extractatt(top_uvalue, 'fileparameters'))[i] *newfileparameters[currentfile] = newfile.fileparameters ptr_free, extractatt(top_uvalue, 'fileparameters') *top_uvalue[1, findline(top_uvalue, 'fileparameters')] = newfileparameters ; newreadparameters = ptrarr(currentfile+1, /allocate_heap) FOR i = 0, currentfile-1 DO $ *newreadparameters[i] = *(extractatt(top_uvalue, 'readparameters'))[i] *newreadparameters[currentfile] = newfile.readparameters ptr_free, extractatt(top_uvalue, 'readparameters') *top_uvalue[1, findline(top_uvalue, 'readparameters')] = newreadparameters ; newmeshparameters = ptrarr(currentfile+1, /allocate_heap) FOR i = 0, currentfile-1 DO $ *newmeshparameters[i] = *(extractatt(top_uvalue, 'meshparameters'))[i] *newmeshparameters[currentfile] = newfile.meshparameters ptr_free, extractatt(top_uvalue, 'meshparameters') *top_uvalue[1, findline(top_uvalue, 'meshparameters')] = newmeshparameters ; on actualise le widget! if cmpgrid(oldmeshparams) then BEGIN domainid = widget_info(event.top, find_by_uname = 'domain') widget_control, domainid, set_value = -1 endif widget_control, event.top, update = 1 end 'New xxx' :BEGIN widget_control, event.top, get_uvalue = top_uvalue extra = extractatt(top_uvalue, 'extra') xxx, CALLERWIDID = event.top, _extra = extra end 'Quit':begin widget_control, event.top, get_uvalue = top_uvalue ptr_free, extractatt(top_uvalue, 'exextra') ptr_free, extractatt(top_uvalue, 'fileparameters') ptr_free, extractatt(top_uvalue, 'readparameters') ptr_free, extractatt(top_uvalue, 'meshparameters') ptr_free, top_uvalue widget_control, event.top, /destroy ;on ferme le widget end 'PostScript' :BEGIN IF lmgr(/demo) EQ 1 THEN BEGIN dummy = report('impossible to save as postscript in demo mode') return ENDIF widget_control, event.top, get_uvalue = top_uvalue ; on recupere la liste des instructions globalcommand = extractatt(top_uvalue, 'globalcommand') ; for i = 0, n_elements(globalcommand)-1 do print, globalcommand[i] ; on complete par le premiere et les dernieres lignes du programme createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $ +', PORTRAIT = portrait, LANDSCAPE = landscape' $ +', DATE1IN = date1in, DATE2IN = date2in' $ , /POSTSCRIPT END 'Animated gif' :begin IF float(strmid(!version.release,0,3)) GE 6.2 THEN xcreateanim, event.top end 'Gif' :BEGIN IF lmgr(/demo) EQ 1 THEN BEGIN dummy = report('impossible to save as an image in demo mode') return ENDIF widget_control, event.top, get_uvalue = top_uvalue smallin = extractatt(top_uvalue, 'smallin') numdessinin = smallin[2]-1 smallout = extractatt(top_uvalue, 'smallout') numdessinout = smallout[2]-1 tracecadre, smallin, /erase tracecadre, smallout, /erase filename = xquestion('dans quelle fichier gif voulez vous sauver !C l''ecran de xxx?', 'xxx_image.gif') if rstrpos(filename, '.gif') NE strlen(filename)-4 then filename = filename+'.gif' filename = isafile(file = filename, io = imagedir, /new) saveimage, filename, /quiet end 'IDL procedure':BEGIN IF lmgr(/demo) EQ 1 THEN BEGIN dummy = report('impossible to save as a idl program file in demo mode') return ENDIF ; on recupere le nom du fichier filename = xquestion('dans quelle procedure IDL voulez vous sauver !C la realisation de ce graph?', 'xxx_figure.pro') ; on le complete par un .pro if rstrpos(filename, '.pro') NE strlen(filename)-4 then filename = filename+'.pro' filename = isafile(file = filename, io = homedir, /new) widget_control, event.top, get_uvalue = top_uvalue ; portrait ou landscape ??? options = extractatt(top_uvalue, 'options') optionsflag = extractatt(top_uvalue, 'optionsflag') portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] ; on lit les commandes pour faire un plot globalcommand = extractatt(top_uvalue, 'globalcommand') ; on complete par le premiere et les dernieres lignes du programme thisOS = strupcase(strmid(!version.os_family, 0, 3)) CASE thisOS of 'MAC':sep = ':' 'WIN':sep = '\' ELSE:sep = '/' ENDCASE poslastsep = rstrpos(filename, sep) proname = strmid(filename, poslastsep+1, strlen(filename)-poslastsep-1-4) globalcommand = ['pro '+proname+', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ , ' ' $ , ' '+globalcommand $ , ' ' $ , 'return' $ , 'end'] ; on les ecrit dans un programme putfile, filename, globalcommand END 'RESTORE kwd of xxx':BEGIN IF lmgr(/demo) EQ 1 THEN BEGIN dummy = report('impossible to save the widget in demo mode') return ENDIF ; on recupere le nom du fichier filename = xquestion('dans quel fichier bianire voulez vous sauver le widget ?', 'xxx_widget.dat') ; on le complete par un .dat if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat' filename = isafile(file = filename, io = homedir, /new) ; widget_control, event.top, get_uvalue = uvalue widget_control, extractatt(uvalue, 'graphid'), get_value = win wshow, win wset, win image = tvrd(/true) save, uvalue, image, filename = filename END 'Print to prompt':BEGIN commande = getfile(myuniquetmpdir + 'xxx_oneplot.pro') for i = 0, n_elements(commande)-1 do print, commande[i] end 'Portrait/Landscape' :begin widget_control, event.top, get_uvalue = top_uvalue options = extractatt(top_uvalue, 'options') index = where(options EQ 'Portrait/Landscape') & index = index[0] optionsflag = extractatt(top_uvalue, 'optionsflag') key_portrait = 1-optionsflag[index, 0] (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = key_portrait ; fenetre separee ou fenetre collee au widget ? if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN ; on tue la fenetre graphid = extractatt(top_uvalue, 'graphid') widget_control, widget_info(graphid, /parent), /destroy ; on la recree basegraph = widget_base(title = 'xxx window', group_leader = event.top, uvalue = event.top, uname = 'basegraph') windsize = givewindowsize() graphid = widget_draw(basegraph, uname = 'graph' $ , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ , /button_events, retain = 2 $ , xsize = windsize[0], ysize = windsize[1]) widget_control, basegraph, /realize xmanager, 'xxx', basegraph, /no_block ; on redessine ce qu''il y avait dedans ; on recupere la liste des instructions globalcommand = extractatt(top_uvalue, 'globalcommand') ; on complete par le premiere et les dernieres lignes du programme createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ , KWDUSED = ', /noerase, PORTRAIT = portrait' ; on reattribue l''element graphid de la top_uvalue *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid ENDIF ELSE BEGIN extra = extractatt(top_uvalue, 'extra') xxx, CALLERWIDID = event.top, /redraw, _extra = extra widget_control, event.top, /destroy ;on ferme le widget ENDELSE end 'Overlay' :begin widget_control, event.top, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 options = extractatt(top_uvalue, 'options') flags = extractatt(top_uvalue, 'optionsflag') index = where(options EQ 'Overlay') ; on change le flag sur Longitude / x index flag = 1-flags[index, numdessinin] & flag = flag[0] ; on le reeatribue (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag end 'Vecteur':BEGIN widget_control, event.top, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 options = extractatt(top_uvalue, 'options') flags = extractatt(top_uvalue, 'optionsflag') index = where(options EQ 'Vecteur') ; on change le flag sur Longitude / x index flag = 1-flags[index, numdessinin] & flag = flag[0] ; on le reeatribue (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag end 'Longitude / x index':BEGIN widget_control, event.top, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 options = extractatt(top_uvalue, 'options') flags = extractatt(top_uvalue, 'optionsflag') index = where(options EQ 'Longitude / x index') ; on change le flag sur Longitude / x index flag = 1-flags[index, numdessinin] & flag = flag[0] ; on le reeatribue (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag ; maintenant on va changer les sliders definissant la boxzoom domainid = widget_info(event.top, find_by_uname = 'domain') boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] ; on veut retrouver le type de grille qui est utilisee currentfile = extractatt(top_uvalue, 'currentfile') listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar vlstid = widget_info(event.top, find_by_uname = 'varlist') namevar = widget_info(vlstid, /combobox_gettext) indexvar = where(listvar EQ namevar) vargrid = strupcase(listgrid[indexvar]) if flag EQ 0 then BEGIN ; longitudes ; on fait un domdef pour retrouver le lon1 lon2 correspondant a la ; boxzoom definie sur le widget... domdef, boxzoom, gridtype = vargrid, /xindex $ , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] widget_control, domainid, set_value = [lon1, lon2, boxzoom[2:3]] ENDIF ELSE BEGIN ; xindex ; maintenant ion veut retrouver firstx, lastx correspondant a la ; boxzoom definie sur le widget... domdef, boxzoom, gridtype = vargrid $ , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz widget_control, domainid, set_value = [firstx, lastx, boxzoom[2:3]] ENDELSE ; on met a jour la top_uvalue widget_control, domainid, get_value = boxzoom (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom end 'Latitude / y index':begin widget_control, event.top, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 options = extractatt(top_uvalue, 'options') flags = extractatt(top_uvalue, 'optionsflag') index = where(options EQ 'Latitude / y index') ; on change le flag sur Latitude / y index flag = 1-flags[index, numdessinin] & flag = flag[0] ; on le reeatribue (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag ; maintenant on va changer les sliders definissant la boxzoom domainid = widget_info(event.top, find_by_uname = 'domain') boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] ; on veut retrouver le type de grille qui est utilisee currentfile = extractatt(top_uvalue, 'currentfile') listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar vlstid = widget_info(event.top, find_by_uname = 'varlist') namevar = widget_info(vlstid, /combobox_gettext) indexvar = where(listvar EQ namevar) vargrid = strupcase(listgrid[indexvar]) if flag EQ 0 then BEGIN ; latitudes ; on fait un domdef pour retrouver le lat1 lat2 correspondant a la ; boxzoom definie sur le widget... domdef, boxzoom, gridtype = vargrid, /yindex $ , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] widget_control, domainid, set_value = [boxzoom[0:1], lat1, lat2] ENDIF ELSE BEGIN ; yindex ; maintenant ion veut retrouver firsty, lasty correspondant a la ; boxzoom definie sur le widget... domdef, boxzoom, gridtype = vargrid $ , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz widget_control, domainid, set_value = [boxzoom[0:1], firsty, lasty] ENDELSE ; on met a jour la top_uvalue widget_control, domainid, get_value = boxzoom (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom END endcase return end