source: trunk/WIDGET/AUTOUR_de_XXX/buildcommand.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 19.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:buildcommand
6;
7; PURPOSE:cette fonction reourne un string qui contient la commande de
8; lecture et les parametres du trace.
9;
10; CATEGORY:
11;
12; CALLING SEQUENCE:
13;
14; INPUTS:
15;
16; KEYWORD PARAMETERS:
17;
18; OUTPUTS:
19;
20; COMMON BLOCKS:
21;
22; SIDE EFFECTS:
23;
24; RESTRICTIONS:
25;
26; EXAMPLE:
27;
28; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
29;
30;-
31;------------------------------------------------------------
32;------------------------------------------------------------
33;------------------------------------------------------------
34FUNCTION buildcommand, base, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, BOITE = boite
35;------------------------------------------------------------
36; on recuper les ID des differents widgets
37;------------------------------------------------------------
38   filelistid = widget_info(base, find_by_uname = 'filelist')
39   champid = widget_info(base, find_by_uname = 'champ')
40   nomexpid = widget_info(base, find_by_uname = 'nom_exp')
41   date1id = widget_info(base, find_by_uname = 'calendar1')
42   date2id = widget_info(base, find_by_uname = 'calendar2')
43   domainid = widget_info(base, find_by_uname = 'domain')
44   graphtypeid = widget_info(base, find_by_uname = 'action')
45;   optionid = widget_info(base, find_by_uname = 'option')
46;------------------------------------------------------------
47   widget_control,base, get_uvalue = top_uvalue
48   petitin = extractatt(top_uvalue, 'petitin')
49   numdessinin = petitin[2]-1
50   petitout = extractatt(top_uvalue, 'petitout')
51   numdessinout = petitout[2]-1
52;------------------------------------------------------------
53;---------------
54; on determine quelle procedure on va etre appele pour faire le dessin
55; et le type
56;---------------
57   widget_control,graphtypeid, get_uvalue = graphtype_uvalue
58   type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)]
59;   type = top_uvalue.nameprocedures[numdessinin]
60   case type of
61      'plt':procedure = 'plt'
62      'pltz':procedure = 'pltz'
63      'pltt':procedure = 'pltt'
64      'xy':procedure = 'plt'
65      'xz':procedure = 'pltz'
66      'yz':procedure = 'pltz'
67      'xt':procedure = 'pltt'
68      'yt':procedure = 'pltt'
69      'zt':procedure = 'pltt'
70      'x':procedure = 'plt1d'
71      'y':procedure = 'plt1d'
72      'z':procedure = 'plt1d'
73      't':procedure = 'pltt'
74   endcase
75   if keyword_set(forplth) then BEGIN
76      procedure = 'plt'
77      type = 'plt'
78   ENDIF
79   if keyword_set(forpltz) then BEGIN
80      procedure = 'pltz'
81      type = 'pltz'
82   ENDIF
83   if keyword_set(forpltt) then BEGIN
84      procedure = 'pltt'
85      type = 'pltt'
86   ENDIF
87;
88;  recherche des options
89;
90   options = extractatt(top_uvalue, 'options')   
91   optionsflag = extractatt(top_uvalue, 'optionsflag')
92   flags = optionsflag[*, numdessinin]
93   xindex = (flags[where(options EQ 'Longitude / x index')])[0]
94   yindex = (flags[where(options EQ 'Latitude / y index')])[0]
95   drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt')
96   drawover = (flags[where(options EQ 'Overlay')])[0]
97;
98   alreadyread = extractatt(top_uvalue, 'alreadyread')
99   alreadyvector = extractatt(top_uvalue, 'alreadyvector')
100   alreadyover = extractatt(top_uvalue, 'alreadyoer')
101; que devons-nous lire ?
102   case 1 of
103      alreadyover NE -1:BEGIN
104         toread = alreadyover+1
105         whichread = 'over'
106      END
107      alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN
108         toread = alreadyvector+1
109         whichread = 'vector'
110      END
111      alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN
112         toread = alreadyread+1
113         whichread = 'classic'
114      END
115      else:BEGIN
116         case 1 of
117            alreadyvector eq !pi:BEGIN
118               toread = alreadyover+1
119               whichread = 'over'
120            END
121            alreadyread EQ !pi:BEGIN
122               toread = alreadyvector+1
123               whichread = 'vector'
124            END
125            alreadyread EQ 2.*!pi:BEGIN
126               toread = alreadyover+1
127               whichread = 'over'
128            END
129            ELSE:BEGIN
130               toread = alreadyread+1
131               whichread = 'classic'
132            END
133         endcase
134      END
135   ENDCASE
136;
137   widget_control, nomexpid, get_value = widcommand
138   widcommand = strcompress(widcommand[0], /remove_all)
139   cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add
140;
141   readcommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = whichread EQ 'classic' AND alreadyread EQ -1)
142; on choppe la ligne ou il y a litchamp pour appliquer coef et operateur
143   i = 0
144   while strpos(readcommande[i], 'litchamp') EQ -1 do i = i+1
145;-----------------------
146;-----------------------
147;-----------------------
148;-----------------------
149;-----------------------
150   case whichread of
151      'classic':BEGIN
152         if alreadyread+1 EQ 0 then BEGIN
153; on commence a ecrire la commande de lecture...
154            readcommande = ['; beginning of reading the field to draw' $
155                            , '; field number: '+strtrim(alreadyread+2, 1), readcommande]
156            readcommande[i+2] = 'field = '+coef+operation+readcommande[i+2]
157            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
158         ENDIF ELSE BEGIN
159            readcommande = ['; field number: '+strtrim(alreadyread+2, 1), readcommande]
160            readcommande[i+1] = 'field = field'+separator+coef+operation+readcommande[i+1]
161            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
162            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
163         ENDELSE
164         if alreadyread+1 NE numberofread-1 THEN BEGIN
165; si il faut lire d''autres champs on sort
166            *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1
167            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1))
168            return,  ''
169         ENDIF
170; on finalise la commande de lecture
171         readcommande = [readcommande, 'field = field'+add $
172                         , 'field = create_struct({tab:field, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
173                         , '; end of reading the field to draw', ';']
174; on recupere le _EXTRA:
175         extra = extractatt(top_uvalue, 'extra')
176         if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
177         if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
178         exextra = cw_specifie_get_value(base)
179         extra =  mixstru(exextra,extra)
180         sextra = struct2string(extra)
181         readcommande = [readcommande, 'extra = '+sextra]
182;
183         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
184         case 1 of
185            drawvecteur:BEGIN
186; quelle function de lecture utilisons nous? trace des vecteurs de
187; facon automatique ou non?
188               currentfile = extractatt(top_uvalue, 'currentfile')
189               funclec_name = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
190               funclec_name = funclec_name.funclec_name
191               if funclec_name EQ 'read_ncdf' then begin
192; il faut lire des vecteurs maintenant?
193                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi
194                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector')
195                  return,  ''
196               ENDIF ELSE BEGIN
197; on fait un trace automatique en appelant un et vn ...
198                  readuncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = 0, namefield = 'un')
199                  i = 0
200                  while strpos(readuncommande[i], 'litchamp') EQ -1 do i = i+1
201                  readuncommande = ['; reading the zonal component of vector', readuncommande]
202                  readuncommande[i+1] = 'fieldu = '+readuncommande[i+1]
203                  readuncommande = [readuncommande,'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
204;
205                  readvncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOITE = boite, complete = 0, namefield = 'vn')
206                  i = 0
207                  while strpos(readvncommande[i], 'litchamp') EQ -1 do i = i+1
208                  readvncommande = ['; reading the zonal component of vector', readvncommande]
209                  readvncommande[i+1] = 'fieldv = '+readvncommande[i+1]
210                  readvncommande = [readvncommande,'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
211;
212                  readcommande = [readcommande,';', readuncommande, ';', readvncommande]
213                  *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
214; on enchaine sur un over plot???
215                  if drawover then begin
216                     *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
217                     *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
218                     return,  ''
219                  ENDIF ELSE *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
220               ENDELSE
221            END
222            drawover:BEGIN
223; il faut lire un autre champ a surcontourer?
224               *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
225               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
226               return,  ''
227            END
228; c'est tout pour la lecture, on va tracer!
229            ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
230         endcase
231      END
232      'vector':BEGIN
233; pour lesvecteurs, il y a 2 composantes! en u et en v donc il faut
234; doubler la lecture. pour alreadyvector entier, on lit u pour
235; alreadyvector entier+0.5, on lit v!
236         if floor(alreadyvector)+1 EQ 0 then begin
237            if floor(alreadyvector) EQ alreadyvector then begin
238               readcommande = ['; beginning of reading the zonal component of vector' $
239                               , '; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
240               readcommande[i+2] = 'fieldu = '+coef+operation+readcommande[i+2]
241               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
242            ENDIF ELSE BEGIN
243               readcommande = ['; beginning of reading the meridional component of vector' $
244                               , '; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
245               readcommande[i+2] = 'fieldv = '+coef+operation+readcommande[i+2]
246               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
247            ENDELSE
248         ENDIF ELSE BEGIN
249            if floor(alreadyvector) EQ alreadyvector then begin
250               readcommande = ['; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
251               readcommande[i+1] = 'fieldu = fieldu'+separator+coef+operation+readcommande[i+1]
252               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
253            ENDIF ELSE BEGIN
254               readcommande = ['; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
255               readcommande[i+1] = 'fieldv = fieldv'+separator+coef+operation+readcommande[i+1]
256               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
257            ENDELSE
258         ENDELSE
259         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
260;
261         case alreadyvector+1 of
262            numberofread-1:BEGIN
263; on finalise la commande de lecture
264               readcommande = [readcommande, 'fieldu = fieldu'+add $
265                               , 'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
266                               , '; end of reading the zonal component of vector', ';']
267               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
268; on vient de finir le lecture des U
269               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5
270               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector')
271               return,  ''
272            END
273            numberofread-0.5:BEGIN
274; on finalise la commande de lecture
275               readcommande = [readcommande, 'fieldv = fieldv'+add $
276                               , 'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
277                               , '; end of reading the meridional component of vector', ';']
278; on vient de finir le lecture des V
279;
280; on recupere le _EXTRA de vector et on complete eventuellement le extra
281; deja constitue:
282               extra = extractatt(top_uvalue, 'extra')
283               exextra = cw_specifie_get_value(base)
284               extra =  mixstru(exextra,extra)
285               sextra = struct2string(extra)
286               readcommande = [readcommande, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)']
287;
288               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
289;
290               if drawover then BEGIN
291; on enchaine sur un surcontour
292                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi
293                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
294                  return,  ''
295               ENDIF ELSE BEGIN
296                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
297                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
298               ENDELSE
299            END
300            ELSE:BEGIN
301               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1
302               if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $
303               ELSE text = ' meridional '
304               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector')
305               return,  ''
306            END
307         endcase
308      END
309      'over':BEGIN
310         if alreadyover+1 EQ 0 then begin
311; on commence a ecrire la commande de lecture...
312            readcommande = ['; beginning of reading the field to overdraw' $
313                            , '; fieldover number: '+strtrim(alreadyread+2, 1), readcommande]
314            readcommande[i+2] = 'fieldover = '+coef+operation+readcommande[i+2]
315            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
316         ENDIF ELSE BEGIN
317            readcommande = ['; fieldover number: '+strtrim(alreadyover+2, 1), readcommande]
318            readcommande[i+1] = 'fieldover = fieldover'+separator+coef+operation+readcommande[i+1]
319            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
320         ENDELSE
321         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
322;
323         if alreadyover+1 NE numberofread-1 THEN BEGIN
324; si il faut lire d''autres champs on sort
325            *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1
326            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay')
327            return,  ''
328         ENDIF
329; on finalise la commande de lecture
330         readcommande = [readcommande, 'fieldover = fieldover'+add $
331                         , 'fieldover = create_struct({tab:fieldover, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
332                         , '; end of reading the field to overdraw', ';']
333; on recupere le _EXTRA de over et on complete eventuellement le extra
334; deja constitue:
335         extra = extractatt(top_uvalue, 'extra')
336         exextra = cw_specifie_get_value(base)
337         extra =  mixstru(exextra,extra)
338         sextra = struct2string(extra)
339         readcommande = [readcommande, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)']
340;
341         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
342; on remet les compteurs a 0
343         *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
344         *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
345         *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1
346      END
347   endcase
348;
349;-----------------------
350;-----------------------
351;-----------------------
352;-----------------------
353;-----------------------
354;-----------------------
355;---------------
356; determination du nom de la boite
357;---------------
358   if NOT keyword_set(boite) then widget_control, domainid, get_value = boite
359; ecriture de celle-ci sous forme d''un string
360   box = '['+strtrim(boite[0], 1)
361   for i = 1, (n_elements(boite)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
362    box = box+', '+strtrim(boite[i], 1)
363; pour les [plots en z, box doit avoir par defaut 0,profmax
364   if strpos(type, 'z') NE -1 then BEGIN
365; si + de 1 niveau est selectionne:
366      widget_control, widget_info(base, find_by_uname = 'depthlev1'), get_value = niv1
367      niv1 = niv1.droplist_select
368      widget_control, widget_info(base, find_by_uname = 'depthlev2'), get_value = niv2
369      niv2 = niv2.droplist_select
370      if niv1 NE niv2 then begin
371         box = box+','+strtrim(boite[4], 1)+','+strtrim(boite[5], 1)
372      ENDIF ELSE BEGIN
373         if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $
374         ELSE pmax = 200
375         box = box+',0,'+strtrim(pmax, 1)
376      ENDELSE
377   endif
378   box = box+']'
379;---------------
380; on determine typein
381;---------------
382   typein = ''''+type+''''
383;---------------
384;---------------
385; determination de petit
386;---------------
387   spetit = tostr(petitout)
388;------------------------------------------------------------
389; on va definir le string qui contiendra la commande a executer par widgetdessine.pro
390;------------------------------------------------------------
391   Commande = [readCommande, procedure+', field $', ', boite=' $
392               +box+', typein='+typein+', petit='+spetit+' $']
393   IF drawvecteur then Commande = [Commande, ', vecteur = {u: fieldu,v: fieldv} $']
394   IF drawover then Commande = [Commande, ', contour = fieldover $']
395   Commande = [Commande, ', _extra= mixstru(ex, extra), NOERASE=noerase']
396
397;    print, '---------------'
398;    for i = 0, n_elements(Commande)-1 do print, Commande[i]
399;    print, '---------------'
400;---------------
401; on complete et/ou actualise la structure top_uvalue...
402;---------------
403   (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure
404   (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type
405   (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boite
406   (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand
407   (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags
408   *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra
409;------------------------------------------------------------
410   return, Commande
411end
412
413
Note: See TracBrowser for help on using the repository browser.