source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xcreateanim.pro @ 226

Last change on this file since 226 was 226, checked in by pinsard, 17 years ago

corrections of some misspellings in some *.pro

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