source: trunk/SRC/ToBeReviewed/WIDGET/xxx.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: 21.1 KB
Line 
1;+
2; @file_comments
3; see <a href="../../../xmldoc/mini_notice.html">Mini Guide for Basic Commands in the XXX Program</a>
4;
5; @categories
6;
7; @param EVENT
8;
9;
10; @returns
11;
12; @uses
13;
14; @restrictions
15;
16; @examples
17;
18; @history
19;
20; @version
21; $Id$
22;-
23PRO xxx_event, event
24;------------------------------------------------------------
25;
26  compile_opt idl2, strictarrsubs
27;
28@common
29;------------------------------------------------------------
30;    = widget_info(event.top,find_by_uname = '')
31; What is the type of event ?
32;   if event.id EQ 622 then help,  event,  /struct
33   widget_control, event.id, get_uvalue=uval
34   if (tag_names(event, /structure_name))[0] EQ 'WIDGET_TRACKING' then uval = {name:'ActiverFenetre'}
35   if keyword_set(uval) EQ 0 then return
36;help,  event, /struct
37;help, uval , /struct
38; case on the type of event
39   widget_control, event.top, get_uvalue = top_uvalue
40; If we activate the keyword separate at the call of xxx
41   if size(top_uvalue, /type) EQ 3 then begin
42      event.top = top_uvalue
43      widget_control, event.top, get_uvalue = top_uvalue
44   endif
45; we delete the small widget created by notice.pro if it exists
46   noticebase = extractatt(top_uvalue, 'noticebase')
47   if noticebase NE 0 then BEGIN
48      widget_control, noticebase, /destroy
49      *top_uvalue[1, findline(top_uvalue, 'noticebase')] = 0l
50   endif
51;
52   options = extractatt(top_uvalue, 'options')
53   case uval.name OF
54      'menubar':xxxmenubar_event, event
55      'ok':nouveaudessin = 1
56      'specifie':
57      'action':
58      'calendar1':BEGIN
59         date2id = widget_info(event.top, find_by_uname = 'calendar2')
60         widget_control, date2id, get_value = date2
61         if event.value GT date2 then widget_control, date2id, set_value = event.value
62      END
63      'calendar2':BEGIN
64         date1id = widget_info(event.top, find_by_uname = 'calendar1')
65         widget_control, date1id, get_value = date1
66         if event.value LT date1 then widget_control, date1id, set_value = event.value
67      END
68      'domain':
69      'varlist':BEGIN
70         currentfile  = extractatt(top_uvalue, 'currentfile')
71         listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar
72         name = listvar[event.index]
73         changefield, event.top, name
74      END
75      'txtcmd':
76      'filelist':BEGIN
77         changefile, event.top, event.index
78      END
79      'ActiverFenetre':BEGIN
80         if event.enter EQ 1 AND !d.name NE 'PS' then BEGIN
81;            graphid = widget_info(event.top,find_by_uname = 'graph')
82            graphid = extractatt(top_uvalue, 'graphid')
83            widget_control,graphid,get_value=win
84            wset, win
85            widget_control,event.top,get_uvalue=top_uvalue
86            numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
87            !p = (extractatt(top_uvalue, 'penvs'))[numdessinin]
88            !x = (extractatt(top_uvalue, 'xenvs'))[numdessinin]
89            !y = (extractatt(top_uvalue, 'yenvs'))[numdessinin]
90         endif
91      END
92      'graph':BEGIN
93         quelclick = identifyclick(event)
94         case quelclick.type of
95            'inutile':return
96            'long':longclickaction, event
97            'single':singleclickaction, event
98            'double':doubleclickaction, event
99         endcase
100      END
101   endcase
102   if keyword_set(nouveaudessin) then letsdraw, event.top
103   return
104end
105;------------------------------------------------------------
106;------------------------------------------------------------
107;------------------------------------------------------------
108;------------------------------------------------------------
109;------------------------------------------------------------
110;------------------------------------------------------------
111;+
112;
113; @file_comments
114; A maximum of possibilities with a minimum of clics
115;
116; @categories
117; Widget
118;
119; @param DATAFILENAME
120;
121;
122; @param IDLFILE
123;
124;
125; @param ARGSPRO
126;
127;
128; @keyword SEPARATE
129; To separate the button part and the drawing part in 2 windows.
130; Useful for small screens, but be careful to do not saturate the
131; video memory of some antiquated Tx.
132;
133; @keyword RESTORE
134; 'toto.dat' or toto.dat is a file created at the time of a precedent
135; use of xxx thanks to the command "Widget" of the menu "save as".
136;
137; @keyword _EXTRA
138; Used to pass your keywords
139;
140; @keyword CALLERWIDID
141;
142;
143; @keyword REDRAW
144;
145;
146; @keyword SEPARATE
147;
148;
149; @keyword UVALUE
150; The user value to be associated with the widget.
151;
152; @uses
153; common.pro
154;
155; @history
156; Sebastien Masson (smasson\@lodyc.jussieu.fr)
157;
158; @version
159; $Id$
160;
161; @todo
162; seb: documenter le reste des keywords
163;
164;-
165;------------------------------------------------------------
166;------------------------------------------------------------
167;------------------------------------------------------------
168;------------------------------------------------------------
169;------------------------------------------------------------
170;------------------------------------------------------------
171PRO xxx, datafilename, idlfile, argspro, CALLERWIDID = CallerWidId $
172         , REDRAW = redraw, SEPARATE = separate, UVALUE = uvalue $
173         , RESTORE = restore, _EXTRA = ex
174;------------------------------------------------------------
175;
176  compile_opt idl2, strictarrsubs
177;
178@all_cm
179;------------------------------------------------------------
180; reinitialize the !p, !x, !y, !z variables
181;------------------------------------------------------------
182  reinitplt
183;------------------------------------------------------------
184; we get back the uvalue of the widget that called xxx to create a new widget
185  if keyword_set(restore) then BEGIN
186    restore = isafile(filename = restore, iodir = homedir, _extra = ex)
187    if size(restore, /type) NE 7 then restore = 0 ELSE BEGIN
188      restore, isafile(file = restore, iodir = homedir, _extra = ex)
189      newgrid = *(extractatt(uvalue, 'meshparameters'))[0]
190      change = changegrid(newgrid)
191    ENDELSE
192  endif
193  if n_elements(CallerWidId) NE 0 THEN $
194     widget_control, CallerWidId, get_uvalue = uvalue ELSE CallerWidId = 0
195;------------------------------------------------------------
196;------------------------------------------------------------
197; list of files we want to look at
198;
199  if keyword_set(uvalue) then BEGIN
200    currentfile = extractatt(uvalue, 'currentfile')
201    filelist = extractatt(uvalue, 'filelist')
202    fileparameters = extractatt(uvalue, 'fileparameters')
203    readparameters = extractatt(uvalue, 'readparameters')
204    meshparameters = extractatt(uvalue, 'meshparameters')
205  ENDIF ELSE BEGIN
206    newfile = selectfile(datafilename, idlfile, argspro, _extra = ex)
207    if size(newfile, /type) NE 8 then return
208    fileparameters = ptrarr(1, /allocate_heap)
209    *fileparameters[0] = newfile.fileparameters
210    readparameters = ptrarr(1, /allocate_heap)
211    *readparameters[0] = newfile.readparameters
212    meshparameters = ptrarr(1, /allocate_heap)
213    *meshparameters[0] = newfile.meshparameters
214    currentfile = 0
215    filelist = newfile.fileparameters.filename
216  ENDELSE
217;
218  if keyword_set(uvalue) THEN BEGIN
219    smallin = extractatt(uvalue, 'smallin')
220    smallout = extractatt(uvalue, 'smallout')
221  ENDIF ELSE BEGIN
222    smallin = [1, 1, 1]
223    smallout = [1, 1, 1]
224  ENDELSE
225  nbredessin = smallin[0]*smallin[1]
226  numdessinin = smallin[2]-1
227; warning flg definition must be consistent with cw_pdmenu argument
228; see also flag definition in cw_pagelayout
229  if keyword_set(uvalue) then BEGIN
230    flag = extractatt(uvalue, 'optionsflag')
231    key_portrait = flag[0, numdessinin]
232  ENDIF ELSE flag = [key_portrait, 0, 0, 0, 0]#replicate(1, nbredessin)
233
234;------------------------------------------------------------
235;------------------------------------------------------------
236; We start the widget definition
237;------------------------------------------------------------
238;------------------------------------------------------------
239;
240; widget and screen size
241  scrsize = get_screen_size()*0.95
242  windsize = givewindowsize()
243  xxxsize = [windsize[0] * (1-keyword_set(separate)) + 350, windsize[1]]
244;
245;------------------------------------------------------------
246; The top base
247;------------------------------------------------------------
248  IF xxxsize[0] LE scrsize[0] AND xxxsize[1] LE scrsize[1] THEN BEGIN
249    base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $
250                       , uname = 'base', space = 0)
251  ENDIF ELSE BEGIN
252    base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $
253                       , uname = 'base', space = 0 $
254                       , xsize = xxxsize[0], ysize = xxxsize[1] $
255                       , x_scroll_size = (xxxsize[0] < scrsize[0]) $
256                       , y_scroll_size = (xxxsize[1] < scrsize[1]))
257  ENDELSE
258
259;------------------------------------------------------------
260; combobox for plots choice
261;------------------------------------------------------------
262  xoff = 0
263  yoff = 0
264  pltlst = ['plt', 'pltv' $
265            , 'pltz', 'pltz diag up', 'pltz diag dn' $
266            , 'pltt', 'pltt diag up', 'pltt diag dn' $
267            , 'xy', 'xz', 'yz', 'xt', 'yt', 'zt' $
268            , 'x', 'y', 'z', 't']
269  actid = widget_combobox(base, value = pltlst, uname = 'action', uvalue = {name:'action'} $
270                            , xoffset = xoff+5, yoffset = yoff+4, xsize = 90)
271  if keyword_set(uvalue) then BEGIN
272    selectact = (extractatt(uvalue, 'types'))[numdessinin]
273    selectact = (where(pltlst EQ selectact))[0]
274    widget_control, actid, set_combobox_select = 0 > selectact
275  ENDIF ELSE selectfile = 0
276
277;------------------------------------------------------------
278; menu/options
279;------------------------------------------------------------
280  xoff = xoff + 110
281  if keyword_set(uvalue) then begin
282    options = extractatt(uvalue, 'options')
283  ENDIF ELSE options = ['Portrait/Landscape', 'Overlay', 'Vecteur' $
284                        , 'Longitude / x index', 'Latitude / y index']
285
286   desc = [ '1\File', $
287            '0\Open' , $
288            '0\New xxx' , $
289            '2\Quit', $
290            '1\Save as' , $
291            '0\PostScript' , $
292            '0\Animated gif' , $
293            '0\Gif' , $
294            '0\IDL procedure', $
295            '0\RESTORE kwd of xxx', $
296            '2\Print to prompt', $
297            '1\Flag options']
298   descsuite = options
299   if n_elements(descsuite) GE 2 then $
300    descsuite[0:n_elements(descsuite)-2] = '0\'+descsuite[0:n_elements(descsuite)-2]
301   descsuite[n_elements(descsuite)-1] = '2\'+descsuite[n_elements(descsuite)-1]
302   desc = [desc, descsuite]
303;
304   menu = cw_pdmenu(base, desc, /RETURN_NAME, uname = 'menubar', uvalue = {name:'menubar'} $
305                    , xoffset = xoff, yoffset = yoff)
306
307;------------------------------------------------------------
308; Ok button
309;------------------------------------------------------------
310  yoff = yoff + 37
311  xoff = 5
312; button 'OK'
313  baseok = widget_button(base, value = ' OK ', uvalue = {name:'ok'}, uname = 'ok button' $
314                         , /frame, xoffset = xoff, yoffset = yoff)
315
316;------------------------------------------------------------
317; Page Layout
318;------------------------------------------------------------
319; page layout
320  xoff = xoff + 65
321  dummyid = cw_pagelayout(base, smallin, /row, /frame, xoffset = xoff, yoffset = yoff)
322;
323;------------------------------------------------------------
324; List of Variables
325;------------------------------------------------------------
326  xoff = xoff + 140
327  currentlistvar = (*fileparameters[currentfile]).listvar
328  vlstid = widget_combobox(base, value = currentlistvar, uvalue = {name:'varlist'} $
329                           , uname = 'varlist', xoffset = xoff, yoffset = yoff+1)
330  if keyword_set(uvalue) then BEGIN
331    selectvar = (extractatt(uvalue, 'varinfo'))[1, numdessinin]
332    selectvar = (where(currentlistvar EQ selectvar))[0]
333    widget_control, vlstid, set_combobox_select = 0 > selectvar
334  ENDIF ELSE selectvar = 0
335;------------------------------------------------------------
336; List of files
337;------------------------------------------------------------
338  yoff = yoff + 35
339  flstid = widget_combobox(base, value = file_basename(filelist), uname = 'filelist' $
340                           , xsize = 345, yoffset = yoff, uvalue = {name:'filelist'})
341  if keyword_set(uvalue) then BEGIN
342    selectfile = (extractatt(uvalue, 'varinfo'))[0, numdessinin]
343    selectfile = (where(file_basename(filelist) EQ selectfile))[0]
344    widget_control, flstid, set_combobox_select = 0 > selectfile
345  ENDIF ELSE selectfile = 0
346;------------------------------------------------------------
347; Text for computation
348;------------------------------------------------------------
349  yoff = yoff + 32
350; computation done on the files...
351  if keyword_set(uvalue) then txtvalue = (extractatt(uvalue, 'txtcmd'))[numdessinin] $
352  ELSE txtvalue = '"' + varexp + '"'
353  dummyid = widget_text(base, value = txtvalue, uvalue = {name:'txtcmd'}, uname = 'txtcmd' $
354                        , /editable, yoffset = yoff, xsize = 54, /frame)
355;------------------------------------------------------------
356; Calendar
357;------------------------------------------------------------
358  yoff = yoff + 40
359  currentcalendar = (*fileparameters[currentfile]).time_counter
360  key_caltype = (*fileparameters[currentfile]).caltype
361  fakecal = (*fileparameters[currentfile]).fakecal
362  if keyword_set(uvalue) then begin
363    dates = (extractatt(uvalue, 'dates'))[*, numdessinin]
364    date1 = date2jul(dates[0])
365    date2 = date2jul(dates[1])
366  ENDIF
367  basecalid = widget_base(base, column = 2, space = 0, yoffset = yoff, uname = 'basecal')
368  dummyid = cw_calendar(basecalid, currentcalendar, date1, FAKECAL = fakecal, uname = 'calendar1', uvalue = {name:'calendar1'}, /frame)
369  dummyid = cw_calendar(basecalid, currentcalendar, date2, FAKECAL = fakecal, uname = 'calendar2', uvalue = {name:'calendar2'}, /frame)
370;------------------------------------------------------------
371; Domain
372;------------------------------------------------------------
373  yoff = yoff + 60
374  vargrid = strupcase((*fileparameters[currentfile]).listgrid[selectvar])
375  IF vargrid EQ 'W' then zgrid = 'W' ELSE zgrid = 'T'
376  if keyword_set(uvalue) then boxzoom = (extractatt(uvalue, 'domaines'))[*, numdessinin]
377  dummyid = cw_domain(base, uname = 'domain', uvalue = {name:'domain'}, /unzoom, /frame $
378                      , boxzoom = boxzoom, yoffset = yoff, xoffset = 15)
379;------------------------------------------------------------
380; Plots specifications
381;------------------------------------------------------------
382  yoff = yoff + 230
383  speid = cw_specifie(base, uname = 'specifie', uvalue = {name:'specifie'}, /frame, /column $
384                      , /forxxx, yoffset = yoff)
385  if keyword_set(uvalue) then BEGIN
386    exextra = *((extractatt(uvalue, 'exextra'))[numdessinin])
387    IF n_elements(exextra) NE 0 THEN widget_control, speid, set_value = exextra
388  ENDIF
389;------------------------------------------------------------
390; drawing part
391;------------------------------------------------------------
392  if keyword_set(separate) then $
393     basegraph = widget_base(title = 'xxx window',  group_leader = base, uvalue = base) $
394  ELSE basegraph = base
395
396  graphid = widget_draw(basegraph, uname = 'graph', /button_events, retain = 2 $
397                        , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $
398                        , xoffset = 350*(1-keyword_set(separate)) $
399                        , xsize = windsize[0], ysize = windsize[1]); , tooltip = 'toto')
400;------------------------------------------------------------
401; realize the widget
402;------------------------------------------------------------
403  widget_control, base, /realize
404  if keyword_set(separate) then begin
405    widget_control, basegraph, /realize
406    xmanager, 'xxx', basegraph, /no_block
407  endif
408
409;------------------------------------------------------------
410  if keyword_set(uvalue) then BEGIN ;
411; We recopy the pointer uvalue in top_uvalue.
412; Beware, we have to redefine completely top_value from variables
413; pointed by uvalue. Otherwise, if we simply do top_value = uvalue,
414; when we delete by uvalue and variables on which it point, we
415; also delete variables on which point top_value.
416    case 1 of
417      keyword_set(redraw):BEGIN
418        top_uvalue = uvalue
419        widget_control, base, set_uvalue = top_uvalue
420; we find homedir
421        homedir = isadirectory(io = homedir, title = 'Bad definition of homedir')
422; We recuperae the list of instructions
423        globalcommand = extractatt(top_uvalue, 'globalcommand')
424; We complete by first and last lines of the program
425        createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $
426                   , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $
427                   +', PORTRAIT = portrait, LANDSCAPE = landscape' $
428                   , /noerase
429      END
430      keyword_set(restore):begin
431        top_uvalue = uvalue
432        widget_control, base, set_uvalue = top_uvalue
433        widget_control, graphid, get_value = win
434        wshow, win
435        wset, win
436        tv, image, /true
437; widgets's state
438        updatewidget, base
439;
440      END
441      ELSE:BEGIN
442        top_uvalue = ptrarr(2, 29, /allocate_heap)
443        FOR i =  0, 28 do *top_uvalue[0, i] = *uvalue[0, i]
444        FOR i =  0, 14 do *top_uvalue[1, i] = *uvalue[1, i]
445        FOR i = 18, 27 do *top_uvalue[1, i] = *uvalue[1, i]
446        numfile = n_elements(extractatt(uvalue, 'filelist'))
447        *top_uvalue[1, 15] = ptrarr(numfile, /allocate_heap)
448        *top_uvalue[1, 16] = ptrarr(numfile, /allocate_heap)
449        *top_uvalue[1, 17] = ptrarr(numfile, /allocate_heap)
450        for i = 0, numfile-1 do begin
451          *(*top_uvalue[1, 15])[i] = *(*uvalue[1, 15])[i]
452          *(*top_uvalue[1, 16])[i] = *(*uvalue[1, 16])[i]
453          *(*top_uvalue[1, 17])[i] = *(*uvalue[1, 17])[i]
454        endfor
455        *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap)
456        for i = 0, nbredessin-1 do *(*top_uvalue[1, 28])[i] = *(*uvalue[1, 28])[i]
457        widget_control, base, set_uvalue = top_uvalue
458; Copy the screen of the widget of uvalue in top_value's one
459        if keyword_set(CallerWidId)  then begin
460          widget_control, extractatt(uvalue, 'graphid'), get_value = win
461          wshow, win
462          wset, win
463          image = tvrd(/true)
464          widget_control, graphid, get_value = win
465          wshow, win
466          wset, win
467          tv, image, /true
468        ENDIF
469      END
470    endcase
471    *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid
472;
473ENDIF ELSE BEGIN
474; Otherwise we will define all elements we will hook at the widget
475; thanks to the top_value which is a pointer array with 2
476; columns: names and variables.
477; We initialize all these elements.
478; Variables concerning the widget in its generality.
479    if NOT keyword_set(ex)  then ex = {nothing:0}
480; variables se rapportant aux differents fichiers que l''on peut lire
481; variables specifiques a chaque dessin
482;
483
484; creation of the pointer we will hook at the widget.
485    top_uvalue = ptrarr(2, 29, /allocate_heap)
486; variables refering to the widget
487    *top_uvalue[0, 0] = 'options' & *top_uvalue[1, 0] = options
488    *top_uvalue[0, 1] = 'smallin' & *top_uvalue[1, 1] = smallin
489    *top_uvalue[0, 2] = 'smallout' & *top_uvalue[1, 2] = smallout
490    *top_uvalue[0, 3] = 'graphid' & *top_uvalue[1, 3] = graphid
491    *top_uvalue[0, 4] = 'alreadyvector' & *top_uvalue[1, 4] = -1
492    *top_uvalue[0, 5] = 'alreadyover' & *top_uvalue[1, 5] = -1
493    *top_uvalue[0, 6] = 'alreadyread' & *top_uvalue[1, 6] = -1
494    *top_uvalue[0, 7] = 'currentreadcmd' & *top_uvalue[1, 7] = ''
495    *top_uvalue[0, 8] = 'globalcommand' & *top_uvalue[1, 8] = ''
496    *top_uvalue[0, 9] = 'globaloldcommand' & *top_uvalue[1, 9] = ''
497    *top_uvalue[0, 10] = 'no more used' & *top_uvalue[1, 10] = 9999
498    *top_uvalue[0, 11] = 'noticebase' & *top_uvalue[1, 11] = 0l
499    *top_uvalue[0, 12] = 'extra' & *top_uvalue[1, 12] = ex
500; variables refering to different files we can read
501    *top_uvalue[0, 13] = 'currentfile' & *top_uvalue[1, 13] = currentfile
502    *top_uvalue[0, 14] = 'filelist' & *top_uvalue[1, 14] = filelist
503    *top_uvalue[0, 15] = 'fileparameters' & *top_uvalue[1, 15] = fileparameters
504    *top_uvalue[0, 16] = 'readparameters' & *top_uvalue[1, 16] = readparameters
505    *top_uvalue[0, 17] = 'meshparameters' & *top_uvalue[1, 17] = meshparameters
506; variables refering to different drawing we can do
507    *top_uvalue[0, 18] = 'penvs' & *top_uvalue[1, 18] = replicate(!p, nbredessin)
508    *top_uvalue[0, 19] = 'xenvs' & *top_uvalue[1, 19] = replicate(!x, nbredessin)
509    *top_uvalue[0, 20] = 'yenvs' & *top_uvalue[1, 20] = replicate(!y, nbredessin)
510    *top_uvalue[0, 21] = 'nameprocedures' & *top_uvalue[1, 21] = strarr(nbredessin)
511    *top_uvalue[0, 22] = 'types' & *top_uvalue[1, 22] = strarr(nbredessin)
512    *top_uvalue[0, 23] = 'varinfo' & *top_uvalue[1, 23] = strarr(2, nbredessin)
513    *top_uvalue[0, 24] = 'domaines' & *top_uvalue[1, 24] = fltarr(6, nbredessin)
514    *top_uvalue[0, 25] = 'dates' & *top_uvalue[1, 25] = lonarr(2, nbredessin)
515    *top_uvalue[0, 26] = 'txtcmd' & *top_uvalue[1, 26] = strarr(nbredessin)
516    *top_uvalue[0, 27] = 'optionsflag' & *top_uvalue[1, 27] = flag
517    *top_uvalue[0, 28] = 'exextra' & *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap)
518;
519    widget_control, base, set_uvalue = top_uvalue
520    createhistory, base, smallin
521;
522  ENDELSE
523;------------------------------------------------------------
524  xmanager, 'xxx', base, /no_block
525;------------------------------------------------------------
526;------------------------------------------------------------
527  return
528end
Note: See TracBrowser for help on using the repository browser.