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

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

improvements/corrections of some *.pro headers

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