Index: trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcmd.pro
===================================================================
--- trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcommand.pro	(revision 49)
+++ trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcmd.pro	(revision 69)
@@ -3,5 +3,5 @@
 ;------------------------------------------------------------
 ;+
-; NAME:buildcommand
+; NAME:buildcmd
 ;
 ; PURPOSE:cette fonction reourne un string qui contient la commande de
@@ -32,23 +32,23 @@
 ;------------------------------------------------------------
 ;------------------------------------------------------------
-FUNCTION buildcommand, base, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, BOXZOOM = boxzoom
-;
-;------------------------------------------------------------
-; on recuper les ID des differents widgets 
-;------------------------------------------------------------
-   filelistid = widget_info(base, find_by_uname = 'filelist')
-   champid = widget_info(base, find_by_uname = 'champ')
-   nomexpid = widget_info(base, find_by_uname = 'nom_exp')
-   date1id = widget_info(base, find_by_uname = 'calendar1')
-   date2id = widget_info(base, find_by_uname = 'calendar2')
-   domainid = widget_info(base, find_by_uname = 'domain')
-   graphtypeid = widget_info(base, find_by_uname = 'action')
+FUNCTION buildcmd, base, BOXZOOM = boxzoom, FORCETYPE = forcetype
+;
+;------------------------------------------------------------
+; we get back the ids of the widget parts
+;------------------------------------------------------------
+  txtcmdid = widget_info(base, find_by_uname = 'txtcmd')
+  domainid = widget_info(base, find_by_uname = 'domain')
+  actionid = widget_info(base, find_by_uname = 'action')
 ;   optionid = widget_info(base, find_by_uname = 'option')
 ;------------------------------------------------------------
-   widget_control,base, get_uvalue = top_uvalue
-   smallin = extractatt(top_uvalue, 'smallin')
-   numdessinin = smallin[2]-1
-   smallout = extractatt(top_uvalue, 'smallout')
-   numdessinout = smallout[2]-1
+  widget_control, base, get_uvalue = top_uvalue
+  smallin = extractatt(top_uvalue, 'smallin')
+  numdessinin = smallin[2]-1
+  smallout = extractatt(top_uvalue, 'smallout')
+  numdessinout = smallout[2]-1
+;
+  options = extractatt(top_uvalue, 'options')   
+  optionsflag = extractatt(top_uvalue, 'optionsflag')
+  portrait = (strtrim(optionsflag[where(options EQ 'Portrait/Landscape'), 0], 1))[0]
 ;------------------------------------------------------------
 ;---------------
@@ -56,295 +56,274 @@
 ; et le type
 ;---------------
-   widget_control,graphtypeid, get_uvalue = graphtype_uvalue
-   type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)]
-;   type = top_uvalue.nameprocedures[numdessinin]
-   case type of
-      'plt':procedure = 'plt'
-      'pltz':procedure = 'pltz'
-      'pltt':procedure = 'pltt'
-      'xy':procedure = 'plt'
-      'xz':procedure = 'pltz'
-      'yz':procedure = 'pltz'
-      'xt':procedure = 'pltt'
-      'yt':procedure = 'pltt'
-      'zt':procedure = 'pltt'
-      'x':procedure = 'plt1d'
-      'y':procedure = 'plt1d'
-      'z':procedure = 'plt1d'
-      't':procedure = 'pltt'
-   endcase
-   if keyword_set(forplth) then BEGIN 
-      procedure = 'plt'
-      type = 'plt'
-   ENDIF 
-   if keyword_set(forpltz) then BEGIN 
-      procedure = 'pltz'
-      type = 'pltz'
-   ENDIF 
-   if keyword_set(forpltt) then BEGIN 
-      procedure = 'pltt'
-      type = 'pltt'
-   ENDIF
+  IF keyword_set(forcetype) THEN type = forcetype $
+  ELSE type = widget_info(actionid, /combobox_gettext)
+  case type of
+    'plt':procedure = 'plt'
+    'pltz':procedure = 'pltz'
+    'pltz_diag':procedure = 'pltz'
+    'pltt':procedure = 'pltt'
+    'pltt_diag':procedure = 'pltt'
+    'xy':procedure = 'plt'
+    'xz':procedure = 'pltz'
+    'yz':procedure = 'pltz'
+    'xt':procedure = 'pltt'
+    'yt':procedure = 'pltt'
+    'zt':procedure = 'pltt'
+    'x':procedure = 'plt1d'
+    'y':procedure = 'plt1d'
+    'z':procedure = 'plt1d'
+    't':procedure = 'pltt'
+  endcase
 ;
 ;  recherche des options
 ;
