[150] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[150] | 3 | ; @file_comments |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; |
---|
| 7 | ; @param EVENT |
---|
| 8 | ; |
---|
| 9 | ; @returns |
---|
[226] | 10 | ; |
---|
[150] | 11 | ; @uses |
---|
[226] | 12 | ; |
---|
[150] | 13 | ; @restrictions |
---|
[226] | 14 | ; |
---|
[150] | 15 | ; @examples |
---|
[226] | 16 | ; |
---|
[150] | 17 | ; @history |
---|
[226] | 18 | ; |
---|
[150] | 19 | ; @version |
---|
[226] | 20 | ; $Id$ |
---|
| 21 | ; |
---|
[150] | 22 | ; @todo |
---|
| 23 | ; seb |
---|
| 24 | ; |
---|
| 25 | ;- |
---|
[114] | 26 | ; |
---|
[231] | 27 | PRO xcreateanim_event, event |
---|
| 28 | ; |
---|
[114] | 29 | compile_opt idl2, strictarrsubs |
---|
| 30 | ; |
---|
[2] | 31 | @common |
---|
[150] | 32 | ; We recuperate arguments contained in the widget |
---|
[74] | 33 | if tag_names(event, /structure_name) NE 'WIDGET_BUTTON' then return |
---|
| 34 | widget_control, event.id, get_uvalue = uval |
---|
| 35 | if n_elements(uval) EQ 0 then return |
---|
| 36 | if uval EQ 'cancel' then begin |
---|
| 37 | widget_control, event.top, /destroy |
---|
| 38 | return |
---|
| 39 | ENDIF |
---|
[150] | 40 | ; We will write the animation! |
---|
[2] | 41 | ; |
---|
[74] | 42 | widget_control, event.top, get_uvalue = local_uvalue |
---|
| 43 | widget_control, local_uvalue.parent, get_uvalue = top_uvalue |
---|
[2] | 44 | ; |
---|
[74] | 45 | calendar = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).time_counter |
---|
| 46 | key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).caltype |
---|
| 47 | fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).fakecal |
---|
[2] | 48 | ; |
---|
[74] | 49 | widget_control, widget_info(event.top, find_by_uname = 'Filename') $ |
---|
| 50 | , get_value = nomfic & nomfic = nomfic[0] |
---|
[2] | 51 | ; |
---|
[74] | 52 | widget_control, widget_info(event.top, find_by_uname = 'directorie') $ |
---|
| 53 | , get_value = animdir & animdir = animdir[0] |
---|
[2] | 54 | ; |
---|
[74] | 55 | widget_control, widget_info(event.top, find_by_uname = 'debut') $ |
---|
| 56 | , get_value = vdate1 |
---|
[226] | 57 | index1 = where(calendar eq date2jul(vdate1)) & index1 = index1[0] |
---|
[74] | 58 | if index1 EQ -1 then return |
---|
[2] | 59 | ; |
---|
[74] | 60 | widget_control, widget_info(event.handler, find_by_uname = 'fin') $ |
---|
| 61 | , get_value = vdate2 |
---|
[226] | 62 | index2 = where(calendar eq date2jul(vdate2)) & index2 = index2[0] |
---|
[74] | 63 | if index2 EQ -1 OR index2 LE index1 then return |
---|
[150] | 64 | ; We delete the widget before create the file .ps |
---|
[74] | 65 | widget_control, event.top, /destroy |
---|
[2] | 66 | ; |
---|
[150] | 67 | ; creation of the routine which will serve us to do the drawing |
---|
[2] | 68 | ; |
---|
[226] | 69 | ; We recuperate the list of instructions |
---|
[74] | 70 | globalcommand = extractatt(top_uvalue, 'globalcommand') |
---|
[150] | 71 | ; We complete by first and last lines of the program |
---|
[74] | 72 | createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ |
---|
| 73 | , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, DATE1IN = date1in, DATE2IN = date2in' |
---|
[2] | 74 | ; |
---|
[150] | 75 | ;--------creation of the file--------- |
---|
[2] | 76 | ; |
---|
[150] | 77 | ; we recuperate the number of octets on which we code the palette. |
---|
[74] | 78 | device, get_visual_depth = depth |
---|
[150] | 79 | ; Picture's size (in number of pixels): |
---|
[74] | 80 | xsize = !d.x_size |
---|
| 81 | ysize = !d.y_size |
---|
[2] | 82 | ; |
---|
[150] | 83 | ; We check that the file's name end by .gif |
---|
[74] | 84 | if strpos(nomfic, '.gif') EQ -1 then nomfic = nomfic+'.gif' |
---|
[2] | 85 | |
---|
[74] | 86 | current_window = !d.window |
---|
| 87 | window, /free, /pixmap, xsize = xsize, ysize = ysize |
---|
[2] | 88 | |
---|
| 89 | |
---|
[150] | 90 | ; indication of the number of the picture we are creating |
---|
[74] | 91 | base = widget_base() |
---|
| 92 | sliderid = widget_slider(base, minimum = 1, maximum = index2-index1+1, value = 1 $ |
---|
| 93 | , title = 'image number: ') |
---|
| 94 | widget_control, base, /realize |
---|
[2] | 95 | ; |
---|
[150] | 96 | ; Beginning of the gif file. Writting of an empty picture. |
---|
[74] | 97 | IF keyword_set(fakecal) THEN date = index1 ELSE date = jul2date(calendar[index1]) |
---|
| 98 | xxx2ps, /noerase, date1in = date, date2in = date |
---|
[2] | 99 | ; |
---|
| 100 | ; |
---|
[74] | 101 | image = tvrd(true = depth GT 8) |
---|
[2] | 102 | ;- If an 8-bit image was read, reduce the number of colors |
---|
[74] | 103 | if depth le 8 then begin |
---|
| 104 | tvlct, red, green, blue, /get |
---|
| 105 | reduce_colors, image, index |
---|
| 106 | red = red[index] |
---|
| 107 | green = green[index] |
---|
| 108 | blue = blue[index] |
---|
[226] | 109 | endif |
---|
[2] | 110 | ; |
---|
[74] | 111 | if depth gt 8 then $ |
---|
[2] | 112 | ;- Convert 24-bit image to 8-bit |
---|
[74] | 113 | image = color_quan(image, 1, red, green, blue, colors = 256, get_translation = translation, /map_all) |
---|
[2] | 114 | ; |
---|
| 115 | ; |
---|
[74] | 116 | write_gif, animdir+nomfic, image, red, green, blue, /multiple |
---|
| 117 | wdelete, !d.window |
---|
[2] | 118 | ; |
---|
[150] | 119 | ; Creation and writting loop in the file. |
---|
[2] | 120 | ; |
---|
[74] | 121 | IF index2 GT index1 THEN BEGIN |
---|
| 122 | FOR ind = index1+1, index2 do BEGIN |
---|
[2] | 123 | ; |
---|
[150] | 124 | widget_control, sliderid, set_value = ind-index1+1 ; We move the slider. |
---|
[2] | 125 | ; |
---|
[74] | 126 | window, /free, /pixmap, xsize = xsize, ysize = ysize |
---|
| 127 | IF keyword_set(fakecal) THEN date = ind ELSE date = jul2date(calendar[ind]) |
---|
[2] | 128 | xxx2ps, /noerase, date1 = date, date2 = date |
---|
[226] | 129 | ; |
---|
[2] | 130 | image = tvrd(true = depth GT 8) |
---|
| 131 | ; |
---|
| 132 | if depth gt 8 then $ |
---|
[74] | 133 | image = color_quan(image, 1, aaa, bbb, ccc, colors = 256, translation = translation) ; |
---|
[2] | 134 | ; |
---|
[74] | 135 | write_gif, animdir+nomfic, image, red, green, blue, /multiple |
---|
[2] | 136 | wdelete, !d.window |
---|
[74] | 137 | ENDFOR |
---|
[226] | 138 | ENDIF |
---|
[150] | 139 | ; We put a last white picture |
---|
[74] | 140 | window, /free, /pixmap, xsize = xsize, ysize = ysize |
---|
| 141 | reinitplt |
---|
| 142 | plot, [0], [0], /nodata |
---|
| 143 | image = tvrd(true = depth GT 8) |
---|
[2] | 144 | ; |
---|
[74] | 145 | if depth gt 8 then $ |
---|
| 146 | image = color_quan(image, 1, aaa, bbb, ccc, colors = 256, translation = translation) ; |
---|
[2] | 147 | ; |
---|
[74] | 148 | write_gif, animdir+nomfic, image, red, green, blue, /multiple |
---|
| 149 | wdelete, !d.window |
---|
[150] | 150 | ; File's closing. |
---|
[226] | 151 | write_gif, animdir+nomfic, /close |
---|
| 152 | widget_control, base, /destroy |
---|
[150] | 153 | ; Rerock in "normal" mode |
---|
[74] | 154 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
[2] | 155 | ; |
---|
[74] | 156 | wset, current_window |
---|
[2] | 157 | |
---|
[150] | 158 | ; If we are under x, we try to lauch xanim... |
---|
[2] | 159 | |
---|
[74] | 160 | if thisOS NE 'MAC' AND thisOS NE 'WIN' then begin |
---|
| 161 | spawn, 'which xanim', result |
---|
| 162 | if strpos(result[0], 'xanim') EQ strlen(result[0])-5 then spawn, 'xanim '+animdir+nomfic+' &' |
---|
| 163 | endif |
---|
[2] | 164 | ; |
---|
[226] | 165 | |
---|
[74] | 166 | return |
---|
[2] | 167 | end |
---|
[231] | 168 | ; |
---|
[150] | 169 | ;+ |
---|
| 170 | ; @file_comments |
---|
| 171 | ; |
---|
| 172 | ; @categories |
---|
| 173 | ; |
---|
| 174 | ; @param PARENT |
---|
| 175 | ; |
---|
| 176 | ; @returns |
---|
[226] | 177 | ; |
---|
[150] | 178 | ; @uses |
---|
[226] | 179 | ; |
---|
[150] | 180 | ; @restrictions |
---|
[226] | 181 | ; |
---|
[150] | 182 | ; @examples |
---|
[226] | 183 | ; |
---|
[150] | 184 | ; @history |
---|
[226] | 185 | ; |
---|
[150] | 186 | ; @version |
---|
[226] | 187 | ; $Id$ |
---|
| 188 | ; |
---|
[150] | 189 | ; @todo |
---|
| 190 | ; seb |
---|
| 191 | ; |
---|
| 192 | ;- |
---|
[231] | 193 | ; |
---|
[2] | 194 | PRO xcreateanim, parent |
---|
[114] | 195 | ; |
---|
| 196 | compile_opt idl2, strictarrsubs |
---|
| 197 | ; |
---|
[2] | 198 | @common |
---|
| 199 | ; |
---|
| 200 | widget_control, parent, get_uvalue = top_uvalue |
---|
| 201 | ; |
---|
[150] | 202 | ; We will make sure that all procedure are not in pltt |
---|
[2] | 203 | ; |
---|
| 204 | procedures = extractatt(top_uvalue, 'nameprocedures') |
---|
| 205 | if total(procedures EQ 'pltt') NE 0 then begin |
---|
| 206 | nothing = report('Certains des plots ont un axe se rapportant au temps. !C Animation impossible!', /error) |
---|
| 207 | return |
---|
| 208 | ENDIF |
---|
| 209 | ; |
---|
[150] | 210 | ; We will make sure that all figure have the same calendar |
---|
[2] | 211 | ; |
---|
| 212 | filelist = extractatt(top_uvalue, 'filelist') |
---|
[69] | 213 | filenames = (extractatt(top_uvalue, 'varinfo'))[0, *] |
---|
[2] | 214 | filenames = reform(filenames) |
---|
| 215 | filenames = filenames[uniq(filenames, sort(filenames))] |
---|
| 216 | if strtrim(filenames[0], 1) EQ '' then filenames = filenames[1:n_elements(filenames)-1] |
---|
| 217 | indexfile = (where(filelist EQ filenames[0]))[0] |
---|
[226] | 218 | calendar = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).time_counter |
---|
[74] | 219 | key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).caltype |
---|
| 220 | fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[indexfile]).fakecal |
---|
[2] | 221 | if n_elements(filenames) GT 1 then begin |
---|
| 222 | for i = 1, n_elements(filenames)-1 do begin |
---|
| 223 | indexfilebis = (where(filelist EQ filenames[i]))[0] |
---|
| 224 | calendarbis = (*(extractatt(top_uvalue, 'fileparameters'))[indexfilebis]).time_counter |
---|
| 225 | if n_elements(calendarbis) NE n_elements(calendar) then begin |
---|
[226] | 226 | nothing = report('plots do not use the same calendar. !C Animation impossible!', /error) |
---|
[2] | 227 | return |
---|
| 228 | ENDIF |
---|
| 229 | if total(calendar NE calendarbis) NE 0 then begin |
---|
[226] | 230 | nothing = report('plots do not use the same calendar. !C Animation impossible!', /error) |
---|
[2] | 231 | return |
---|
| 232 | endif |
---|
| 233 | endfor |
---|
| 234 | endif |
---|
| 235 | ; |
---|
[150] | 236 | ; It is possible to do an animation. |
---|
[2] | 237 | ; |
---|
[226] | 238 | base = widget_base(/column, title = 'animation creation', uvalue = {parent:parent, indexfile:indexfile}) |
---|
[69] | 239 | rien = widget_label(base, value = 'animation name') |
---|
[2] | 240 | rien = widget_text(base,value='anim_idl.gif', uname='Filename', /editable) |
---|
[69] | 241 | rien = widget_label(base, value = 'animation directory') |
---|
[2] | 242 | if n_elements(animdir) EQ 0 then cd, current = animdir |
---|
| 243 | rien = widget_text(base,value=animdir, uname='directorie', /editable) |
---|
[69] | 244 | rien = widget_label(base, value = 'starting date') |
---|
[74] | 245 | rien = cw_calendar(base, calendar, calendar[0] $ |
---|
| 246 | , FAKECAL = fakecal, uname = 'debut', uvalue = {name:'calendar'}, /frame) |
---|
[69] | 247 | rien = widget_label(base, value = 'ending date') |
---|
[2] | 248 | rien = cw_calendar(base, calendar, calendar[n_elements(calendar)-1] $ |
---|
[74] | 249 | , FAKECAL = fakecal, uname = 'fin', uvalue = {name:'calendar'}, /frame) |
---|
[2] | 250 | rien = widget_button(base,value='OK', uvalue = 'ok') |
---|
| 251 | rien = widget_button(base,value='Cancel', uvalue = 'cancel') |
---|
| 252 | ; |
---|
| 253 | widget_control,base,/realize |
---|
| 254 | xmanager,'xcreateanim', base, /no_block |
---|
[226] | 255 | |
---|
[2] | 256 | return |
---|
| 257 | end |
---|