;+ ; ; @file_comments ; ; @categories ; ; @param EVENT ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ; ; @todo ; seb ; ;- PRO xcreateanim_event, event ; compile_opt idl2, strictarrsubs ; @common ; We recuperate arguments contained in the 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 ; We will write the 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 key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).caltype fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).fakecal ; 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(abs(calendar - date2jul(vdate1)) LT 1./86400.))[0] if index1 EQ -1 then return ; widget_control, widget_info(event.handler, find_by_uname = 'fin') $ , get_value = vdate2 index2 = (where(abs(calendar - date2jul(vdate2)) LT 1./86400.))[0] if index2 EQ -1 OR index2 LE index1 then return ; We delete the widget before create the file .ps widget_control, event.top, /destroy ; ; creation of the routine which will serve us to do the drawing ; ; We recuperate the list of instructions globalcommand = extractatt(top_uvalue, 'globalcommand') ; We complete by first and last lines of the program createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, DATE1IN = date1in, DATE2IN = date2in' ; ;--------creation of the file--------- ; ; we recuperate the number of octets on which we code the palette. device, get_visual_depth = depth ; Picture's size (in number of pixels): xsize = !d.x_size ysize = !d.y_size ; ; We check that the file's name end by .gif if strpos(nomfic, '.gif') EQ -1 then nomfic = nomfic+'.gif' current_window = !d.window window, /free, /pixmap, xsize = xsize, ysize = ysize ; indication of the number of the picture we are creating base = widget_base() sliderid = widget_slider(base, minimum = 1, maximum = index2-index1+1, value = 1 $ , title = 'image number: ') widget_control, base, /realize ; ; Beginning of the gif file. Writing of an empty picture. IF keyword_set(fakecal) THEN date = index1 ELSE date = jul2date(calendar[index1]) 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 ; ; Creation and writting loop in the file. ; IF index2 GT index1 THEN BEGIN FOR ind = index1+1, index2 do BEGIN ; widget_control, sliderid, set_value = ind-index1+1 ; We move the slider. ; window, /free, /pixmap, xsize = xsize, ysize = ysize IF keyword_set(fakecal) THEN date = ind ELSE date = jul2date(calendar[ind]) 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 ENDIF ; We put a last white picture 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 ; File's closing. write_gif, animdir+nomfic, /close widget_control, base, /destroy ; Rerock in "normal" mode thisOS = strupcase(strmid(!version.os_family, 0, 3)) ; wset, current_window ; If we are under X, we try to launch 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 ; ;+ ; @file_comments ; ; @categories ; ; @param PARENT ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ; ; @todo ; seb ; ;- PRO xcreateanim, parent ; compile_opt idl2, strictarrsubs ; @common ; widget_control, parent, get_uvalue = top_uvalue ; ; We will make sure that all procedure are not in 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 ; ; We will make sure that all figure have the same calendar ; filelist = extractatt(top_uvalue, 'filelist') filenames = (extractatt(top_uvalue, 'varinfo'))[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 key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).caltype fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).fakecal 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('plots do not use the same calendar. !C Animation impossible!', /error) return ENDIF if total(calendar NE calendarbis) NE 0 then begin nothing = report('plots do not use the same calendar. !C Animation impossible!', /error) return endif endfor endif ; ; It is possible to do an animation. ; base = widget_base(/column, title = 'animation creation', uvalue = {parent:parent, indexfile:indexfile}) rien = widget_label(base, value = 'animation name') rien = widget_text(base,value='anim_idl.gif', uname='Filename', /editable) rien = widget_label(base, value = 'animation directory') if n_elements(animdir) EQ 0 then cd, current = animdir rien = widget_text(base,value=animdir, uname='directorie', /editable) rien = widget_label(base, value = 'starting date') rien = cw_calendar(base, calendar, calendar[0] $ , FAKECAL = fakecal, uname = 'debut', uvalue = {name:'calendar'}, /frame) rien = widget_label(base, value = 'ending date') rien = cw_calendar(base, calendar, calendar[n_elements(calendar)-1] $ , FAKECAL = fakecal, 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