-   options = extractatt(top_uvalue, 'options')   
-   optionsflag = extractatt(top_uvalue, 'optionsflag')
-   flags = optionsflag[*, numdessinin]
-   xindex = (flags[where(options EQ 'Longitude / x index')])[0]
-   yindex = (flags[where(options EQ 'Latitude / y index')])[0]
-   drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt')
-   drawover = (flags[where(options EQ 'Overlay')])[0]
-;
-   alreadyread = extractatt(top_uvalue, 'alreadyread')
-   alreadyvector = extractatt(top_uvalue, 'alreadyvector')
-   alreadyover = extractatt(top_uvalue, 'alreadyoer')
+  options = extractatt(top_uvalue, 'options')   
+  optionsflag = extractatt(top_uvalue, 'optionsflag')
+  flags = optionsflag[*, numdessinin]
+  xindex = (flags[where(options EQ 'Longitude / x index')])[0]
+  yindex = (flags[where(options EQ 'Latitude / y index')])[0]
+  drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt')
+  drawover = (flags[where(options EQ 'Overlay')])[0]
+;
+  alreadyread = extractatt(top_uvalue, 'alreadyread')
+  alreadyvector = extractatt(top_uvalue, 'alreadyvector')
+  alreadyover = extractatt(top_uvalue, 'alreadyoer')
 ; que devons-nous lire ?
