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

Last change on this file since 157 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

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