source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xxxmenubar_event.pro @ 74

Last change on this file since 74 was 74, checked in by smasson, 18 years ago

debug xxx and cie + clean data file + rm perldoc_idl

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 16.0 KB
Line 
1;------------------------------------------------
2PRO xxxmenubar_event, event
3@common
4
5
6  case event.value of
7    'Open' :begin
8      oldmeshparams = ccmeshparameters
9      newfile = selectfile()
10      if size(newfile, /type) NE 8 then return
11      widget_control, event.top, /hourglass
12      widget_control, event.top, update = 0
13      widget_control, event.top, get_uvalue = top_uvalue
14; on s''occupe de filelist
15      filelist = extractatt(top_uvalue, 'filelist')
16      filelist = [filelist, newfile.fileparameters.filename]
17      currentfile = n_elements(filelist)-1
18; on update le widget
19      filelistid = widget_info(event.top, find_by_uname = 'filelist')
20      widget_control, filelistid, combobox_additem = file_basename(newfile.fileparameters.filename)
21      widget_control, filelistid, set_combobox_select = currentfile
22; on update les elements filelist et currentfile de la top_uvalue
23      *top_uvalue[1, findline(top_uvalue, 'filelist')] = filelist
24      oldfile = *top_uvalue[1, findline(top_uvalue, 'currentfile')]
25      *top_uvalue[1, findline(top_uvalue, 'currentfile')] = currentfile
26; on s''occupe du nom de la variable
27      vlstid = widget_info(event.top, find_by_uname = 'varlist')
28; quel etait le champ selectionne ? on le reselectionne ?
29      fieldname = widget_info(vlstid, /combobox_gettext)
30      index = where(newfile.fileparameters.listvar EQ fieldname)
31      widget_control, vlstid, set_value = newfile.fileparameters.listvar
32      widget_control, vlstid, set_combobox_select = 0 > index[0]
33; on s''occupe du calendrier
34      key_caltype = newfile.fileparameters.caltype
35      date1id = widget_info(event.top, find_by_uname = 'calendar1')
36      widget_control, date1id, get_value = date1
37      widget_control, date1id, /destroy
38      jdate1 = jul2date(date1)
39      if (where(newfile.fileparameters.time_counter EQ jdate1))[0] EQ -1 $
40      then jdate1 = newfile.fileparameters.time_counter[0]
41      date2id = widget_info(event.top, find_by_uname = 'calendar2')
42      widget_control, date2id, get_value = date2
43      widget_control, date2id, /destroy
44      jdate2 = jul2date(date2)
45      if (where(newfile.fileparameters.time_counter EQ jdate2))[0] EQ -1 then jdate2 = jdate1
46      basecal = widget_info(event.top, find_by_uname = 'basecal')
47      fakecal = newfile.fileparameters.fakecal
48      rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate1, uname = 'calendar1' $
49                         , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame)
50      rien = cw_calendar(basecal, newfile.fileparameters.time_counter, jdate2, uname = 'calendar2' $
51                         , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame)
52; on update les elements fileparameters, readparameters et meshparameters de la top_uvalue
53      newfileparameters = ptrarr(currentfile+1, /allocate_heap)
54      FOR i = 0, currentfile-1 DO $
55         *newfileparameters[i] = *(extractatt(top_uvalue, 'fileparameters'))[i]
56      *newfileparameters[currentfile] = newfile.fileparameters
57      ptr_free, extractatt(top_uvalue, 'fileparameters')
58      *top_uvalue[1, findline(top_uvalue, 'fileparameters')] = newfileparameters
59;
60      newreadparameters = ptrarr(currentfile+1, /allocate_heap)
61      FOR i = 0, currentfile-1 DO $
62         *newreadparameters[i] = *(extractatt(top_uvalue, 'readparameters'))[i]
63      *newreadparameters[currentfile] = newfile.readparameters
64      ptr_free, extractatt(top_uvalue, 'readparameters')
65      *top_uvalue[1, findline(top_uvalue, 'readparameters')] = newreadparameters
66;
67      newmeshparameters = ptrarr(currentfile+1, /allocate_heap)
68      FOR i = 0, currentfile-1 DO $
69         *newmeshparameters[i] = *(extractatt(top_uvalue, 'meshparameters'))[i]
70      *newmeshparameters[currentfile] = newfile.meshparameters
71      ptr_free, extractatt(top_uvalue, 'meshparameters')
72      *top_uvalue[1, findline(top_uvalue, 'meshparameters')] = newmeshparameters
73; on actualise le widget!
74      if cmpgrid(oldmeshparams) then BEGIN
75        domainid = widget_info(event.top, find_by_uname = 'domain')
76        widget_control, domainid, set_value = -1
77      endif
78      widget_control, event.top, update = 1
79    end
80    'New xxx' :BEGIN
81      widget_control, event.top, get_uvalue = top_uvalue
82      extra = extractatt(top_uvalue, 'extra')
83      xxx, CALLERWIDID = event.top, _extra = extra
84    end
85    'Quit':begin
86      widget_control, event.top, get_uvalue = top_uvalue
87      ptr_free, extractatt(top_uvalue, 'exextra')
88      ptr_free, extractatt(top_uvalue, 'fileparameters')
89      ptr_free, extractatt(top_uvalue, 'readparameters')
90      ptr_free, extractatt(top_uvalue, 'meshparameters')
91      ptr_free, top_uvalue
92      widget_control, event.top, /destroy ;on ferme le widget
93    end
94    'PostScript' :BEGIN
95      IF lmgr(/demo) EQ 1 THEN BEGIN
96        dummy = report('impossible to save as postscript in demo mode')
97        return
98      ENDIF
99      widget_control, event.top, get_uvalue = top_uvalue
100; on recupere la liste des instructions
101      globalcommand = extractatt(top_uvalue, 'globalcommand')
102;      for i = 0, n_elements(globalcommand)-1 do print, globalcommand[i]
103; on complete par le premiere et les dernieres lignes du programme
104      createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $
105                 , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $
106                 +', PORTRAIT = portrait, LANDSCAPE = landscape' $
107                 +', DATE1IN = date1in, DATE2IN = date2in' $
108                 , /POSTSCRIPT
109    END
110    'Animated gif' :begin
111      IF float(strmid(!version.release,0,3)) GE 6.2 THEN xcreateanim, event.top
112    end
113    'Gif' :BEGIN
114      IF lmgr(/demo) EQ 1 THEN BEGIN
115        dummy = report('impossible to save as an image in demo mode')
116        return
117      ENDIF
118      widget_control, event.top, get_uvalue = top_uvalue
119      smallin = extractatt(top_uvalue, 'smallin')
120      numdessinin = smallin[2]-1
121      smallout = extractatt(top_uvalue, 'smallout')
122      numdessinout = smallout[2]-1
123      tracecadre, smallin, /erase
124      tracecadre, smallout, /erase
125      filename = xquestion('dans quelle fichier gif voulez vous sauver !C l''ecran de xxx?', 'xxx_image.gif')
126      if rstrpos(filename, '.gif') NE strlen(filename)-4 then filename = filename+'.gif'
127      filename = isafile(file = filename, io = imagedir, /new)
128      saveimage, filename, /quiet
129    end
130    'IDL procedure':BEGIN
131      IF lmgr(/demo) EQ 1 THEN BEGIN
132        dummy = report('impossible to save as a idl program file in demo mode')
133        return
134      ENDIF
135; on recupere le nom du fichier
136      filename = xquestion('dans quelle procedure IDL voulez vous sauver !C la realisation de ce graph?', 'xxx_figure.pro')
137; on le complete par un .pro
138      if rstrpos(filename, '.pro') NE strlen(filename)-4 then filename = filename+'.pro'
139      filename = isafile(file = filename, io = homedir, /new)
140      widget_control, event.top, get_uvalue = top_uvalue
141; portrait ou landscape ???
142      options = extractatt(top_uvalue, 'options')   
143      optionsflag = extractatt(top_uvalue, 'optionsflag')
144      portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0]
145; on lit les commandes pour faire un plot
146      globalcommand = extractatt(top_uvalue, 'globalcommand')
147; on complete par le premiere et les dernieres lignes du programme
148      thisOS = strupcase(strmid(!version.os_family, 0, 3))
149      CASE thisOS of
150        'MAC':sep = ':'
151        'WIN':sep = '\'
152        ELSE:sep = '/'
153      ENDCASE
154      poslastsep = rstrpos(filename, sep)
155      proname = strmid(filename, poslastsep+1, strlen(filename)-poslastsep-1-4)
156      globalcommand = ['pro '+proname+', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $
157                       , ' ' $
158                       , '   '+globalcommand $
159                       , ' ' $
160                       , 'return' $
161                       , 'end']
162; on les ecrit dans un programme
163      putfile, filename, globalcommand
164    END
165    'RESTORE kwd of xxx':BEGIN
166      IF lmgr(/demo) EQ 1 THEN BEGIN
167        dummy = report('impossible to save the widget in demo mode')
168        return
169      ENDIF
170; on recupere le nom du fichier
171      filename = xquestion('dans quel fichier bianire voulez vous sauver le widget ?', 'xxx_widget.dat')
172; on le complete par un .dat
173      if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat'
174      filename = isafile(file = filename, io = homedir, /new)
175;
176      widget_control, event.top, get_uvalue = uvalue
177      widget_control, extractatt(uvalue, 'graphid'), get_value = win
178      wshow, win
179      wset, win
180      image = tvrd(/true)
181      save, uvalue, image, filename = filename
182    END
183    'Print to prompt':BEGIN
184      commande = getfile(myuniquetmpdir + 'xxx_oneplot.pro')
185      for i = 0,  n_elements(commande)-1 do print, commande[i]
186    end
187   'Portrait/Landscape' :begin
188      widget_control, event.top, get_uvalue = top_uvalue
189      options = extractatt(top_uvalue, 'options')
190      index = where(options EQ 'Portrait/Landscape') & index = index[0]
191      optionsflag = extractatt(top_uvalue, 'optionsflag')
192      key_portrait = 1-optionsflag[index, 0]
193      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = key_portrait
194; fenetre separee ou fenetre collee au widget ?
195      if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN
196; on tue la fenetre
197        graphid = extractatt(top_uvalue, 'graphid')
198        widget_control, widget_info(graphid, /parent), /destroy
199; on la recree
200        basegraph = widget_base(title = 'xxx window',  group_leader = event.top, uvalue = event.top,  uname = 'basegraph')
201        windsize = givewindowsize()
202        graphid = widget_draw(basegraph, uname = 'graph' $
203                              , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $
204                              , /button_events, retain = 2 $
205                              , xsize = windsize[0], ysize = windsize[1])
206        widget_control, basegraph, /realize
207        xmanager, 'xxx', basegraph, /no_block
208; on redessine ce qu''il y avait dedans
209; on recupere la liste des instructions
210        globalcommand = extractatt(top_uvalue, 'globalcommand')
211; on complete par le premiere et les dernieres lignes du programme
212        createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $
213                   , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $
214                   , KWDUSED = ', /noerase, PORTRAIT = portrait'
215; on reattribue l''element graphid de la top_uvalue
216        *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid
217      ENDIF ELSE BEGIN
218        extra = extractatt(top_uvalue, 'extra')
219        xxx, CALLERWIDID = event.top, /redraw, _extra = extra
220        widget_control, event.top, /destroy ;on ferme le widget
221      ENDELSE
222    end
223    'Overlay' :begin
224      widget_control, event.top, get_uvalue = top_uvalue
225      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
226      options = extractatt(top_uvalue, 'options')   
227      flags = extractatt(top_uvalue, 'optionsflag')
228      index = where(options EQ 'Overlay')
229; on change le flag sur Longitude / x index
230      flag = 1-flags[index, numdessinin] & flag = flag[0]
231; on le reeatribue
232      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag
233    end
234    'Vecteur':BEGIN
235      widget_control, event.top, get_uvalue = top_uvalue
236      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
237      options = extractatt(top_uvalue, 'options')   
238      flags = extractatt(top_uvalue, 'optionsflag')
239      index = where(options EQ 'Vecteur')
240; on change le flag sur Longitude / x index
241      flag = 1-flags[index, numdessinin] & flag = flag[0]
242; on le reeatribue
243      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag
244    end
245    'Longitude / x index':BEGIN
246      widget_control, event.top, get_uvalue = top_uvalue
247      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
248      options = extractatt(top_uvalue, 'options')   
249      flags = extractatt(top_uvalue, 'optionsflag')
250      index = where(options EQ 'Longitude / x index')
251; on change le flag sur Longitude / x index
252      flag = 1-flags[index, numdessinin] & flag = flag[0]
253; on le reeatribue
254      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag
255; maintenant on va changer les sliders definissant la boxzoom
256      domainid = widget_info(event.top, find_by_uname = 'domain')
257      boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin]
258; on veut retrouver le type de grille qui est utilisee
259      currentfile = extractatt(top_uvalue, 'currentfile')
260      listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid
261      listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar
262      vlstid = widget_info(event.top, find_by_uname = 'varlist')
263      namevar = widget_info(vlstid, /combobox_gettext)
264      indexvar = where(listvar EQ namevar)
265      vargrid = strupcase(listgrid[indexvar])
266      if flag EQ 0 then BEGIN   ; longitudes
267; on fait un domdef pour retrouver le lon1 lon2 correspondant a la
268; boxzoom definie sur le widget...
269        domdef, boxzoom, gridtype = vargrid, /xindex $
270                , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0]
271        widget_control, domainid, set_value = [lon1, lon2, boxzoom[2:3]]
272      ENDIF ELSE BEGIN          ; xindex
273; maintenant ion veut retrouver firstx, lastx correspondant a la
274; boxzoom definie sur le widget...
275        domdef, boxzoom, gridtype = vargrid $
276                , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0]
277        grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz
278        widget_control, domainid, set_value = [firstx, lastx, boxzoom[2:3]]
279      ENDELSE
280; on met a jour la top_uvalue
281      widget_control, domainid, get_value = boxzoom
282      (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom
283    end
284    'Latitude / y index':begin
285      widget_control, event.top, get_uvalue = top_uvalue
286      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
287      options = extractatt(top_uvalue, 'options')   
288      flags = extractatt(top_uvalue, 'optionsflag')
289      index = where(options EQ 'Latitude / y index')
290; on change le flag sur Latitude / y index
291      flag = 1-flags[index, numdessinin] & flag = flag[0]
292; on le reeatribue
293      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag
294; maintenant on va changer les sliders definissant la boxzoom
295      domainid = widget_info(event.top, find_by_uname = 'domain')
296      boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin]
297; on veut retrouver le type de grille qui est utilisee
298      currentfile = extractatt(top_uvalue, 'currentfile')
299      listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid
300      listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar
301      vlstid = widget_info(event.top, find_by_uname = 'varlist')
302      namevar = widget_info(vlstid, /combobox_gettext)
303      indexvar = where(listvar EQ namevar)
304      vargrid = strupcase(listgrid[indexvar])
305      if flag EQ 0 then BEGIN   ; latitudes
306; on fait un domdef pour retrouver le lat1 lat2 correspondant a la
307; boxzoom definie sur le widget...
308        domdef, boxzoom, gridtype = vargrid, /yindex $
309                , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0]
310        widget_control, domainid, set_value = [boxzoom[0:1], lat1, lat2]
311      ENDIF ELSE BEGIN          ; yindex
312; maintenant ion veut retrouver firsty, lasty correspondant a la
313; boxzoom definie sur le widget...
314        domdef, boxzoom, gridtype = vargrid $
315                , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0]
316        grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz
317        widget_control, domainid, set_value = [boxzoom[0:1], firsty, lasty]
318      ENDELSE
319; on met a jour la top_uvalue
320      widget_control, domainid, get_value = boxzoom
321      (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom
322    END
323  endcase
324  return
325end
Note: See TracBrowser for help on using the repository browser.