;------------------------------------------------ PRO xxxmenubar_event, event @common case event.value of 'Open' :begin 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, set_value = filelist widget_control, filelistid, set_list_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 champid = widget_info(event.top, find_by_uname = 'champ') ; quel etait le champ selectionne ? on le reselectionne ? oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar fieldname = oldlistvar[widget_info(champid,/droplist_select)] index = where(newfile.fileparameters.listvar EQ fieldname) & index = 0>index[0] widget_control, champid, set_value = newfile.fileparameters.listvar widget_control, champid, set_droplist_select = index ; on s''occupe du calendrier date1id = widget_info(event.top, find_by_uname = 'calendar1') widget_control, date1id, get_value = date1 widget_control, date1id, /destroy if (where(newfile.fileparameters.time_counter EQ date1))[0] EQ -1 $ then date1 = newfile.fileparameters.time_counter[0] date2id = widget_info(event.top, find_by_uname = 'calendar2') widget_control, date2id, get_value = date2 widget_control, date2id, /destroy if (where(newfile.fileparameters.time_counter EQ date2))[0] EQ -1 then date2 = date1 base12 = widget_info(event.top, find_by_uname = 'base12') rien = cw_calendar(base12,newfile.fileparameters.time_counter,date1, uname = 'calendar1' $ , uvalue = {name:'calendar1'}, /frame) rien = cw_calendar(base12,newfile.fileparameters.time_counter,date2, uname = 'calendar2' $ , uvalue = {name:'calendar2'}, /frame) ; update la grille??? change = changegrid(newfile.meshparameters) if change then BEGIN domainid = widget_info(event.top, find_by_uname = 'domain') widget_control, domainid, set_value = -1 endif ; 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! 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 'PS' :BEGIN ; we find homedir homedir = isadirectory(io = homedir, title = 'Bad definition of homedir') 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 recupere la liste des instructions globalcommand = extractatt(top_uvalue, 'globalcommand') ; on complete par le premiere et les dernieres lignes du programme globalcommand = ['pro xxx2ps, NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ , globalcommand $ , 'return', 'end'] putfile, homedir+'xxx2ps.pro', globalcommand ; on l''ecrit resolve_routine, 'xxx2ps' ; on le compile xxx2ps, /post, portrait = portrait ; on l''applique END 'Anim' :begin xcreateanim, event.top end 'Gif' :BEGIN widget_control,event.top, get_uvalue = top_uvalue petitin = extractatt(top_uvalue, 'petitin') numdessinin = petitin[2]-1 petitout = extractatt(top_uvalue, 'petitout') numdessinout = petitout[2]-1 tracecadre, petitin, /erase tracecadre, petitout, /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 'Script':BEGIN ; 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' $ , '@common' $ , ' ' $ , ' portrait = '+strtrim(portrait, 1) $ , ' '+globalcommand $ , ' ' $ , 'return' $ , 'end'] ; on les ecrit dans un programme putfile, filename, globalcommand END 'Widget':BEGIN ; 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 'Prompt':BEGIN commande = getfile(isadirectory(io = homedir)+'xxx_oneplot.pro') for i = 0, n_elements(commande)-1 do print, commande[i] end 'Ok button' :begin widget_control, event.top, get_uvalue = top_uvalue options = extractatt(top_uvalue, 'options') index = where(options EQ 'Ok button') & index = index[0] optionsflag = extractatt(top_uvalue, 'optionsflag') flag = 1-optionsflag[index, 0] (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = flag widget_control, widget_info(event.top, find_by_uname = 'base ok button'), map = flag 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 ; we find homedir homedir = isadirectory(io = homedir, title = 'Bad definition of homedir') ; on recupere la liste des instructions globalcommand = extractatt(top_uvalue, 'globalcommand') ; on complete par le premiere et les dernieres lignes du programme globalcommand = ['pro xxx2ps, NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ , globalcommand $ , 'return', 'end'] putfile, homedir+'xxx2ps.pro', globalcommand ; on l''ecrit resolve_routine, 'xxx2ps' ; on le compile xxx2ps, /noerase, portrait = key_portrait ; on l''applique ; 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, 'petitin'))[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, 'petitin'))[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, 'petitin'))[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 boite domainid = widget_info(event.top, find_by_uname = 'domain') boite = (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 indexvar = widget_info(widget_info(event.top, find_by_uname = 'champ'), /droplist_select) vargrid = strupcase(listgrid[indexvar]) if flag EQ 0 then BEGIN ; longitudes ; on fait un domdef pour retrouver le lon1 lon2 correspondant a la ; boite definie sur le widget... domdef, boite, grille = vargrid, /xindex $ , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] widget_control, domainid, set_value = [lon1, lon2, boite[2:3]] ENDIF ELSE BEGIN ; xindex ; maintenant ion veut retrouver premierx, dernierx correspondant a la ; boite definie sur le widget... domdef, boite, grille = vargrid $ , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] grille, mask,glam,gphi,gdep,nx,ny,nz,premierx,premiery,premierz,dernierx,derniery,dernierz widget_control, domainid, set_value = [premierx, dernierx, boite[2:3]] ENDELSE ; on met a jour la top_uvalue widget_control, domainid, get_value = boite (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boite end 'Latitude / y index':begin widget_control, event.top, get_uvalue = top_uvalue numdessinin = (extractatt(top_uvalue, 'petitin'))[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 boite domainid = widget_info(event.top, find_by_uname = 'domain') boite = (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 indexvar = widget_info(widget_info(event.top, find_by_uname = 'champ'), /droplist_select) vargrid = strupcase(listgrid[indexvar]) if flag EQ 0 then BEGIN ; latitudes ; on fait un domdef pour retrouver le lat1 lat2 correspondant a la ; boite definie sur le widget... domdef, boite, grille = vargrid, /yindex $ , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] widget_control, domainid, set_value = [boite[0:1], lat1, lat2] ENDIF ELSE BEGIN ; yindex ; maintenant ion veut retrouver premiery, derniery correspondant a la ; boite definie sur le widget... domdef, boite, grille = vargrid $ , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] grille, mask,glam,gphi,gdep,nx,ny,nz,premierx,premiery,premierz,dernierx,derniery,dernierz widget_control, domainid, set_value = [boite[0:1], premiery, derniery] ENDELSE ; on met a jour la top_uvalue widget_control, domainid, get_value = boite (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boite end endcase return end ;------------------------------------------------ PRO xxxmenubar, parent, OPTIONS =options, _EXTRA = ex ; desc = [ '1\Colors' , $ ; '0\Red' , $ ; '0\Green' , $ ; '1\Blue' , $ ; '0\Light' , $ ; '0\Medium' , $ ; '0\Dark' , $ ; '0\Navy' , $ ; '2\Royal' , $ ; '0\Cyan' , $ ; '2\Magenta' , $ ; '2\Quit' ] desc = [ '1\File' , $ '0\Open' , $ '0\New xxx' , $ '2\Quit', $ '1\Save as' , $ '0\PS' , $ '0\Anim' , $ '0\Gif' , $ '0\Script', $ '0\Widget', $ '2\Prompt', $ '1\Flag options'] descsuite = options if n_elements(descsuite) GE 2 then $ descsuite[0:n_elements(descsuite)-2] = '0\'+descsuite[0:n_elements(descsuite)-2] descsuite[n_elements(descsuite)-1] = '2\'+descsuite[n_elements(descsuite)-1] desc = [desc, descsuite] menu = CW_PDMENU(parent, desc, /RETURN_NAME, /mbar, uname = 'menubar', uvalue = {name:'menubar'}, _EXTRA = ex) ;------------------------------------------------ return end