-   case 1 of
-      alreadyover NE -1:BEGIN
-         toread = alreadyover+1
-         whichread = 'over'
-      END
-      alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN
-         toread = alreadyvector+1
-         whichread = 'vector'
-      END
-      alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN
-         toread = alreadyread+1
-         whichread = 'classic'
-      END
-      else:BEGIN
-         case 1 of
-            alreadyvector eq !pi:BEGIN
-               toread = alreadyover+1
-               whichread = 'over'
-            END
-            alreadyread EQ !pi:BEGIN
-               toread = alreadyvector+1
-               whichread = 'vector'
-            END
-            alreadyread EQ 2.*!pi:BEGIN
-               toread = alreadyover+1
-               whichread = 'over'
-            END
-            ELSE:BEGIN
-               toread = alreadyread+1
-               whichread = 'classic'
-            END
-         endcase
-      END
-   ENDCASE
-;
-   widget_control, nomexpid, get_value = widcommand
-   widcommand = strcompress(widcommand[0], /remove_all)
-   cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add
-;
-   readcommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = whichread EQ 'classic' AND alreadyread EQ -1)
-; on choppe la ligne ou il y a litchamp pour appliquer coef et operateur
-   i = 0
-   while strpos(readcommande[i], 'litchamp') EQ -1 do i = i+1
-;-----------------------
-;-----------------------
-;-----------------------
-;-----------------------
-;-----------------------
-   case whichread of
-      'classic':BEGIN
-         if alreadyread+1 EQ 0 then BEGIN
-; on commence a ecrire la commande de lecture...
-            readcommande = ['; beginning of reading the field to draw' $
-                            , '; field number: '+strtrim(alreadyread+2, 1), readcommande]
-            readcommande[i+2] = 'field = '+coef+operation+readcommande[i+2]
-            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-         ENDIF ELSE BEGIN
-            readcommande = ['; field number: '+strtrim(alreadyread+2, 1), readcommande]
-            readcommande[i+1] = 'field = field'+separator+coef+operation+readcommande[i+1]
-            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-            *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-         ENDELSE
-         if alreadyread+1 NE numberofread-1 THEN BEGIN 
-; si il faut lire d''autres champs on sort
-            *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1
-            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1))
+  case 1 of
+    alreadyover NE -1:BEGIN
+      toread = alreadyover+1
+      readswitch = 'over'
+    END
+    alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN
+      toread = alreadyvector+1
+      readswitch = 'vector'
+    END
+    alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN
+      toread = alreadyread+1
+      readswitch = 'classic'
+    END
+    else:BEGIN
+      case 1 of
+        alreadyvector eq !pi:BEGIN
+          toread = alreadyover+1
+          readswitch = 'over'
+        END
+        alreadyread EQ !pi:BEGIN
+          toread = alreadyvector+1
+          readswitch = 'vector'
+        END
+        alreadyread EQ 2.*!pi:BEGIN
+          toread = alreadyover+1
+          readswitch = 'over'
+        END
+        ELSE:BEGIN
+          toread = alreadyread+1
+          readswitch = 'classic'
+        END
+      endcase
+    END
+  ENDCASE
+;
+  widget_control, txtcmdid, get_value = widcmd
+  IF widcmd[0] EQ '' THEN widcmd = 'zzz'
+  
+  cutcmd, widcmd[0], toread, numberofread, prefix, nameexp, ending
+;
+  readcmd = buildreadcmd(base, ''''+nameexp+'''', procedure, type $
+                         , BOXZOOM = boxzoom, complete = readswitch EQ 'classic' AND alreadyread EQ -1)
+; we look for the line containing funclec_name
+  currentfile = extractatt(top_uvalue, 'currentfile')
+  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
+  i = 0
+  while strpos(readcmd[i], readparameters.funclec_name + '(') EQ -1 do i = i+1
+
+;-----------------------
+;-----------------------
+;-----------------------
+;-----------------------
+;-----------------------
+  case readswitch of
+    'classic':BEGIN
+      if alreadyread+1 EQ 0 then BEGIN
+; we start the reading command
+        readcmd = ['; beginning of reading the field to draw', readcmd]
+        readcmd[i+1] = 'field = ' + prefix + readcmd[i+1]
+      ENDIF ELSE BEGIN
+; we complet the reading command
+        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd')
+        nl = n_elements(oldrdcmd) 
+        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $'
+        readcmd[i] = prefix + readcmd[i]
+        readcmd = [temporary(oldrdcmd), temporary(readcmd)]
+      ENDELSE
+; exit if we have to read other fields...
+      if alreadyread+1 NE numberofread-1 THEN BEGIN 
+        *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+        *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1
+        *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1))
+        return,  ''
+      ENDIF
+; we finalize the reading command
+      IF ending NE '' THEN BEGIN 
+        nl = n_elements(readcmd) 
+        readcmd[nl-1] = readcmd[nl-1] + ' $'
+        readcmd = [temporary(readcmd), ending]
+      ENDIF
+      readcmd = [temporary(readcmd) $
+                 , 'field = create_struct({arr:temporary(field), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $
+                 , '; end of reading the field to draw', ';']
+; we get back _EXTRA:
+      extra = extractatt(top_uvalue, 'extra')
+      if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
+      if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
+      exextra = cw_specifie_get_value(base)
+      extra =  mixstru(exextra, extra)
+      sextra = struct2string(extra)
+      readcmd = [temporary(readcmd), 'extra = '+sextra]
+;
+      *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+      case 1 of
+        drawvecteur:BEGIN
+; we have to read the vectors
+          *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi
+          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector')
+          return,  ''
+        END
+        drawover:BEGIN
+; we have to read the field to overlay...
+          *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
+          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
+          return,  ''
+        END
+; finished, we draw the plot...
+        ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
+      endcase
+    END
+    'vector':BEGIN
+; for the vectors, there is 2 components. we read u when alreadyvector
+; is a interger and v when alreadyvector is a interger+0.5
+      if floor(alreadyvector)+1 EQ 0 then begin
+        if floor(alreadyvector) EQ alreadyvector then begin
+          readcmd = ['; beginning of reading the zonal component of vector', readcmd]
+          readcmd[i+1] = 'fieldu = ' + prefix + readcmd[i+1]
+        ENDIF ELSE BEGIN
+          readcmd = ['; beginning of reading the meridional component of vector', readcmd]
+          readcmd[i+1] = 'fieldv = ' + prefix + readcmd[i+1]
+        ENDELSE
+        readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)]
+      ENDIF ELSE BEGIN
+        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd')
+        nl = n_elements(oldrdcmd) 
+        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $'
+        readcmd[i] = prefix + readcmd[i]
+        readcmd = [temporary(oldrdcmd), temporary(readcmd)]
+      ENDELSE
+;
+      case alreadyvector+1 of
+        numberofread-1:BEGIN
+; we finalize the reading command
+          IF ending NE '' THEN BEGIN 
+            nl = n_elements(readcmd) 
+            readcmd[nl-1] = readcmd[nl-1] + ' $'
+            readcmd = [temporary(readcmd), ending]
+          ENDIF
+          readcmd = [temporary(readcmd) $
+                     , 'fieldu = create_struct({arr:temporary(fieldu), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $
+                     , '; end of reading the zonal component of vector', ';']
+          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+; we finished zonal component reading...
+; we know switch to meridional component...
+          *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5
+          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector')
+          return,  ''
+        END
+        numberofread-0.5:BEGIN
+; we finalize the reading command
+          IF ending NE '' THEN BEGIN 
+            nl = n_elements(readcmd) 
+            readcmd[nl-1] = readcmd[nl-1] + ' $'
+            readcmd = [temporary(readcmd), ending]
+          ENDIF
+          readcmd = [temporary(readcmd)  $
+                     , 'fieldv = create_struct({arr:temporary(fieldv), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $
+                     , '; end of reading the meridional component of vector', ';']
+; we finished meridional component reading...
+;
+; we get back _EXTRA of the vector and we complet extra already build
+          extra = extractatt(top_uvalue, 'extra')
+          exextra = cw_specifie_get_value(base)
+          extra =  mixstru(exextra, extra)
+          sextra = struct2string(extra)
+          readcmd = [readcmd, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)']
+;
+          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+;
+          if drawover then BEGIN
+; shall we do an overlay???
+            *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi
+            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
             return,  ''
