pro xcreateanim_event, event @common ; on recupere les aguments contenus ds le widget if tag_names(event, /structure_name) NE 'WIDGET_BUTTON' then return widget_control, event.id, get_uvalue = uval if n_elements(uval) EQ 0 then return if uval EQ 'cancel' then begin widget_control, event.top, /destroy return ENDIF ; on va ecrire l''animation! ; widget_control, event.top, get_uvalue = local_uvalue widget_control, local_uvalue.parent, get_uvalue = top_uvalue ; calendar = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).time_counter ; widget_control, widget_info(event.top, find_by_uname = 'Filename') $ , get_value = nomfic & nomfic = nomfic[0] ; widget_control, widget_info(event.top, find_by_uname = 'directorie') $ , get_value = animdir & animdir = animdir[0] ; widget_control, widget_info(event.top, find_by_uname = 'debut') $ , get_value = vdate1 index1 = where(calendar eq juldate(vdate1, /vraidate)) & index1 = index1[0] if index1 EQ -1 then return ; widget_control, widget_info(event.handler, find_by_uname = 'fin') $ , get_value = vdate2 index2 = where(calendar eq juldate(vdate2, /vraidate)) & index2 = index2[0] if index2 EQ -1 OR index2 LE index1 then return ; on detruit le widget avant de creer le fichier .ps widget_control, event.top, /destroy ; test pour savoir quel type des calendrier on a caldat, calendar, m, d if total(d EQ 15) EQ n_elements(d) then mensuel = 1 ELSE mensuel = 0 if total(d EQ 1) EQ n_elements(d) AND total(m EQ 6) EQ n_elements(m) $ then annuel = 1 ELSE annuel = 0 ; ; creation de la routine qui nous serviera pour faire le dessin ; ; 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, DATE1IN = date1in, DATE2IN = date2in' $ , globalcommand $ , 'return', 'end'] putfile, isadirectory(io = homedir, title = 'Bad definition of homedir')+'xxx2ps.pro', globalcommand ; on l''ecrit resolve_routine, 'xxx2ps' ; on le compile ; ;--------creation du fichier---------- ; ; recupere le nombre d'octets surlequel on code la palette device, get_visual_depth = depth ; taille de l''image (en nombre de pixel: xsize = !d.x_size ysize = !d.y_size ; ; on verifie que le nom du fichier termine bien par .gif if strpos(nomfic, '.gif') EQ -1 then nomfic = nomfic+'.gif' current_window = !d.window window, /free, /pixmap, xsize=xsize, ysize=ysize ; indication du numero de l''image que l''on est en train de creer base = widget_base() sliderid = widget_slider(base, minimum = 1, maximum = index2-index1+1, value = 1 $ , title = 'image que l''on est en train de creer') widget_control,base,/realize ; ; commencement du fichier gif. ecriture d''une image vide date = vairdate(calendar[index1], mensuel = mensuel, annuel= annuel) xxx2ps, /noerase, date1in = date, date2in = date ; ; image = tvrd(true = depth GT 8) ;- If an 8-bit image was read, reduce the number of colors if depth le 8 then begin tvlct, red, green, blue, /get reduce_colors, image, index red = red[index] green = green[index] blue = blue[index] endif ; if depth gt 8 then $ ;- Convert 24-bit image to 8-bit image = color_quan(image, 1, red, green, blue, colors=256, get_translation = translation, /map_all) ; ; write_gif,animdir+nomfic, image, red, green, blue, /multiple wdelete, !d.window ; ; boucle de creation et d''ecriture ds le fichier. ; for ind = index1+1, index2 do BEGIN ; widget_control, sliderid, set_value = ind-index1+1 ; on bouge le slider ; window, /free, /pixmap, xsize=xsize, ysize=ysize date = vairdate(calendar[ind], mensuel = mensuel, annuel= annuel) xxx2ps, /noerase, date1 = date, date2 = date ; image = tvrd(true = depth GT 8) ; if depth gt 8 then $ image = color_quan(image, 1, aaa, bbb, ccc, colors=256, translation = translation) ; ; write_gif,animdir+nomfic,image,red, green, blue, /multiple wdelete, !d.window ENDFOR ; on met une derniere image blanche window, /free, /pixmap, xsize=xsize, ysize=ysize reinitplt plot, [0], [0], /nodata image = tvrd(true = depth GT 8) ; if depth gt 8 then $ image = color_quan(image, 1, aaa, bbb, ccc, colors=256, translation = translation) ; ; write_gif,animdir+nomfic,image,red, green, blue, /multiple wdelete, !d.window ; fermeture du fichier write_gif,animdir+nomfic,/close widget_control, base, /destroy ; rebascule en mode "normal" thisOS = strupcase(strmid(!version.os_family, 0, 3)) ; wset, current_window ; si on est sous x on essaie de lancer xanim... if thisOS NE 'MAC' AND thisOS NE 'WIN' then begin spawn, 'which xanim',result if strpos(result[0],'xanim') EQ strlen(result[0])-5 then spawn, 'xanim '+animdir+nomfic+' &' endif ; return end ;---------------------------------------------------------------- PRO xcreateanim, parent @common ; widget_control, parent, get_uvalue = top_uvalue ; ; on va s''assurer que toutes les procedures de sont pas pltt ; procedures = extractatt(top_uvalue, 'nameprocedures') if total(procedures EQ 'pltt') NE 0 then begin nothing = report('Certains des plots ont un axe se rapportant au temps. !C Animation impossible!', /error) return ENDIF ; ; on va s''assurer que toutes les figures ont le meme calendrier ; filelist = extractatt(top_uvalue, 'filelist') filenames = (extractatt(top_uvalue, 'champs'))[0, *] filenames = reform(filenames) filenames = filenames[uniq(filenames, sort(filenames))] if strtrim(filenames[0], 1) EQ '' then filenames = filenames[1:n_elements(filenames)-1] indexfile = (where(filelist EQ filenames[0]))[0] calendar = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).time_counter if n_elements(filenames) GT 1 then begin for i = 1, n_elements(filenames)-1 do begin indexfilebis = (where(filelist EQ filenames[i]))[0] calendarbis = (*(extractatt(top_uvalue, 'fileparameters'))[indexfilebis]).time_counter if n_elements(calendarbis) NE n_elements(calendar) then begin nothing = report('Les diffrents plots n''utilisent pas le meme calendrier. !C Animation impossible!', /error) return ENDIF if total(calendar NE calendarbis) NE 0 then begin nothing = report('Les diffrents plots n''utilisent pas le meme calendrier. !C Animation impossible!', /error) return endif endfor endif ; ; c''est possible de faire une animation ; base = widget_base(/column, title = 'creation d''une animation', uvalue = {parent:parent, indexfile:indexfile}) rien = widget_label(base, value = 'Quel nom donner a l''animation') rien = widget_text(base,value='anim_idl.gif', uname='Filename', /editable) rien = widget_label(base, value = 'repertoire ou mettre le fichier') if n_elements(animdir) EQ 0 then cd, current = animdir rien = widget_text(base,value=animdir, uname='directorie', /editable) rien = widget_label(base, value = 'Debut de l''animation') rien = cw_calendar(base, calendar, uname = 'debut', uvalue = {name:'calendar'}, /frame) rien = widget_label(base, value = 'Fin de l''animation') rien = cw_calendar(base, calendar, calendar[n_elements(calendar)-1] $ , uname = 'fin', uvalue = {name:'calendar'}, /frame) rien = widget_button(base,value='OK', uvalue = 'ok') rien = widget_button(base,value='Cancel', uvalue = 'cancel') ; widget_control,base,/realize xmanager,'xcreateanim', base, /no_block return end