source: trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xxxmenubar.pro @ 49

Last change on this file since 49 was 49, checked in by pinsard, 18 years ago

upgrade of AUTOUR_de_XXX according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

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