-         ENDIF
+          ENDIF ELSE BEGIN
+; it is done know!
+            *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
+            *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
+          ENDELSE
+        END
+        ELSE:BEGIN
+; we still need to read some vector components...
+          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+          *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1
+          if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $
+          ELSE text = ' meridional '
+          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector')
+          return,  ''
+        END
+      endcase
+    END
+    'over':BEGIN
+      if alreadyover+1 EQ 0 then begin
+; we start the reading...
+        readcmd = ['; beginning of reading the field to overdraw', readcmd]
+        readcmd[i+1] = 'fieldover = '+ prefix +readcmd[i+1]
+        readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)]
+      ENDIF ELSE BEGIN
+        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd')
+        nl = n_elements(oldrdcmd) 
+        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $'
+        readcmd[i] = prefix + readcmd[i]
+        readcmd = [temporary(oldrdcmd), temporary(readcmd)]
+      ENDELSE
+;
+      if alreadyover+1 NE numberofread-1 THEN BEGIN 
+; we still need to read some files...
+        *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+        *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1
+        *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay')
+        return,  ''
+      ENDIF
+; we finalize the reading command
+      IF ending NE '' THEN BEGIN 
+        nl = n_elements(readcmd) 
+        readcmd[nl-1] = readcmd[nl-1] + ' $'
+        readcmd = [temporary(readcmd), ending]
+      ENDIF
 ; on finalise la commande de lecture
