source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro @ 327

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.0 KB
Line 
1;+
2;
3; @param BASE {in}{required}
4; The id of the widget where apply the drawing.
5;
6; @param SNAMEEXP {in}{required}
7;
8; @param PROCEDURE {in}{required}
9;
10; @param TYPE {in}{required}
11;
12; @keyword BOXZOOM
13; Vector indicating the geographic zone on which we want to cut the map.
14; If BOXZOOM has :
15;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
16;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
17;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
18;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
19;   6 elements: The extraction is made on Boxzoom
20; Where lon1, lon2,lat1,lat2 are global variables defined at the last
21; <pro>domdef</pro> !
22;
23; @keyword COMPLETE
24;
25; @keyword NAMEFIELD
26;
27; @uses
28; common.pro
29;
30; @history
31; Sebastien Masson (smasson\@lodyc.jussieu.fr)
32;
33; @version
34; $Id$
35;
36; @todo
37; seb: documenter les param et les keyword qui ne le sont pas.
38;
39;-
40FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM=boxzoom $
41                     , COMPLETE=complete, NAMEFIELD=namefield
42;
43;
44  compile_opt idl2, strictarrsubs
45;
46@cm_4cal ; for key_caltype
47;------------------------------------------------------------
48; get back widgets IDs
49;------------------------------------------------------------
50  vlstid = widget_info(base, find_by_uname = 'varlist')
51  date1id = widget_info(base, find_by_uname = 'calendar1')
52  date2id = widget_info(base, find_by_uname = 'calendar2')
53  domainid = widget_info(base, find_by_uname = 'domain')
54;   optionid = widget_info(base, find_by_uname = 'option')
55;------------------------------------------------------------
56  widget_control, base, get_uvalue = top_uvalue
57  numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
58  numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1
59;---------------
60; name of the file
61;---------------
62  currentfile = extractatt(top_uvalue, 'currentfile')
63  filelist = extractatt(top_uvalue, 'filelist')
64  filename = filelist[currentfile]
65  sfilename = ''''+filename+''''
66;---------------
67; name of the variable
68;---------------
69  if keyword_set(namefield) then namevar = namefield $
70  ELSE namevar = widget_info(vlstid, /combobox_gettext)
71  snamevar = ''''+namevar+''''
72;
73; get the options
74;
75  options = extractatt(top_uvalue, 'options')
76  flags = extractatt(top_uvalue, 'optionsflag')
77  flags = flags[*, numdessinin]
78  xindex = (flags[where(options EQ 'Longitude / x index')])[0]
79  yindex = (flags[where(options EQ 'Latitude / y index')])[0]
80;
81  extra = extractatt(top_uvalue, 'extra')
82  if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
83  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
84  exextra = cw_specifie_get_value(base)
85  tgnm = strlowcase(tag_names(exextra))
86  indtmp = where(tgnm EQ 'box' OR tgnm EQ 'boxzoom', cnt)
87  IF cnt EQ 1 THEN boxextra = exextra.(indtmp[0])
88  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct', 'box', 'boxzoom'])
89  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra)
90  sextra = struct2string(extra)
91;---------------
92; find date1 and date2
93;---------------
94  key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype
95  widget_control, date1id, get_value = date1
96  widget_control, date2id, get_value = date2
97
98  if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN
99; we redefine the dates to the begining and end of the calendar
100    calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter
101    date1 = jul2date(calendar[0])
102    date2 = jul2date(calendar[n_elements(calendar)-1])
103    widget_control, date1id, set_value = date1
104    widget_control, date2id, set_value = date2
105  endif
106;
107  fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal
108  IF keyword_set(fakecal) THEN BEGIN
109    date1 = date2jul(date1) - fakecal
110    date2 = date2jul(date2) - fakecal
111  ENDIF
112  IF size(date1, /type) EQ 5 THEN sdate1 = string(date1, format='(f15.6)')+'d' $
113  ELSE sdate1 = string(date1, format='(i10)')+'L'
114  IF size(date2, /type) EQ 5 THEN sdate2 = string(date2, format='(f15.6)')+'d' $
115  ELSE sdate2 = string(date2, format='(i10)')+'L'
116;---------------
117; find boxzoom
118;---------------
119  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
120  CASE n_elements(boxextra) OF
121    0:
122    1:boxzoom[5] = boxextra
123    2:boxzoom[4:5] = boxextra
124    4:boxzoom[0:3] = boxextra
125    5:boxzoom = [boxextra[0:3], 0, boxextra[4]]
126    6:boxzoom = boxextra
127  ENDCASE
128; put boxzoom into a string
129  box = '['+strtrim(boxzoom[0], 1)
130  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
131     box = box+', '+strtrim(boxzoom[i], 1)
132  if strpos(type, 'z') NE -1 then BEGIN
133      @cm_4mesh
134      min = min([gdept, gdepw, boxzoom[4:5]], max = max)
135      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1)
136    endif
137  box = box+']'
138  IF strpos(type, ' diag up') NE -1 THEN BEGIN
139    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
140                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
141  ENDIF
142  IF strpos(type, ' diag dn') NE -1 THEN BEGIN
143    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[3], 1) + $
144                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[2], 1) + ']'
145  ENDIF
146;---------------
147; find funclec_name, readparameters, meshparameters
148;---------------
149  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
150  funclec_name = readparameters.funclec_name
151  if keyword_set(complete) then begin
152    sreadparameters = struct2string(readparameters)
153    meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile]
154    smeshparameters = struct2string(meshparameters)
155;------------------------------------------------------------
156;------------------------------------------------------------
157;------------------------------------------------------------
158; We will define the string which will contain the command to be executed for the reading.
159;------------------------------------------------------------
160    Cmd = ['; Definition of extra structure:', 'extra = '+sextra $
161           , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $
162           , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $
163           , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $
164           , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $
165           , '; Read the data...' $
166           , 'if n_elements(date1in) ne 0 then date1 = date1in else date1 = ' + sdate1 $
167           , 'if n_elements(date2in) ne 0 then date2 = date2in else date2 = ' + sdate2 $
168           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $
169           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2)+' $' $
170           , '    , boxzoom = '+box+', /findalways $' $
171           , '    , filename = '+sfilename+' $']
172    if n_elements(sendpoints) NE 0 then $
173       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
174    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
175    (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar]
176    (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2]
177  ENDIF ELSE BEGIN
178    Cmd = [funclec_name+'('+snamevar+', '+sdate1+', '+sdate2+', '+snameexp $
179           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 1)+' $' $
180           , '    , boxzoom = '+box+', /findalways $' $
181           , '    , filename = '+sfilename+' $']
182    if n_elements(sendpoints) NE 0 then $
183       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $']
184    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)']
185  ENDELSE
186;    print, '::::::::::::::::::::::'
187;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
188;    print, '::::::::::::::::::::::'
189;------------------------------------------------------------
190
191;------------------------------------------------------------
192  return, cmd
193end
Note: See TracBrowser for help on using the repository browser.