-         readcommande = [readcommande, 'field = field'+add $
-                         , 'field = create_struct({tab:field, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
-                         , '; end of reading the field to draw', ';']
-; on recupere le _EXTRA:
-         extra = extractatt(top_uvalue, 'extra')
-         if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex)
-         if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex)
-         exextra = cw_specifie_get_value(base)
-         extra =  mixstru(exextra,extra)
-         sextra = struct2string(extra)
-         readcommande = [readcommande, 'extra = '+sextra]
-;
-         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-         case 1 of
-            drawvecteur:BEGIN
-; quelle function de lecture utilisons nous? trace des vecteurs de
-; facon automatique ou non?
-               currentfile = extractatt(top_uvalue, 'currentfile')
-               funclec_name = *(extractatt(top_uvalue, 'readparameters'))[currentfile]
-               funclec_name = funclec_name.funclec_name
-               if funclec_name EQ 'read_ncdf' then begin
-; il faut lire des vecteurs maintenant?
-                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi
-                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector')
-                  return,  ''
-               ENDIF ELSE BEGIN
-; on fait un trace automatique en appelant un et vn ...
-                  readuncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'un')
-                  i = 0
-                  while strpos(readuncommande[i], 'litchamp') EQ -1 do i = i+1
-                  readuncommande = ['; reading the zonal component of vector', readuncommande]
-                  readuncommande[i+1] = 'fieldu = '+readuncommande[i+1]
-                  readuncommande = [readuncommande,'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
-;
-                  readvncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'vn')
-                  i = 0
-                  while strpos(readvncommande[i], 'litchamp') EQ -1 do i = i+1
-                  readvncommande = ['; reading the zonal component of vector', readvncommande]
-                  readvncommande[i+1] = 'fieldv = '+readvncommande[i+1]
-                  readvncommande = [readvncommande,'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})']
-;
-                  readcommande = [readcommande,';', readuncommande, ';', readvncommande]
-                  *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-; on enchaine sur un over plot???
-                  if drawover then begin
-                     *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
-                     *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
-                     return,  ''
-                  ENDIF ELSE *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
-               ENDELSE
-            END
-            drawover:BEGIN
-; il faut lire un autre champ a surcontourer?
-               *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi
-               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
-               return,  ''
-            END
-; c'est tout pour la lecture, on va tracer!
-            ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
-         endcase
-      END
-      'vector':BEGIN
-; pour lesvecteurs, il y a 2 composantes! en u et en v donc il faut
-; doubler la lecture. pour alreadyvector entier, on lit u pour
-; alreadyvector entier+0.5, on lit v!
-         if floor(alreadyvector)+1 EQ 0 then begin
-            if floor(alreadyvector) EQ alreadyvector then begin
-               readcommande = ['; beginning of reading the zonal component of vector' $
-                               , '; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
-               readcommande[i+2] = 'fieldu = '+coef+operation+readcommande[i+2]
-               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-            ENDIF ELSE BEGIN
-               readcommande = ['; beginning of reading the meridional component of vector' $
-                               , '; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
-               readcommande[i+2] = 'fieldv = '+coef+operation+readcommande[i+2]
-               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-            ENDELSE
-         ENDIF ELSE BEGIN
-            if floor(alreadyvector) EQ alreadyvector then begin
-               readcommande = ['; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande]
-               readcommande[i+1] = 'fieldu = fieldu'+separator+coef+operation+readcommande[i+1]
-               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-            ENDIF ELSE BEGIN
-               readcommande = ['; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande]
-               readcommande[i+1] = 'fieldv = fieldv'+separator+coef+operation+readcommande[i+1]
-               readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-            ENDELSE
-         ENDELSE
-         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-;
-         case alreadyvector+1 of
-            numberofread-1:BEGIN
-; on finalise la commande de lecture
-               readcommande = [readcommande, 'fieldu = fieldu'+add $
-                               , 'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
-                               , '; end of reading the zonal component of vector', ';']
-               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-; on vient de finir le lecture des U
-               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5
-               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector')
-               return,  ''
-            END
-            numberofread-0.5:BEGIN
-; on finalise la commande de lecture
-               readcommande = [readcommande, 'fieldv = fieldv'+add $
-                               , 'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
-                               , '; end of reading the meridional component of vector', ';']
-; on vient de finir le lecture des V
-;
-; on recupere le _EXTRA de vector et on complete eventuellement le extra
-; deja constitue:
-               extra = extractatt(top_uvalue, 'extra')
-               exextra = cw_specifie_get_value(base)
-               extra =  mixstru(exextra,extra)
-               sextra = struct2string(extra)
-               readcommande = [readcommande, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)']
-;
-               *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-;
-               if drawover then BEGIN
-; on enchaine sur un surcontour
-                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi
-                  *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay')
-                  return,  ''
-               ENDIF ELSE BEGIN
-                  *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
-                  *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
-               ENDELSE
-            END
-            ELSE:BEGIN
-               *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1
-               if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $
-               ELSE text = ' meridional '
-               *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector')
-               return,  ''
-            END
-         endcase
-      END
-      'over':BEGIN
-         if alreadyover+1 EQ 0 then begin
-; on commence a ecrire la commande de lecture...
-            readcommande = ['; beginning of reading the field to overdraw' $
-                            , '; fieldover number: '+strtrim(alreadyread+2, 1), readcommande]
-            readcommande[i+2] = 'fieldover = '+coef+operation+readcommande[i+2]
-            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-         ENDIF ELSE BEGIN
-            readcommande = ['; fieldover number: '+strtrim(alreadyover+2, 1), readcommande]
-            readcommande[i+1] = 'fieldover = fieldover'+separator+coef+operation+readcommande[i+1]
-            readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande]
-         ENDELSE
-         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-;
-         if alreadyover+1 NE numberofread-1 THEN BEGIN 
-; si il faut lire d''autres champs on sort
-            *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1
-            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay')
-            return,  ''
-         ENDIF
-; on finalise la commande de lecture
-         readcommande = [readcommande, 'fieldover = fieldover'+add $
-                         , 'fieldover = create_struct({tab:fieldover, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $
-                         , '; end of reading the field to overdraw', ';']
-; on recupere le _EXTRA de over et on complete eventuellement le extra
-; deja constitue:
-         extra = extractatt(top_uvalue, 'extra')
-         exextra = cw_specifie_get_value(base)
-         extra =  mixstru(exextra,extra)
-         sextra = struct2string(extra)
-         readcommande = [readcommande, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)']
-;
-         *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande
-; on remet les compteurs a 0
-         *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
-         *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
-         *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1
-      END
-   endcase
+      readcmd = [readcmd $
+                 , 'fieldover = create_struct({arr:temporary(fieldover), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $
+                 , '; end of reading the field to overdraw', ';']
+; we get back _EXTRA of over and we complet extra already build
+      extra = extractatt(top_uvalue, 'extra')
+      exextra = cw_specifie_get_value(base)
+      extra =  mixstru(exextra, extra)
+      sextra = struct2string(extra)
+      readcmd = [readcmd, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)']
+;
+      *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd
+; we reinitialize
+      *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1
+      *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1
+      *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1
+    END
+  endcase
 ;
 ;-----------------------
@@ -357,57 +336,63 @@
 ; determination du nom de la boxzoom 
 ;---------------
-   if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
+  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom
 ; ecriture de celle-ci sous forme d''un string
-   box = '['+strtrim(boxzoom[0], 1)
-   for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
+  box = '['+strtrim(boxzoom[0], 1)
+  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $
     box = box+', '+strtrim(boxzoom[i], 1)
 ; pour les [plots en z, box doit avoir par defaut 0,profmax
-   if strpos(type, 'z') NE -1 then BEGIN
+  if strpos(type, 'z') NE -1 then BEGIN
 ; si + de 1 niveau est selectionne:
-      widget_control, widget_info(base, find_by_uname = 'depthlev1'), get_value = niv1
-      niv1 = niv1.droplist_select
-      widget_control, widget_info(base, find_by_uname = 'depthlev2'), get_value = niv2
-      niv2 = niv2.droplist_select
-      if niv1 NE niv2 then begin
-         box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[5], 1)
-      ENDIF ELSE BEGIN
-         if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $
-         ELSE pmax = 200
-         box = box+',0,'+strtrim(pmax, 1)
-      ENDELSE
-   endif
-   box = box+']'
+    widget_control, widget_info(base, find_by_uname = 'dthlv1'), get_value = niv1
+    niv1 = niv1.combobox_index
+    widget_control, widget_info(base, find_by_uname = 'dthlv2'), get_value = niv2
+    niv2 = niv2.combobox_index
+    if niv1 NE niv2 then begin
+      box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[5], 1)
+    ENDIF ELSE BEGIN
+      if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $
+      ELSE pmax = 200
+      box = box+',0,'+strtrim(pmax, 1)
+    ENDELSE
+  endif
+  box = box+']'
+  IF strpos(type, '_diag') NE -1 THEN BEGIN
+    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $
+                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']'
+  ENDIF
 ;---------------
 ; on determine typein
 ;---------------
-   typein = ''''+type+''''
+    IF strpos(type, '_diag') NE -1 THEN typein = ''''+strmid(type, 0, 4)+'''' $
+    ELSE typein = ''''+type+''''
 ;---------------
 ;---------------
 ; determination de small
 ;---------------
-   ssmall = tostr(smallout)
+  ssmall = tostr(smallout)
 ;------------------------------------------------------------
 ; on va definir le string qui contiendra la commande a executer par widgetdessine.pro
 ;------------------------------------------------------------
-   Commande = [readCommande, procedure+', field $', ', boxzoom=' $
-               +box+', typein='+typein+', small='+ssmall+' $']
-   IF drawvecteur then Commande = [Commande, ', vecteur = {u: fieldu,v: fieldv} $']
-   IF drawover then Commande = [Commande, ', contour = fieldover $']
-   Commande = [Commande, ', _extra= mixstru(ex, extra), NOERASE=noerase']
+  Cmd = [readCmd, procedure+ ', field $' $
+         , '    , boxzoom = '+box+', typein='+typein+', small='+ssmall+' $']
+  IF drawvecteur then Cmd = [Cmd, '    , vecteur = {u: fieldu,v: fieldv} $']
+  IF drawover then Cmd = [Cmd, '    , contour = fieldover $']
+  IF n_elements(sendpoints) NE 0 then Cmd = [Cmd, '    , endpoints = ' + sendpoints + ' $']
+  Cmd = [Cmd, '    , _extra= mixstru(ex, extra), portrait = ' + portrait + ', NOERASE=noerase']
 
 ;    print, '---------------'
-;    for i = 0, n_elements(Commande)-1 do print, Commande[i]
+;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i]
 ;    print, '---------------'
 ;---------------
 ; on complete et/ou actualise la structure top_uvalue...
 ;---------------
-   (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure
-   (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type
-   (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boxzoom
-   (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand
-   (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags
-   *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra
-;------------------------------------------------------------
-   return, Commande
+  (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure
+  (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type
+  (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boxzoom
+  (*top_uvalue[1, findline(top_uvalue, 'txtcmd')])[numdessinout] = widcmd
+  (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags
+  *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra
+;------------------------------------------------------------
+  return, Cmd
 end
 
