Ignore:
Timestamp:
05/11/06 12:35:53 (18 years ago)
Author:
smasson
Message:

debug + new xxx

Location:
trunk/ToBeReviewed/WIDGET
Files:
2 added
5 deleted
22 edited
5 moved

Legend:

Unmodified
Added
Removed
  • trunk/ToBeReviewed/WIDGET/.idlwave_catalog

    r68 r69  
    22;; IDLWAVE catalog for library saxo 
    33;; Automatically Generated -- do not edit. 
    4 ;; Created by idlwave_catalog on Tue Jan 24 17:06:19 2006 
     4;; Created by idlwave_catalog on Thu May  4 08:42:55 2006 
    55;; 
    66(setq idlwave-library-catalog-libname "saxo") 
     
    1313   ("xx" pro nil (lib "xx.pro" nil "saxo") "%s" (nil ("_extra") ("CALENDAR") ("FUNCLEC_NAME") ("JOUR") ("LISTGRID") ("LISTVAR") ("MESHFILENAME"))) 
    1414   ("xxx_event" pro nil (lib "xxx.pro" nil "saxo") "%s, event" (nil)) 
    15    ("xxx" pro nil (lib "xxx.pro" nil "saxo") "%s" (nil ("_EXTRA") ("BOXZOOM") ("CALLERWIDID") ("DATE1") ("DATE2") ("MULTISTRUCTURE") ("REDRAW") ("RESTORE") ("SEPARATE") ("SMALL") ("UVALUE"))))) 
     15   ("xxx" pro nil (lib "xxx.pro" nil "saxo") "%s, datafilename, idlfile, argspro" (nil ("_EXTRA") ("CALLERWIDID") ("REDRAW") ("RESTORE") ("SEPARATE") ("UVALUE"))) 
     16   ("xxx_event" pro nil (lib "xxx_save.pro" nil "saxo") "%s, event" (nil)) 
     17   ("xxx" pro nil (lib "xxx_save.pro" nil "saxo") "%s, datafilename, idlfile, argspro" (nil ("_EXTRA") ("BOXZOOM") ("CALLERWIDID") ("DATE1") ("DATE2") ("MULTISTRUCTURE") ("REDRAW") ("RESTORE") ("SEPARATE") ("SMALL") ("UVALUE"))))) 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/.idlwave_catalog

    r68 r69  
    22;; IDLWAVE catalog for library saxo 
    33;; Automatically Generated -- do not edit. 
    4 ;; Created by idlwave_catalog on Tue Jan 24 17:06:19 2006 
     4;; Created by idlwave_catalog on Thu May  4 08:42:55 2006 
    55;; 
    66(setq idlwave-library-catalog-libname "saxo") 
    77(setq idlwave-library-catalog-routines 
    8  '(("buildcommand" fun nil (lib "buildcommand.pro" nil "saxo") "Result = %s(base)" (nil ("BOXZOOM") ("FORPLTH") ("FORPLTT") ("FORPLTZ"))) 
    9    ("buildreadcommand" fun nil (lib "buildreadcommand.pro" nil "saxo") "Result = %s(base, snameexp, procedure, type)" (nil ("BOXZOOM") ("COMPLETE") ("NAMEFIELD"))) 
     8 '(("buildcmd" fun nil (lib "buildcmd.pro" nil "saxo") "Result = %s(base)" (nil ("BOXZOOM") ("FORCETYPE"))) 
     9   ("buildreadcmd" fun nil (lib "buildreadcmd.pro" nil "saxo") "Result = %s(base, snameexp, procedure, type)" (nil ("BOXZOOM") ("COMPLETE") ("NAMEFIELD"))) 
    1010   ("changefield" pro nil (lib "changefield.pro" nil "saxo") "%s, base, newfieldname" (nil ("BOXZOOM"))) 
    1111   ("changefile" pro nil (lib "changefile.pro" nil "saxo") "%s, base, newfilename" (nil ("BOXZOOM") ("DATE1") ("DATE2") ("FIELDNAME"))) 
    1212   ("createhistory" pro nil (lib "createhistory.pro" nil "saxo") "%s, base, small" (nil)) 
    13    ("cutcommand" pro nil (lib "cutcommand.pro" nil "saxo") "%s, widcommand, toread, coef, numberofread, operation, nameexp, separator, add" (nil)) 
     13   ("cutcmd" pro nil (lib "cutcmd.pro" nil "saxo") "%s, widcmd, toread, numberofread, prefix, nameexp, ending" (nil)) 
    1414   ("definedefaultextra" fun nil (lib "definedefaultextra.pro" nil "saxo") "Result = %s(nomvariable)" (nil)) 
    1515   ("doubleclickaction" pro nil (lib "doubleclickaction.pro" nil "saxo") "%s, event" (nil)) 
     
    1818   ("identifyclick" fun nil (lib "identifyclick.pro" nil "saxo") "Result = %s(event)" (nil)) 
    1919   ("inserthistory" pro nil (lib "inserthistory.pro" nil "saxo") "%s, base, text, line1, line2" (nil)) 
    20    ("letsdraw" pro nil (lib "letsdraw.pro" nil "saxo") "%s, base" (nil ("_extra") ("COMMANDE") ("FORPLTH") ("FORPLTT") ("FORPLTZ"))) 
     20   ("letsdraw" pro nil (lib "letsdraw.pro" nil "saxo") "%s, base" (nil ("_extra") ("COMMANDE"))) 
     21   ("loadgrid" pro nil (lib "loadgrid.pro" nil "saxo") "%s, meshfilein" (nil ("_extra"))) 
    2122   ("longclickaction" pro nil (lib "longclickaction.pro" nil "saxo") "%s, event" (nil)) 
    2223   ("read_vermair" fun nil (lib "read_vermair.pro" nil "saxo") "Result = %s(name, debut, fin, nomexp)" (nil ("_EXTRA") ("BOXZOOM") ("PARENT"))) 
    23    ("scanfile" fun nil (lib "scanfile.pro" nil "saxo") "Result = %s(nomficher)" (nil ("_extra"))) 
     24   ("scanfile" fun nil (lib "scanfile.pro" nil "saxo") "Result = %s(namefile)" (nil ("_extra") ("GRID"))) 
    2425   ("selectfile_event" pro nil (lib "selectfile.pro" nil "saxo") "%s, event" (nil)) 
    25    ("selectfile" fun nil (lib "selectfile.pro" nil "saxo") "Result = %s" (nil)) 
    26    ("singleclickaction" pro nil (lib "singleclickaction.pro" nil "saxo") "%s, event, quelclick" (nil)) 
     26   ("selectfile" fun nil (lib "selectfile.pro" nil "saxo") "Result = %s(datafilename, idlfile, argspro)" (nil ("_extra"))) 
     27   ("singleclickaction" pro nil (lib "singleclickaction.pro" nil "saxo") "%s, event" (nil)) 
    2728   ("tracecadre" pro nil (lib "tracecadre.pro" nil "saxo") "%s, small" (nil ("erase") ("fill") ("out"))) 
    2829   ("updatewidget" pro nil (lib "updatewidget.pro" nil "saxo") "%s, base" (nil ("NOBOXZOOM") ("NODATES") ("NOTYPE"))) 
    2930   ("xcreateanim_event" pro nil (lib "xcreateanim.pro" nil "saxo") "%s, event" (nil)) 
    3031   ("xcreateanim" pro nil (lib "xcreateanim.pro" nil "saxo") "%s, parent" (nil)) 
    31    ("xxxmenubar_event" pro nil (lib "xxxmenubar.pro" nil "saxo") "%s, event" (nil)) 
    32    ("xxxmenubar" pro nil (lib "xxxmenubar.pro" nil "saxo") "%s, parent" (nil ("_EXTRA") ("OPTIONS"))))) 
     32   ("xxxmenubar_event" pro nil (lib "xxxmenubar_event.pro" nil "saxo") "%s, event" (nil)))) 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildcmd.pro

    r68 r69  
    33;------------------------------------------------------------ 
    44;+ 
    5 ; NAME:buildcommand 
     5; NAME:buildcmd 
    66; 
    77; PURPOSE:cette fonction reourne un string qui contient la commande de 
     
    3232;------------------------------------------------------------ 
    3333;------------------------------------------------------------ 
    34 FUNCTION buildcommand, base, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, BOXZOOM = boxzoom 
    35 ; 
    36 ;------------------------------------------------------------ 
    37 ; on recuper les ID des differents widgets  
    38 ;------------------------------------------------------------ 
    39    filelistid = widget_info(base, find_by_uname = 'filelist') 
    40    champid = widget_info(base, find_by_uname = 'champ') 
    41    nomexpid = widget_info(base, find_by_uname = 'nom_exp') 
    42    date1id = widget_info(base, find_by_uname = 'calendar1') 
    43    date2id = widget_info(base, find_by_uname = 'calendar2') 
    44    domainid = widget_info(base, find_by_uname = 'domain') 
    45    graphtypeid = widget_info(base, find_by_uname = 'action') 
     34FUNCTION buildcmd, base, BOXZOOM = boxzoom, FORCETYPE = forcetype 
     35; 
     36;------------------------------------------------------------ 
     37; we get back the ids of the widget parts 
     38;------------------------------------------------------------ 
     39  txtcmdid = widget_info(base, find_by_uname = 'txtcmd') 
     40  domainid = widget_info(base, find_by_uname = 'domain') 
     41  actionid = widget_info(base, find_by_uname = 'action') 
    4642;   optionid = widget_info(base, find_by_uname = 'option') 
    4743;------------------------------------------------------------ 
    48    widget_control,base, get_uvalue = top_uvalue 
    49    smallin = extractatt(top_uvalue, 'smallin') 
    50    numdessinin = smallin[2]-1 
    51    smallout = extractatt(top_uvalue, 'smallout') 
    52    numdessinout = smallout[2]-1 
     44  widget_control, base, get_uvalue = top_uvalue 
     45  smallin = extractatt(top_uvalue, 'smallin') 
     46  numdessinin = smallin[2]-1 
     47  smallout = extractatt(top_uvalue, 'smallout') 
     48  numdessinout = smallout[2]-1 
     49; 
     50  options = extractatt(top_uvalue, 'options')    
     51  optionsflag = extractatt(top_uvalue, 'optionsflag') 
     52  portrait = (strtrim(optionsflag[where(options EQ 'Portrait/Landscape'), 0], 1))[0] 
    5353;------------------------------------------------------------ 
    5454;--------------- 
     
    5656; et le type 
    5757;--------------- 
    58    widget_control,graphtypeid, get_uvalue = graphtype_uvalue 
    59    type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)] 
    60 ;   type = top_uvalue.nameprocedures[numdessinin] 
    61    case type of 
    62       'plt':procedure = 'plt' 
    63       'pltz':procedure = 'pltz' 
    64       'pltt':procedure = 'pltt' 
    65       'xy':procedure = 'plt' 
    66       'xz':procedure = 'pltz' 
    67       'yz':procedure = 'pltz' 
    68       'xt':procedure = 'pltt' 
    69       'yt':procedure = 'pltt' 
    70       'zt':procedure = 'pltt' 
    71       'x':procedure = 'plt1d' 
    72       'y':procedure = 'plt1d' 
    73       'z':procedure = 'plt1d' 
    74       't':procedure = 'pltt' 
    75    endcase 
    76    if keyword_set(forplth) then BEGIN  
    77       procedure = 'plt' 
    78       type = 'plt' 
    79    ENDIF  
    80    if keyword_set(forpltz) then BEGIN  
    81       procedure = 'pltz' 
    82       type = 'pltz' 
    83    ENDIF  
    84    if keyword_set(forpltt) then BEGIN  
    85       procedure = 'pltt' 
    86       type = 'pltt' 
    87    ENDIF 
     58  IF keyword_set(forcetype) THEN type = forcetype $ 
     59  ELSE type = widget_info(actionid, /combobox_gettext) 
     60  case type of 
     61    'plt':procedure = 'plt' 
     62    'pltz':procedure = 'pltz' 
     63    'pltz_diag':procedure = 'pltz' 
     64    'pltt':procedure = 'pltt' 
     65    'pltt_diag':procedure = 'pltt' 
     66    'xy':procedure = 'plt' 
     67    'xz':procedure = 'pltz' 
     68    'yz':procedure = 'pltz' 
     69    'xt':procedure = 'pltt' 
     70    'yt':procedure = 'pltt' 
     71    'zt':procedure = 'pltt' 
     72    'x':procedure = 'plt1d' 
     73    'y':procedure = 'plt1d' 
     74    'z':procedure = 'plt1d' 
     75    't':procedure = 'pltt' 
     76  endcase 
    8877; 
    8978;  recherche des options 
    9079; 
    91    options = extractatt(top_uvalue, 'options')    
    92    optionsflag = extractatt(top_uvalue, 'optionsflag') 
    93    flags = optionsflag[*, numdessinin] 
    94    xindex = (flags[where(options EQ 'Longitude / x index')])[0] 
    95    yindex = (flags[where(options EQ 'Latitude / y index')])[0] 
    96    drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt') 
    97    drawover = (flags[where(options EQ 'Overlay')])[0] 
    98 ; 
    99    alreadyread = extractatt(top_uvalue, 'alreadyread') 
    100    alreadyvector = extractatt(top_uvalue, 'alreadyvector') 
    101    alreadyover = extractatt(top_uvalue, 'alreadyoer') 
     80  options = extractatt(top_uvalue, 'options')    
     81  optionsflag = extractatt(top_uvalue, 'optionsflag') 
     82  flags = optionsflag[*, numdessinin] 
     83  xindex = (flags[where(options EQ 'Longitude / x index')])[0] 
     84  yindex = (flags[where(options EQ 'Latitude / y index')])[0] 
     85  drawvecteur = (flags[where(options EQ 'Vecteur')])[0]*(procedure eq 'plt') 
     86  drawover = (flags[where(options EQ 'Overlay')])[0] 
     87; 
     88  alreadyread = extractatt(top_uvalue, 'alreadyread') 
     89  alreadyvector = extractatt(top_uvalue, 'alreadyvector') 
     90  alreadyover = extractatt(top_uvalue, 'alreadyoer') 
    10291; que devons-nous lire ? 
    103    case 1 of 
    104       alreadyover NE -1:BEGIN 
    105          toread = alreadyover+1 
    106          whichread = 'over' 
    107       END 
    108       alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN 
    109          toread = alreadyvector+1 
    110          whichread = 'vector' 
    111       END 
    112       alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN 
    113          toread = alreadyread+1 
    114          whichread = 'classic' 
    115       END 
    116       else:BEGIN 
    117          case 1 of 
    118             alreadyvector eq !pi:BEGIN 
    119                toread = alreadyover+1 
    120                whichread = 'over' 
    121             END 
    122             alreadyread EQ !pi:BEGIN 
    123                toread = alreadyvector+1 
    124                whichread = 'vector' 
    125             END 
    126             alreadyread EQ 2.*!pi:BEGIN 
    127                toread = alreadyover+1 
    128                whichread = 'over' 
    129             END 
    130             ELSE:BEGIN 
    131                toread = alreadyread+1 
    132                whichread = 'classic' 
    133             END 
    134          endcase 
    135       END 
    136    ENDCASE 
    137 ; 
    138    widget_control, nomexpid, get_value = widcommand 
    139    widcommand = strcompress(widcommand[0], /remove_all) 
    140    cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add 
    141 ; 
    142    readcommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = whichread EQ 'classic' AND alreadyread EQ -1) 
    143 ; on choppe la ligne ou il y a litchamp pour appliquer coef et operateur 
    144    i = 0 
    145    while strpos(readcommande[i], 'litchamp') EQ -1 do i = i+1 
    146 ;----------------------- 
    147 ;----------------------- 
    148 ;----------------------- 
    149 ;----------------------- 
    150 ;----------------------- 
    151    case whichread of 
    152       'classic':BEGIN 
    153          if alreadyread+1 EQ 0 then BEGIN 
    154 ; on commence a ecrire la commande de lecture... 
    155             readcommande = ['; beginning of reading the field to draw' $ 
    156                             , '; field number: '+strtrim(alreadyread+2, 1), readcommande] 
    157             readcommande[i+2] = 'field = '+coef+operation+readcommande[i+2] 
    158             *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    159          ENDIF ELSE BEGIN 
    160             readcommande = ['; field number: '+strtrim(alreadyread+2, 1), readcommande] 
    161             readcommande[i+1] = 'field = field'+separator+coef+operation+readcommande[i+1] 
    162             readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    163             *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    164          ENDELSE 
    165          if alreadyread+1 NE numberofread-1 THEN BEGIN  
    166 ; si il faut lire d''autres champs on sort 
    167             *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1 
    168             *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1)) 
     92  case 1 of 
     93    alreadyover NE -1:BEGIN 
     94      toread = alreadyover+1 
     95      readswitch = 'over' 
     96    END 
     97    alreadyvector NE -1 AND alreadyvector NE !pi:BEGIN 
     98      toread = alreadyvector+1 
     99      readswitch = 'vector' 
     100    END 
     101    alreadyread NE -1 AND alreadyread NE !pi AND alreadyread NE 2.*!pi:BEGIN 
     102      toread = alreadyread+1 
     103      readswitch = 'classic' 
     104    END 
     105    else:BEGIN 
     106      case 1 of 
     107        alreadyvector eq !pi:BEGIN 
     108          toread = alreadyover+1 
     109          readswitch = 'over' 
     110        END 
     111        alreadyread EQ !pi:BEGIN 
     112          toread = alreadyvector+1 
     113          readswitch = 'vector' 
     114        END 
     115        alreadyread EQ 2.*!pi:BEGIN 
     116          toread = alreadyover+1 
     117          readswitch = 'over' 
     118        END 
     119        ELSE:BEGIN 
     120          toread = alreadyread+1 
     121          readswitch = 'classic' 
     122        END 
     123      endcase 
     124    END 
     125  ENDCASE 
     126; 
     127  widget_control, txtcmdid, get_value = widcmd 
     128  IF widcmd[0] EQ '' THEN widcmd = 'zzz' 
     129   
     130  cutcmd, widcmd[0], toread, numberofread, prefix, nameexp, ending 
     131; 
     132  readcmd = buildreadcmd(base, ''''+nameexp+'''', procedure, type $ 
     133                         , BOXZOOM = boxzoom, complete = readswitch EQ 'classic' AND alreadyread EQ -1) 
     134; we look for the line containing funclec_name 
     135  currentfile = extractatt(top_uvalue, 'currentfile') 
     136  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] 
     137  i = 0 
     138  while strpos(readcmd[i], readparameters.funclec_name + '(') EQ -1 do i = i+1 
     139 
     140;----------------------- 
     141;----------------------- 
     142;----------------------- 
     143;----------------------- 
     144;----------------------- 
     145  case readswitch of 
     146    'classic':BEGIN 
     147      if alreadyread+1 EQ 0 then BEGIN 
     148; we start the reading command 
     149        readcmd = ['; beginning of reading the field to draw', readcmd] 
     150        readcmd[i+1] = 'field = ' + prefix + readcmd[i+1] 
     151      ENDIF ELSE BEGIN 
     152; we complet the reading command 
     153        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') 
     154        nl = n_elements(oldrdcmd)  
     155        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' 
     156        readcmd[i] = prefix + readcmd[i] 
     157        readcmd = [temporary(oldrdcmd), temporary(readcmd)] 
     158      ENDELSE 
     159; exit if we have to read other fields... 
     160      if alreadyread+1 NE numberofread-1 THEN BEGIN  
     161        *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     162        *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = alreadyread+1 
     163        *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyread+3, 1)) 
     164        return,  '' 
     165      ENDIF 
     166; we finalize the reading command 
     167      IF ending NE '' THEN BEGIN  
     168        nl = n_elements(readcmd)  
     169        readcmd[nl-1] = readcmd[nl-1] + ' $' 
     170        readcmd = [temporary(readcmd), ending] 
     171      ENDIF 
     172      readcmd = [temporary(readcmd) $ 
     173                 , 'field = create_struct({arr:temporary(field), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ 
     174                 , '; end of reading the field to draw', ';'] 
     175; we get back _EXTRA: 
     176      extra = extractatt(top_uvalue, 'extra') 
     177      if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) 
     178      if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
     179      exextra = cw_specifie_get_value(base) 
     180      extra =  mixstru(exextra, extra) 
     181      sextra = struct2string(extra) 
     182      readcmd = [temporary(readcmd), 'extra = '+sextra] 
     183; 
     184      *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     185      case 1 of 
     186        drawvecteur:BEGIN 
     187; we have to read the vectors 
     188          *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi 
     189          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector') 
     190          return,  '' 
     191        END 
     192        drawover:BEGIN 
     193; we have to read the field to overlay... 
     194          *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi 
     195          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') 
     196          return,  '' 
     197        END 
     198; finished, we draw the plot... 
     199        ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
     200      endcase 
     201    END 
     202    'vector':BEGIN 
     203; for the vectors, there is 2 components. we read u when alreadyvector 
     204; is a interger and v when alreadyvector is a interger+0.5 
     205      if floor(alreadyvector)+1 EQ 0 then begin 
     206        if floor(alreadyvector) EQ alreadyvector then begin 
     207          readcmd = ['; beginning of reading the zonal component of vector', readcmd] 
     208          readcmd[i+1] = 'fieldu = ' + prefix + readcmd[i+1] 
     209        ENDIF ELSE BEGIN 
     210          readcmd = ['; beginning of reading the meridional component of vector', readcmd] 
     211          readcmd[i+1] = 'fieldv = ' + prefix + readcmd[i+1] 
     212        ENDELSE 
     213        readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)] 
     214      ENDIF ELSE BEGIN 
     215        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') 
     216        nl = n_elements(oldrdcmd)  
     217        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' 
     218        readcmd[i] = prefix + readcmd[i] 
     219        readcmd = [temporary(oldrdcmd), temporary(readcmd)] 
     220      ENDELSE 
     221; 
     222      case alreadyvector+1 of 
     223        numberofread-1:BEGIN 
     224; we finalize the reading command 
     225          IF ending NE '' THEN BEGIN  
     226            nl = n_elements(readcmd)  
     227            readcmd[nl-1] = readcmd[nl-1] + ' $' 
     228            readcmd = [temporary(readcmd), ending] 
     229          ENDIF 
     230          readcmd = [temporary(readcmd) $ 
     231                     , 'fieldu = create_struct({arr:temporary(fieldu), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ 
     232                     , '; end of reading the zonal component of vector', ';'] 
     233          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     234; we finished zonal component reading... 
     235; we know switch to meridional component... 
     236          *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5 
     237          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector') 
     238          return,  '' 
     239        END 
     240        numberofread-0.5:BEGIN 
     241; we finalize the reading command 
     242          IF ending NE '' THEN BEGIN  
     243            nl = n_elements(readcmd)  
     244            readcmd[nl-1] = readcmd[nl-1] + ' $' 
     245            readcmd = [temporary(readcmd), ending] 
     246          ENDIF 
     247          readcmd = [temporary(readcmd)  $ 
     248                     , 'fieldv = create_struct({arr:temporary(fieldv), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ 
     249                     , '; end of reading the meridional component of vector', ';'] 
     250; we finished meridional component reading... 
     251; 
     252; we get back _EXTRA of the vector and we complet extra already build 
     253          extra = extractatt(top_uvalue, 'extra') 
     254          exextra = cw_specifie_get_value(base) 
     255          extra =  mixstru(exextra, extra) 
     256          sextra = struct2string(extra) 
     257          readcmd = [readcmd, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)'] 
     258; 
     259          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     260; 
     261          if drawover then BEGIN 
     262; shall we do an overlay??? 
     263            *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi 
     264            *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') 
    169265            return,  '' 
    170          ENDIF 
     266          ENDIF ELSE BEGIN 
     267; it is done know! 
     268            *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
     269            *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 
     270          ENDELSE 
     271        END 
     272        ELSE:BEGIN 
     273; we still need to read some vector components... 
     274          *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     275          *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1 
     276          if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $ 
     277          ELSE text = ' meridional ' 
     278          *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector') 
     279          return,  '' 
     280        END 
     281      endcase 
     282    END 
     283    'over':BEGIN 
     284      if alreadyover+1 EQ 0 then begin 
     285; we start the reading... 
     286        readcmd = ['; beginning of reading the field to overdraw', readcmd] 
     287        readcmd[i+1] = 'fieldover = '+ prefix +readcmd[i+1] 
     288        readcmd = [extractatt(top_uvalue, 'currentreadcmd'), temporary(readcmd)] 
     289      ENDIF ELSE BEGIN 
     290        oldrdcmd = extractatt(top_uvalue, 'currentreadcmd') 
     291        nl = n_elements(oldrdcmd)  
     292        oldrdcmd[nl-1] = oldrdcmd[nl-1] + ' $' 
     293        readcmd[i] = prefix + readcmd[i] 
     294        readcmd = [temporary(oldrdcmd), temporary(readcmd)] 
     295      ENDELSE 
     296; 
     297      if alreadyover+1 NE numberofread-1 THEN BEGIN  
     298; we still need to read some files... 
     299        *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     300        *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1 
     301        *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay') 
     302        return,  '' 
     303      ENDIF 
     304; we finalize the reading command 
     305      IF ending NE '' THEN BEGIN  
     306        nl = n_elements(readcmd)  
     307        readcmd[nl-1] = readcmd[nl-1] + ' $' 
     308        readcmd = [temporary(readcmd), ending] 
     309      ENDIF 
    171310; on finalise la commande de lecture 
    172          readcommande = [readcommande, 'field = field'+add $ 
    173                          , 'field = create_struct({tab:field, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ 
    174                          , '; end of reading the field to draw', ';'] 
    175 ; on recupere le _EXTRA: 
    176          extra = extractatt(top_uvalue, 'extra') 
    177          if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) 
    178          if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    179          exextra = cw_specifie_get_value(base) 
    180          extra =  mixstru(exextra,extra) 
    181          sextra = struct2string(extra) 
    182          readcommande = [readcommande, 'extra = '+sextra] 
    183 ; 
    184          *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    185          case 1 of 
    186             drawvecteur:BEGIN 
    187 ; quelle function de lecture utilisons nous? trace des vecteurs de 
    188 ; facon automatique ou non? 
    189                currentfile = extractatt(top_uvalue, 'currentfile') 
    190                funclec_name = *(extractatt(top_uvalue, 'readparameters'))[currentfile] 
    191                funclec_name = funclec_name.funclec_name 
    192                if funclec_name EQ 'read_ncdf' then begin 
    193 ; il faut lire des vecteurs maintenant? 
    194                   *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = !pi 
    195                   *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the zonal component of vector') 
    196                   return,  '' 
    197                ENDIF ELSE BEGIN 
    198 ; on fait un trace automatique en appelant un et vn ... 
    199                   readuncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'un') 
    200                   i = 0 
    201                   while strpos(readuncommande[i], 'litchamp') EQ -1 do i = i+1 
    202                   readuncommande = ['; reading the zonal component of vector', readuncommande] 
    203                   readuncommande[i+1] = 'fieldu = '+readuncommande[i+1] 
    204                   readuncommande = [readuncommande,'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})'] 
    205 ; 
    206                   readvncommande = buildreadcommand(base, ''''+nameexp+'''', procedure, type, BOXZOOM = boxzoom, complete = 0, namefield = 'vn') 
    207                   i = 0 
    208                   while strpos(readvncommande[i], 'litchamp') EQ -1 do i = i+1 
    209                   readvncommande = ['; reading the zonal component of vector', readvncommande] 
    210                   readvncommande[i+1] = 'fieldv = '+readvncommande[i+1] 
    211                   readvncommande = [readvncommande,'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})'] 
    212 ; 
    213                   readcommande = [readcommande,';', readuncommande, ';', readvncommande] 
    214                   *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    215 ; on enchaine sur un over plot??? 
    216                   if drawover then begin 
    217                      *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi 
    218                      *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') 
    219                      return,  '' 
    220                   ENDIF ELSE *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
    221                ENDELSE 
    222             END 
    223             drawover:BEGIN 
    224 ; il faut lire un autre champ a surcontourer? 
    225                *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = 2.*!pi 
    226                *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') 
    227                return,  '' 
    228             END 
    229 ; c'est tout pour la lecture, on va tracer! 
    230             ELSE:*top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
    231          endcase 
    232       END 
    233       'vector':BEGIN 
    234 ; pour lesvecteurs, il y a 2 composantes! en u et en v donc il faut 
    235 ; doubler la lecture. pour alreadyvector entier, on lit u pour 
    236 ; alreadyvector entier+0.5, on lit v! 
    237          if floor(alreadyvector)+1 EQ 0 then begin 
    238             if floor(alreadyvector) EQ alreadyvector then begin 
    239                readcommande = ['; beginning of reading the zonal component of vector' $ 
    240                                , '; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande] 
    241                readcommande[i+2] = 'fieldu = '+coef+operation+readcommande[i+2] 
    242                readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    243             ENDIF ELSE BEGIN 
    244                readcommande = ['; beginning of reading the meridional component of vector' $ 
    245                                , '; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande] 
    246                readcommande[i+2] = 'fieldv = '+coef+operation+readcommande[i+2] 
    247                readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    248             ENDELSE 
    249          ENDIF ELSE BEGIN 
    250             if floor(alreadyvector) EQ alreadyvector then begin 
    251                readcommande = ['; fieldu number: '+strtrim(alreadyvector+2, 1), readcommande] 
    252                readcommande[i+1] = 'fieldu = fieldu'+separator+coef+operation+readcommande[i+1] 
    253                readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    254             ENDIF ELSE BEGIN 
    255                readcommande = ['; fieldv number: '+strtrim(floor(alreadyvector)+2, 1), readcommande] 
    256                readcommande[i+1] = 'fieldv = fieldv'+separator+coef+operation+readcommande[i+1] 
    257                readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    258             ENDELSE 
    259          ENDELSE 
    260          *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    261 ; 
    262          case alreadyvector+1 of 
    263             numberofread-1:BEGIN 
    264 ; on finalise la commande de lecture 
    265                readcommande = [readcommande, 'fieldu = fieldu'+add $ 
    266                                , 'fieldu = create_struct({tab:fieldu, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ 
    267                                , '; end of reading the zonal component of vector', ';'] 
    268                *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    269 ; on vient de finir le lecture des U 
    270                *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -.5 
    271                *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the meridional component of vector') 
    272                return,  '' 
    273             END 
    274             numberofread-0.5:BEGIN 
    275 ; on finalise la commande de lecture 
    276                readcommande = [readcommande, 'fieldv = fieldv'+add $ 
    277                                , 'fieldv = create_struct({tab:fieldv, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ 
    278                                , '; end of reading the meridional component of vector', ';'] 
    279 ; on vient de finir le lecture des V 
    280 ; 
    281 ; on recupere le _EXTRA de vector et on complete eventuellement le extra 
    282 ; deja constitue: 
    283                extra = extractatt(top_uvalue, 'extra') 
    284                exextra = cw_specifie_get_value(base) 
    285                extra =  mixstru(exextra,extra) 
    286                sextra = struct2string(extra) 
    287                readcommande = [readcommande, 'vectorextra = '+sextra, 'extra=mixstru(extra,vectorextra)'] 
    288 ; 
    289                *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    290 ; 
    291                if drawover then BEGIN 
    292 ; on enchaine sur un surcontour 
    293                   *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = !pi 
    294                   *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field to overlay') 
    295                   return,  '' 
    296                ENDIF ELSE BEGIN 
    297                   *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
    298                   *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 
    299                ENDELSE 
    300             END 
    301             ELSE:BEGIN 
    302                *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = alreadyvector+1 
    303                if floor(alreadyvector) EQ alreadyvector then text = ' zonal ' $ 
    304                ELSE text = ' meridional ' 
    305                *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the '+strtrim(floor(alreadyread)+3, 1)+text+'component of vector') 
    306                return,  '' 
    307             END 
    308          endcase 
    309       END 
    310       'over':BEGIN 
    311          if alreadyover+1 EQ 0 then begin 
    312 ; on commence a ecrire la commande de lecture... 
    313             readcommande = ['; beginning of reading the field to overdraw' $ 
    314                             , '; fieldover number: '+strtrim(alreadyread+2, 1), readcommande] 
    315             readcommande[i+2] = 'fieldover = '+coef+operation+readcommande[i+2] 
    316             readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    317          ENDIF ELSE BEGIN 
    318             readcommande = ['; fieldover number: '+strtrim(alreadyover+2, 1), readcommande] 
    319             readcommande[i+1] = 'fieldover = fieldover'+separator+coef+operation+readcommande[i+1] 
    320             readcommande = [extractatt(top_uvalue, 'currentreadcommand'), readcommande] 
    321          ENDELSE 
    322          *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    323 ; 
    324          if alreadyover+1 NE numberofread-1 THEN BEGIN  
    325 ; si il faut lire d''autres champs on sort 
    326             *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = alreadyover+1 
    327             *top_uvalue[1, findline(top_uvalue, 'noticebase')] = xnotice('Select the field number '+strtrim(alreadyover+3, 1)+' to overlay') 
    328             return,  '' 
    329          ENDIF 
    330 ; on finalise la commande de lecture 
    331          readcommande = [readcommande, 'fieldover = fieldover'+add $ 
    332                          , 'fieldover = create_struct({tab:fieldover, grille:vargrid, unite:varunit, experience:varexp, nom:varname})' $ 
    333                          , '; end of reading the field to overdraw', ';'] 
    334 ; on recupere le _EXTRA de over et on complete eventuellement le extra 
    335 ; deja constitue: 
    336          extra = extractatt(top_uvalue, 'extra') 
    337          exextra = cw_specifie_get_value(base) 
    338          extra =  mixstru(exextra,extra) 
    339          sextra = struct2string(extra) 
    340          readcommande = [readcommande, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)'] 
    341 ; 
    342          *top_uvalue[1, findline(top_uvalue, 'currentreadcommand')] = readcommande 
    343 ; on remet les compteurs a 0 
    344          *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
    345          *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 
    346          *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1 
    347       END 
    348    endcase 
     311      readcmd = [readcmd $ 
     312                 , 'fieldover = create_struct({arr:temporary(fieldover), grid:vargrid, unit:varunit, experiment:varexp, name:varname})' $ 
     313                 , '; end of reading the field to overdraw', ';'] 
     314; we get back _EXTRA of over and we complet extra already build 
     315      extra = extractatt(top_uvalue, 'extra') 
     316      exextra = cw_specifie_get_value(base) 
     317      extra =  mixstru(exextra, extra) 
     318      sextra = struct2string(extra) 
     319      readcmd = [readcmd, 'overextra = '+sextra, 'extra=mixstru(extra,overextra)'] 
     320; 
     321      *top_uvalue[1, findline(top_uvalue, 'currentreadcmd')] = readcmd 
     322; we reinitialize 
     323      *top_uvalue[1, findline(top_uvalue, 'alreadyread')] = -1 
     324      *top_uvalue[1, findline(top_uvalue, 'alreadyvector')] = -1 
     325      *top_uvalue[1, findline(top_uvalue, 'alreadyover')] = -1 
     326    END 
     327  endcase 
    349328; 
    350329;----------------------- 
     
    357336; determination du nom de la boxzoom  
    358337;--------------- 
    359    if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     338  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
    360339; ecriture de celle-ci sous forme d''un string 
    361    box = '['+strtrim(boxzoom[0], 1) 
    362    for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ 
     340  box = '['+strtrim(boxzoom[0], 1) 
     341  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ 
    363342    box = box+', '+strtrim(boxzoom[i], 1) 
    364343; pour les [plots en z, box doit avoir par defaut 0,profmax 
    365    if strpos(type, 'z') NE -1 then BEGIN 
     344  if strpos(type, 'z') NE -1 then BEGIN 
    366345; si + de 1 niveau est selectionne: 
    367       widget_control, widget_info(base, find_by_uname = 'depthlev1'), get_value = niv1 
    368       niv1 = niv1.droplist_select 
    369       widget_control, widget_info(base, find_by_uname = 'depthlev2'), get_value = niv2 
    370       niv2 = niv2.droplist_select 
    371       if niv1 NE niv2 then begin 
    372          box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[5], 1) 
    373       ENDIF ELSE BEGIN 
    374          if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $ 
    375          ELSE pmax = 200 
    376          box = box+',0,'+strtrim(pmax, 1) 
    377       ENDELSE 
    378    endif 
    379    box = box+']' 
     346    widget_control, widget_info(base, find_by_uname = 'dthlv1'), get_value = niv1 
     347    niv1 = niv1.combobox_index 
     348    widget_control, widget_info(base, find_by_uname = 'dthlv2'), get_value = niv2 
     349    niv2 = niv2.combobox_index 
     350    if niv1 NE niv2 then begin 
     351      box = box+','+strtrim(boxzoom[4], 1)+','+strtrim(boxzoom[5], 1) 
     352    ENDIF ELSE BEGIN 
     353      if chkstru(exextra, 'profmax') then  pmax = exextra.profmax $ 
     354      ELSE pmax = 200 
     355      box = box+',0,'+strtrim(pmax, 1) 
     356    ENDELSE 
     357  endif 
     358  box = box+']' 
     359  IF strpos(type, '_diag') NE -1 THEN BEGIN 
     360    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $ 
     361                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']' 
     362  ENDIF 
    380363;--------------- 
    381364; on determine typein 
    382365;--------------- 
    383    typein = ''''+type+'''' 
     366    IF strpos(type, '_diag') NE -1 THEN typein = ''''+strmid(type, 0, 4)+'''' $ 
     367    ELSE typein = ''''+type+'''' 
    384368;--------------- 
    385369;--------------- 
    386370; determination de small 
    387371;--------------- 
    388    ssmall = tostr(smallout) 
     372  ssmall = tostr(smallout) 
    389373;------------------------------------------------------------ 
    390374; on va definir le string qui contiendra la commande a executer par widgetdessine.pro 
    391375;------------------------------------------------------------ 
    392    Commande = [readCommande, procedure+', field $', ', boxzoom=' $ 
    393                +box+', typein='+typein+', small='+ssmall+' $'] 
    394    IF drawvecteur then Commande = [Commande, ', vecteur = {u: fieldu,v: fieldv} $'] 
    395    IF drawover then Commande = [Commande, ', contour = fieldover $'] 
    396    Commande = [Commande, ', _extra= mixstru(ex, extra), NOERASE=noerase'] 
     376  Cmd = [readCmd, procedure+ ', field $' $ 
     377         , '    , boxzoom = '+box+', typein='+typein+', small='+ssmall+' $'] 
     378  IF drawvecteur then Cmd = [Cmd, '    , vecteur = {u: fieldu,v: fieldv} $'] 
     379  IF drawover then Cmd = [Cmd, '    , contour = fieldover $'] 
     380  IF n_elements(sendpoints) NE 0 then Cmd = [Cmd, '    , endpoints = ' + sendpoints + ' $'] 
     381  Cmd = [Cmd, '    , _extra= mixstru(ex, extra), portrait = ' + portrait + ', NOERASE=noerase'] 
    397382 
    398383;    print, '---------------' 
    399 ;    for i = 0, n_elements(Commande)-1 do print, Commande[i] 
     384;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i] 
    400385;    print, '---------------' 
    401386;--------------- 
    402387; on complete et/ou actualise la structure top_uvalue... 
    403388;--------------- 
    404    (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure 
    405    (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type 
    406    (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boxzoom 
    407    (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand 
    408    (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags 
    409    *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra 
    410 ;------------------------------------------------------------ 
    411    return, Commande 
     389  (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessinout] = procedure 
     390  (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessinout] = type 
     391  (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinout] = boxzoom 
     392  (*top_uvalue[1, findline(top_uvalue, 'txtcmd')])[numdessinout] = widcmd 
     393  (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[*, numdessinout] = flags 
     394  *((*top_uvalue[1, findline(top_uvalue, 'exextra')])[numdessinout]) = extra 
     395;------------------------------------------------------------ 
     396  return, Cmd 
    412397end 
    413398 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro

    r68 r69  
    33;------------------------------------------------------------ 
    44;+ 
    5 ; NAME:buildreadcommand 
     5; NAME:buildreadcmd 
    66; 
    77; PURPOSE: 
     
    3131;------------------------------------------------------------ 
    3232;------------------------------------------------------------ 
    33 FUNCTION buildreadcommand, base, snameexp, procedure, type, BOXZOOM = boxzoom, COMPLETE = complete, NAMEFIELD = namefield 
     33FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $ 
     34                       , COMPLETE = complete, NAMEFIELD = namefield 
     35; 
     36@cm_4cal ; for key_caltype 
    3437;------------------------------------------------------------ 
    35 ; on recuper les ID des differents widgets  
     38; get back widgets IDs 
    3639;------------------------------------------------------------ 
    37    filelistid = widget_info(base, find_by_uname = 'filelist') 
    38    champid = widget_info(base, find_by_uname = 'champ') 
    39    nomexpid = widget_info(base, find_by_uname = 'nom_exp') 
    40    date1id = widget_info(base, find_by_uname = 'calendar1') 
    41    date2id = widget_info(base, find_by_uname = 'calendar2') 
    42    domainid = widget_info(base, find_by_uname = 'domain') 
     40  vlstid = widget_info(base, find_by_uname = 'varlist') 
     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') 
    4344;   optionid = widget_info(base, find_by_uname = 'option') 
    4445;------------------------------------------------------------ 
    45    widget_control,base, get_uvalue = top_uvalue 
    46    numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
    47    numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 
     46  widget_control, base, get_uvalue = top_uvalue 
     47  numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
     48  numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 
    4849;--------------- 
    49 ; determination du nom du fichier 
     50; name of the file 
    5051;--------------- 
    51    currentfile = extractatt(top_uvalue, 'currentfile') 
    52    filelist = extractatt(top_uvalue, 'filelist') 
    53    filename = filelist[currentfile] 
    54    sfilename = ''''+filename+'''' 
     52  currentfile = extractatt(top_uvalue, 'currentfile') 
     53  filelist = extractatt(top_uvalue, 'filelist') 
     54  filename = filelist[currentfile] 
     55  sfilename = ''''+filename+'''' 
    5556;--------------- 
    56 ; on recupere le nom de la variable 
     57; name of the variable 
    5758;--------------- 
    58    if NOT keyword_set(namefield) then begin 
    59       listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
    60       nomvariable = listvar[widget_info(champid, /droplist_select)] 
    61    ENDIF ELSE nomvariable = namefield 
    62    snomvariable = ''''+nomvariable+'''' 
     59  if keyword_set(namefield) then namevar = namefield $ 
     60  ELSE namevar = widget_info(vlstid, /combobox_gettext) 
     61  snamevar = ''''+namevar+'''' 
    6362; 
    64 ;  recherche des options 
     63; get the options 
    6564; 
    66    options = extractatt(top_uvalue, 'options')    
    67    flags = extractatt(top_uvalue, 'optionsflag') 
    68    flags = flags[*, numdessinin] 
    69    xindex = (flags[where(options EQ 'Longitude / x index')])[0] 
    70    yindex = (flags[where(options EQ 'Latitude / y index')])[0] 
     65  options = extractatt(top_uvalue, 'options')    
     66  flags = extractatt(top_uvalue, 'optionsflag') 
     67  flags = flags[*, numdessinin] 
     68  xindex = (flags[where(options EQ 'Longitude / x index')])[0] 
     69  yindex = (flags[where(options EQ 'Latitude / y index')])[0] 
    7170; 
    72    extra = extractatt(top_uvalue, 'extra') 
    73    if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) 
    74    if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
    75    exextra = cw_specifie_get_value(base) 
    76    exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) 
    77    if size(exextra, /type) EQ 8 then extra = mixstru(exextra,extra) 
    78    sextra = struct2string(extra) 
     71  extra = extractatt(top_uvalue, 'extra') 
     72  if xindex NE 0 then extra = create_struct(extra, 'xindex', xindex) 
     73  if yindex NE 0 then extra = create_struct(extra, 'yindex', yindex) 
     74  exextra = cw_specifie_get_value(base) 
     75  exextra = extractstru(exextra, ['min', 'max', 'inter', 'lct']) 
     76  if size(exextra, /type) EQ 8 then extra = mixstru(exextra, extra) 
     77  sextra = struct2string(extra) 
    7978 
    8079;--------------- 
    81 ; determination de date1 et date2 
     80; find date1 and date2 
    8281;--------------- 
    83    widget_control, date1id, get_value = date1 
     82  key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).caltype 
     83  widget_control, date1id, get_value = date1 
     84  widget_control, date2id, get_value = date2 
     85 
     86  if procedure EQ 'pltt' AND date1 EQ date2 then BEGIN 
     87; we redefine the dates to the begining and end of the calendar 
     88    calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter 
     89    date1 = jul2date(calendar[0]) 
     90    date2 = jul2date(calendar[n_elements(calendar)-1]) 
     91    widget_control, date1id, set_value = date1 
     92    widget_control, date2id, set_value = date2 
     93  endif 
    8494; 
    85    widget_control, date2id, get_value = date2 
    86    date1 = long(date1) & date2 = long(date2) 
    87 ; 
    88    if procedure EQ 'pltt' AND date1 EQ date2 then begin 
    89       currentfile = extractatt(top_uvalue, 'currentfile') 
    90       calendar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).time_counter 
    91       caldat, calendar,monthcal,daycal,yearcal 
    92       if total(daycal eq 15) EQ n_elements(calendar) then monthly = 1 
    93       if total(monthcal EQ 6) EQ n_elements(calendar) then BEGIN  
    94          monthly = 1  
    95          yearly = 1 
    96       endif 
    97       date1 = vairdate(calendar[0], mensuel = monthly, annuel = yearly) 
    98       date2 = vairdate(calendar[n_elements(calendar)-1], mensuel = monthly, annuel = yearly) 
    99       widget_control, date1id, set_value = date1 
    100       widget_control, date2id, set_value = date2 
    101    endif 
    102 ; 
    103    sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) 
     95  fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).fakecal 
     96  IF keyword_set(fakecal) THEN BEGIN 
     97    date1 = date2jul(date1) - fakecal 
     98    date2 = date2jul(date2) - fakecal 
     99  ENDIF 
     100  sdate1 = strtrim(date1, 1) & sdate2 = strtrim(date2, 1) 
    104101;--------------- 
    105 ; determination du nom de la boxzoom  
     102; find boxzoom 
    106103;--------------- 
    107    if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
    108 ; ecriture de celle-ci sous forme d''un string 
    109    box = '['+strtrim(boxzoom[0], 1) 
    110    for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ 
    111     box = box+', '+strtrim(boxzoom[i], 1) 
    112    if strpos(type, 'z') NE -1 then BEGIN 
     104  if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 
     105; put boxzoom into a string 
     106  box = '['+strtrim(boxzoom[0], 1) 
     107  for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ 
     108     box = box+', '+strtrim(boxzoom[i], 1) 
     109  if strpos(type, 'z') NE -1 then BEGIN 
    113110      @common 
    114111      min = min([gdept, gdepw], max = max) 
    115112      box = box+','+strtrim(floor(min), 1)+','+strtrim(ceil(max), 1) 
    116    endif 
    117    box = box+']' 
     113    endif 
     114  box = box+']' 
     115  IF strpos(type, '_diag') NE -1 THEN BEGIN 
     116    sendpoints = '[' + strtrim(boxzoom[0], 1) + ', ' + strtrim(boxzoom[2], 1) + $ 
     117                ', ' + strtrim(boxzoom[1], 1) + ', ' + strtrim(boxzoom[3], 1) + ']' 
     118  ENDIF 
    118119;--------------- 
    119 ; determination de funclec_name, readparameters, meshparameters 
     120; find funclec_name, readparameters, meshparameters 
    120121;--------------- 
    121    readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] 
    122    funclec_name = readparameters.funclec_name 
    123    if keyword_set(complete) then begin 
    124       sreadparameters = struct2string(readparameters) 
    125       meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] 
    126       smeshparameters = struct2string(meshparameters) 
     122  readparameters = *(extractatt(top_uvalue, 'readparameters'))[currentfile] 
     123  funclec_name = readparameters.funclec_name 
     124  if keyword_set(complete) then begin 
     125    sreadparameters = struct2string(readparameters) 
     126    meshparameters = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] 
     127    smeshparameters = struct2string(meshparameters) 
    127128;------------------------------------------------------------ 
    128129;------------------------------------------------------------ 
     
    131132; la lecture 
    132133;------------------------------------------------------------ 
    133       Commande = ['; declaration de la structure extra:', 'extra='+sextra $ 
    134                   , '; declaration de la structure readparameters:', 'readparameters='+sreadparameters $ 
    135                   , '; on change de lecture?:', 'nothing=changeread(readparameters)' $ 
    136                   , '; declaration de la structure meshparameters:', 'meshparameters='+smeshparameters $ 
    137                   , '; on change de grille?:', 'nothing=changegrid(meshparameters)' $ 
    138                   , '; lecture du champ' $ 
    139                   , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ 
    140                   , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ 
    141                   , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ 
    142                   +',parent='+strtrim(base, 1)+',boxzoom='+box+' $',', filename='+sfilename+' $' $ 
    143                   , ', _extra=mixstru(ex, extra)))'] 
    144       (*top_uvalue[1, findline(top_uvalue, 'champs')])[*, numdessinout] = [filename, nomvariable] 
    145       (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] 
    146    ENDIF ELSE BEGIN 
    147       Commande = ['; lecture du champ' $ 
    148                   , 'if keyword_set(date1in) then date1 = date1in else date1 = '+sdate1 $ 
    149                   , 'if keyword_set(date2in) then date2 = date2in else date2 = '+sdate2 $ 
    150                   , 'litchamp('+funclec_name+'('+snomvariable+', date1, date2,'+snameexp $ 
    151                   +',parent='+strtrim(base, 1)+',boxzoom='+box+' $',', filename='+sfilename+' $' $ 
    152                   , ', _extra=mixstru(ex, extra)))'] 
    153    ENDELSE 
     134    Cmd = ['; Definition of extra structure:', 'extra = '+sextra $ 
     135           , '; Definition of readparameters structure:', 'readparameters = '+sreadparameters $ 
     136           , '; Do we change of reading?:', 'dummy = changeread(readparameters)' $ 
     137           , '; Definition of meshparameters structure:', 'meshparameters = '+smeshparameters $ 
     138           , '; Do we change the grid?:', 'dummy = changegrid(meshparameters)' $ 
     139           , '; Read the data...' $ 
     140           , 'if keyword_set(date1in) then date1 = date1in else date1 = ' + sdate1 $ 
     141           , 'if keyword_set(date2in) then date2 = date2in else date2 = ' + sdate2 $ 
     142           , funclec_name+'('+snamevar+', date1, date2, '+snameexp $ 
     143           + ', timestep = '+strtrim(keyword_set(fakecal), 1)+', parent = '+strtrim(base, 2) $ 
     144           + ', boxzoom = '+box+' $' $ 
     145           , '    , filename = '+sfilename+' $'] 
     146    if n_elements(sendpoints) NE 0 then $ 
     147       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $'] 
     148    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)'] 
     149    (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessinout] = [filename, namevar] 
     150    (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessinout] = [date1, date2] 
     151  ENDIF ELSE BEGIN 
     152    Cmd = [funclec_name+'('+snamevar+', date1, date2, '+snameexp $ 
     153           +', parent = '+strtrim(base, 1)+', boxzoom = '+box+' $' $ 
     154           , '    , filename = '+sfilename+' $'] 
     155    if n_elements(sendpoints) NE 0 then $ 
     156       Cmd = [Cmd, '    , endpoints = ' + sendpoints + ', type = ''' + type  + ''' $'] 
     157    Cmd = [Cmd, '    , _extra = mixstru(ex, extra), /nostruct)'] 
     158  ENDELSE 
    154159;    print, '::::::::::::::::::::::' 
    155 ;    for i = 0, n_elements(Commande)-1 do print, Commande[i] 
     160;    for i = 0, n_elements(Cmd)-1 do print, Cmd[i] 
    156161;    print, '::::::::::::::::::::::' 
    157162;------------------------------------------------------------ 
    158163 
    159164;------------------------------------------------------------ 
    160    return, commande 
     165  return, cmd 
    161166end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/changefield.pro

    r49 r69  
    11PRO changefield, base, newfieldname, BOXZOOM = boxzoom 
    22; 
    3    widget_control, base, get_uvalue = top_uvalue 
     3  widget_control, base, get_uvalue = top_uvalue 
    44; 
    5 ; changement de exextra : 
    6    exextra = definedefaultextra(newfieldname) 
    7    specifieid = widget_info(base,find_by_uname = 'specifie') 
    8    widget_control, specifieid, set_value = exextra 
    9 ; chamgement de variable -> devra-t-on changer de domaine verticale? 
    10    oldzgrid = extractatt(top_uvalue, 'zgrid') 
    11    currentfile = extractatt(top_uvalue, 'currentfile') 
    12    listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
    13    listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
     5; Change exextra : 
     6  exextra = definedefaultextra(newfieldname) 
     7  specifieid = widget_info(base, find_by_uname = 'specifie') 
     8  widget_control, specifieid, set_value = exextra 
     9; Change the variable -> Do we need to change the vertical axis 
     10; according to the tye of points (T or W)? 
     11  dthlv1id = widget_info(base, find_by_uname = 'dthlv1') 
     12  widget_control, dthlv1id, get_uvalue = dthlv1_uval 
     13  oldzgridt = dthlv1_uval.grid_t 
     14; get the type of point 
     15  currentfile = extractatt(top_uvalue, 'currentfile') 
     16  listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
     17  listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
    1418;   for i = 0,  n_elements(listvar)-1 do print,  listvar[i], '/', listgrid[i] 
    15    indexvar = where(listvar EQ newfieldname) & indexvar = 0 > indexvar[0] 
    16    vargrid = strupcase(listgrid[indexvar]) 
    17    IF vargrid EQ 'W' then zgrid = 'W' ELSE zgrid = 'T' 
    18    if zgrid NE oldzgrid then BEGIN 
    19       *top_uvalue[1, findline(top_uvalue, 'zgrid')] = zgrid 
    20       if NOT keyword_set(boxzoom) THEN BEGIN 
    21          widget_control, widget_info(base, find_by_uname = 'domain'), get_value = boxzoom 
    22          widget_control, widget_info(base, find_by_uname = 'domain'), set_value = boxzoom 
    23       endif 
    24    endif 
     19  indexvar = where(listvar EQ newfieldname) 
     20  indexvar = 0 > indexvar[0] 
     21  zgridt = strupcase(listgrid[indexvar]) NE 'W' 
     22; if we change the type of point 
     23  if zgridt NE oldzgridt then BEGIN 
     24; update dthlv1_uval.grid_t 
     25    dthlv1_uval.grid_t = zgridt 
     26    widget_control, dthlv1id, set_uvalue = dthlv1_uval 
     27; update cw_domain 
     28    if NOT keyword_set(boxzoom) THEN $ 
     29       widget_control, widget_info(base, find_by_uname = 'domain'), get_value = boxzoom 
     30    widget_control, widget_info(base, find_by_uname = 'domain'), set_value = boxzoom 
     31  endif 
    2532; 
    26    return 
     33  return 
    2734end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/changefile.pro

    r49 r69  
    11PRO changefile, base, newfilename, BOXZOOM = boxzoom, DATE1 = date1, DATE2 = date2, FIELDNAME = fieldname 
    22; 
    3    widget_control, base, /hourglass 
    4    widget_control, base, get_uvalue = top_uvalue 
    5    filelist = extractatt(top_uvalue, 'filelist') 
    6    newfile = (where(filelist EQ newfilename))[0] 
    7    if newfile EQ -1 then begin 
    8       nothing, report('invalid filename') 
    9       return 
    10    endif 
    11    listid = widget_info(base, find_by_uname = 'filelist') 
    12    widget_control, listid, set_list_select = newfile 
    13    oldfile = extractatt(top_uvalue, 'currentfile') 
    14    oldfilename = filelist[oldfile] 
    15 ; a-t-on reelement change de fichier? 
    16    if oldfile EQ newfile AND NOT (keyword_set(BOXZOOM) OR keyword_set(DATE1) OR keyword_set(DATE2) OR keyword_set(FIELDNAME)) then return 
     3  widget_control, base, /hourglass 
     4  widget_control, base, get_uvalue = top_uvalue 
     5  filelist = extractatt(top_uvalue, 'filelist') 
     6  IF size(newfilename, /type) EQ 7 THEN newfile = (where(filelist EQ newfilename))[0] $ 
     7  ELSE newfile = newfilename    ; it is already the index of the new file 
     8  if newfile EQ -1 then begin 
     9    nothing, report('invalid filename') 
     10    return 
     11  endif 
     12  oldfile = extractatt(top_uvalue, 'currentfile') 
     13  oldfilename = filelist[oldfile] 
     14 
     15; did we really change the file??? 
     16  if oldfile EQ newfile AND NOT (keyword_set(BOXZOOM) OR keyword_set(DATE1) OR keyword_set(DATE2) OR keyword_set(FIELDNAME)) then return 
     17 
    1718;-------------- 
    18    widget_control, base, update = 0 
     19  widget_control, base, update = 0 
    1920;-------------- 
    2021; 
    21 ; on update l''element currentfile de la top_uvalue 
     22; we update currentfile element of the top_uvalue 
    2223; 
    23    *top_uvalue[1, findline(top_uvalue, 'currentfile')] = newfile 
    24 ; on s''occupe du nom de la variable 
    25    oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar 
    26    newlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).listvar 
     24  *top_uvalue[1, findline(top_uvalue, 'currentfile')] = newfile 
    2725; 
    28    champid = widget_info(base, find_by_uname = 'champ')  
    29    oldindexvar = widget_info(champid,/droplist_select) 
    30    oldfieldname = oldlistvar[oldindexvar] 
    31 ; a-t-on change de liste de variables ? 
    32    if n_elements(oldlistvar) NE n_elements(newlistvar) $ 
    33     OR total(oldlistvar NE newlistvar) NE 0 THEN $ 
    34     widget_control, champid, set_value = newlistvar 
     26; Calendar 
    3527; 
    36    if keyword_set(fieldname) then newfieldname = fieldname ELSE newfieldname = oldfieldname 
    37    indexvar = where(newlistvar EQ newfieldname) & indexvar = 0 > indexvar[0] 
    38    if oldindexvar NE indexvar then widget_control, champid, set_droplist_select = indexvar 
    39    newfieldname = newlistvar[indexvar] 
    40 ; on a modifiee le nom de la variable? 
    41    if newfieldname NE oldfieldname then BEGIN 
    42       changefield, base, newfieldname, BOXZOOM = boxzoom 
    43       widget_control, champid, set_droplist_select = indexvar 
    44    ENDIF 
     28  oldcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).time_counter 
     29  newcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).time_counter 
     30; Did we change the calendar? 
     31  if array_equal(oldcalendar, newcalendar) NE 1 then begin 
     32@cm_4cal ; for key_caltype 
     33    key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).caltype 
     34; Which dates were selected?     
     35    date1id = widget_info(base, find_by_uname = 'calendar1') 
     36    if NOT keyword_set(date1) then widget_control, date1id, get_value = date1 
     37    jdate1 = date2jul(date1) 
     38    if (where(newcalendar EQ jdate1))[0] EQ -1 then jdate1 = newcalendar[0] 
     39    date2id = widget_info(base, find_by_uname = 'calendar2') 
     40    if NOT keyword_set(date2) then widget_control, date2id, get_value = date2 
     41    jdate2 = date2jul(date2) 
     42    if (where(newcalendar EQ jdate2))[0] EQ -1 then jdate2 = date1 
     43    if jdate2 LT jdate1 THEN jdate2 = jdate1 
     44    widget_control, date1id, /destroy 
     45    widget_control, date2id, /destroy 
     46    basecal = widget_info(base, find_by_uname = 'basecal') 
     47    rien = cw_calendar(basecal, newcalendar, jdate1, uname = 'calendar1' $ 
     48                       , uvalue = {name:'calendar1'}, /frame) 
     49    rien = cw_calendar(basecal, newcalendar, jdate2, uname = 'calendar2' $ 
     50                       , uvalue = {name:'calendar2'}, /frame) 
     51  ENDIF ELSE BEGIN  
     52    if keyword_set(date1) then begin 
     53      date1id = widget_info(base, find_by_uname = 'calendar1') 
     54      widget_control, date1id, set_value = date1 
     55    endif 
     56    if keyword_set(date2) then begin 
     57      date2id = widget_info(base, find_by_uname = 'calendar2') 
     58      widget_control, date2id, set_value = date2 
     59    endif 
     60  ENDELSE 
    4561; 
    46 ; on s''occupe du calendrier 
     62; Grid parameters and domain 
    4763; 
    48    oldcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).time_counter 
    49    newcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).time_counter 
    50 ; a-t-on change de calendrier ? 
    51    if n_elements(oldcalendar) NE n_elements(newcalendar) $ 
    52     OR total(oldcalendar NE newcalendar) NE 0 then begin 
    53 ; quelles etaient les dates selectionnees ?     
    54       date1id = widget_info(base, find_by_uname = 'calendar1') 
    55       if NOT keyword_set(date1) then widget_control, date1id, get_value = date1 
    56       if (where(newcalendar EQ juldate(date1)))[0] EQ -1 then date1 = newcalendar[0] 
    57       date2id = widget_info(base, find_by_uname = 'calendar2') 
    58       if NOT keyword_set(date2) then widget_control, date2id, get_value = date2 
    59       if (where(newcalendar EQ juldate(date2)))[0] EQ -1 then date2 = date1 
    60       if date2 LT date1 THEN date2 = date1 
    61       widget_control, date1id, /destroy 
    62       widget_control, date2id, /destroy 
    63       base12 = widget_info(base, find_by_uname = 'base12') 
    64       rien = cw_calendar(base12,newcalendar, juldate(date1), uname = 'calendar1' $ 
    65                          , uvalue = {name:'calendar1'}, /frame) 
    66       rien = cw_calendar(base12,newcalendar, juldate(date2), uname = 'calendar2' $ 
    67                          , uvalue = {name:'calendar2'}, /frame) 
    68    ENDIF ELSE BEGIN  
    69       if keyword_set(date1) then begin 
    70          date1id = widget_info(base, find_by_uname = 'calendar1') 
    71          widget_control, date1id, set_value = date1 
    72       endif 
    73       if keyword_set(date2) then begin 
    74          date2id = widget_info(base, find_by_uname = 'calendar2') 
    75          widget_control, date2id, set_value = date2 
    76       endif 
    77    ENDELSE 
     64  newgrid = *(extractatt(top_uvalue, 'meshparameters'))[newfile] 
     65  change = changegrid(newgrid) 
     66  if change OR keyword_set(boxzoom) then BEGIN 
     67    if NOT keyword_set(boxzoom) then boxzoom = -1 
     68    domainid = widget_info(base, find_by_uname = 'domain') 
     69    widget_control, domainid, set_value = boxzoom 
     70  endif 
    7871; 
    79 ; parametres de la grille 
     72; file name 
    8073; 
    81    newgrid = *(extractatt(top_uvalue, 'meshparameters'))[newfile] 
    82    change = changegrid(newgrid) 
    83    if change OR keyword_set(boxzoom) then BEGIN 
    84       if NOT keyword_set(boxzoom) then boxzoom = -1 
    85       domainid = widget_info(base, find_by_uname = 'domain') 
    86       widget_control, domainid, set_value = boxzoom 
    87    endif 
     74  IF oldfile NE newfile THEN BEGIN  
     75    flstid = widget_info(base, find_by_uname = 'filelist') 
     76    widget_control, flstid, set_combobox_select =  newfile 
     77  ENDIF  
     78; 
     79; Variables name 
     80; 
     81  vlstid = widget_info(base, find_by_uname = 'varlist') 
     82  oldfieldname = widget_info(vlstid, /combobox_gettext) 
     83; did we really change the liste of variables? 
     84  oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar 
     85  newlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).listvar 
     86  if array_equal(oldlistvar, newlistvar) NE 1 THEN $ 
     87     widget_control, vlstid, set_value = newlistvar 
     88; set the liste of variables to the new variable name 
     89  if keyword_set(fieldname) then newfieldname = fieldname ELSE newfieldname = oldfieldname 
     90  indexvar = where(newlistvar EQ newfieldname) & indexvar = 0 > indexvar[0] 
     91  widget_control, vlstid, set_combobox_select = indexvar 
     92  newfieldname = newlistvar[indexvar] 
     93; did we change the name of the variable? 
     94  if newfieldname NE oldfieldname then BEGIN 
     95    changefield, base, newfieldname, BOXZOOM = boxzoom 
     96  ENDIF 
     97; 
    8898;-------------- 
    89    widget_control, base, update = 1 
     99  widget_control, base, update = 1 
    90100;-------------- 
    91    return 
     101  return 
    92102end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/createhistory.pro

    r49 r69  
    66   globalcommand = extractatt(top_uvalue, 'globalcommand') 
    77   *top_uvalue[1, findline(top_uvalue, 'globaloldcommand')] = globalcommand 
     8; portrait or landscape ??? 
     9   options = extractatt(top_uvalue, 'options')    
     10   optionsflag = extractatt(top_uvalue, 'optionsflag') 
     11   portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] 
    812; composition du text contennu ds history.pro 
    913   texte = ['@common' $ 
    1014            , ' ' $ 
    11             , 'if n_elements(portrait) ne 0 then key_portrait = portrait' $ 
    12             , 'if n_elements(landscape) ne 0 then key_portrait = 1-landscape' $ 
    13             , ' ' $ 
    1415            , 'if keyword_set(postscript) then begin'  $ 
    1516            , '    noerase = 1' $ 
    16             , '    openps, infowidget = infowidget' $ 
     17            , '    openps, infowidget = infowidget, portrait = ' + strtrim(portrait, 2) $ 
    1718            , 'endif' $ 
    1819            , ' ' $ 
     
    3637   *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = texte 
    3738;------------------------------------------------------------- 
    38  for i = 0, n_elements(texte)-1 do print, texte[i] 
     39for i = 0, n_elements(texte)-1 do print, texte[i] 
    3940;------------------------------------------------------------- 
    4041   return 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/cutcmd.pro

    r68 r69  
    1 PRO cutcommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add 
     1PRO cutcmd, widcmd, toread, numberofread, prefix, nameexp, ending 
    22; 
    3 ; on separe widcommand en bloc separes par de + ou des - 
    4 ; par ex on peut avoir: 
    5 ; widcommand=2*champ1+champ2-8*champ9+678 
     3  dummy = where(byte(widcmd) EQ (byte('"'))[0], nbdblquote)  
     4  CASE 1 OF 
     5    nbdblquote MOD 2: stop ; odd numbers are impossibles... 
     6    nbdblquote GT 0: 
     7    nbdblquote EQ 0:BEGIN 
     8; widcmd is an expression of type: 
     9; numb1*a + numb2*b ... + numb 
     10; we will change into the form 
     11; numb1*"a" + numb2*"b" ... + numb 
     12; in order to suits the new method of cutcmd 
     13      widcmd = strtrim(widcmd, 2) 
     14; we force to start with a + or - 
     15      case 1 of 
     16        strpos(widcmd, '+') EQ 0: 
     17        strpos(widcmd, '-') EQ 0: 
     18        ELSE:widcmd = '+' + widcmd 
     19      ENDCASE 
     20      separator = strsplit(widcmd, '[^-/*+]', /extract, /regex) 
     21      other = strsplit(widcmd, '+-*/', /extract) 
     22      IF n_elements(separator) NE n_elements(other) THEN stop 
     23      widcmd = '' 
     24      FOR i = 0, n_elements(other)-1 DO BEGIN  
     25        IF isnumber(other[i]) LT 1 THEN other[i] = '"' + other[i] + '"' 
     26        widcmd = widcmd + separator[i] + other[i] 
     27      ENDFOR 
     28;      print, widcmd 
     29    END  
     30  ENDCASE 
     31 
     32  cutted = strsplit(widcmd, '"', /extract) 
     33  IF strpos(widcmd, '"') EQ 0 THEN start = 0 ELSE start = 1 
     34  nameexp = cutted[start:*:2] 
     35  numberofread = n_elements(nameexp)  
     36  IF toread GE numberofread then begin 
     37    dummy = report('toread cannot be larger than numberofread') 
     38    stop 
     39  ENDIF 
     40  other = cutted[1-start:*:2] 
     41; make sure that we have a prefix for each nameexp 
     42  IF start EQ 0 THEN other = ['', other] 
    643; 
    7 ; si on ne commence pas par un singne + ou - 
    8    case 1 of 
    9       strpos(widcommand, '+') EQ 0:BEGIN 
    10          widcommand = strmid(widcommand, 1) 
    11          firstsign = '+' 
    12       end 
    13       strpos(widcommand, '-') EQ 0:BEGIN 
    14          widcommand = strmid(widcommand, 1) 
    15          firstsign = '-' 
    16       END 
    17       ELSE:firstsign = '+' 
    18    endcase 
    19  
    20    sepplus = str_sep(widcommand, '+', /trim) 
    21    sepmoins = str_sep(sepplus[0], '-', /trim) 
    22    singleread = sepmoins 
    23    if n_elements(sepmoins) NE 1 then $ 
    24     separator = [replicate('-', n_elements(sepmoins)-1), '+'] ELSE $ 
    25     separator = ['+'] 
    26    if n_elements(sepplus) GT 1 then $ 
    27     for i = 1, n_elements(sepplus)-1 do begin 
    28       sepmoins = str_sep(sepplus[i], '-', /trim) 
    29       singleread = [singleread, sepmoins] 
    30       if n_elements(sepmoins) NE 1 then $ 
    31        separator = [separator, replicate('-', n_elements(sepmoins)-1), '+'] ELSE $ 
    32        separator = [separator, '+'] 
    33    ENDFOR 
    34    separator = [firstsign, separator] 
     44  nameexp = nameexp[toread] 
     45  prefix = other[toread] 
     46  IF n_elements(other) EQ numberofread + 1 THEN ending = other[numberofread] ELSE ending = '' 
    3547; 
    36    numberofread = n_elements(singleread)  
    37 ; cas simple ou il n''y a qu''un champ a lire... 
    38    if numberofread EQ 1 and isnumber(singleread[0]) GE 1 then begin 
    39       coef = '' 
    40       numberofread = 1 
    41       operation = '' 
    42       nameexp = '???' 
    43       separator = '' 
    44       add = separator[0]+singleread[0] 
    45       return 
    46    endif 
     48;help, prefix, nameexp, ending 
    4749; 
    48 ; les dernier element de singleread est-il un ordre de lecture ou une 
    49 ; constant a ajouter ??? 
    50 ; 
    51    if isnumber(singleread[numberofread-1]) GE 1 then begin 
    52       add = separator[numberofread-1]+singleread[numberofread-1] 
    53       singleread = singleread[0:numberofread-2] 
    54       numberofread = numberofread-1 
    55    ENDIF ELSE add = '' 
    56 ; 
    57    IF toread GE numberofread then begin 
    58       rien = report('toread ne peut etre + grand que numberofread') 
    59       return 
    60    ENDIF 
    61 ; 
    62 ;   for i = 0,  n_elements(singleread)-1 do print, separator[i], ' ',  singleread[i] 
    63 ; 
    64    pieceofread = singleread[toread] 
    65    separator = separator[toread] 
    66 ; 
    67    case 1 of 
    68       strpos(pieceofread, '*') NE -1:operation = '*' 
    69       strpos(pieceofread, '/') NE -1:operation = '/' 
    70       ELSE:operation = '' 
    71    ENDCASE 
    72    if operation NE '' then begin 
    73       finalread = str_sep(pieceofread, operation, /trim) 
    74       coef = finalread[0] 
    75       nameexp = finalread[1] 
    76    ENDIF ELSE BEGIN 
    77       if toread EQ 0 AND firstsign EQ '-' then begin 
    78       coef = '-1' 
    79       operation = '*' 
    80       ENDIF ELSE coef = '' 
    81       nameexp = pieceofread 
    82    ENDELSE 
    83 ; 
    84 ; 
    85    return 
     50  return 
    8651end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/doubleclickaction.pro

    r49 r69  
    11PRO doubleclickaction, event 
    22;------------------------------------------------------------ 
    3    widget_control, event.id, get_uvalue = uval 
    4    widget_control,event.top, get_uvalue = top_uvalue 
     3   widget_control, event.id , get_uvalue = uval 
     4   widget_control, event.top, get_uvalue = top_uvalue 
    55; on active la bonne fenetre  
    6    widget_control,event.id,get_value=win 
     6   widget_control, event.id, get_value = win 
    77   wset, win 
    88; quel est le dessin selectionne?? 
     
    4646 
    4747         numdessin = numdessin-1 
    48          (*top_uvalue[1, findline(top_uvalue, 'champs')])[*, numdessin] = ['', ''] 
     48         (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessin] = ['', ''] 
    4949         (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessin] = [0l, 0l] 
    5050         (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessin] = '' 
    5151         (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessin] = '' 
    5252         (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessin] = fltarr(6) 
    53          (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessin] = '' 
     53         (*top_uvalue[1, findline(top_uvalue, 'txtcmd')])[numdessin] = '' 
    5454 
    5555         if numdessin EQ smallin[2] then $ 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/inserthistory.pro

    r49 r69  
    1919    globalcommand = [globalcommand[0:index1], text, globalcommand[index2:n_elements(globalcommand)-1]] 
    2020; the new globalcommand 
    21    *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = globalcommand 
     21    *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = globalcommand 
    2222 
    2323;------------------------------------------------------------- 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/letsdraw.pro

    r49 r69  
    3535;------------------------------------------------------------ 
    3636 
    37 PRO letsdraw, base, COMMANDE = commande, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt, _extra = ex 
     37PRO letsdraw, base, COMMANDE = commande, _extra = ex 
    3838@common 
    3939; on recupere la uvalue de base 
     
    4343; help,  top_uvalue.exextra, /struct 
    4444   if NOT keyword_set(commande) then $ 
    45     commande = buildcommand(base, FORPLTH=forplt, FORPLTZ=forpltz, FORPLTT=forpltt, _extra=ex) 
     45    commande = buildcmd(base, _extra=ex) 
    4646   if commande[0] EQ '' then return 
    4747; on recupere la uvalue de base 
     
    8888   createpro, ['@common' $ 
    8989               , 'noerase = 1' $ 
    90                , 'portrait = '+portrait $ 
     90               , 'key_portrait = '+ portrait $ 
    9191               , Commande] $ 
    9292    , filename =  myuniquetmpdir + 'xxx_oneplot.pro' 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/longclickaction.pro

    r49 r69  
    11PRO longclickaction, event 
    2    widget_control, event.id, get_uvalue=uval 
    3    widget_control,event.top, get_uvalue = top_uvalue 
     2  widget_control, event.id, get_uvalue = uval 
     3  widget_control, event.top, get_uvalue = top_uvalue 
    44; quel est le dessin selectionne?? 
    5    smallout = extractatt(top_uvalue, 'smallout') 
    6    smallin = extractatt(top_uvalue, 'smallin') 
    7    small = smallin 
    8    x = (convert_coord(uval.x[0],uval.y[0], /device, /to_normal))[0] 
    9    y = (convert_coord(uval.x[0],uval.y[0], /device, /to_normal))[1] 
    10    numcolonne = n_elements(where(findgen(small[0])/small[0] lt x))-1 
    11    numligne = n_elements(where(findgen(small[1])/small[1] lt 1-y))-1 
    12    numdessin = numcolonne+numligne*small[0] 
    13 ; on met ce cadrant en leader 
    14    tracecadre, smallin, /erase 
    15    if total(smallin EQ smallout) EQ 3 then $ 
    16     tracecadre, smallout, /out 
    17    smallin = [smallin[0:1], numdessin+1] 
    18    *top_uvalue[1, findline(top_uvalue, 'smallin')] = smallin 
    19    tracecadre, smallin 
    20    !p = (extractatt(top_uvalue, 'penvs'))[numdessin] 
    21    !x = (extractatt(top_uvalue, 'xenvs'))[numdessin] 
    22    !y = (extractatt(top_uvalue, 'yenvs'))[numdessin] 
     5  smallout = extractatt(top_uvalue, 'smallout') 
     6  smallin = extractatt(top_uvalue, 'smallin') 
     7  small = smallin 
     8  x = (convert_coord(uval.x[0], uval.y[0], /device, /to_normal))[0] 
     9  y = (convert_coord(uval.x[0], uval.y[0], /device, /to_normal))[1] 
     10  numcolonne = n_elements(where(findgen(small[0])/small[0] lt x))-1 
     11  numligne = n_elements(where(findgen(small[1])/small[1] lt 1-y))-1 
     12  numdessin = numcolonne+numligne*small[0] 
     13; we put on numdessin as the leader plot 
     14  tracecadre, smallin, /erase 
     15  if total(smallin EQ smallout) EQ 3 then $ 
     16     tracecadre, smallout, /out 
     17  smallin = [smallin[0:1], numdessin+1] 
     18  *top_uvalue[1, findline(top_uvalue, 'smallin')] = smallin 
     19  tracecadre, smallin 
     20  !p = (extractatt(top_uvalue, 'penvs'))[numdessin] 
     21  !x = (extractatt(top_uvalue, 'xenvs'))[numdessin] 
     22  !y = (extractatt(top_uvalue, 'yenvs'))[numdessin] 
     23;------------------------------------------------------------ 
     24; Change the domain box: 
     25;------------------------------------------------------------ 
     26  coor = (convert_coord(uval.x, uval.y, /device, /to_data)) 
     27  x = [coor[0, 0], coor[0, 1]] 
     28  y = [coor[1, 0], coor[1, 1]] 
     29  domainid = widget_info(event.top, find_by_uname = 'domain') 
     30  boxzoom = [x, y] 
     31; faut-il passer la boxzoom en indexes ??? 
     32  currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 
     33  options = extractatt(top_uvalue, 'options')    
     34  flags = extractatt(top_uvalue, 'optionsflag') 
     35  flags = flags[*, currentplot] 
     36  changex = (flags[where(options EQ 'Longitude / x index')])[0] EQ 1 
     37  changey = (flags[where(options EQ 'Latitude / y index')])[0] EQ 1 
     38  if changex OR changey then begin 
     39; on veut retrouver le type de grille qui est utilisee 
     40    currentfile = extractatt(top_uvalue, 'currentfile') 
     41    listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
     42    listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
     43    vlstid = widget_info(event.top, find_by_uname = 'varlist') 
     44    namevar = widget_info(vlstid, /combobox_gettext) 
     45    indexvar = where(listvar EQ namevar) 
     46    vargrid = strupcase(listgrid[indexvar]) 
     47    domdef, boxzoom, gridtype = vargrid 
     48    grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 
     49    if changex then boxzoom[0:1] = [firstx, lastx] 
     50    if changey then boxzoom[2:3] = [firsty, lasty] 
     51  endif 
     52; 
     53  widget_control, domainid, set_value = boxzoom 
    2354; 
    2455;------------------------------------------------------------ 
    25 ; changement de domaine: 
     56  actionid = widget_info(event.top, find_by_uname = 'action') 
     57  type = widget_info(actionid, /combobox_gettext) 
     58  case uval.press of 
     59    1:BEGIN 
     60      nodates = (type EQ 'xt' OR type EQ 'yt' OR type EQ 'zt' OR type EQ 't') 
     61      updatewidget, event.top, /noboxzoom, nodates = nodates, notype = type NE 'plt' 
     62      letsdraw, event.top 
     63    END 
     64    2:BEGIN  
     65      IF type EQ 'plt' THEN BEGIN  
     66        (*top_uvalue[1, findline(top_uvalue, 'types')])[smallout[2]-1] = 'pltz' 
     67        forcetype = 'pltz' 
     68      ENDIF  
     69      updatewidget, event.top, /noboxzoom 
     70      letsdraw, event.top 
     71    END 
     72    4:BEGIN 
     73      IF type EQ 'plt' THEN BEGIN  
     74        (*top_uvalue[1, findline(top_uvalue, 'types')])[smallout[2]-1] = 'pltt' 
     75        forcetype = 'pltt' 
     76      ENDIF  
     77      updatewidget, event.top, /noboxzoom, /nodates 
     78      letsdraw, event.top, forcetype = forcetype 
     79    END 
     80  endcase 
    2681;------------------------------------------------------------ 
    27    coor = (convert_coord(uval.x,uval.y, /device, /to_data)) 
    28    x = [coor[0, 0],coor[0, 1]] 
    29    y = [coor[1, 0],coor[1, 1]] 
    30    domainid = widget_info(event.top,find_by_uname = 'domain') 
    31    boxzoom = [x, y] 
    32 ; faut-il passer la boxzoom en indexes ??? 
    33    currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 
    34    options = extractatt(top_uvalue, 'options')    
    35    flags = extractatt(top_uvalue, 'optionsflag') 
    36    flags = flags[*, currentplot] 
    37    changex = (flags[where(options EQ 'Longitude / x index')])[0] EQ 1 
    38    changey = (flags[where(options EQ 'Latitude / y index')])[0] EQ 1 
    39    if changex OR changey then begin 
    40 ; on veut retrouver le type de grille qui est utilisee 
    41       currentfile = extractatt(top_uvalue, 'currentfile') 
    42       listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
    43       indexvar = widget_info(widget_info(event.top, find_by_uname = 'champ'), /droplist_select) 
    44       vargrid = strupcase(listgrid[indexvar]) 
    45       domdef, boxzoom, gridtype = vargrid 
    46       grille, -1, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 
    47       if changex then boxzoom[0:1] = [firstx, lastx] 
    48       if changey then boxzoom[2:3] = [firsty, lasty] 
    49    endif 
    50 ; 
    51    widget_control, domainid, set_value = boxzoom 
    52 ; 
    53 ;------------------------------------------------------------ 
    54    graphtypeid = widget_info(event.top, find_by_uname = 'action') 
    55    widget_control,graphtypeid, get_uvalue = graphtype_uvalue 
    56    type = graphtype_uvalue.choix[widget_info(graphtypeid, /droplist_select)] 
    57    case uval.press of 
    58       1:BEGIN 
    59          nodates = (type EQ 'xt' OR type EQ 'yt' OR type EQ 'zt' OR type EQ 't') 
    60          updatewidget, event.top, /noboxzoom, nodates = nodates, notype = type NE 'plt' 
    61          forplth = type EQ 'plt' 
    62          letsdraw, event.top, forplth = forplth 
    63       END 
    64       2:BEGIN  
    65          updatewidget, event.top, /noboxzoom 
    66          forpltz = type EQ 'plt' 
    67          letsdraw, event.top, forpltz = forpltz 
    68       END 
    69       4:BEGIN 
    70          updatewidget, event.top, /noboxzoom, /nodates 
    71          forpltt = type EQ 'plt' 
    72          letsdraw, event.top, forpltt = forpltt 
    73       END 
    74    endcase 
    75 ;------------------------------------------------------------ 
    76    return 
     82  return 
    7783end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/read_vermair.pro

    r49 r69  
    1 FUNCTION read_vermair, name,debut,fin, nomexp, PARENT = parent, BOXZOOM=boxzoom, _EXTRA = ex 
     1FUNCTION read_vermair, name, debut, fin, nomexp, PARENT = parent, BOXZOOM=boxzoom, _EXTRA = ex 
    22@common 
    33;------------------------------------------------------------  
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/scanfile.pro

    r49 r69  
    99;       3) ce fichier contient une dimension infinie qui doit etre 
    1010;       celle qui se rapporte au temps et au mois 2 autres dimensions 
    11 ;       dont les noms sont 'x','lon','longitude' et 'y','lat' ou 
    12 ;       'latitude' ou bien en majuscule. 
     11;       dont les noms sont 'x','lon...','xi_...' et 'y','lat...' ou 
     12;       'eta_...' ou bien en majuscule. 
    1313;       4) il doit exiter ds ce fichier une unique variable n''ayant 
    1414;       qu''une dimension et etant la dimension temporelle. cette 
     
    2626; je crois que c''est tout! 
    2727; 
    28 ; 
    29 ;------------------------------------------------------------ 
    30 FUNCTION scanfile, nomficher, _extra = ex 
     28;        GRID='[UTVWF]' to specify the type of grid. Defaut is (1) 
     29;        based on the name of the file if the file ends by 
     30;        GRID[._][TUVFW].NC (not case sensible) or (2) T if case (1) 
     31;        is not found. 
     32; 
     33;------------------------------------------------------------ 
     34FUNCTION scanfile, namefile, GRID = GRID, _extra = ex 
    3135@common 
    3236;------------------------------------------------------------ 
    33 ; bidouille pour utiliser les mots cles (on passe par des variables 
    34 ; declarees ds un common) 
    35 ;------------------------------------------------------------ 
    3637  res = -1 
    3738;------------------------------------------------------------ 
    38 ; choix du nom du fichier 
    39 ;------------------------------------------------------------ 
    40   nom = isafile(filename = nomficher, IODIRECTORY = iodir, _extra = ex) 
    41 ;------------------------------------------------------------ 
    42 ; ouverture du fichier nom 
    43 ;------------------------------------------------------------ 
    44   cdfid = ncdf_open(nom) 
    45 ;------------------------------------------------------------ 
    46 ; que contient le fichier?? 
    47 ;------------------------------------------------------------ 
    48   contient = ncdf_inquire(cdfid); 
     39; filename 
     40;------------------------------------------------------------ 
     41  fullname = isafile(filename = namefile, IODIRECTORY = iodir, _extra = ex) 
     42;------------------------------------------------------------ 
     43; open file 
     44;------------------------------------------------------------ 
     45  cdfid = ncdf_open(fullname) 
     46;------------------------------------------------------------ 
     47; What contains the file? 
     48;------------------------------------------------------------ 
     49  infile = ncdf_inquire(cdfid)  ; 
    4950; find vargrid ... 
    50   vargrid = 'T'                 ; default definition 
    51   pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
    52   gdtype = ['T', 'U', 'V', 'W', 'F'] 
    53   fnametest = strupcase(nom) 
    54   FOR i = 0, n_elements(pattern)-1 DO BEGIN 
    55     FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
    56       substr = pattern[i]+gdtype[j] 
    57       pos = strpos(fnametest, substr) 
    58       IF pos NE -1 THEN $ 
    59         vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
    60     ENDFOR 
     51  IF keyword_set(grid) THEN vargrid = strupcase(grid) ELSE BEGIN 
     52    vargrid = 'T'               ; default definition 
     53    IF finite(glamu[0]) EQ 1 THEN BEGIN 
     54      pattern = ['GRID.', 'GRID_', 'GRID', 'UPID_', '30ID_'] 
     55      gdtype = ['T', 'U', 'V', 'W', 'F'] 
     56      fnametest = strupcase(fullname) 
     57      FOR i = 0, n_elements(pattern)-1 DO BEGIN 
     58        FOR j = 0, n_elements(gdtype)-1 DO BEGIN 
     59          substr = pattern[i]+gdtype[j] 
     60          pos = strpos(fnametest, substr) 
     61          IF pos NE -1 THEN $ 
     62             vargrid = strmid(fnametest, pos+strlen(substr)-1, 1) 
     63        ENDFOR 
     64      ENDFOR 
     65    ENDIF 
     66  ENDELSE 
     67;------------------------------------------------------------ 
     68; name of all dimensions 
     69;------------------------------------------------------------ 
     70  namedim = strarr(infile.ndims) 
     71  for dimiq = 0, infile.ndims-1 do begin 
     72    ncdf_diminq, cdfid, dimiq, tmpname, value  
     73    namedim[dimiq] = strlowcase(tmpname) 
    6174  ENDFOR 
    62 ;------------------------------------------------------------ 
    63 ; nom des differentes variables 
    64 ;------------------------------------------------------------ 
    65 ; on ne garde les noms de variable uniquement si cette variable 
    66 ; contient au moins les dimensions qui doivent etre appelles x et y 
    67 ; et la dimension infinie 
    68   nomdim   = strarr(contient.ndims) 
    69   for dimiq = 0, contient.ndims-1 do begin 
    70     ncdf_diminq, cdfid, dimiq, name, value ; nom et valeur de la dimension 
    71     nomdim[dimiq] = strlowcase(name) 
    72   ENDFOR 
    73   indexdimx = where(nomdim EQ 'x' OR nomdim EQ 'lon' OR nomdim EQ 'longitude' OR nomdim EQ 'xt_i7_156' OR nomdim EQ 'xi_rho' OR nomdim EQ 'xi_u' OR nomdim EQ 'xi_v' OR nomdim EQ 'xi_psi') 
    74   indexdimx = indexdimx[0] 
    75   if indexdimx EQ -1 then begin 
    76     print, 'one of the dimensions must have the name: ''x'' or ''lon'' or ''longitude'' or ''xt_i7_156''' 
     75; we are looking for a x dimension... 
     76  dimidx = where(namedim EQ 'x' OR strmid(namedim, 0, 3) EQ 'lon' OR strmid(namedim, 0, 3) EQ 'xi_' OR namedim EQ 'xt_i7_156') 
     77  dimidx = dimidx[0] 
     78  if dimidx EQ -1 then begin 
     79    print, 'one of the dimensions must have the name: ''x'' or ''lon...'' or ''xi_...'' or ''xt_i7_156''' 
    7780    stop 
    7881  endif 
    79   indexdimy = where(nomdim EQ 'y' OR nomdim EQ 'lat' OR nomdim EQ 'latitude' OR nomdim EQ 'yt_j6_75' OR nomdim EQ 'eta_rho' OR nomdim EQ 'eta_u' OR nomdim EQ 'eta_v' OR nomdim EQ 'eta_psi') 
    80   indexdimy = indexdimy[0] 
    81   if indexdimy EQ -1 then begin 
    82     print, 'one of the dimensions must have the name: ''y'' or ''lat'' or ''latitude'' or ''yt_j6_75''' 
     82; we are looking for a y dimension... 
     83  dimidy = where(namedim EQ 'y' OR strmid(namedim, 0, 3) EQ 'lat' OR strmid(namedim, 4) EQ 'eta_' OR namedim EQ 'yt_j6_75') 
     84  dimidy = dimidy[0] 
     85  if dimidy EQ -1 then begin 
     86    print, 'one of the dimensions must have the name: ''y'' or ''lat...'' or ''eta_...'' or ''yt_j6_75''' 
    8387    stop 
    8488  endif 
    85 ; 
    86   namevar = strarr(contient.nvars) 
    87   for varid = 0, contient.nvars-1 do begin 
    88     varcontient = ncdf_varinq(cdfid, varid) ; que contient la variable 
    89     if (where(varcontient.dim EQ indexdimx))[0] NE -1 AND $ 
    90       (where(varcontient.dim EQ indexdimy))[0] NE -1 AND $ 
    91       (where(varcontient.dim EQ contient.recdim))[0] NE -1 THEN namevar[varid] = varcontient.name  
     89;------------------------------------------------------------ 
     90; name of all variables 
     91;------------------------------------------------------------ 
     92; we keep only the variables containing at least x, y and time dimension (if existing...) 
     93  namevar = strarr(infile.nvars) 
     94  for varid = 0, infile.nvars-1 do begin 
     95    invar = ncdf_varinq(cdfid, varid) ; what contains the variable? 
     96    if (where(invar.dim EQ dimidx))[0] NE -1 AND $ 
     97       (where(invar.dim EQ dimidy))[0] NE -1 AND $ 
     98       ((where(invar.dim EQ infile.recdim))[0] NE -1 OR infile.recdim EQ -1) $ 
     99    THEN namevar[varid] = invar.name  
    92100  ENDFOR 
    93101  namevar = namevar[where(namevar NE '')] 
    94   listgrid = replicate(vargrid,  n_elements(namevar)) 
    95 ;------------------------------------------------------------ 
    96 ; on recupere l''axe des temps 
    97 ;------------------------------------------------------------ 
    98 ; on recupere le nom de la variable contenant l''axe des temps 
    99   varid = 0 
    100   repeat BEGIN ; tant que l''on a pas trouve une variable qui n''a qu'' 
    101                                 ; une dimension: la dimension infinie 
    102     varcontient = ncdf_varinq(cdfid, varid) ; que contient la variable 
    103     varid = varid+1 
    104   endrep until n_elements(varcontient.dim) EQ 1 AND varcontient.dim[0] EQ contient.recdim ; 
    105   varid = varid-1 
    106 ; 
    107 ; we want to know which attrributes are attached to the time variable... 
    108 ; 
    109   if varcontient.natts EQ 0 then BEGIN 
    110     ncdf_close, cdfid 
    111     return, report('the variable '+varcontient.name+' has no attribut.!C we need attribut ''units'' for the calendar ...') 
    112   endif 
    113   attnames = strarr(varcontient.natts) 
    114   for attiq = 0, varcontient.natts-1 do attnames[attiq] = ncdf_attname(cdfid, varid, attiq) 
    115   if (where(attnames EQ 'units'))[0] EQ -1 then BEGIN 
    116     ncdf_close, cdfid 
    117     return, report('Attribut ''units'' not found for the variable '+varid.name+'we need it for the calendar...') 
    118   endif 
     102  listgrid = replicate(vargrid, n_elements(namevar)) 
     103;------------------------------------------------------------ 
     104; time axis 
     105;------------------------------------------------------------ 
     106  date0fk = date2jul(19000101) 
     107  IF infile.recdim EQ -1 THEN BEGIN  
     108    jpt = 1 
     109    time = date0fk 
     110    fakecal = 1 
     111  ENDIF ELSE BEGIN 
     112    ncdf_diminq, cdfid, infile.recdim, timedimname, jpt 
     113; we look for the variable containing the time axis 
     114; we look for the first variable having for only dimension infile.recdim 
     115    varid = 0 
     116    repeat BEGIN 
     117      invar = ncdf_varinq(cdfid, varid)  
     118      varid = varid+1 
     119    endrep until n_elements(invar.dim) EQ 1 AND invar.dim[0] EQ infile.recdim 
     120    varid = varid-1 
     121; 
     122    CASE 1 OF 
     123      varid EQ -1:BEGIN  
     124        dummy = report('the file '+fullname+' has no time axis.!C we create a fake calendar ...') 
     125        fakecal = 1 
     126        time = date0fk + lindgen(jpt) 
     127      END 
     128      invar.natts EQ 0:BEGIN  
     129        dummy = report('the variable '+invar.name+' has no attribut.!C we create a fake calendar ...') 
     130        fakecal = 1 
     131        time = date0fk + lindgen(jpt) 
     132      END 
     133      ELSE:BEGIN 
     134; 
     135; we want to know which attributes are attached to the time variable... 
     136; 
     137        attnames = strarr(invar.natts) 
     138        for attiq = 0, invar.natts-1 do attnames[attiq] = ncdf_attname(cdfid, varid, attiq) 
     139        if (where(attnames EQ 'units'))[0] EQ -1 then BEGIN 
     140          dummy = report('Attribut ''units'' not found for the variable '+varid.name+'!C we create a fake calendar ...') 
     141          fakecal = 1 
     142          time = date0fk + lindgen(jpt) 
     143        ENDIF ELSE BEGIN  
    119144; on lit l''axe des temps 
    120   ncdf_varget, cdfid, varid, time 
    121   time = double(time) 
    122   ncdf_attget, cdfid, varid, 'units', value 
     145          ncdf_varget, cdfid, varid, time 
     146          time = double(time) 
     147          ncdf_attget, cdfid, varid, 'units', value 
    123148; time_counter:units = "seconds since 0001-01-01 00:00:00" ; 
    124149; time_counter:units = "hours since 0001-01-01 00:00:00" ; 
     
    126151; time_counter:units = "months since 1979-01-01 00:00:00" ; 
    127152; time_counter:units = "years since 1979-01-01 00:00:00" ; 
    128   value = strtrim(strcompress(string(value)), 2) 
    129   mots = str_sep(value, ' ') 
    130   unite = mots[0] 
    131   debut = str_sep(mots[2], '-') 
     153          value = strtrim(strcompress(string(value)), 2) 
     154          mots = str_sep(value, ' ') 
     155          unite = mots[0] 
     156          debut = str_sep(mots[2], '-') 
    132157; 
    133158; now we try to find the attribut called calendar... 
     
    135160; If no, we suppose that the calendar is gregorian calendar 
    136161; 
    137   if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
    138       ncdf_attget, cdfid, varid, 'calendar', value 
    139       value = string(value) 
    140         CASE value OF 
    141           '360d':key_caltype = '360d' 
    142           'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
    143           ELSE:BEGIN 
     162          if (where(attnames EQ 'calendar'))[0] NE -1 then BEGIN 
     163            ncdf_attget, cdfid, varid, 'calendar', value 
     164            value = string(value) 
     165            CASE value OF 
     166              'noleap':key_caltype = 'noleap' 
     167              '360d':key_caltype = '360d' 
     168              'greg':IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     169              ELSE:BEGIN 
    144170;            notused = report('Unknown calendar: '+value+', we use greg calendar.')  
    145             key_caltype = 'greg' 
    146           END 
    147         ENDCASE 
    148       ENDIF ELSE BEGIN 
     171                key_caltype = 'greg' 
     172              END 
     173            ENDCASE 
     174          ENDIF ELSE BEGIN 
    149175;        notused = report('Unknown calendar, we use '+key_caltype+' calendar.')  
    150         IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
    151       ENDELSE 
     176            IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 
     177          ENDELSE 
    152178; 
    153179; ATTENTION il faut recuperer l''attribut calendar et ajuster time en 
     
    156182; 
    157183; on passe time en jour julien d''idl  
    158 ; on suppose qu''on utilise le vrai calendrier. 
    159 ; 
    160   unite = strlowcase(unite) 
    161   IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
    162   IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
    163   case unite of 
    164     'second':time = julday(debut[1], debut[2], debut[0])+time/(long(24)*3600) 
    165     'hour':time = julday(debut[1], debut[2], debut[0])+time/(long(24)) 
    166     'day':time = julday(debut[1], debut[2], debut[0])+time 
    167     'month':BEGIN  
    168       if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
    169         time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
    170       ELSE for t = 0, n_elements(time)-1 DO $ 
    171         time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
    172     END 
    173     'year':BEGIN 
    174       if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
    175         time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
    176       ELSE for t = 0, n_elements(time)-1 do $ 
    177         time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
    178     END 
    179   ENDCASE 
    180   time = long(time) 
    181 ;------------------------------------------------------------ 
    182   return, {filename:nom, time_counter:time, listvar:namevar, listgrid:strupcase(listgrid), calendartype:key_caltype} 
     184; 
     185          unite = strlowcase(unite) 
     186          IF strpos(unite, 's', strlen(unite)-1) NE -1 THEN unite = strmid(unite, 0, strlen(unite)-1) 
     187          IF strpos(unite, 'julian_') NE -1 THEN unite = strmid(unite, 7) 
     188          case unite of 
     189            'second':time = julday(debut[1], debut[2], debut[0])+time/86400.d 
     190            'hour':time = julday(debut[1], debut[2], debut[0])+time/24.d 
     191            'day':time = julday(debut[1], debut[2], debut[0])+time 
     192            'month':BEGIN  
     193              if total(fix(time) NE time) NE 0 then $ ; we switch to days with 30d/m 
     194                 time = julday(debut[1], debut[2], debut[0])+round(time*30) $ 
     195              ELSE for t = 0, n_elements(time)-1 DO $ 
     196                 time[t] = julday(debut[1]+time[t], debut[2], debut[0]) 
     197            END 
     198            'year':BEGIN 
     199              if total(fix(time) NE time) NE 0 then $ ; we switch to days with 365d/y 
     200                 time = julday(debut[1], debut[2], debut[0])+round(time*365) $ 
     201              ELSE for t = 0, n_elements(time)-1 do $ 
     202                 time[t] = julday(debut[1], debut[2], debut[0]+time[t]) 
     203            END 
     204          ENDCASE 
     205; 
     206; high frequency calendar: more than one element per day 
     207          IF max(histogram([long(time)])) GT 1 THEN fakecal = 1 ELSE fakecal = 0 
     208          date0fk = date2jul(19000101) 
     209          IF keyword_set(fakecal) THEN time = date0fk+lindgen(jpt) $ 
     210          ELSE time = long(time) 
     211; 
     212        ENDELSE 
     213      END 
     214    ENDCASE 
     215  ENDELSE 
     216;------------------------------------------------------------ 
     217  ncdf_close, cdfid 
     218;------------------------------------------------------------ 
     219  return, {filename:fullname, time_counter:time, listvar:namevar $ 
     220           , listgrid:strupcase(listgrid), caltype:key_caltype $ 
     221           , fakecal:date0fk*fakecal} 
    183222end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/selectfile.pro

    r49 r69  
    44@common 
    55; 
    6    widget_control, event.id,  get_uvalue = eventuvalue 
    7    IF chkstru(eventuvalue,'name') EQ 0 THEN return 
    8    case eventuvalue.name of 
    9       'Global Cancel':BEGIN  
    10          widget_control, event.handler, get_uvalue = messenger 
    11          *messenger = -1 
    12          widget_control,event.handler,/destroy 
    13       END 
    14       'datafilename':BEGIN 
    15          widget_control, event.id, get_value = filename 
    16          filename = isafile(filename = filename[0]) 
    17          if size(filename, /type) NE 7 then return 
    18          widget_control, event.id, set_value = filename 
    19       END 
    20       'browse datafilename':BEGIN 
    21          filename = isafile(iodir = iodir) 
    22          if size(filename, /type) NE 7 then return 
    23          widget_control, widget_info(event.handler, find_by_uname = 'datafilename') $ 
    24           , set_value = filename 
    25       END 
    26       'meshfilename':BEGIN 
    27          widget_control, event.id, get_value = filename 
    28          filename = isafile(filename = filename[0]) 
    29          if size(filename, /type) NE 7 then return 
    30          widget_control, event.id, set_value = filename 
    31       END 
    32       'browse meshfilename':BEGIN 
    33          filename = isafile(iodir = homedir) 
    34          if size(filename, /type) NE 7 then return 
    35          widget_control, widget_info(event.handler, find_by_uname = 'meshfilename') $ 
    36           , set_value = filename 
    37       END 
    38       'Lets Go!':BEGIN 
    39          widget_control, widget_info(event.handler, find_by_uname = 'datafilename') $ 
    40           , get_value = datafilename & datafilename = datafilename[0] 
    41          widget_control, widget_info(event.handler, find_by_uname = 'meshfilename') $ 
    42           , get_value = meshfilename & meshfilename = meshfilename[0] 
    43          widget_control, event.handler, get_uvalue = messenger 
    44          *messenger = create_struct('datafilename', datafilename, 'meshfilename', meshfilename) 
    45          widget_control,event.handler,/destroy 
    46       END 
    47  
    48    endcase 
    49    return 
     6  widget_control, event.id, get_uvalue = eventuvalue 
     7; default definition of messenger when selectfile_event is called 
     8; directly without calling xmanager 
     9  widget_control, event.handler, get_uvalue = messenger 
     10  *messenger = -1 
     11 
     12  IF chkstru(eventuvalue, 'name') EQ 0 THEN return 
     13 
     14  case eventuvalue.name of 
     15; cancel button 
     16    'Global Cancel':BEGIN  
     17      widget_control, event.handler, get_uvalue = messenger 
     18      *messenger = -1 
     19      widget_control, event.handler, /destroy 
     20    END 
     21; data file informations 
     22    'datafilename':BEGIN 
     23      widget_control, event.id, get_value = filename 
     24      filename = isafile(filename = filename[0], iodir = iodir, /onlync, title = 'data file name') 
     25      if size(filename, /type) NE 7 then BEGIN  
     26        widget_control, event.id, set_value = '' 
     27        return 
     28      ENDIF 
     29      widget_control, event.id, set_value = filename 
     30    END 
     31    'browse datafilename':BEGIN 
     32      filename = isafile(iodir = iodir, /onlync, title = 'data file name') 
     33      if size(filename, /type) NE 7 then return 
     34      widget_control, widget_info(event.handler, find_by_uname = 'datafilename') $ 
     35                      , set_value = filename 
     36    END 
     37; switch automatic/by and mesh definition buttons 
     38    'gridload':BEGIN 
     39      IF event.select EQ 1 THEN BEGIN  
     40        widget_control, widget_info(event.handler, find_by_uname = 'argtxt'), set_value = '' 
     41        widget_control, widget_info(event.handler, find_by_uname = 'kwdtxt'), set_value = '' 
     42        widget_control, widget_info(event.handler, find_by_uname = 'kwd base'), sensitive = 1 
     43        CASE event.value OF 
     44          'via initnetcdf':BEGIN 
     45            widget_control, widget_info(event.handler, find_by_uname = 'meshload'), set_value = 'initncdf', editable = 0 
     46            widget_control, widget_info(event.handler, find_by_uname = 'arg base'), sensitive = 0 
     47            widget_control, widget_info(event.handler, find_by_uname = 'kwdlab'), set_value = 'initncdf keywords:' 
     48          END 
     49          'via perso':BEGIN 
     50            widget_control, widget_info(event.handler, find_by_uname = 'meshload'), set_value = '', editable = 1 
     51            widget_control, widget_info(event.handler, find_by_uname = 'arg base'), sensitive = 1 
     52            widget_control, widget_info(event.handler, find_by_uname = 'kwdlab'), set_value = 'keywords of IDL procedure:' 
     53          END  
     54        ENDCASE 
     55      ENDIF  
     56    END 
     57; name of the procedure or batch file 
     58    'meshload':BEGIN 
     59      widget_control, event.id, get_value = filename 
     60      filename = (find(filename[0], /onlypro, /firstfound))[0] 
     61      if filename EQ 'NOT FOUND' then begin 
     62        widget_control, event.id, set_value = '' 
     63        return 
     64      endif  
     65      CASE protype(filename) OF 
     66; this is a procedure 
     67        'proc':BEGIN  
     68          widget_control, widget_info(event.handler, find_by_uname = 'arg base'), sensitive = 1 
     69          widget_control, widget_info(event.handler, find_by_uname = 'kwd base'), sensitive = 1 
     70          widget_control, widget_info(event.handler, find_by_uname = 'kwdlab'), set_value = file_basename(filename, '.pro')+' keywords:' 
     71        END 
     72; this is a function, this case is not accepted 
     73        'func':BEGIN  
     74          widget_control, event.id, set_value = '' 
     75          return 
     76        END 
     77; this is an IDL batch file 
     78        'batch':BEGIN  
     79          widget_control, widget_info(event.handler, find_by_uname = 'arg base'), sensitive = 0 
     80          widget_control, widget_info(event.handler, find_by_uname = 'kwd base'), sensitive = 0 
     81          widget_control, widget_info(event.handler, find_by_uname = 'kwdlab'), set_value = 'no keywords:' 
     82        END 
     83      ENDCASE 
     84      widget_control, widget_info(event.handler, find_by_uname = 'argtxt'), set_value = '' 
     85      widget_control, widget_info(event.handler, find_by_uname = 'kwdtxt'), set_value = '' 
     86      widget_control, event.id, set_value = file_basename(filename, '.pro') 
     87    END 
     88    'browse meshload':BEGIN 
     89      filename = isafile(iodir = homedir, /onlypro, title = 'to load the grid file') 
     90      if size(filename, /type) NE 7 then return 
     91      meshload_id = widget_info(event.handler, find_by_uname = 'meshload') 
     92      widget_control, meshload_id, set_value = filename 
     93      selectfile_event, {ID:meshload_id, TOP:event.top, HANDLER:event.handler} 
     94    END 
     95; 'Lets Go!' button 
     96    'Lets Go!':BEGIN 
     97      widget_control, widget_info(event.handler, find_by_uname = 'datafilename') $ 
     98                      , get_value = datafilename 
     99      datafilename = datafilename[0] 
     100      IF datafilename EQ '' THEN return 
     101      datafilename = isafile(filename = datafilename, iodir = iodir, /onlync, title = 'data file name') 
     102      if size(datafilename, /type) NE 7 then BEGIN  
     103        widget_control, widget_info(event.handler, find_by_uname = 'datafilename') $ 
     104                        , set_value = '' 
     105        return 
     106      ENDIF  
     107      widget_control, widget_info(event.handler, find_by_uname = 'gridload') $ 
     108                      , get_value = gridload 
     109      widget_control, widget_info(event.handler, find_by_uname = 'argtxt') $ 
     110                      , get_value = argtxt 
     111      argtxt = strtrim(argtxt[0], 2) 
     112      IF strpos(argtxt, ',') EQ 0 THEN argtxt = strmid(argtxt, 1) 
     113      widget_control, widget_info(event.handler, find_by_uname = 'kwdtxt') $ 
     114                      , get_value = kwdtxt 
     115      kwdtxt = strtrim(kwdtxt[0], 2) 
     116      IF strpos(kwdtxt, ',') EQ 0 THEN kwdtxt = strmid(kwdtxt, 1) 
     117 
     118      CASE gridload[0] OF 
     119        'via perso':BEGIN 
     120          meshload_id = widget_info(event.handler, find_by_uname = 'meshload') 
     121          widget_control, meshload_id, get_value = meshload 
     122          meshload = meshload[0] 
     123          IF meshload EQ '' THEN return 
     124          meshload = (find(meshload[0], /onlypro, /firstfound))[0] 
     125          if meshload EQ 'NOT FOUND' then begin 
     126            widget_control, meshload_id, set_value = '' 
     127            return 
     128          endif  
     129        END  
     130        'via initnetcdf':meshload = datafilename 
     131      ENDCASE 
     132      IF strlen(argtxt) NE 0 THEN meshload = meshload + ', ' + argtxt 
     133      IF strlen(kwdtxt) NE 0 THEN meshload = meshload + ', ' + kwdtxt 
     134      widget_control, event.handler, get_uvalue = messenger 
     135      *messenger = create_struct('datafilename', datafilename, 'meshload', meshload) 
     136      widget_control, event.handler, /destroy 
     137    END 
     138 
     139  endcase 
     140  return 
    50141end 
    51142;********************************************************************* 
    52 FUNCTION selectfile 
     143FUNCTION selectfile, datafilename, idlfile, argspro, _extra = ex 
    53144; 
    54145@common 
     146;------------------------------------------------------------ 
    55147;------------------------------------------------------------ 
    56148; 
     
    61153; du widget) n''est pas detruite est on peut recuperer le resultat! 
    62154; 
    63    messenger = ptr_new(/allocate_heap) 
    64    base=widget_base(/COLUMN, title = 'selectfile', /align_center, uvalue = messenger, _EXTRA = ex) 
    65 ; 
    66    nothing = widget_button(base, value = 'Cancel', uvalue = {name:'Global Cancel'}) 
    67 ; 
    68    basea=widget_base(base, /row, /align_center) 
    69    nothing = widget_label(basea, value = 'Data file name: ') 
    70    nothing = widget_text(basea, value = '', uvalue = {name:'datafilename'}, uname = 'datafilename', xsize = 45, /EDITABLE) 
    71    nothing = widget_button(basea, value = 'Browse', uvalue = {name:'browse datafilename'}) 
    72 ; 
    73    baseb=widget_base(base, /row, /align_center) 
    74    nothing = widget_label(baseb, value = 'Mesh file or IDL batch file: ') 
    75    nothing = widget_text(baseb, value = '', uvalue = {name:'meshfilename'}, uname = 'meshfilename', xsize = 45, /EDITABLE) 
    76    nothing = widget_button(baseb, value = 'Browse', uvalue = {name:'browse meshfilename'}) 
    77 ; 
    78    nothing = widget_button(base, value = 'Lets Go!', uvalue = {name:'Lets Go!'}) 
    79  
    80 ;------------------------------------------------------------ 
    81    widget_control,base,/realize 
    82    xmanager,'selectfile', base,event_handler = 'selectfile_event', no_block = 0 
    83 ; 
    84 ; 
    85    res = *messenger 
    86    ptr_free, messenger 
    87    if size(res, /type) NE 8 then return,  -1 
    88 ; 
    89    res1 = whichgrid(res.meshfilename, iodir = iodir) 
    90    if size(res1, /type) NE 8 then return,  -1 
    91    res2 = whichread() 
    92    if size(res2, /type) NE 8 then return,  -1 
    93    res3 = scanfile(res.datafilename, iodir = iodir) 
    94    if size(res3, /type) NE 8 then return,  -1 
    95  
    96    return, {fileparameters:res3, readparameters:res2, meshparameters:res1}  
     155  messenger = ptr_new(/allocate_heap) 
     156  base = widget_base(/column, title = 'selectfile', /align_center, uvalue = messenger, _EXTRA = ex) 
     157; cancel button 
     158  dummyid = widget_button(base, value = 'Cancel', uvalue = {name:'Global Cancel'}) 
     159; data file informations 
     160  basea = widget_base(base, /row, /align_center) 
     161  dummyid = widget_label(basea, value = 'Data file name: ') 
     162  database = widget_text(basea, value = '', uvalue = {name:'datafilename'} $ 
     163                        , uname = 'datafilename', xsize = 45, /EDITABLE) 
     164  dummyid = widget_button(basea, value = 'Browse', uvalue = {name:'browse datafilename'}) 
     165; switch automatic/by and mesh definition buttons 
     166  baseb = widget_base(base, /row, /align_center) 
     167  gdldid = cw_bgroup(baseb, ['automatic grid construction with initncdf.pro' $ 
     168                              , 'grid construction with other IDL batch or procedure'] $ 
     169                      , /exclusive, set_value = 0, uvalue = {name:'gridload'} $ 
     170                      , uname = 'gridload', button_uvalue = ['via initnetcdf', 'via perso']) 
     171; name of the procedure or batch file 
     172  basec = widget_base(base, /row, /align_center, uname = 'pro base') 
     173  dummyid = widget_label(basec, value = 'IDL batch file of procedure') 
     174  basemeshload = widget_text(basec, value = 'initncdf', uvalue = {name:'meshload'} $ 
     175                        , uname = 'meshload', xsize = 45, editable = 0) 
     176  dummyid = widget_button(basec, value = 'Browse', uvalue = {name:'browse meshload'}) 
     177; arguments informations 
     178  based = widget_base(base, /row, /align_center, uname = 'arg base', sensitive = 0) 
     179  dummyid = widget_label(based, value = 'procedure arguments') 
     180  agrbase = widget_text(based, value = '', uvalue = {name:'argtxt'} $ 
     181                        , uname = 'argtxt', xsize = 45, /EDITABLE) 
     182; keyword informations 
     183  basee = widget_base(base, /row, /align_center, uname = 'kwd base') 
     184  dummyid = widget_label(basee, uname = 'kwdlab', value = '     keywords of initncdf:') 
     185  dummyid = widget_text(basee, value = '' $ 
     186                        , uvalue = {name:'kwdtxt'}, uname = 'kwdtxt', xsize = 45, /EDITABLE) 
     187; 'Lets Go!' button 
     188  basego = widget_button(base, value = 'Lets Go!', uvalue = {name:'Lets Go!'}) 
     189 
     190;------------------------------------------------------------ 
     191  IF n_elements(datafilename) NE 0 THEN BEGIN  
     192    widget_control, database, set_value = datafilename 
     193    selectfile_event, {ID:database, TOP:base, HANDLER:base} 
     194  ENDIF  
     195  IF n_elements(idlfile) NE 0 THEN BEGIN  
     196    widget_control, basemeshload, set_value = idlfile 
     197    selectfile_event, {ID:basemeshload, TOP:base, HANDLER:base} 
     198    widget_control, basemeshload, get_value = idlfile2 
     199    IF idlfile2[0] NE '' THEN widget_control, gdldid, set_value = 1 
     200  ENDIF  
     201  IF n_elements(argspro) NE 0 THEN widget_control, argbase, set_value = argspro 
     202;------------------------------------------------------------ 
     203  IF n_elements(datafilename) EQ 0 THEN BEGIN  
     204    widget_control, base, /realize 
     205    xmanager, 'selectfile', base, event_handler = 'selectfile_event', no_block = 0 
     206  ENDIF ELSE selectfile_event, {ID:basego, TOP:base, HANDLER:base} 
     207;------------------------------------------------------------ 
     208; get back the information from selectfile_event 
     209  res = *messenger 
     210  ptr_free, messenger 
     211  if size(res, /type) NE 8 then return, -1 
     212 
     213  loadgrid, res.meshload, _extra = ex 
     214 
     215  glaminfo = moment(glamt) 
     216  IF finite(glaminfo[2]) EQ 0 THEN glaminfo = glaminfo[0:1] 
     217  gphiinfo = moment(gphit) 
     218  IF finite(gphiinfo[2]) EQ 0 THEN gphiinfo = gphiinfo[0:1] 
     219  ccmeshparameters = {filename: res.meshload $ 
     220          , glaminfo:glaminfo $ 
     221          , gphiinfo:gphiinfo $ 
     222          , jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo $ 
     223          , jpi:jpi, jpj:jpj, jpk:jpk $ 
     224          , ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $ 
     225          , iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $ 
     226          , izminmesh:izminmesh, izmaxmesh:izmaxmesh $ 
     227          , key_shift:key_shift, key_periodic:key_periodic $ 
     228          , key_stride:key_stride, key_gridtype:key_gridtype $ 
     229          , key_yreverse:key_yreverse, key_zreverse:key_zreverse $ 
     230          , key_partialstep:key_partialstep, key_onearth:key_onearth} 
     231 
     232  ccreadparameters = {funclec_name:'read_ncdf' $ 
     233          , jpidta:jpidta, jpjdta:jpjdta, jpkdta:jpkdta $ 
     234          , ixmindta:ixmindta, ixmaxdta:ixmaxdta $ 
     235          , iymindta:iymindta, iymaxdta:iymaxdta $ 
     236          , izmindta:izmindta, izmaxdta:izmaxdta} 
     237 
     238  res3 = scanfile(res.datafilename, iodir = iodir, _extra = ex) 
     239  if size(res3, /type) NE 8 then return,  -1 
     240 
     241  return, {fileparameters:res3, readparameters:ccreadparameters, meshparameters:ccmeshparameters}  
    97242end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/singleclickaction.pro

    r49 r69  
    1 PRO singleclickaction, event, quelclick 
     1PRO singleclickaction, event 
     2@cm_4mesh 
     3@cm_4data 
    24 
    3    return 
     5return 
     6 
     7;------------------------------------------------------------ 
     8  widget_control, event.id, get_uvalue = uval 
     9  widget_control, event.top, get_uvalue = top_uvalue 
     10  actionid = widget_info(event.top, find_by_uname = 'action') 
     11  type = widget_info(actionid, /combobox_gettext) 
     12  IF type NE 'plt' THEN return 
     13; on active la bonne fenetre  
     14  widget_control, event.id, get_value = win 
     15  wset, win 
     16; choix du type d''action 
     17  case uval.press of 
     18    1:BEGIN 
     19      coor = (convert_coord(uval.x[0], uval.y[0], /device, /to_data)) 
     20      x = coor[0] 
     21      y = coor[1] 
     22      help,  x,  y 
     23      oldgrid = vargrid 
     24      CASE strupcase(vargrid) OF 
     25        'T':vargrid = 'F' 
     26        'W':vargrid = 'F' 
     27        'U':vargrid = 'V' 
     28        'V':vargrid = 'U' 
     29        'F':vargrid = 'T' 
     30      ENDCASE 
     31      grille, -1, glam, gphi, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 
     32      vargrid = oldgrid 
     33; define the corner of the cells in the clockwise direction 
     34      IF keyword_set(key_periodic) AND nx EQ jpi THEN BEGIN 
     35        x1 = glam[*, 0:ny-2] 
     36        y1 = gphi[*, 0:ny-2] 
     37        x2 = glam[*, 1:ny-1] 
     38        y2 = gphi[*, 1:ny-1] 
     39        x3 = shift(glam[*, 1:ny-1], -1, 0) 
     40        y3 = shift(gphi[*, 1:ny-1], -1, 0) 
     41        x4 = shift(glam[*, 0:ny-2], -1, 0) 
     42        y4 = shift(gphi[*, 0:ny-2], -1, 0) 
     43      ENDIF ELSE BEGIN 
     44        x1 = glam[0:nx-2, 0:ny-2] 
     45        y1 = gphi[0:nx-2, 0:ny-2] 
     46        x2 = glam[0:nx-2, 1:ny-1] 
     47        y2 = gphi[0:nx-2, 1:ny-1] 
     48        x3 = glam[1:nx-1, 1:ny-1] 
     49        y3 = gphi[1:nx-1, 1:ny-1] 
     50        x4 = glam[1:nx-1, 0:ny-2] 
     51        y4 = gphi[1:nx-1, 0:ny-2] 
     52      ENDELSE 
     53      glam = -1                 ; free memory 
     54      gphi = -1                 ; free memory 
     55; 
     56; What is the longitude? 
     57      WHILE x GT !x.range[1] DO x = x-360 
     58      WHILE x LT !x.range[0] DO x = x+360 
     59      IF x GT !x.range[1] THEN RETURN 
     60      IF y GT !y.range[1] THEN RETURN 
     61      IF y LT !y.range[0] THEN RETURN 
     62; 
     63      cell = inquad(x, y, x1, y1, x2, y2, x3, y3, x4, y4 $ 
     64                    , onsphere = key_onearth) 
     65; 
     66        x1 = -1                 ; free memory 
     67        y1 = -1                 ; free memory 
     68        x2 = -1                 ; free memory 
     69        y2 = -1                 ; free memory 
     70        x3 = -1                 ; free memory 
     71        y3 = -1                 ; free memory 
     72        x4 = -1                 ; free memory 
     73        y4 = -1                 ; free memory 
     74       
     75      IF cell[0] EQ -1 OR n_elements(cell) GT 1 THEN RETURN       
     76; 
     77      yy = cell[0]/(nx-1+key_periodic*(nx EQ jpi)) 
     78      xx = cell[0] MOD (nx-1+key_periodic*(nx EQ jpi)) 
     79; 
     80      CASE strupcase(vargrid) OF 
     81        'T':BEGIN 
     82          xx = xx+firstx+1 
     83          yy = yy+firsty+1 
     84        END 
     85        'W':BEGIN 
     86          xx = xx+firstx+1 
     87          yy = yy+firsty+1 
     88        END 
     89        'U':BEGIN 
     90          xx = xx+firstx 
     91          yy = yy+firsty+1 
     92        END 
     93        'V':BEGIN 
     94          xx = xx+firstx+1 
     95          yy = yy+firsty 
     96        END 
     97        'F':BEGIN 
     98          xx = xx+firstx 
     99          yy = yy+firsty 
     100        END 
     101      ENDCASE 
     102; 
     103      bad = where(xx GE jpi) 
     104      IF bad[0] NE -1 THEN BEGIN 
     105        xx[bad] = xx[bad]-jpi 
     106        yy[bad] = yy[bad]+1 
     107      ENDIF 
     108      bad = where(yy GE jpj) 
     109      IF bad[0] NE -1 THEN stop 
     110; 
     111      print, glamt[xx, yy], gphit[xx, yy] 
     112; 
     113      cmd =  buildcmd(event.top, boxzoom = boxzoom) 
     114; 
     115    END 
     116    ELSE: 
     117  endcase 
     118 
     119  RETURN 
    4120end 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/updatewidget.pro

    r49 r69  
    1818   ENDELSE 
    1919;-------------- 
    20 ; domaine 
     20; domain 
    2121;-------------- 
    2222   boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
     
    2424   if keyword_set(noboxzoom) then boxzoom = 0 
    2525;-------------- 
    26 ; champ: filename & nomvar 
     26; varinfo: filename & namevar 
    2727;-------------- 
    28    champ = (extractatt(top_uvalue,  'champs'))[*, numdessinin] 
    29    filename = champ[0] & nomvar = champ[1] 
     28   varinfo = (extractatt(top_uvalue, 'varinfo'))[*, numdessinin] 
     29   filename = varinfo[0] & nomvar = varinfo[1] 
    3030; 
    3131   if filename NE '' OR nomvar NE '' THEN BEGIN 
     
    5454   endif 
    5555;-------------- 
    56 ; nomexp 
     56; text command 
    5757;-------------- 
    58    nomexp = (extractatt(top_uvalue,  'prefixes'))[numdessinin] 
    59    if nomexp NE '' then begin 
    60       nomexpid = widget_info(base, find_by_uname = 'nom_exp') 
    61       widget_control, nomexpid, set_value = nomexp 
     58   txtcmd = (extractatt(top_uvalue,  'txtcmd'))[numdessinin] 
     59   if txtcmd NE '' then begin 
     60      txtcmdid = widget_info(base, find_by_uname = 'txtcmd') 
     61      widget_control, txtcmdid, set_value = txtcmd 
    6262   endif 
    6363;-------------- 
     
    6868      if graphtype NE '' then begin 
    6969         actionid = widget_info(base,find_by_uname = 'action') 
    70          widget_control, actionid, get_uvalue = action_uvalue 
    71          widget_control, actionid, set_droplist_select = (where(action_uvalue.choix EQ graphtype))[0] 
     70         widget_control, actionid, get_value = action_value 
     71         widget_control, actionid, set_combobox_select = (where(action_value EQ graphtype))[0] 
    7272      endif 
    7373   endif 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xcreateanim.pro

    r49 r69  
    1515; 
    1616   calendar = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).time_counter 
     17   key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).caltype 
    1718; 
    1819   widget_control, widget_info(event.top, find_by_uname = 'Filename') $ 
     
    2425   widget_control, widget_info(event.top, find_by_uname = 'debut') $ 
    2526    , get_value = vdate1 
    26    index1 = where(calendar eq juldate(vdate1)) & index1 = index1[0]  
     27   index1 = where(calendar eq date2jul(vdate1)) & index1 = index1[0]  
    2728   if index1 EQ -1 then return 
    2829; 
    2930   widget_control, widget_info(event.handler, find_by_uname = 'fin') $ 
    3031    , get_value = vdate2 
    31    index2 = where(calendar eq juldate(vdate2)) & index2 = index2[0]  
     32   index2 = where(calendar eq date2jul(vdate2)) & index2 = index2[0]  
    3233   if index2 EQ -1 OR index2 LE index1 then return 
    3334; on detruit le widget avant de creer le fichier .ps 
     
    6566   base = widget_base() 
    6667   sliderid = widget_slider(base, minimum = 1, maximum = index2-index1+1, value = 1 $ 
    67                             , title = 'image que l''on est en train de creer') 
     68                            , title = 'image number: ') 
    6869   widget_control,base,/realize 
    6970; 
    7071; commencement du fichier gif. ecriture d''une image vide  
    71    date = vairdate(calendar[index1], mensuel = mensuel, annuel= annuel) 
     72   date = jul2date(calendar[index1]) 
    7273   xxx2ps, /noerase, date1in = date, date2in = date 
    7374; 
     
    9899; 
    99100      window, /free, /pixmap, xsize=xsize, ysize=ysize 
    100       date = vairdate(calendar[ind], mensuel = mensuel, annuel= annuel) 
     101      date = jul2date(calendar[ind]) 
    101102      xxx2ps, /noerase, date1 = date, date2 = date 
    102103;       
     
    155156; 
    156157   filelist = extractatt(top_uvalue,  'filelist') 
    157    filenames = (extractatt(top_uvalue,  'champs'))[0, *] 
     158   filenames = (extractatt(top_uvalue,  'varinfo'))[0, *] 
    158159   filenames = reform(filenames) 
    159160   filenames = filenames[uniq(filenames, sort(filenames))] 
     
    178179; c''est possible de faire une animation   
    179180; 
    180    base = widget_base(/column, title = 'creation d''une animation', uvalue = {parent:parent, indexfile:indexfile})    
    181    rien = widget_label(base, value = 'Quel nom donner a l''animation') 
     181   base = widget_base(/column, title = 'animation creation', uvalue = {parent:parent, indexfile:indexfile})    
     182   rien = widget_label(base, value = 'animation name') 
    182183   rien = widget_text(base,value='anim_idl.gif', uname='Filename', /editable) 
    183    rien = widget_label(base, value = 'repertoire ou mettre le fichier') 
     184   rien = widget_label(base, value = 'animation directory') 
    184185   if n_elements(animdir) EQ 0 then cd, current = animdir 
    185186   rien = widget_text(base,value=animdir, uname='directorie', /editable) 
    186    rien = widget_label(base, value = 'Debut de l''animation') 
     187   rien = widget_label(base, value = 'starting date') 
    187188   rien = cw_calendar(base, calendar, uname = 'debut', uvalue = {name:'calendar'}, /frame) 
    188    rien = widget_label(base, value = 'Fin de l''animation') 
     189   rien = widget_label(base, value = 'ending date') 
    189190   rien = cw_calendar(base, calendar, calendar[n_elements(calendar)-1] $ 
    190191                      , uname = 'fin', uvalue = {name:'calendar'}, /frame) 
  • trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xxxmenubar_event.pro

    r68 r69  
    44 
    55 
    6    case event.value of 
    7       'Open' :begin  
    8          newfile = selectfile() 
    9          if size(newfile, /type) NE 8 then return 
    10          widget_control, event.top, /hourglass 
    11          widget_control, event.top, update = 0 
    12          widget_control, event.top, get_uvalue = top_uvalue 
     6  case event.value of 
     7    'Open' :begin  
     8      oldmeshparams = ccmeshparameters 
     9      newfile = selectfile() 
     10      if size(newfile, /type) NE 8 then return 
     11      widget_control, event.top, /hourglass 
     12      widget_control, event.top, update = 0 
     13      widget_control, event.top, get_uvalue = top_uvalue 
    1314; on s''occupe de filelist 
    14          filelist = extractatt(top_uvalue, 'filelist') 
    15          filelist = [filelist, newfile.fileparameters.filename] 
    16          currentfile = n_elements(filelist)-1 
     15      filelist = extractatt(top_uvalue, 'filelist') 
     16      filelist = [filelist, newfile.fileparameters.filename] 
     17      currentfile = n_elements(filelist)-1 
    1718; on update le widget 
    18          filelistid = widget_info(event.top, find_by_uname = 'filelist') 
    19          widget_control, filelistid, set_value = filelist 
    20          widget_control, filelistid, set_list_select = currentfile 
     19      filelistid = widget_info(event.top, find_by_uname = 'filelist') 
     20      widget_control, filelistid, combobox_additem = file_basename(newfile.fileparameters.filename) 
     21      widget_control, filelistid, set_combobox_select = currentfile 
    2122; on update les elements filelist et currentfile de la top_uvalue 
    22          *top_uvalue[1, findline(top_uvalue, 'filelist')] = filelist 
    23          oldfile = *top_uvalue[1, findline(top_uvalue, 'currentfile')] 
    24          *top_uvalue[1, findline(top_uvalue, 'currentfile')] = currentfile 
     23      *top_uvalue[1, findline(top_uvalue, 'filelist')] = filelist 
     24      oldfile = *top_uvalue[1, findline(top_uvalue, 'currentfile')] 
     25      *top_uvalue[1, findline(top_uvalue, 'currentfile')] = currentfile 
    2526; on s''occupe du nom de la variable 
    26          champid = widget_info(event.top, find_by_uname = 'champ') 
     27      vlstid = widget_info(event.top, find_by_uname = 'varlist') 
    2728; quel etait le champ selectionne ? on le reselectionne ? 
    28          oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar 
    29          fieldname = oldlistvar[widget_info(champid,/droplist_select)] 
    30          index = where(newfile.fileparameters.listvar EQ fieldname) & index = 0>index[0] 
    31          widget_control, champid, set_value = newfile.fileparameters.listvar 
    32          widget_control, champid, set_droplist_select = index 
     29      fieldname = widget_info(vlstid, /combobox_gettext) 
     30      index = where(newfile.fileparameters.listvar EQ fieldname)  
     31      widget_control, vlstid, set_value = newfile.fileparameters.listvar 
     32      widget_control, vlstid, set_combobox_select = 0 > index[0] 
    3333; on s''occupe du calendrier 
    34          date1id = widget_info(event.top, find_by_uname = 'calendar1') 
    35          widget_control, date1id, get_value = date1 
    36          widget_control, date1id, /destroy 
    37          if (where(newfile.fileparameters.time_counter EQ date1))[0] EQ -1 $ 
    38           then date1 = newfile.fileparameters.time_counter[0] 
    39          date2id = widget_info(event.top, find_by_uname = 'calendar2') 
    40          widget_control, date2id, get_value = date2 
    41          widget_control, date2id, /destroy 
    42          if (where(newfile.fileparameters.time_counter EQ date2))[0] EQ -1 then date2 = date1 
    43          base12 = widget_info(event.top, find_by_uname = 'base12') 
    44          rien = cw_calendar(base12,newfile.fileparameters.time_counter,date1, uname = 'calendar1' $ 
    45                             , uvalue = {name:'calendar1'}, /frame) 
    46          rien = cw_calendar(base12,newfile.fileparameters.time_counter,date2, uname = 'calendar2' $ 
    47                             , uvalue = {name:'calendar2'}, /frame) 
    48 ; update la grille??? 
    49          change = changegrid(newfile.meshparameters) 
    50          if change then BEGIN 
    51             domainid = widget_info(event.top, find_by_uname = 'domain') 
    52             widget_control, domainid, set_value = -1 
    53          endif 
     34      date1id = widget_info(event.top, find_by_uname = 'calendar1') 
     35      widget_control, date1id, get_value = date1 
     36      widget_control, date1id, /destroy 
     37      if (where(newfile.fileparameters.time_counter EQ date1))[0] EQ -1 $ 
     38      then date1 = newfile.fileparameters.time_counter[0] 
     39      date2id = widget_info(event.top, find_by_uname = 'calendar2') 
     40      widget_control, date2id, get_value = date2 
     41      widget_control, date2id, /destroy 
     42      if (where(newfile.fileparameters.time_counter EQ date2))[0] EQ -1 then date2 = date1 
     43      basecal = widget_info(event.top, find_by_uname = 'basecal') 
     44      rien = cw_calendar(basecal, newfile.fileparameters.time_counter, date1, uname = 'calendar1' $ 
     45                         , uvalue = {name:'calendar1'}, /frame) 
     46      rien = cw_calendar(basecal, newfile.fileparameters.time_counter, date2, uname = 'calendar2' $ 
     47                         , uvalue = {name:'calendar2'}, /frame) 
    5448; on update les elements fileparameters, readparameters et meshparameters de la top_uvalue 
    55          newfileparameters = ptrarr(currentfile+1, /allocate_heap) 
    56          FOR i = 0, currentfile-1 DO $ 
    57           *newfileparameters[i] = *(extractatt(top_uvalue, 'fileparameters'))[i] 
    58          *newfileparameters[currentfile] = newfile.fileparameters 
    59          ptr_free, extractatt(top_uvalue, 'fileparameters') 
    60          *top_uvalue[1, findline(top_uvalue, 'fileparameters')] = newfileparameters 
     49      newfileparameters = ptrarr(currentfile+1, /allocate_heap) 
     50      FOR i = 0, currentfile-1 DO $ 
     51         *newfileparameters[i] = *(extractatt(top_uvalue, 'fileparameters'))[i] 
     52      *newfileparameters[currentfile] = newfile.fileparameters 
     53      ptr_free, extractatt(top_uvalue, 'fileparameters') 
     54      *top_uvalue[1, findline(top_uvalue, 'fileparameters')] = newfileparameters 
    6155; 
    62          newreadparameters = ptrarr(currentfile+1, /allocate_heap) 
    63          FOR i = 0, currentfile-1 DO $ 
    64           *newreadparameters[i] = *(extractatt(top_uvalue, 'readparameters'))[i] 
    65          *newreadparameters[currentfile] = newfile.readparameters 
    66          ptr_free, extractatt(top_uvalue, 'readparameters') 
    67          *top_uvalue[1, findline(top_uvalue, 'readparameters')] = newreadparameters 
     56      newreadparameters = ptrarr(currentfile+1, /allocate_heap) 
     57      FOR i = 0, currentfile-1 DO $ 
     58         *newreadparameters[i] = *(extractatt(top_uvalue, 'readparameters'))[i] 
     59      *newreadparameters[currentfile] = newfile.readparameters 
     60      ptr_free, extractatt(top_uvalue, 'readparameters') 
     61      *top_uvalue[1, findline(top_uvalue, 'readparameters')] = newreadparameters 
    6862; 
    69          newmeshparameters = ptrarr(currentfile+1, /allocate_heap) 
    70          FOR i = 0, currentfile-1 DO $ 
    71           *newmeshparameters[i] = *(extractatt(top_uvalue, 'meshparameters'))[i] 
    72          *newmeshparameters[currentfile] = newfile.meshparameters 
    73          ptr_free, extractatt(top_uvalue, 'meshparameters') 
    74          *top_uvalue[1, findline(top_uvalue, 'meshparameters')] = newmeshparameters 
     63      newmeshparameters = ptrarr(currentfile+1, /allocate_heap) 
     64      FOR i = 0, currentfile-1 DO $ 
     65         *newmeshparameters[i] = *(extractatt(top_uvalue, 'meshparameters'))[i] 
     66      *newmeshparameters[currentfile] = newfile.meshparameters 
     67      ptr_free, extractatt(top_uvalue, 'meshparameters') 
     68      *top_uvalue[1, findline(top_uvalue, 'meshparameters')] = newmeshparameters 
    7569; on actualise le widget! 
    76          widget_control, event.top, update = 1 
    77       end 
    78       'New xxx' :BEGIN 
    79          widget_control, event.top, get_uvalue = top_uvalue 
    80          extra = extractatt(top_uvalue, 'extra') 
    81          xxx, CALLERWIDID = event.top, _extra = extra 
    82       end 
    83       'Quit':begin  
    84          widget_control, event.top, get_uvalue = top_uvalue 
    85          ptr_free, extractatt(top_uvalue, 'exextra') 
    86          ptr_free, extractatt(top_uvalue, 'fileparameters') 
    87          ptr_free, extractatt(top_uvalue, 'readparameters') 
    88          ptr_free, extractatt(top_uvalue, 'meshparameters') 
    89          ptr_free, top_uvalue 
    90          widget_control, event.top, /destroy ;on ferme le widget 
    91       end 
    92       'PS' :BEGIN 
    93          IF lmgr(/demo) EQ 1 THEN BEGIN 
    94             dummy = report('impossible to save as postscript in demo mode') 
    95             return 
    96          ENDIF 
    97          widget_control,event.top, get_uvalue = top_uvalue 
     70      if cmpgrid(oldmeshparams) then BEGIN 
     71        domainid = widget_info(event.top, find_by_uname = 'domain') 
     72        widget_control, domainid, set_value = -1 
     73      endif 
     74      widget_control, event.top, update = 1 
     75    end 
     76    'New xxx' :BEGIN 
     77      widget_control, event.top, get_uvalue = top_uvalue 
     78      extra = extractatt(top_uvalue, 'extra') 
     79      xxx, CALLERWIDID = event.top, _extra = extra 
     80    end 
     81    'Quit':begin  
     82      widget_control, event.top, get_uvalue = top_uvalue 
     83      ptr_free, extractatt(top_uvalue, 'exextra') 
     84      ptr_free, extractatt(top_uvalue, 'fileparameters') 
     85      ptr_free, extractatt(top_uvalue, 'readparameters') 
     86      ptr_free, extractatt(top_uvalue, 'meshparameters') 
     87      ptr_free, top_uvalue 
     88      widget_control, event.top, /destroy ;on ferme le widget 
     89    end 
     90    'PostScript' :BEGIN 
     91      IF lmgr(/demo) EQ 1 THEN BEGIN 
     92        dummy = report('impossible to save as postscript in demo mode') 
     93        return 
     94      ENDIF 
     95      widget_control, event.top, get_uvalue = top_uvalue 
     96; on recupere la liste des instructions 
     97      globalcommand = extractatt(top_uvalue, 'globalcommand') 
     98;      for i = 0, n_elements(globalcommand)-1 do print, globalcommand[i] 
     99; on complete par le premiere et les dernieres lignes du programme 
     100      createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
     101                 , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $ 
     102                 +', PORTRAIT = portrait, LANDSCAPE = landscape' $ 
     103                 +', DATE1IN = date1in, DATE2IN = date2in' $ 
     104                 , /POSTSCRIPT 
     105    END 
     106    'Animated gif' :begin  
     107      IF float(strmid(!version.release,0,3)) GE 6.2 THEN xcreateanim, event.top 
     108    end 
     109    'Gif' :BEGIN 
     110      IF lmgr(/demo) EQ 1 THEN BEGIN 
     111        dummy = report('impossible to save as an image in demo mode') 
     112        return 
     113      ENDIF 
     114      widget_control, event.top, get_uvalue = top_uvalue 
     115      smallin = extractatt(top_uvalue, 'smallin') 
     116      numdessinin = smallin[2]-1 
     117      smallout = extractatt(top_uvalue, 'smallout') 
     118      numdessinout = smallout[2]-1 
     119      tracecadre, smallin, /erase 
     120      tracecadre, smallout, /erase 
     121      filename = xquestion('dans quelle fichier gif voulez vous sauver !C l''ecran de xxx?', 'xxx_image.gif') 
     122      if rstrpos(filename, '.gif') NE strlen(filename)-4 then filename = filename+'.gif' 
     123      filename = isafile(file = filename, io = imagedir, /new) 
     124      saveimage, filename, /quiet 
     125    end 
     126    'IDL procedure':BEGIN 
     127      IF lmgr(/demo) EQ 1 THEN BEGIN 
     128        dummy = report('impossible to save as a idl program file in demo mode') 
     129        return 
     130      ENDIF 
     131; on recupere le nom du fichier 
     132      filename = xquestion('dans quelle procedure IDL voulez vous sauver !C la realisation de ce graph?', 'xxx_figure.pro') 
     133; on le complete par un .pro 
     134      if rstrpos(filename, '.pro') NE strlen(filename)-4 then filename = filename+'.pro' 
     135      filename = isafile(file = filename, io = homedir, /new) 
     136      widget_control, event.top, get_uvalue = top_uvalue 
    98137; portrait ou landscape ??? 
    99          options = extractatt(top_uvalue, 'options')    
    100          optionsflag = extractatt(top_uvalue, 'optionsflag') 
    101          portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] 
    102 ; on recupere la liste des instructions 
    103          globalcommand = extractatt(top_uvalue, 'globalcommand') 
     138      options = extractatt(top_uvalue, 'options')    
     139      optionsflag = extractatt(top_uvalue, 'optionsflag') 
     140      portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] 
     141; on lit les commandes pour faire un plot 
     142      globalcommand = extractatt(top_uvalue, 'globalcommand') 
    104143; on complete par le premiere et les dernieres lignes du programme 
    105          createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
    106                     , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ 
    107                     , KWDUSED = ', /POSTSCRIPT, PORTRAIT = portrait' 
    108        END 
    109       'Anim' :begin  
    110 ;;; no more working...         xcreateanim, event.top 
    111       end 
    112       'Gif' :BEGIN 
    113          IF lmgr(/demo) EQ 1 THEN BEGIN 
    114             dummy = report('impossible to save as an image in demo mode') 
    115             return 
    116          ENDIF 
    117          widget_control,event.top, get_uvalue = top_uvalue 
    118          smallin = extractatt(top_uvalue, 'smallin') 
    119          numdessinin = smallin[2]-1 
    120          smallout = extractatt(top_uvalue, 'smallout') 
    121          numdessinout = smallout[2]-1 
    122          tracecadre, smallin, /erase 
    123          tracecadre, smallout, /erase 
    124          filename = xquestion('dans quelle fichier gif voulez vous sauver !C l''ecran de xxx?', 'xxx_image.gif') 
    125          if rstrpos(filename, '.gif') NE strlen(filename)-4 then filename = filename+'.gif' 
    126          filename = isafile(file = filename, io = imagedir, /new) 
    127          saveimage, filename, /quiet 
    128       end 
    129       'Script':BEGIN 
    130          IF lmgr(/demo) EQ 1 THEN BEGIN 
    131             dummy = report('impossible to save as a idl program file in demo mode') 
    132             return 
    133          ENDIF 
     144      thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
     145      CASE thisOS of 
     146        'MAC':sep = ':' 
     147        'WIN':sep = '\' 
     148        ELSE:sep = '/' 
     149      ENDCASE 
     150      poslastsep = rstrpos(filename, sep) 
     151      proname = strmid(filename, poslastsep+1, strlen(filename)-poslastsep-1-4) 
     152      globalcommand = ['pro '+proname+', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ 
     153                       , ' ' $ 
     154                       , '   '+globalcommand $ 
     155                       , ' ' $ 
     156                       , 'return' $ 
     157                       , 'end'] 
     158; on les ecrit dans un programme 
     159      putfile, filename, globalcommand 
     160    END 
     161    'RESTORE kwd of xxx':BEGIN 
     162      IF lmgr(/demo) EQ 1 THEN BEGIN 
     163        dummy = report('impossible to save the widget in demo mode') 
     164        return 
     165      ENDIF 
    134166; on recupere le nom du fichier 
    135          filename = xquestion('dans quelle procedure IDL voulez vous sauver !C la realisation de ce graph?', 'xxx_figure.pro') 
    136 ; on le complete par un .pro 
    137          if rstrpos(filename, '.pro') NE strlen(filename)-4 then filename = filename+'.pro' 
    138          filename = isafile(file = filename, io = homedir, /new) 
    139          widget_control,event.top, get_uvalue = top_uvalue 
    140 ; portrait ou landscape ??? 
    141          options = extractatt(top_uvalue, 'options')    
    142          optionsflag = extractatt(top_uvalue, 'optionsflag') 
    143          portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] 
    144 ; on lit les commandes pour faire un plot 
    145          globalcommand = extractatt(top_uvalue, 'globalcommand') 
    146 ; on complete par le premiere et les dernieres lignes du programme 
    147          thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    148          CASE thisOS of 
    149             'MAC':sep = ':' 
    150             'WIN':sep = '\' 
    151             ELSE:sep = '/' 
    152          ENDCASE 
    153          poslastsep = rstrpos(filename, sep) 
    154          proname = strmid(filename, poslastsep+1, strlen(filename)-poslastsep-1-4) 
    155          globalcommand = ['pro '+proname+', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape, DATE1IN = date1in, DATE2IN = date2in, _extra = ex' $ 
    156                           , '@common' $ 
    157                           , ' ' $ 
    158                           , '   portrait = '+strtrim(portrait, 1) $ 
    159                           , '   '+globalcommand $ 
    160                           , ' ' $ 
    161                           , 'return' $ 
    162                           , 'end'] 
    163 ; on les ecrit dans un programme 
    164          putfile, filename, globalcommand 
    165       END 
    166       'Widget':BEGIN 
    167          IF lmgr(/demo) EQ 1 THEN BEGIN 
    168             dummy = report('impossible to save the widget in demo mode') 
    169             return 
    170          ENDIF 
    171 ; on recupere le nom du fichier 
    172          filename = xquestion('dans quel fichier bianire voulez vous sauver le widget ?', 'xxx_widget.dat') 
     167      filename = xquestion('dans quel fichier bianire voulez vous sauver le widget ?', 'xxx_widget.dat') 
    173168; on le complete par un .dat 
    174          if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat' 
    175          filename = isafile(file = filename, io = homedir, /new) 
     169      if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat' 
     170      filename = isafile(file = filename, io = homedir, /new) 
    176171; 
    177          widget_control, event.top, get_uvalue = uvalue 
    178          widget_control, extractatt(uvalue, 'graphid'),get_value=win 
    179          wshow, win 
    180          wset, win 
    181          image = tvrd(/true) 
    182          save, uvalue, image, filename = filename 
    183       END 
    184       'Prompt':BEGIN 
    185          commande = getfile(myuniquetmpdir + 'xxx_oneplot.pro') 
    186          for i = 0,  n_elements(commande)-1 do print, commande[i] 
    187       end 
    188       'Ok button' :begin  
    189          widget_control, event.top, get_uvalue = top_uvalue 
    190          options = extractatt(top_uvalue, 'options') 
    191          index = where(options EQ 'Ok button') & index = index[0] 
    192          optionsflag = extractatt(top_uvalue, 'optionsflag') 
    193          flag = 1-optionsflag[index, 0] 
    194          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = flag 
    195          widget_control, widget_info(event.top, find_by_uname = 'base ok button'), map = flag 
    196       end 
    197       'Portrait/Landscape' :begin  
    198          widget_control, event.top, get_uvalue = top_uvalue 
    199          options = extractatt(top_uvalue, 'options') 
    200          index = where(options EQ 'Portrait/Landscape') & index = index[0] 
    201          optionsflag = extractatt(top_uvalue, 'optionsflag') 
    202          key_portrait= 1-optionsflag[index, 0] 
    203          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = key_portrait 
     172      widget_control, event.top, get_uvalue = uvalue 
     173      widget_control, extractatt(uvalue, 'graphid'), get_value = win 
     174      wshow, win 
     175      wset, win 
     176      image = tvrd(/true) 
     177      save, uvalue, image, filename = filename 
     178    END 
     179    'Print to prompt':BEGIN 
     180      commande = getfile(myuniquetmpdir + 'xxx_oneplot.pro') 
     181      for i = 0,  n_elements(commande)-1 do print, commande[i] 
     182    end 
     183   'Portrait/Landscape' :begin  
     184      widget_control, event.top, get_uvalue = top_uvalue 
     185      options = extractatt(top_uvalue, 'options') 
     186      index = where(options EQ 'Portrait/Landscape') & index = index[0] 
     187      optionsflag = extractatt(top_uvalue, 'optionsflag') 
     188      key_portrait = 1-optionsflag[index, 0] 
     189      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, *] = key_portrait 
    204190; fenetre separee ou fenetre collee au widget ? 
    205          if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN 
     191      if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN 
    206192; on tue la fenetre 
    207             graphid = extractatt(top_uvalue, 'graphid') 
    208             widget_control, widget_info(graphid, /parent), /destroy 
     193        graphid = extractatt(top_uvalue, 'graphid') 
     194        widget_control, widget_info(graphid, /parent), /destroy 
    209195; on la recree 
    210             basegraph = widget_base(title = 'xxx window',  group_leader = event.top, uvalue = event.top,  uname = 'basegraph') 
    211             windsize = givewindowsize() 
    212             graphid = widget_draw(basegraph, uname = 'graph' $ 
    213                                   , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ 
    214                                   , /button_events, retain = 2 $ 
    215                                   , xsize = windsize[0],ysize = windsize[1]) 
    216             widget_control,basegraph,/realize 
    217             xmanager,'xxx',basegraph, /no_block 
     196        basegraph = widget_base(title = 'xxx window',  group_leader = event.top, uvalue = event.top,  uname = 'basegraph') 
     197        windsize = givewindowsize() 
     198        graphid = widget_draw(basegraph, uname = 'graph' $ 
     199                              , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ 
     200                              , /button_events, retain = 2 $ 
     201                              , xsize = windsize[0], ysize = windsize[1]) 
     202        widget_control, basegraph, /realize 
     203        xmanager, 'xxx', basegraph, /no_block 
    218204; on redessine ce qu''il y avait dedans 
    219205; on recupere la liste des instructions 
    220             globalcommand = extractatt(top_uvalue, 'globalcommand') 
     206        globalcommand = extractatt(top_uvalue, 'globalcommand') 
    221207; on complete par le premiere et les dernieres lignes du programme 
    222             createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
    223                        , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ 
    224                        , KWDUSED = ', /noerase, PORTRAIT = portrait' 
     208        createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
     209                   , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ 
     210                   , KWDUSED = ', /noerase, PORTRAIT = portrait' 
    225211; on reattribue l''element graphid de la top_uvalue 
    226             *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid 
    227          ENDIF ELSE BEGIN 
    228             extra = extractatt(top_uvalue, 'extra') 
    229             xxx, CALLERWIDID = event.top, /redraw, _extra = extra 
    230             widget_control, event.top, /destroy ;on ferme le widget 
    231          ENDELSE 
    232       end 
    233       'Overlay' :begin  
    234          widget_control, event.top, get_uvalue = top_uvalue 
    235          numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
    236          options = extractatt(top_uvalue, 'options')    
    237          flags = extractatt(top_uvalue, 'optionsflag') 
    238          index = where(options EQ 'Overlay') 
     212        *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid 
     213      ENDIF ELSE BEGIN 
     214        extra = extractatt(top_uvalue, 'extra') 
     215        xxx, CALLERWIDID = event.top, /redraw, _extra = extra 
     216        widget_control, event.top, /destroy ;on ferme le widget 
     217      ENDELSE 
     218    end 
     219    'Overlay' :begin  
     220      widget_control, event.top, get_uvalue = top_uvalue 
     221      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
     222      options = extractatt(top_uvalue, 'options')    
     223      flags = extractatt(top_uvalue, 'optionsflag') 
     224      index = where(options EQ 'Overlay') 
    239225; on change le flag sur Longitude / x index 
    240          flag = 1-flags[index, numdessinin] & flag = flag[0] 
     226      flag = 1-flags[index, numdessinin] & flag = flag[0] 
    241227; on le reeatribue 
    242          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
    243       end 
    244       'Vecteur':BEGIN 
    245          widget_control, event.top, get_uvalue = top_uvalue 
    246          numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
    247          options = extractatt(top_uvalue, 'options')    
    248          flags = extractatt(top_uvalue, 'optionsflag') 
    249          index = where(options EQ 'Vecteur') 
     228      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
     229    end 
     230    'Vecteur':BEGIN 
     231      widget_control, event.top, get_uvalue = top_uvalue 
     232      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
     233      options = extractatt(top_uvalue, 'options')    
     234      flags = extractatt(top_uvalue, 'optionsflag') 
     235      index = where(options EQ 'Vecteur') 
    250236; on change le flag sur Longitude / x index 
    251          flag = 1-flags[index, numdessinin] & flag = flag[0] 
     237      flag = 1-flags[index, numdessinin] & flag = flag[0] 
    252238; on le reeatribue 
    253          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
    254       end 
    255       'Longitude / x index':BEGIN 
    256          widget_control, event.top, get_uvalue = top_uvalue 
    257          numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
    258          options = extractatt(top_uvalue, 'options')    
    259          flags = extractatt(top_uvalue, 'optionsflag') 
    260          index = where(options EQ 'Longitude / x index') 
     239      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
     240    end 
     241    'Longitude / x index':BEGIN 
     242      widget_control, event.top, get_uvalue = top_uvalue 
     243      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
     244      options = extractatt(top_uvalue, 'options')    
     245      flags = extractatt(top_uvalue, 'optionsflag') 
     246      index = where(options EQ 'Longitude / x index') 
    261247; on change le flag sur Longitude / x index 
    262          flag = 1-flags[index, numdessinin] & flag = flag[0] 
     248      flag = 1-flags[index, numdessinin] & flag = flag[0] 
    263249; on le reeatribue 
    264          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
     250      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
    265251; maintenant on va changer les sliders definissant la boxzoom 
    266          domainid = widget_info(event.top, find_by_uname = 'domain') 
    267          boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
     252      domainid = widget_info(event.top, find_by_uname = 'domain') 
     253      boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
    268254; on veut retrouver le type de grille qui est utilisee 
    269          currentfile = extractatt(top_uvalue, 'currentfile') 
    270          listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
    271          indexvar = widget_info(widget_info(event.top, find_by_uname = 'champ'), /droplist_select) 
    272          vargrid = strupcase(listgrid[indexvar]) 
    273          if flag EQ 0 then BEGIN ; longitudes 
     255      currentfile = extractatt(top_uvalue, 'currentfile') 
     256      listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
     257      listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
     258      vlstid = widget_info(event.top, find_by_uname = 'varlist') 
     259      namevar = widget_info(vlstid, /combobox_gettext) 
     260      indexvar = where(listvar EQ namevar) 
     261      vargrid = strupcase(listgrid[indexvar]) 
     262      if flag EQ 0 then BEGIN   ; longitudes 
    274263; on fait un domdef pour retrouver le lon1 lon2 correspondant a la 
    275264; boxzoom definie sur le widget...  
    276             domdef, boxzoom, gridtype = vargrid, /xindex $ 
    277              , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] 
    278             widget_control, domainid, set_value = [lon1, lon2, boxzoom[2:3]] 
    279          ENDIF ELSE BEGIN       ; xindex 
     265        domdef, boxzoom, gridtype = vargrid, /xindex $ 
     266                , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] 
     267        widget_control, domainid, set_value = [lon1, lon2, boxzoom[2:3]] 
     268      ENDIF ELSE BEGIN          ; xindex 
    280269; maintenant ion veut retrouver firstx, lastx correspondant a la 
    281270; boxzoom definie sur le widget... 
    282             domdef, boxzoom, gridtype = vargrid $ 
    283              , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] 
    284             grille, -1, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 
    285             widget_control, domainid, set_value = [firstx, lastx, boxzoom[2:3]] 
    286          ENDELSE 
     271        domdef, boxzoom, gridtype = vargrid $ 
     272                , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0] 
     273        grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 
     274        widget_control, domainid, set_value = [firstx, lastx, boxzoom[2:3]] 
     275      ENDELSE 
    287276; on met a jour la top_uvalue 
    288          widget_control, domainid, get_value = boxzoom 
    289          (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom 
    290       end 
    291       'Latitude / y index':begin  
    292          widget_control, event.top, get_uvalue = top_uvalue 
    293          numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
    294          options = extractatt(top_uvalue, 'options')    
    295          flags = extractatt(top_uvalue, 'optionsflag') 
    296          index = where(options EQ 'Latitude / y index') 
     277      widget_control, domainid, get_value = boxzoom 
     278      (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom 
     279    end 
     280    'Latitude / y index':begin  
     281      widget_control, event.top, get_uvalue = top_uvalue 
     282      numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 
     283      options = extractatt(top_uvalue, 'options')    
     284      flags = extractatt(top_uvalue, 'optionsflag') 
     285      index = where(options EQ 'Latitude / y index') 
    297286; on change le flag sur Latitude / y index 
    298          flag = 1-flags[index, numdessinin] & flag = flag[0] 
     287      flag = 1-flags[index, numdessinin] & flag = flag[0] 
    299288; on le reeatribue 
    300          (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
     289      (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 
    301290; maintenant on va changer les sliders definissant la boxzoom 
    302          domainid = widget_info(event.top, find_by_uname = 'domain') 
    303          boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
     291      domainid = widget_info(event.top, find_by_uname = 'domain') 
     292      boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
    304293; on veut retrouver le type de grille qui est utilisee 
    305          currentfile = extractatt(top_uvalue, 'currentfile') 
    306          listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
    307          indexvar = widget_info(widget_info(event.top, find_by_uname = 'champ'), /droplist_select) 
    308          vargrid = strupcase(listgrid[indexvar]) 
    309          if flag EQ 0 then BEGIN ; latitudes 
     294      currentfile = extractatt(top_uvalue, 'currentfile') 
     295      listgrid = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listgrid 
     296      listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
     297      vlstid = widget_info(event.top, find_by_uname = 'varlist') 
     298      namevar = widget_info(vlstid, /combobox_gettext) 
     299      indexvar = where(listvar EQ namevar) 
     300      vargrid = strupcase(listgrid[indexvar]) 
     301      if flag EQ 0 then BEGIN   ; latitudes 
    310302; on fait un domdef pour retrouver le lat1 lat2 correspondant a la 
    311303; boxzoom definie sur le widget...  
    312             domdef, boxzoom, gridtype = vargrid, /yindex $ 
    313              , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] 
    314             widget_control, domainid, set_value = [boxzoom[0:1], lat1, lat2] 
    315          ENDIF ELSE BEGIN       ; yindex 
     304        domdef, boxzoom, gridtype = vargrid, /yindex $ 
     305                , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] 
     306        widget_control, domainid, set_value = [boxzoom[0:1], lat1, lat2] 
     307      ENDIF ELSE BEGIN          ; yindex 
    316308; maintenant ion veut retrouver firsty, lasty correspondant a la 
    317309; boxzoom definie sur le widget... 
    318             domdef, boxzoom, gridtype = vargrid $ 
    319              , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] 
    320             grille, -1, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 
    321             widget_control, domainid, set_value = [boxzoom[0:1], firsty, lasty] 
    322          ENDELSE 
     310        domdef, boxzoom, gridtype = vargrid $ 
     311                , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0] 
     312        grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz 
     313        widget_control, domainid, set_value = [boxzoom[0:1], firsty, lasty] 
     314      ENDELSE 
    323315; on met a jour la top_uvalue 
    324          widget_control, domainid, get_value = boxzoom 
    325          (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom 
    326       end 
    327    endcase 
    328    return 
     316      widget_control, domainid, get_value = boxzoom 
     317      (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom 
     318    END 
     319  endcase 
     320  return 
    329321end 
    330 ;------------------------------------------------ 
    331 PRO xxxmenubar, parent, OPTIONS =options, _EXTRA = ex 
    332 ;       desc = [ '1\Colors' , $ 
    333 ;    '0\Red' , $ 
    334 ;    '0\Green' , $ 
    335 ;    '1\Blue' , $ 
    336 ;    '0\Light' , $ 
    337 ;    '0\Medium' , $ 
    338 ;    '0\Dark' , $ 
    339 ;    '0\Navy' , $ 
    340 ;    '2\Royal' , $ 
    341 ;    '0\Cyan' , $ 
    342 ;    '2\Magenta' , $ 
    343 ;    '2\Quit' ] 
    344    desc = [ '1\File' , $ 
    345             '0\Open' , $ 
    346             '0\New xxx' , $ 
    347             '2\Quit', $ 
    348             '1\Save as' , $ 
    349             '0\PS' , $ 
    350             '0\Anim' , $ 
    351             '0\Gif' , $ 
    352             '0\Script', $ 
    353             '0\Widget', $ 
    354             '2\Prompt', $ 
    355             '1\Flag options'] 
    356    descsuite = options 
    357    if n_elements(descsuite) GE 2 then $ 
    358     descsuite[0:n_elements(descsuite)-2] = '0\'+descsuite[0:n_elements(descsuite)-2] 
    359    descsuite[n_elements(descsuite)-1] = '2\'+descsuite[n_elements(descsuite)-1] 
    360    desc = [desc, descsuite] 
    361              
    362    menu = CW_PDMENU(parent, desc, /RETURN_NAME, /mbar, uname = 'menubar', uvalue = {name:'menubar'}, _EXTRA = ex) 
    363  
    364  
    365 ;------------------------------------------------ 
    366    return 
    367 end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/.idlwave_catalog

    r68 r69  
    22;; IDLWAVE catalog for library saxo 
    33;; Automatically Generated -- do not edit. 
    4 ;; Created by idlwave_catalog on Tue Jan 24 17:06:19 2006 
     4;; Created by idlwave_catalog on Thu May  4 08:42:55 2006 
    55;; 
    66(setq idlwave-library-catalog-libname "saxo") 
     
    99   ("CW_BGROUP_GETV" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(id, value)" (nil)) 
    1010   ("CW_BGROUP_EVENT" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(ev)" (nil)) 
    11    ("CW_BGROUP" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(parent, names)" (nil ("_EXTRA") ("BUTTON_UVALUE") ("COLUMN") ("EVENT_FUNCT") ("EXCLUSIVE") ("FONT") ("FRAME") ("IDS") ("LABEL_LEFT") ("LABEL_TOP") ("MAP") ("NO_RELEASE") ("NONEXCLUSIVE") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("ROW") ("SCROLL") ("SET_VALUE") ("SPACE") ("UNAME") ("UVALUE") ("X_SCROLL_SIZE") ("XOFFSET") ("XPAD") ("XSIZE") ("Y_SCROLL_SIZE") ("YOFFSET") ("YPAD") ("YSIZE"))) 
    12    ("testwid_event" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event" (nil)) 
    13    ("testwid" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, calendar, date0" (nil ("_extra"))) 
     11   ("CW_BGROUP" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(parent, names)" (nil ("BUTTON_UVALUE") ("COLUMN") ("EVENT_FUNCT") ("EXCLUSIVE") ("FONT") ("FRAME") ("IDS") ("LABEL_LEFT") ("LABEL_TOP") ("MAP") ("NO_RELEASE") ("NONEXCLUSIVE") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("ROW") ("SCROLL") ("SET_VALUE") ("SPACE") ("TAB_MODE") ("UNAME") ("UVALUE") ("X_SCROLL_SIZE") ("XOFFSET") ("XPAD") ("XSIZE") ("Y_SCROLL_SIZE") ("YOFFSET") ("YPAD") ("YSIZE"))) 
    1412   ("cw_calendar_set_value" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, id, value" (nil)) 
    1513   ("cw_calendar_get_value" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(id)" (nil)) 
    16    ("set_droplist" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename, date0" (nil)) 
     14   ("get_cal_value" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(id, winfoid)" (nil)) 
     15   ("set_cal_combobox" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename, date0" (nil)) 
    1716   ("move" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename" (nil)) 
    1817   ("cw_calendar_event" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(event)" (nil)) 
    19    ("cw_calendar" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(parent, calendar, date0)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE"))) 
     18   ("cw_calendar" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(parent, calendar, jdate0)" (nil ("_extra") ("CALTYPE") ("FAKECAL") ("UNAME") ("UVALUE"))) 
     19   ("cw_combobox_pm_set_value" pro nil (lib "cw_combobox_pm.pro" nil "saxo") "%s, id, value" (nil)) 
     20   ("cw_combobox_pm_get_value" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
     21   ("cw_combobox_pm_event" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
     22   ("cw_combobox_pm" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE") ("VALUE"))) 
    2023   ("cw_domain_set_value" pro nil (lib "cw_domain.pro" nil "saxo") "%s, id, value" (nil)) 
    2124   ("cw_domain_get_value" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(id)" (nil)) 
    2225   ("cw_domain_event" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(event)" (nil)) 
    23    ("cw_domain" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("BOXZOOM") ("COLUMN") ("ROW") ("STRICT") ("UNAME") ("UNZOOM") ("UVALUE"))) 
     26   ("cw_domain" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("BOXZOOM") ("STRICT") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    2427   ("cw_droplist_pm_set_value" pro nil (lib "cw_droplist_pm.pro" nil "saxo") "%s, id, value" (nil)) 
    2528   ("cw_droplist_pm_get_value" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
    2629   ("cw_droplist_pm_event" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
    2730   ("cw_droplist_pm" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE"))) 
    28    ("cw_fourparameter_get_value" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(id)" (nil)) 
    29    ("cw_fourparameter_event" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(event)" (nil)) 
    30    ("cw_fourparameter" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(parent, xgloin, xin, xminin, xmaxin, direction, type)" (nil ("CLEAR") ("EDITABLE") ("UNAME") ("UVALUE"))) 
    31    ("cw_miseenpage_event" fun nil (lib "cw_miseenpage.pro" nil "saxo") "Result = %s(event)" (nil)) 
    32    ("cw_miseenpage" fun nil (lib "cw_miseenpage.pro" nil "saxo") "Result = %s(parent, small)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    33    ("CW_PDMENU_EVENT" fun nil (lib "cw_pdmenu.pro" nil "saxo") "Result = %s(ev)" (nil)) 
    34    ("CW_PDMENU_BUILD" pro nil (lib "cw_pdmenu.pro" nil "saxo") "%s, parent, desc, cur, n, ev_type, full_qual_str, delim, ids, mbars, HELP_KW" (nil ("FONT"))) 
    35    ("CW_PDMENU" fun nil (lib "cw_pdmenu.pro" nil "saxo") "Result = %s(parent, desc)" (nil ("_EXTRA") ("COLUMN") ("DELIMITER") ("FONT") ("HELP") ("IDS") ("MBAR") ("RETURN_FULL_NAME") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("UNAME") ("UVALUE") ("XOFFSET") ("YOFFSET"))) 
     31   ("cw_pagelayout_event" fun nil (lib "cw_pagelayout.pro" nil "saxo") "Result = %s(event)" (nil)) 
     32   ("cw_pagelayout" fun nil (lib "cw_pagelayout.pro" nil "saxo") "Result = %s(parent, small)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    3633   ("cw_slide_slice_set_value" pro nil (lib "cw_slide_slice.pro" nil "saxo") "%s, id, value" (nil)) 
    3734   ("cw_slide_slice_event" fun nil (lib "cw_slide_slice.pro" nil "saxo") "Result = %s(event)" (nil)) 
    3835   ("cw_slide_slice" fun nil (lib "cw_slide_slice.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("boxzoom") ("COLUMN") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))) 
     36   ("decvalue" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(value)" (nil)) 
     37   ("decind" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(value)" (nil)) 
    3938   ("cw_slider_pm_set_value" pro nil (lib "cw_slider_pm.pro" nil "saxo") "%s, id, value" (nil)) 
    4039   ("cw_slider_pm_get_value" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
    4140   ("cw_slider_pm_event" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
    42    ("cw_slider_pm" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE") ("VERTICAL"))) 
     41   ("cw_slider_pm" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("MAXIMUM") ("MINIMUM") ("STRMINLEN") ("title") ("UNAME") ("UVALUE") ("VALUE"))) 
    4342   ("cw_specifie_set_value" pro nil (lib "cw_specifie.pro" nil "saxo") "%s, id, value" (nil)) 
    4443   ("cw_specifie_get_value" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(id)" (nil)) 
    4544   ("cw_specifie_event" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(event)" (nil)) 
    46    ("cw_specifie" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("FORXXX") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))) 
    47    ("testwid_event" pro nil (lib "testwid.pro" nil "saxo") "%s, event" (nil)) 
    48    ("testwid" pro nil (lib "testwid.pro" nil "saxo") "%s, calendar, date0" (nil ("_extra"))))) 
     45   ("cw_specifie" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("FORXXX") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))))) 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_bgroup.pro

    r51 r69  
    11; $Id$ 
    22; 
    3 ; Copyright (c) 1992-1998, Research Systems, Inc.  All rights reserved. 
    4 ;       Unauthorized reproduction prohibited. 
     3; Copyright (c) 1992-2005, Research Systems, Inc.  All rights reserved. 
     4;   Unauthorized reproduction prohibited. 
    55;+ 
    66; NAME: 
    7 ;       CW_BGROUP 
     7;   CW_BGROUP 
    88; 
    99; PURPOSE: 
    10 ;       CW_BGROUP is a compound widget that simplifies creating 
    11 ;       a base of buttons. It handles the details of creating the 
    12 ;       proper base (standard, exclusive, or non-exclusive) and filling 
    13 ;       in the desired buttons. Events for the individual buttons are 
    14 ;       handled transparently, and a CW_BGROUP event returned. This 
    15 ;       event can return any one of the following: 
    16 ;               - The Index of the button within the base. 
    17 ;               - The widget ID of the button. 
    18 ;               - The name of the button. 
    19 ;               - An arbitrary value taken from an array of User values. 
     10;   CW_BGROUP is a compound widget that simplifies creating 
     11;   a base of buttons. It handles the details of creating the 
     12;   proper base (standard, exclusive, or non-exclusive) and filling 
     13;   in the desired buttons. Events for the individual buttons are 
     14;   handled transparently, and a CW_BGROUP event returned. This 
     15;   event can return any one of the following: 
     16;       - The Index of the button within the base. 
     17;       - The widget ID of the button. 
     18;       - The name of the button. 
     19;       - An arbitrary value taken from an array of User values. 
    2020; 
    2121; CATEGORY: 
    22 ;       Compound widgets. 
     22;   Compound widgets. 
    2323; 
    2424; CALLING SEQUENCE: 
    25 ;               Widget = CW_BGROUP(Parent, Names) 
    26 ; 
    27 ;       To get or set the value of a CW_BGROUP, use the GET_VALUE and 
    28 ;       SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_BGROUP 
    29 ;       is: 
    30 ; 
    31 ;               ----------------------------------------------- 
    32 ;               Type            Value 
    33 ;               ----------------------------------------------- 
    34 ;               normal          None 
    35 ;               exclusive       Index of currently set button 
    36 ;               non-exclusive   Vector indicating the position 
    37 ;                               of each button (1-set, 0-unset) 
    38 ;               ----------------------------------------------- 
     25;       Widget = CW_BGROUP(Parent, Names) 
     26; 
     27;   To get or set the value of a CW_BGROUP, use the GET_VALUE and 
     28;   SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_BGROUP 
     29;   is: 
     30; 
     31;       ----------------------------------------------- 
     32;       Type        Value 
     33;       ----------------------------------------------- 
     34;       normal      None 
     35;       exclusive       Index of currently set button 
     36;       non-exclusive   Vector indicating the position 
     37;               of each button (1-set, 0-unset) 
     38;       ----------------------------------------------- 
    3939; 
    4040; 
    4141; INPUTS: 
    42 ;       Parent:         The ID of the parent widget. 
    43 ;       Names:          A string array, containing one string per button, 
    44 ;                       giving the name of each button. 
     42;       Parent:     The ID of the parent widget. 
     43;   Names:      A string array, containing one string per button, 
     44;           giving the name of each button. 
    4545; 
    4646; KEYWORD PARAMETERS: 
    4747; 
    48 ;       BUTTON_UVALUE:  An array of user values to be associated with 
    49 ;                       each button and returned in the event structure. 
    50 ;       COLUMN:         Buttons will be arranged in the number of columns 
    51 ;                       specified by this keyword. 
    52 ;       EVENT_FUNCT:    The name of an optional user-supplied event function  
    53 ;                       for buttons. This function is called with the return 
    54 ;                       value structure whenever a button is pressed, and  
    55 ;                       follows the conventions for user-written event 
    56 ;                       functions. 
    57 ;       EXCLUSIVE:      Buttons will be placed in an exclusive base, with 
    58 ;                       only one button allowed to be selected at a time. 
    59 ;       FONT:           The name of the font to be used for the button 
    60 ;                       titles. If this keyword is not specified, the default 
    61 ;                       font is used. 
    62 ;       FRAME:          Specifies the width of the frame to be drawn around 
    63 ;                       the base. 
    64 ;       IDS:            A named variable into which the button IDs will be 
    65 ;                       stored, as a longword vector. 
    66 ;       LABEL_LEFT:     Creates a text label to the left of the buttons. 
    67 ;       LABEL_TOP:      Creates a text label above the buttons. 
    68 ;       MAP:            If set, the base will be mapped when the widget 
    69 ;                       is realized (the default). 
    70 ;       NONEXCLUSIVE:   Buttons will be placed in an non-exclusive base. 
    71 ;                       The buttons will be independent. 
    72 ;       NO_RELEASE:     If set, button release events will not be returned. 
    73 ;       RETURN_ID:      If set, the VALUE field of returned events will be 
    74 ;                       the widget ID of the button. 
    75 ;       RETURN_INDEX:   If set, the VALUE field of returned events will be 
    76 ;                       the zero-based index of the button within the base. 
    77 ;                       THIS IS THE DEFAULT. 
    78 ;       RETURN_NAME:    If set, the VALUE field of returned events will be 
    79 ;                       the name of the button within the base. 
    80 ;       ROW:            Buttons will be arranged in the number of rows 
    81 ;                       specified by this keyword. 
    82 ;       SCROLL:         If set, the base will include scroll bars to allow 
    83 ;                       viewing a large base through a smaller viewport. 
    84 ;       SET_VALUE:      The initial value of the buttons. This is equivalent 
    85 ;                       to the later statement: 
    86 ; 
    87 ;                       WIDGET_CONTROL, widget, set_value=value 
    88 ; 
    89 ;       SPACE:          The space, in pixels, to be left around the edges 
    90 ;                       of a row or column major base. This keyword is 
    91 ;                       ignored if EXCLUSIVE or NONEXCLUSIVE are specified. 
    92 ;       UVALUE:         The user value to be associated with the widget. 
    93 ;       XOFFSET:        The X offset of the widget relative to its parent. 
    94 ;       XPAD:           The horizontal space, in pixels, between children 
    95 ;                       of a row or column major base. Ignored if EXCLUSIVE 
    96 ;                       or NONEXCLUSIVE are specified. 
    97 ;       XSIZE:          The width of the base.  
    98 ;       X_SCROLL_SIZE:  The width of the viewport if SCROLL is specified. 
    99 ;       YOFFSET:        The Y offset of the widget relative to its parent. 
    100 ;       YPAD:           The vertical space, in pixels, between children of 
    101 ;                       a row or column major base. Ignored if EXCLUSIVE 
    102 ;                       or NONEXCLUSIVE are specified. 
    103 ;       YSIZE:          The height of the base.  
    104 ;       Y_SCROLL_SIZE:  The height of the viewport if SCROLL is specified. 
     48;   BUTTON_UVALUE:  An array of user values to be associated with 
     49;           each button and returned in the event structure. 
     50;   COLUMN:     Buttons will be arranged in the number of columns 
     51;           specified by this keyword. 
     52;   EVENT_FUNCT:    The name of an optional user-supplied event function 
     53;           for buttons. This function is called with the return 
     54;           value structure whenever a button is pressed, and 
     55;           follows the conventions for user-written event 
     56;           functions. 
     57;   EXCLUSIVE:  Buttons will be placed in an exclusive base, with 
     58;           only one button allowed to be selected at a time. 
     59;   FONT:       The name of the font to be used for the button 
     60;           titles. If this keyword is not specified, the default 
     61;           font is used. 
     62;   FRAME:      Specifies the width of the frame to be drawn around 
     63;           the base. 
     64;   IDS:        A named variable into which the button IDs will be 
     65;           stored, as a longword vector. 
     66;   LABEL_LEFT: Creates a text label to the left of the buttons. 
     67;   LABEL_TOP:  Creates a text label above the buttons. 
     68;   MAP:        If set, the base will be mapped when the widget 
     69;           is realized (the default). 
     70;   NONEXCLUSIVE:   Buttons will be placed in an non-exclusive base. 
     71;           The buttons will be independent. 
     72;   NO_RELEASE: If set, button release events will not be returned. 
     73;   RETURN_ID:  If set, the VALUE field of returned events will be 
     74;           the widget ID of the button. 
     75;   RETURN_INDEX:   If set, the VALUE field of returned events will be 
     76;           the zero-based index of the button within the base. 
     77;           THIS IS THE DEFAULT. 
     78;   RETURN_NAME:    If set, the VALUE field of returned events will be 
     79;           the name of the button within the base. 
     80;   ROW:        Buttons will be arranged in the number of rows 
     81;           specified by this keyword. 
     82;   SCROLL:     If set, the base will include scroll bars to allow 
     83;           viewing a large base through a smaller viewport. 
     84;   SET_VALUE:  The initial value of the buttons. This is equivalent 
     85;           to the later statement: 
     86; 
     87;           WIDGET_CONTROL, widget, set_value=value 
     88; 
     89;   SPACE:      The space, in pixels, to be left around the edges 
     90;           of a row or column major base. This keyword is 
     91;           ignored if EXCLUSIVE or NONEXCLUSIVE are specified. 
     92;   UVALUE:     The user value to be associated with the widget. 
     93;   UNAME:      The user name to be associated with the widget. 
     94;   XOFFSET:    The X offset of the widget relative to its parent. 
     95;   XPAD:       The horizontal space, in pixels, between children 
     96;           of a row or column major base. Ignored if EXCLUSIVE 
     97;           or NONEXCLUSIVE are specified. 
     98;   XSIZE:      The width of the base. 
     99;   X_SCROLL_SIZE:  The width of the viewport if SCROLL is specified. 
     100;   YOFFSET:    The Y offset of the widget relative to its parent. 
     101;   YPAD:       The vertical space, in pixels, between children of 
     102;           a row or column major base. Ignored if EXCLUSIVE 
     103;           or NONEXCLUSIVE are specified. 
     104;   YSIZE:      The height of the base. 
     105;   Y_SCROLL_SIZE:  The height of the viewport if SCROLL is specified. 
    105106; 
    106107; OUTPUTS: 
     
    108109; 
    109110; SIDE EFFECTS: 
    110 ;       This widget generates event structures with the following definition: 
    111 ; 
    112 ;               event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 } 
    113 ; 
    114 ;       The SELECT field is passed through from the button event. VALUE is 
    115 ;       either the INDEX, ID, NAME, or BUTTON_UVALUE of the button, 
    116 ;       depending on how the widget was created. 
     111;   This widget generates event structures with the following definition: 
     112; 
     113;       event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 } 
     114; 
     115;   The SELECT field is passed through from the button event. VALUE is 
     116;   either the INDEX, ID, NAME, or BUTTON_UVALUE of the button, 
     117;   depending on how the widget was created. 
    117118; 
    118119; RESTRICTIONS: 
    119 ;       Only buttons with textual names are handled by this widget. 
    120 ;       Bitmaps are not understood. 
     120;   Only buttons with textual names are handled by this widget. 
     121;   Bitmaps are not understood. 
    121122; 
    122123; MODIFICATION HISTORY: 
    123 ;       15 June 1992, AB 
    124 ;       7 April 1993, AB, Removed state caching. 
    125 ;       6 Oct. 1994, KDB, Font keyword is not applied to the label. 
     124;   15 June 1992, AB 
     125;   7 April 1993, AB, Removed state caching. 
     126;   6 Oct. 1994, KDB, Font keyword is not applied to the label. 
    126127;       10 FEB 1995, DJC  fixed bad bug in event procedure, getting 
    127128;                         id of stash widget. 
    128 ;       11 April 1995, AB Removed Motif special cases. 
     129;   11 April 1995, AB Removed Motif special cases. 
    129130;- 
    130131 
    131132 
    132133pro CW_BGROUP_SETV, id, value 
    133  
    134   ON_ERROR, 2                                           ;return to caller 
     134  compile_opt hidden 
     135 
     136  ON_ERROR, 2                       ;return to caller 
    135137 
    136138  stash = WIDGET_INFO(id, /CHILD) 
     
    140142    0: message,'unable to set plain button group value' 
    141143    1: begin 
    142           WIDGET_CONTROL, SET_BUTTON=0, state.ids[state.excl_pos] 
    143           state.excl_pos = value 
    144           WIDGET_CONTROL, /SET_BUTTON, state.ids[value] 
    145         end 
     144      WIDGET_CONTROL, SET_BUTTON=0, state.ids[state.excl_pos] 
     145      state.excl_pos = value 
     146      WIDGET_CONTROL, /SET_BUTTON, state.ids[value] 
     147    end 
    146148    2: begin 
    147           n = n_elements(value)-1 
    148           for i = 0, n do begin 
    149             state.nonexcl_curpos[i] = value[i] 
    150             WIDGET_CONTROL, state.ids[i], SET_BUTTON=value[i] 
    151           endfor 
    152         end 
     149      n = n_elements(value)-1 
     150      for i = 0, n do begin 
     151        state.nonexcl_curpos[i] = value[i] 
     152        WIDGET_CONTROL, state.ids[i], SET_BUTTON=value[i] 
     153      endfor 
     154    end 
    153155  endcase 
    154156 
     
    160162function CW_BGROUP_GETV, id, value 
    161163 
    162    ON_ERROR, 2                  ;return to caller 
    163  
    164    stash = WIDGET_INFO(id, /CHILD) 
    165    WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
    166  
    167    case state.type of 
    168       0: message,'unable to get plain button group value' 
     164  compile_opt hidden 
     165  ON_ERROR, 2                       ;return to caller 
     166 
     167  stash = WIDGET_INFO(id, /CHILD) 
     168  WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
     169 
     170  case state.type of 
     171    0: message, 'unable to get plain button group value' 
    169172;    1: ret = state.excl_pos 
    170       1: ret = state.ret_arr[state.excl_pos] 
     173    1: ret = state.ret_arr[state.excl_pos] 
    171174;    2: ret = state.nonexcl_curpos 
    172       2: BEGIN  
    173          index = where(state.nonexcl_curpos NE 0) 
    174          if index[0] EQ -1 then begin 
    175             if size(state.ret_arr, /type) EQ 7 then ret = '' ELSE ret = -1 
    176          ENDIF ELSE ret = state.ret_arr[index] 
    177       END 
    178    endcase 
    179  
    180    WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    181  
    182    return, ret 
     175    2: BEGIN  
     176      index = where(state.nonexcl_curpos NE 0) 
     177      if index[0] EQ -1 then begin 
     178        if size(state.ret_arr, /type) EQ 7 then ret = '' ELSE ret = -1 
     179      ENDIF ELSE ret = state.ret_arr[index] 
     180    END 
     181  endcase 
     182   
     183  WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
     184 
     185  return, ret 
    183186 
    184187end 
     
    187190 
    188191function CW_BGROUP_EVENT, ev 
     192  compile_opt hidden 
    189193  WIDGET_CONTROL, ev.handler, GET_UVALUE=stash 
    190194  WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
    191195  WIDGET_CONTROL, ev.id, get_uvalue=uvalue 
    192196 
    193   ret = 1                       ;Assume we return a struct 
     197  ret = 1           ;Assume we return a struct 
    194198  case state.type of 
    195199    0: 
    196200    1: if (ev.select eq 1) then begin 
    197           state.excl_pos = uvalue 
    198         ENDIF else begin 
    199           if (state.no_release ne 0) then ret = 0 
    200         ENDELSE 
     201      state.excl_pos = uvalue 
     202    ENDIF else begin 
     203      if (state.no_release ne 0) then ret = 0 
     204    ENDELSE 
    201205    2: begin 
    202           ; Keep track of the current state 
    203           state.nonexcl_curpos[uvalue] = ev.select 
     206      ; Keep track of the current state 
     207      state.nonexcl_curpos[uvalue] = ev.select 
    204208          if (state.no_release ne 0) and (ev.select eq 0) then ret = 0 
    205         end 
     209    end 
    206210  endcase 
    207211 
    208   if ret then begin             ;Return a struct? 
     212  if ret then begin     ;Return a struct? 
    209213      ret = { ID:state.base, TOP:ev.top, HANDLER:0L, SELECT:ev.select, $ 
    210                VALUE:state.ret_arr[uvalue] } 
     214           VALUE:state.ret_arr[uvalue] } 
    211215      efun = state.efun 
    212216      WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    213217      if efun ne '' then return, CALL_FUNCTION(efun, ret) $ 
    214218      else return, ret 
    215   endif else begin              ;Trash the event 
     219  endif else begin      ;Trash the event 
    216220      WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    217221      return, 0 
     
    226230 
    227231function CW_BGROUP, parent, names, $ 
    228         BUTTON_UVALUE = button_uvalue, COLUMN=column, EVENT_FUNCT = efun, $ 
    229         EXCLUSIVE=excl, FONT=font, FRAME=frame, IDS=ids, LABEL_TOP=label_top, $ 
    230         LABEL_LEFT=label_left, MAP=map, $ 
    231         NONEXCLUSIVE=nonexcl, NO_RELEASE=no_release, RETURN_ID=return_id, $ 
    232         RETURN_INDEX=return_index, RETURN_NAME=return_name, $ 
    233         ROW=row, SCROLL=scroll, SET_VALUE=sval, SPACE=space, UVALUE=uvalue, UNAME = uname, $ 
    234         XOFFSET=xoffset, XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size,$ 
    235         YOFFSET=yoffset, YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
    236            _EXTRA = ex 
     232    BUTTON_UVALUE = button_uvalue, COLUMN=column, EVENT_FUNCT = efun, $ 
     233    EXCLUSIVE=excl, FONT=font, FRAME=frame, IDS=ids, LABEL_TOP=label_top, $ 
     234    LABEL_LEFT=label_left, MAP=map, $ 
     235    NONEXCLUSIVE=nonexcl, NO_RELEASE=no_release, RETURN_ID=return_id, $ 
     236    RETURN_INDEX=return_index, RETURN_NAME=return_name, $ 
     237    ROW=row, SCROLL=scroll, SET_VALUE=sval, SPACE=space, $ 
     238    TAB_MODE=tab_mode, UVALUE=uvalue, $ 
     239    XOFFSET=xoffset, XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size,$ 
     240    YOFFSET=yoffset, YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
     241    UNAME=uname 
    237242 
    238243 
    239244  IF (N_PARAMS() ne 2) THEN MESSAGE, 'Incorrect number of arguments' 
    240245 
    241   ON_ERROR, 2                                           ;return to caller 
     246  ON_ERROR, 2                       ;return to caller 
    242247 
    243248  ; Set default values for the keywords 
    244249  version = WIDGET_INFO(/version) 
    245250  if (version.toolkit eq 'OLIT') then def_space_pad = 4 else def_space_pad = 3 
    246   IF (N_ELEMENTS(column) eq 0)          then column = 0 
    247   IF (N_ELEMENTS(excl) eq 0)            then excl = 0 
    248   IF (N_ELEMENTS(frame) eq 0)           then frame = 0 
    249   IF (N_ELEMENTS(map) eq 0)             then map=1 
    250   IF (N_ELEMENTS(nonexcl) eq 0)         then nonexcl = 0 
    251   IF (N_ELEMENTS(no_release) eq 0)      then no_release = 0 
    252   IF (N_ELEMENTS(row) eq 0)             then row = 0 
    253   IF (N_ELEMENTS(scroll) eq 0)          then scroll = 0 
    254   IF (N_ELEMENTS(space) eq 0)           then space = def_space_pad 
    255   IF (N_ELEMENTS(uvalue) eq 0)          then uvalue = 0 
    256   IF (N_ELEMENTS(uname) eq 0)           then uname = ' ' 
    257   IF (N_ELEMENTS(xoffset) eq 0)         then xoffset=0 
    258   IF (N_ELEMENTS(xpad) eq 0)            then xpad = def_space_pad 
    259   IF (N_ELEMENTS(xsize) eq 0)           then xsize = 0 
    260   IF (N_ELEMENTS(x_scroll_size) eq 0)   then x_scroll_size = 0 
    261   IF (N_ELEMENTS(yoffset) eq 0)         then yoffset=0 
    262   IF (N_ELEMENTS(ypad) eq 0)            then ypad = def_space_pad 
    263   IF (N_ELEMENTS(ysize) eq 0)           then ysize = 0 
    264   IF (N_ELEMENTS(y_scroll_size) eq 0)   then y_scroll_size = 0 
    265    
     251  IF (N_ELEMENTS(column) eq 0)      then column = 0 
     252  IF (N_ELEMENTS(excl) eq 0)        then excl = 0 
     253  IF (N_ELEMENTS(frame) eq 0)       then frame = 0 
     254  IF (N_ELEMENTS(map) eq 0)     then map=1 
     255  IF (N_ELEMENTS(nonexcl) eq 0)     then nonexcl = 0 
     256  IF (N_ELEMENTS(no_release) eq 0)  then no_release = 0 
     257  IF (N_ELEMENTS(row) eq 0)     then row = 0 
     258  IF (N_ELEMENTS(scroll) eq 0)      then scroll = 0 
     259  IF (N_ELEMENTS(space) eq 0)       then space = def_space_pad 
     260  IF (N_ELEMENTS(uname) eq 0)      then uname = 'CW_BGROUP_UNAME' 
     261  IF (N_ELEMENTS(uvalue) eq 0)      then uvalue = 0 
     262  IF (N_ELEMENTS(xoffset) eq 0)     then xoffset=0 
     263  IF (N_ELEMENTS(xpad) eq 0)        then xpad = def_space_pad 
     264  IF (N_ELEMENTS(xsize) eq 0)       then xsize = 0 
     265  IF (N_ELEMENTS(x_scroll_size) eq 0)   then x_scroll_size = 0 
     266  IF (N_ELEMENTS(yoffset) eq 0)     then yoffset=0 
     267  IF (N_ELEMENTS(ypad) eq 0)        then ypad = def_space_pad 
     268  IF (N_ELEMENTS(ysize) eq 0)       then ysize = 0 
     269  IF (N_ELEMENTS(y_scroll_size) eq 0)   then y_scroll_size = 0 
     270 
    266271 
    267272 
     
    269274  top_base = 0L 
    270275  if (n_elements(label_top) ne 0) then begin 
    271     next_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, /COLUMN, _EXTRA = ex) 
     276    next_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, /COLUMN) 
    272277    if(keyword_set(font))then $ 
    273278       junk = WIDGET_LABEL(next_base, value=label_top,font=font) $ 
     
    275280    top_base = next_base 
    276281  endif else next_base = parent 
     282 
    277283  if (n_elements(label_left) ne 0) then begin 
    278     next_base = WIDGET_BASE(next_base, XOFFSET=xoffset, YOFFSET=yoffset, /ROW, _EXTRA = ex) 
     284    next_base = WIDGET_BASE(next_base, XOFFSET=xoffset, YOFFSET=yoffset, /ROW) 
    279285    if(keyword_set(font))then $ 
    280286       junk = WIDGET_LABEL(next_base, value=label_left, font=font) $ 
     
    284290  ; We need some kind of outer base to hold the users UVALUE 
    285291  if (top_base eq 0L) then begin 
    286     top_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, _EXTRA = ex) 
     292    top_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset) 
    287293    next_base = top_base 
    288294  endif 
    289295  If (top_base EQ next_base) THEN $ 
    290      next_base = WIDGET_BASE(top_base, Xpad=1, Ypad=1, Space=1, _EXTRA = ex) 
     296     next_base = WIDGET_BASE(top_base, Xpad=1, Ypad=1, Space=1) 
    291297 
    292298  ; Set top level base attributes 
    293299  WIDGET_CONTROL, top_base, MAP=map, $ 
    294         FUNC_GET_VALUE='CW_BGROUP_GETV', PRO_SET_VALUE='CW_BGROUP_SETV', $ 
    295         SET_UVALUE=uvalue, SET_UNAME = uname 
     300    FUNC_GET_VALUE='CW_BGROUP_GETV', PRO_SET_VALUE='CW_BGROUP_SETV', $ 
     301    SET_UVALUE=uvalue, SET_UNAME=uname 
     302 
     303  ; Tabbing 
     304  if (n_elements(tab_mode) ne 0) then begin 
     305    WIDGET_CONTROL, top_base, TAB_MODE=tab_mode 
     306    WIDGET_CONTROL, next_base, TAB_MODE=tab_mode 
     307  end 
    296308 
    297309  ; The actual button holding base 
    298310  base = WIDGET_BASE(next_base, COLUMN=column, EXCLUSIVE=excl, FRAME=frame, $ 
    299         NONEXCLUSIVE=nonexcl, ROW=row, SCROLL=scroll, SPACE=space, $ 
    300         XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size, $ 
    301         YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
    302         EVENT_FUNC='CW_BGROUP_EVENT', _EXTRA = ex, $ 
    303         UVALUE=WIDGET_INFO(top_base, /child)) 
     311    NONEXCLUSIVE=nonexcl, ROW=row, SCROLL=scroll, SPACE=space, $ 
     312    XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size, $ 
     313    YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
     314    EVENT_FUNC='CW_BGROUP_EVENT', $ 
     315    UVALUE=WIDGET_INFO(top_base, /child)) 
    304316 
    305317 
     
    308320  for i = 0, n-1 do begin 
    309321    if (n_elements(font) eq 0) then begin 
    310       ids[i] = WIDGET_BUTTON(base, value=names[i], UVALUE=i) 
     322      ids[i] = WIDGET_BUTTON(base, value=names[i], UVALUE=i, $ 
     323      UNAME=uname+'_BUTTON'+STRTRIM(i,2)) 
    311324    endif else begin 
    312       ids[i] = WIDGET_BUTTON(base, value=names[i], FONT=font, UVALUE=i) 
     325      ids[i] = WIDGET_BUTTON(base, value=names[i], FONT=font, $ 
     326      UVALUE=i, UNAME=uname+'_BUTTON'+STRTRIM(i,2)) 
    313327    endelse 
    314328  endfor 
     
    316330  ; Keep the state info in the real (inner) base UVALUE. 
    317331  ; Pick an event value type: 
    318   ;     0 - Return ID 
    319   ;     1 - Return INDEX 
    320   ;     2 - Return NAME 
     332  ; 0 - Return ID 
     333  ; 1 - Return INDEX 
     334  ; 2 - Return NAME 
    321335  ret_type = 1 
    322336  if KEYWORD_SET(RETURN_ID) then ret_type = 0 
     
    334348  if (nonexcl ne 0) then type = 2 
    335349  if n_elements(efun) le 0 then efun = '' 
    336   state = { type:type, $        ; 0-Standard, 1-Exclusive, 2-Non-exclusive 
    337             base: top_base, $   ; cw_bgroup base... 
    338             ret_arr:ret_arr, $  ; Vector of event values 
    339             efun : efun, $      ; Name of event fcn 
    340             nonexcl_curpos:intarr(n), $ ; If non-exclus, tracks state 
    341             excl_pos:0, $                       ; If exclusive, current button 
    342             ids:ids, $                  ; Ids of buttons 
    343             no_release:no_release } 
     350  state = { type:type, $    ; 0-Standard, 1-Exclusive, 2-Non-exclusive 
     351        base: top_base, $   ; cw_bgroup base... 
     352        ret_arr:ret_arr, $  ; Vector of event values 
     353        efun : efun, $  ; Name of event fcn 
     354        nonexcl_curpos:intarr(n), $ ; If non-exclus, tracks state 
     355        excl_pos:0, $           ; If exclusive, current button 
     356        ids:ids, $          ; Ids of buttons 
     357        no_release:no_release } 
    344358  WIDGET_CONTROL, WIDGET_INFO(top_base, /CHILD), SET_UVALUE=state, /NO_COPY 
    345359 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_calendar.pro

    r51 r69  
    11; IDL> testwid,julday(1,1,1980)+lindgen(100)*5 
    22; 
    3 PRO testwid_event, event 
    4     DroplistId = widget_info(event.top,find_by_uname = 'c''est lui') 
    5    widget_control, event.id, get_uvalue=uval 
    6    if n_elements(uval) EQ 0 then return 
    7    case uval of 
    8       'done':widget_control, event.top, /destroy 
    9       'set':BEGIN  
    10          widget_control, event.id, get_value = value 
    11          widget_control, DroplistId, set_value = value 
    12       END 
    13       'get':BEGIN  
    14          widget_control, DroplistId, get_value = value 
    15          help,  value, /struct 
    16       END 
    17       ELSE: 
    18    endcase 
     3; PRO testwid_event, event 
     4;     ComboboxId = widget_info(event.top,find_by_uname = 'c''est lui') 
     5;    widget_control, event.id, get_uvalue=uval 
     6;    if n_elements(uval) EQ 0 then return 
     7;    case uval of 
     8;       'done':widget_control, event.top, /destroy 
     9;       'set':BEGIN  
     10;          widget_control, event.id, get_value = value 
     11;          widget_control, ComboboxId, set_value = value 
     12;       END 
     13;       'get':BEGIN  
     14;          widget_control, ComboboxId, get_value = value 
     15;          help,  value, /struct 
     16;       END 
     17;       ELSE: 
     18;    endcase 
     19;    return 
     20; end 
     21; PRO testwid, calendar, date0, _extra = ex 
     22;    base=widget_base(/COLUMN) 
     23; print, 'base=', base 
     24;    nothing = widget_label(base, value = 'beginning of the test') 
     25; ; 
     26;    nothing = cw_calendar(base,calendar, date0, _extra = ex, uname = 'c''est lui', uvalue = 'c''est lui' ) 
     27; print, 'cw_calendar ID =', nothing 
     28; ; 
     29;    nothing = widget_label(base, value = 'end of the test') 
     30;     nothing = widget_text(base, value = string(calendar[0]), uvalue = 'set', /editable) 
     31;     nothing = widget_button(base, value = 'get', uvalue = 'get') 
     32;     nothing = widget_button(base, value = 'done', uvalue = 'done') 
     33;    widget_control, base, /REALIZE 
     34;    xmanager,'testwid', base 
     35;    return 
     36; END 
     37; 
     38; 
     39; 
     40PRO cw_calendar_set_value, id, value 
     41; 
     42  compile_opt strictarr, strictarrsubs  
     43; 
     44; 
     45@cm_4cal 
     46; get back the calendar and its related informations 
     47  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     48  widget_control, winfo_id, get_uvalue = infowid 
     49  key_caltype = infowid.caltype 
     50   
     51; high freqeuncy calendar 
     52  IF keyword_set(infowid.fakecal) THEN BEGIN 
     53    value2 = date2jul(long(value)) - infowid.fakecal 
     54    IF value2 LT n_elements(infowid.calendar) AND value2 GE 0 THEN BEGIN   
     55      stepid = widget_info(id, find_by_uname = 'step') 
     56      widget_control, stepid, set_value = {combobox_select:value2} 
     57      infowid.date = jul2date(value2 + infowid.fakecal) 
     58      widget_control, winfo_id, set_uvalue = infowid 
     59    ENDIF 
     60  ENDIF ELSE BEGIN  
     61; 
     62    value = long(value[0]) 
     63; define year month day 
     64    year = value/10000l 
     65    month = (value MOD 10000L)/100L 
     66    day = value MOD 100L 
     67; make sure the values correspond to real dates 
     68    if year EQ 0 then year = -1  
     69    if month EQ 0 then month = 6 
     70    if day EQ 0 then day = 15 
     71; check that the date exists in the calendar 
     72  if (where(infowid.calendar EQ julday(month, day, year)))[0] EQ - 1 then return 
     73; update the value of infocal 
     74    infowid.date = value 
     75    widget_control, winfo_id, set_uvalue = infowid 
     76; update the combobox if needed... 
     77    possiblecase = ['day', 'month', 'year'] 
     78    for name = 2, 0, -1 do BEGIN 
     79; call set_cal_combobox with out = 2 to specify that the call is coming 
     80; from cw_calendar_set_value 
     81      if widget_info(id, find_by_uname = possiblecase[name]) NE 0 then $ 
     82         set_cal_combobox, {handler:id, out:2}, possiblecase[name], value 
     83    ENDFOR 
     84  ENDELSE 
     85; 
     86  return 
     87end 
     88;---------------------------------------------------------------------- 
     89FUNCTION cw_calendar_get_value, id 
     90; 
     91  compile_opt strictarr, strictarrsubs  
     92; 
     93  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     94  widget_control, winfo_id, get_uvalue = infowid 
     95  return, infowid.date 
     96END 
     97;---------------------------------------------------------------------- 
     98FUNCTION get_cal_value, id, winfoid  
     99; 
     100  compile_opt strictarr, strictarrsubs  
     101; 
     102  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     103  widget_control, winfo_id, get_uvalue = infowid 
     104  oldate = infowid.date 
     105;-------------day----------------- 
     106  wid_id = widget_info(id, find_by_uname = 'day') 
     107  if wid_id NE 0 then BEGIN 
     108    widget_control, wid_id, get_value = wid_value 
     109    date = long(wid_value.combobox_gettext) 
     110  ENDIF ELSE date = oldate MOD 100L 
     111;-------------month--------------- 
     112  wid_id = widget_info(id, find_by_uname = 'month') 
     113  if wid_id NE 0 then BEGIN 
     114    widget_control, wid_id, get_value = wid_value 
     115    allmonths = string(format = '(C(CMoA))', 31*(indgen(12))) 
     116    month = (where(allmonths EQ wid_value.combobox_gettext))[0] + 1  
     117    date = date + 100L * long(month) 
     118  ENDIF ELSE date = date + (oldate MOD 10000L)/100L 
     119;-------------year---------------- 
     120  wid_id = widget_info(id, find_by_uname = 'year') 
     121  widget_control, wid_id, get_value = wid_value 
     122  date = date + 10000L * long(wid_value.combobox_gettext) 
     123; 
     124  IF arg_present(winfoid) NE 0 THEN BEGIN 
     125    winfoid = winfo_id 
     126    infowid.date = date 
     127    return, infowid 
     128  ENDIF ELSE return, date 
     129end 
     130;---------------------------------------------------------------------- 
     131; redefine the value and index position of the combobox 
     132PRO set_cal_combobox, event, casename, date0 
     133; 
     134  compile_opt strictarr, strictarrsubs  
     135; 
     136; casename: Which widget shall we move: 'day', 'month' or 'year' ? 
     137  wid_id = widget_info(event.handler, find_by_uname = casename) 
     138; we get back the calendar... 
     139  winfo_id = widget_info(event.handler, find_by_uname = 'infocal') 
     140  widget_control, winfo_id, get_uvalue = infowid 
     141  caldat, infowid.calendar, monthcal, daycal, yearcal 
     142; ... and the current date 
     143  IF n_elements(date0) EQ 0 then date0 = get_cal_value(event.handler) 
     144  year0 = date0/10000L 
     145  month0 = (date0 MOD 10000L)/100L 
     146  day0 = date0 MOD 100L 
     147; index of days/months/years according to date0 
     148  case casename of 
     149    'day':BEGIN  
     150; list of days corresponding to month0 and year0 
     151      index = where(monthcal EQ month0 AND yearcal EQ year0) 
     152      current = daycal[index] 
     153    END 
     154    'month':BEGIN  
     155; list of months corresponding to year0 
     156      index = where(yearcal EQ year0) 
     157      current = monthcal[index] 
     158; keep only the uniq values 
     159      indexbis = uniq(current) 
     160      index = index[indexbis] 
     161      current = current[indexbis] 
     162    END 
     163    'year':BEGIN  
     164; keep only the uniq years 
     165      index = uniq(yearcal) 
     166      current = yearcal[index] 
     167    END 
     168  ENDCASE 
     169; we update the uvalue of the widget 
     170  widget_control, wid_id, set_uvalue = {name:casename} 
     171; for event.out = 0, we store the previous position of the combobox to use 
     172; it as the default position. 
     173  IF event.out EQ 0 THEN widget_control, wid_id, get_value = oldselect 
     174; we redefine the new list 
     175  if casename EQ 'month' then begin 
     176    widget_control, wid_id, set_value = string(format = '(C(CMoA))', 31*(current-1)) 
     177  ENDIF ELSE BEGIN  
     178    widget_control, wid_id, set_value = strtrim(current, 1) 
     179  ENDELSE 
     180; specify the index position within the new list of values. 
     181  widget_control, wid_id, get_value = combobox 
     182  CASE event.out OF 
     183; -1: we put to the biggest position 
     184    -1:selected = combobox.combobox_number - 1 
     185; 0: same as the previous position is the best choice... 
     186    0:selected = oldselect.combobox_index < (combobox.combobox_number - 1) 
     187; 1: we put to the smallest position 
     188    1:selected = 0 
     189; 2: a new date has been specified... 
     190    2:BEGIN  
     191      case casename of 
     192        'day':selected = (where(current EQ day0))[0] 
     193        'month':selected = (where(current EQ month0))[0] 
     194        'year':selected = (where(current EQ year0))[0] 
     195      ENDCASE 
     196    END 
     197  ENDCASE 
     198  widget_control, wid_id, set_value = {combobox_select:selected} 
     199; update the date... 
     200  infowid.date = get_cal_value(event.handler) 
     201  widget_control, winfo_id, set_uvalue = infowid 
     202  return 
     203end 
     204;---------------------------------------------------------------------- 
     205; move cyclicly the calendar to the 
     206; value 0 if event.out=1 or combobox_number-1 if event.out=-1 
     207PRO move, event, casename 
     208; 
     209  compile_opt strictarr, strictarrsubs  
     210; 
     211   possiblecase = ['day', 'month', 'year', 'impossiblecase'] 
     212   id = widget_info(event.handler, find_by_uname = casename) 
     213   widget_control, id, get_value = wvalue 
     214; we try to move but we are already at the beginning/end of the combobox 
     215; wvalue.combobox_index EQ (wvalue.combobox_number-1) and event.out EQ 1 
     216; wvalue.combobox_index EQ 0 and event.out EQ -1 (move is not called when out eq 0) 
     217   whichcase = (where(possiblecase EQ casename))[0] 
     218   if wvalue.combobox_index EQ (wvalue.combobox_number-1)*(event.out EQ 1) THEN BEGIN 
     219      if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then begin 
     220; it is impossible to move the "next" combobox... 
     221         widget_control, id, get_value = widvalue 
     222; we set to "widvalue.combobox_number-1" when event.out EQ -1 
     223; and to 0 when event.out EQ 1 
     224         selected = (widvalue.combobox_number-1)*(event.out EQ -1) 
     225         widget_control, id, set_value = {combobox_select:selected} 
     226; we call move for the next combobox 
     227      ENDIF ELSE move, event, possiblecase[whichcase+1] 
     228; it is possible to move from +/- 1 
     229   ENDIF ELSE widget_control, id, set_value = {combobox_select:wvalue.combobox_index+event.out} 
     230   set_cal_combobox, event, possiblecase[whichcase-1] 
    19231   return 
    20232end 
    21 PRO testwid, calendar, date0, _extra = ex 
    22    base=widget_base(/COLUMN) 
    23 print, 'base=', base 
    24    nothing = widget_label(base, value = 'beginning of the test') 
    25 ; 
    26    nothing = cw_calendar(base,calendar, date0, _extra = ex, uname = 'c''est lui', uvalue = 'c''est lui' ) 
    27 print, 'cw_calendar ID =', nothing 
    28 ; 
    29    nothing = widget_label(base, value = 'end of the test') 
    30     nothing = widget_text(base, value = string(calendar[0]), uvalue = 'set', /editable) 
    31     nothing = widget_button(base, value = 'get', uvalue = 'get') 
    32     nothing = widget_button(base, value = 'done', uvalue = 'done') 
    33    widget_control, base, /REALIZE 
    34    xmanager,'testwid', base 
    35    return 
    36 END 
    37 ; 
    38 ; 
    39 ; 
    40 PRO cw_calendar_set_value, id, value 
    41    possiblecase = ['day', 'month', 'year', 'century'] 
    42    name = 0 
    43    repeat begin 
    44       wid_id = widget_info(id,find_by_uname = possiblecase[name]) 
    45       name = name+1 
    46    endrep until wid_id NE 0 
    47    widget_control,wid_id, get_uvalue=wid_uvalue 
    48    value = long(value[0]) 
    49    year = value/10000l & month = (value-year*10000l)/100L & day = value-year*10000l-month*100L 
    50    if year EQ 0 then year = -1 & if month EQ 0 then month = 6 & if day EQ 0 then day = 15 
    51    julianvalue = julday(month, day, year) 
    52    if (where(wid_uvalue.calendar EQ julianvalue))[0] EQ - 1 then return 
    53    for name = 3, 0, -1 do BEGIN 
    54       if widget_info(id,find_by_uname = possiblecase[name]) NE 0  then $ 
    55          set_droplist, {handler:id, out:2}, possiblecase[name], value 
    56    endfor 
    57    return 
    58 end 
    59 ;---------------------------------------------------------------------- 
    60 FUNCTION cw_calendar_get_value, id 
    61    possiblecase = ['day', 'month', 'year', 'century'] 
    62    name = 0 
    63    repeat begin 
    64       wid_id = widget_info(id,find_by_uname = possiblecase[name]) 
    65       name = name+1 
    66    endrep until wid_id NE 0 
    67    widget_control,wid_id, get_uvalue=wid_uvalue 
    68    caldat, wid_uvalue.calendar,monthcal,daycal,yearcal 
    69    centurycal = yearcal/100L 
    70    if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then $  
    71     yearcal = yearcal-centurycal*100 
    72    droplistname = ['day','month','year','century'] 
    73    for name = 0, n_elements(droplistname)-1  do begin 
    74       nothing = execute('wid_id = widget_info(id,find_by_uname = '''+droplistname[name]+''')') 
    75       if wid_id NE 0 then begin 
    76          widget_control,wid_id, get_value=wid_value 
    77          widget_control,wid_id, get_uvalue=wid_uvalue 
    78          nothing = execute('array = '+droplistname[name]+'cal[wid_uvalue.index]') 
    79          nothing = execute(droplistname[name]+' = array[wid_value.droplist_select]') 
    80       ENDIF ELSE nothing = execute(droplistname[name]+'= 0') 
    81    ENDFOR 
    82    return, 10000L*(year+100L*century)+100L*month+day 
    83 end 
    84 ;---------------------------------------------------------------------- 
    85 PRO set_droplist, event, casename, date0 
    86 ; casename: quel est le widget que l''on veut bouger: 'day', 'month', 
    87 ; 'year', 'century' ??? 
    88    wid_id = widget_info(event.handler,find_by_uname = casename) 
    89    possiblecase = ['day', 'month', 'year', 'century'] 
    90    whichcase = (where(possiblecase EQ casename))[0] 
    91 ; on recupere la uvalue attache au widget et qui nous donne ques sont 
    92 ; les 'day', 'month', 'year', 'century' en train d''etre traites et le 
    93 ; calendrier 
    94 ; on recuper ici le calendrier 
    95    widget_control,wid_id, get_uvalue=wid_uvalue 
    96    caldat, wid_uvalue.calendar,monthcal,daycal,yearcal 
    97    centurycal = yearcal/100 
    98 ; et la date courrante 
    99    if n_elements(date0) EQ 0 then date0 = cw_calendar_get_value(event.handler) 
    100    year0 = date0/10000l 
    101    century0 = year0/100 
    102    month0 = (date0-year0*10000l)/100L 
    103    day0 = date0-year0*10000l-month0*100L 
    104    if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then BEGIN  
    105       yearcal = yearcal-centurycal*100 
    106       year0   = year0  -centurycal*100 
    107    ENDIF 
    108 ; index: 'day', 'month', 'year', 'century' possibles pour la date donnee 
    109    case casename of 
    110       'day':index = where(monthcal EQ month0 AND yearcal EQ year0 AND centurycal EQ century0) 
    111       'month':index = where(yearcal EQ year0 AND centurycal EQ century0) 
    112       'year':index = where(centurycal EQ century0) 
    113       'century':index = uniq(centurycal, sort(long(centurycal))) 
    114    ENDCASE 
    115 ; current: liste des mois possibles par ex 
    116    nothing = execute('current = '+possiblecase[whichcase]+'cal[index]') 
    117 ; supprime les boublons 
    118    indexbis = uniq(current, sort(current)) 
    119    index = index[indexbis]; 
    120 ; nouvelle liste des possibilites offertes par la droplist (par ex 
    121 ; liste des mois possibles) 
    122    current = current[indexbis] 
    123 ; on accualise la uvalue du widget (par ex on met la nouvelle liste de 
    124 ; mois possibles) 
    125    widget_control, wid_id, set_uvalue = {name:wid_uvalue.name, calendar:wid_uvalue.calendar, index:index} 
    126 ;on met en place la nouvelle liste possible 
    127    widget_control, wid_id, get_value = oldselect 
    128    if casename EQ 'month' then begin 
    129       widget_control, wid_id, set_value = string(format='(C(CMoA))',31*(current-1)) 
    130    ENDIF ELSE BEGIN  
    131       widget_control, wid_id, set_value = strtrim(current, 1) 
    132   ENDELSE 
    133 ; quel est l''index qu'il faut selectionner parmis la nouvelle liste! 
    134    widget_control, wid_id, get_value = droplist 
    135    if event.out EQ 2 then BEGIN  
    136     nothing = execute('widget_control, wid_id, set_value = {droplist_select:(where(current EQ '+casename+'0))[0]}')  
    137    ENDIF ELSE widget_control, wid_id, set_value $ 
    138     = {droplist_select:((droplist.droplist_number-1)*(event.out EQ -1)+oldselect.droplist_select*(event.out EQ 0)) < (droplist.droplist_number-1)} 
    139    return 
    140 end 
    141 ;---------------------------------------------------------------------- 
    142 PRO move, event, casename 
    143    possiblecase = ['day', 'month', 'year', 'century', 'impossiblecase'] 
    144    whichcase = (where(possiblecase EQ casename))[0] 
    145    id = widget_info(event.handler,find_by_uname = casename) 
    146    widget_control, id, get_value=wvalue 
    147    if wvalue.droplist_select EQ (wvalue.droplist_number-1)*(event.out EQ 1) THEN BEGIN 
    148       if casename EQ 'century' $ 
    149        OR widget_info(event.handler,find_by_uname = possiblecase[whichcase+1]) EQ 0 then begin 
    150          widget_control, id, get_value=widvalue 
    151          widget_control, id, set_value={droplist_select:(widvalue.droplist_number-1)*(event.out EQ -1)} 
    152       ENDIF ELSE nothing = execute('move, event,'''+possiblecase[whichcase+1]+'''')  
    153    ENDIF ELSE widget_control, id, set_value={droplist_select:wvalue.droplist_select+event.out} 
    154    nothing = execute('set_droplist, event,'''+possiblecase[whichcase-1]+'''') 
    155    return 
    156 end 
    157233;---------------------------------------------------------------------- 
    158234FUNCTION cw_calendar_event, event 
    159 ;help,  /struct, event 
    160    widget_control, event.id, get_uvalue=uval 
    161    possiblecase = ['day', 'month', 'year', 'century', 'impossiblecase'] 
    162    whichcase = (where(possiblecase EQ uval.name))[0] 
    163    if event.out NE 0 then BEGIN ; we use the +/- button and we want to go out of the droplist: 
    164 ; to index -1 (event.out=-1) or to index droplist_number (event.out=1) 
    165 ; we try to move the droplist just right named possiblecase[whichcase+1] 
    166       if widget_info(event.handler,find_by_uname = possiblecase[whichcase+1]) EQ 0 then BEGIN 
     235; 
     236@cm_4cal 
     237  compile_opt strictarr, strictarrsubs  
     238; 
     239  winfo_id = widget_info(event.top, find_by_uname = 'infocal') 
     240  widget_control, winfo_id, get_uvalue = infowid 
     241  key_caltype = infowid.caltype 
     242; 
     243  widget_control, event.id, get_uvalue = uval 
     244; high frequency calendar 
     245  IF uval.name EQ 'step' THEN BEGIN  
     246    infowid.date = jul2date(event.index + infowid.fakecal) 
     247  ENDIF ELSE BEGIN 
     248; 
     249    possiblecase = ['day', 'month', 'year', 'impossiblecase'] 
     250    whichcase = (where(possiblecase EQ uval.name))[0] 
     251    if event.out NE 0 then BEGIN ; we use the +/- button and we want to go out of the combobox: 
     252; to index = -1 (event.out=-1) or to index = combobox_number (event.out=1) 
     253; we try to move the combobox just right, with name: possiblecase[whichcase+1] 
     254      if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then BEGIN 
    167255; this widget do not exist we set cyclicly the current widget to the 
    168 ; value 0 if event.out=1 or droplist_number-1 if event.out=-1 
    169          widget_control, event.id, get_value=widvalue 
    170          widget_control, event.id, set_value={droplist_select:(widvalue.droplist_number-1)*(event.out EQ -1)} 
     256; value 0 if event.out=1 or combobox_number-1 if event.out=-1 
     257        widget_control, event.id, get_value = widvalue 
     258        selected = (widvalue.combobox_number-1)*(event.out EQ -1) 
     259        widget_control, event.id, set_value = {combobox_select:selected} 
    171260      ENDIF ELSE move, event, possiblecase[whichcase+1] 
    172    ENDIF 
    173    if uval.name NE 'day' then begin 
     261    ENDIF 
     262; if we changed month(year), we need to update the day (and month) list 
     263    if uval.name NE 'day' then begin 
    174264      event.out = 0 
    175       for name = whichcase-1, 0, -1 do begin 
    176          if widget_info(event.handler,find_by_uname = possiblecase[name]) NE 0 then $ 
    177           set_droplist, event, possiblecase[name] 
     265      for name = whichcase-1, 0, -1 do BEGIN 
     266        if widget_info(event.handler, find_by_uname = possiblecase[name]) NE 0 then $ 
     267           set_cal_combobox, event, possiblecase[name] 
    178268      endfor 
    179    endif 
    180    return, {CW_CALENDAR, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    181             , VALUE:cw_calendar_get_value(event.handler)} 
    182 end 
    183 ;---------------------------------------------------------------------- 
    184 FUNCTION cw_calendar, parent, calendar, date0, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _extra = ex 
    185 ; cheking for row and column keywords 
    186    column = keyword_set(column)*(1-keyword_set(row)) 
    187    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
    188 ; liste des mois, jours annee disponibles ds le calendrier 
    189    caldat, calendar,monthcal,daycal,yearcal 
    190    centurycal = yearcal/100 
    191 ; date de depart 
    192    if n_elements(date0) EQ 0 then date0 = calendar[0] 
    193    if (where(calendar EQ date0))[0] EQ -1 then date0 = calendar[0] 
    194    caldat, date0,month0,day0,year0 
    195    century0 = year0/100 
    196 ; test du type de calendrier 
    197    if n_elements(calendar) GT 1 then begin 
    198       if total(daycal eq 15) EQ n_elements(calendar) then monthly = 1 
    199    if total(monthcal EQ 6) EQ n_elements(calendar) AND n_elements(uniq(daycal, sort(daycal))) EQ 1 then BEGIN  & monthly = 1 & yearly = 1 & endif 
    200    if total(yearcal EQ 50) EQ n_elements(calendar) then BEGIN  & monthly = 1 & yearly = 1 & centuryly = 1 & ENDIF 
    201    endif 
     269    ENDIF 
     270; we update the date 
     271    infowid = get_cal_value(event.handler, winfo_id) 
     272  ENDELSE  
     273; 
     274  widget_control, winfo_id, set_uvalue = infowid 
     275  return, {CW_CALENDAR, ID:event.handler, TOP:event.top, HANDLER:0L $ 
     276           , VALUE:infowid.date, FAKECAL: infowid.fakecal} 
     277end 
     278;---------------------------------------------------------------------- 
     279;---------------------------------------------------------------------- 
     280FUNCTION cw_calendar, parent, calendar, jdate0, CALTYPE = CALTYPE, FAKECAL = fakecal, UVALUE = uvalue, UNAME = uname, _extra = ex 
     281; 
     282@cm_4cal 
     283; 
     284  compile_opt strictarr, strictarrsubs  
     285; 
     286  if keyword_set(caltype) then key_caltype = caltype 
     287; months days years found in the calendar 
     288  caldat, calendar, monthcal, daycal, yearcal, hourcal, mincal, scdcal 
     289; starting date 
     290  if n_elements(jdate0) EQ 0 then jdate0 = calendar[0] 
     291  if (where(calendar EQ jdate0))[0] EQ -1 then jdate0 = calendar[0] 
     292 
     293  caldat, jdate0, month0, day0, year0 
     294; test the type of calendar 
     295  if n_elements(calendar) GT 1 then BEGIN 
     296; each day have the same value 
     297    if n_elements(uniq(daycal, sort(daycal))) EQ 1 then monthly = 1 
     298; each month and each day have the same value 
     299    if keyword_set(monthly) AND n_elements(uniq(monthcal, sort(monthcal))) EQ 1 then yearly = 1 
     300  endif 
    202301;--------------------------------------------------------------------------------------- 
    203    if NOT keyword_set(uvalue) then uvalue = '' 
    204    if NOT keyword_set(uname) then uname = '' 
    205    base = widget_base(parent, ROW = row, COLUMN = column $ 
     302  if NOT keyword_set(uvalue) then uvalue = {dummy:''} 
     303  if NOT keyword_set(uname) then uname = '' 
     304  base0 = widget_base(parent, /ROW $ 
    206305                      , EVENT_FUNC = 'cw_calendar_event' $ 
    207                       , FUNC_GET_VALUE='cw_calendar_get_value' $ 
    208                       , PRO_SET_VALUE='cw_calendar_set_value' $ 
    209                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
    210 ;-------------day---------------- 
    211    if NOT keyword_set(monthly)  then begin 
    212       dayindex = where(monthcal EQ month0 AND yearcal EQ year0 AND centurycal EQ century0) 
     306                      , FUNC_GET_VALUE = 'cw_calendar_get_value' $ 
     307                      , PRO_SET_VALUE = 'cw_calendar_set_value' $ 
     308                      , UVALUE = uvalue, UNAME = uname, space = 0, _extra = ex) 
     309; 
     310 
     311  if n_elements(fakecal) eq 0 then fakecal = 0 
     312  base = widget_base(base0, space = 0, uname = 'infocal' $ 
     313                     , uvalue = {calendar:calendar, date:jul2date(jdate0), fakecal:fakecal, caltype: key_caltype}) 
     314; 
     315  IF keyword_set(fakecal) THEN BEGIN  
     316    cmbbid = cw_combobox_pm(base, UVALUE = {name:'step'}, UNAME = 'step' $ 
     317                            , value = strtrim(indgen(n_elements(calendar)), 1)) 
     318    widget_control, cmbbid, set_value = {combobox_select:(where(calendar EQ jdate0))[0]} 
     319  ENDIF ELSE BEGIN  
     320; 
     321    vallen = widget_info(base, string_size = 'm') 
     322;-------------day----------------- 
     323    if NOT keyword_set(monthly)  then begin 
     324      dayindex = where(monthcal EQ month0 AND yearcal EQ year0) 
    213325      currentday = daycal[dayindex] 
    214       currentday = string(currentday) 
    215       for i = 0, n_elements(currentday)-1 do currentday[i] = strtrim(currentday[i], 1) 
    216       rien = cw_droplist_pm(base,UVALUE = {name:'day', calendar:calendar, index:dayindex}, UNAME = 'day', value = currentday) 
    217       widget_control, rien, set_value = {droplist_select:(where(long(currentday) EQ day0))[0]} 
    218    endif 
    219 ;-------------month---------------- 
    220    if NOT keyword_set(yearly)  then BEGIN 
    221 ; les mois du siecle en cours et de l''anne en cours 
    222       monthindex = where(yearcal EQ year0 AND centurycal EQ century0) 
     326      currentday = strtrim(currentday, 1) 
     327      cmbbid = cw_combobox_pm(base, UVALUE = {name:'day'}, UNAME = 'day', value = currentday) 
     328      widget_control, cmbbid, set_value = {combobox_select:(where(long(currentday) EQ day0))[0]} 
     329    endif 
     330;-------------month--------------- 
     331    if NOT keyword_set(yearly)  then BEGIN 
     332      monthindex = where(yearcal EQ year0) 
    223333      currentmonth = long(monthcal[monthindex]) 
    224 ; on supprime les elements repetes 
     334; we suppress the repeted months 
    225335      monthindexbis = uniq(currentmonth, sort(currentmonth)) 
    226336      monthindex = monthindex[monthindexbis] 
    227337      currentmonth = currentmonth[monthindexbis] 
    228 ; on cree une droplist avec comme valeur tous les mois possibles de 
    229 ; l''annee courrante (year0) 
    230 ;       rien = cw_droplist_pm(base,UVALUE = {name:'month', calendar:calendar, index:monthindex}, UNAME = 'month', value = string(format='(C(CMoA))',31*indgen(12))) 
    231       rien = cw_droplist_pm(base,UVALUE = {name:'month', calendar:calendar, index:monthindex}, UNAME = 'month', value = string(format='(C(CMoA))',31*(currentmonth-1))) 
    232 ; on possitionne le mois courrant sur le bon mois parmis les mois 
    233 ; possibles de l''annee courrante 
    234       widget_control, rien, set_value = {droplist_select:(where(long(currentmonth) EQ month0))[0]} 
    235    endif 
     338      xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) 
     339      cmbbid = cw_combobox_pm(base, UVALUE = {name:'month'}, UNAME = 'month', value = string(format = '(C(CMoA))', 31*(currentmonth-1)), xoffset = xoff) 
     340      widget_control, cmbbid, set_value = {combobox_select:(where(long(currentmonth) EQ month0))[0]} 
     341    endif 
    236342;-------------year---------------- 
    237    if NOT keyword_set(centuryly)  then begin 
    238       if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then BEGIN  
    239          yearcal = yearcal-centurycal*100 
    240          year0   = year0-centurycal*100 
    241       endif 
    242       yearindex = where(centurycal EQ century0) 
    243       currentyear = yearcal[yearindex] 
    244       yearindexbis = uniq(currentyear, sort(long(currentyear))) 
    245       yearindex = yearindex[yearindexbis] 
    246       currentyear = currentyear[yearindexbis] 
    247       currentyear = string(currentyear) 
    248       for i = 0, n_elements(currentyear)-1 do currentyear[i] = strtrim(currentyear[i], 1) 
    249       rien = cw_droplist_pm(base,UVALUE = {name:'year', calendar:calendar, index:yearindex}, UNAME = 'year', value = currentyear) 
    250       widget_control, rien, set_value = {droplist_select:(where(long(currentyear) EQ year0))[0]} 
    251    endif 
    252 ;-------------century---------------- 
    253    centuryindex = uniq(centurycal, sort(long(centurycal))) 
    254    currentcentury = centurycal[centuryindex] 
    255    currentcentury = string(currentcentury) 
    256    for i = 0, n_elements(currentcentury)-1 do currentcentury[i] = strtrim(currentcentury[i], 1) 
    257    if n_elements(uniq(centurycal, sort(centurycal))) NE 1 then BEGIN 
    258       rien = cw_droplist_pm(base,UVALUE = {name:'century', calendar:calendar, index:centuryindex}, UNAME = 'century', value = currentcentury) 
    259       widget_control, rien, set_value = {droplist_select:(where(long(currentcentury) EQ century0))[0]} 
    260    endif 
     343    yearindex = uniq(yearcal, sort(yearcal)) 
     344    currentyear = strtrim(yearcal[yearindex], 1) 
     345    xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) + (33 + 3*vallen[0])*(1-keyword_set(yearly)) 
     346    cmbbid = cw_combobox_pm(base, UVALUE = {name:'year'}, UNAME = 'year', value = currentyear, xoffset = xoff) 
     347    widget_control, cmbbid, set_value = {combobox_select:(where(long(currentyear) EQ year0))[0]} 
    261348;----------------------------- 
    262 ; 
    263 ; 
    264    return, base 
    265 end 
     349  ENDELSE 
     350; 
     351  return, base 
     352end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_domain.pro

    r51 r69  
    4040;********************************************************************* 
    4141pro cw_domain_set_value, id, value 
    42 @common 
     42@cm_4mesh 
     43; 
     44   topid = findtopid(id) 
     45   widget_control, topid, get_uvalue = top_uvalue 
     46;------------------------------------------------ 
     47; make sure that we have the good grid stored in the cm_4mesh common parameters. 
     48   currentfile = extractatt(top_uvalue, 'currentfile') 
     49   currentgrid = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] 
     50   change = changegrid(currentgrid) 
    4351;------------------------------------------------ 
    4452; quel est le type de boxzoom? 
    45    topid = findtopid(id) 
    46    widget_control, topid, get_uvalue=top_uvalue 
    4753   currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 
    4854   options = extractatt(top_uvalue, 'options')    
     
    6268      lonn1 = firstxt 
    6369      lonn2 = lastxt 
    64       xtitle = 'x index' 
     70      xtitle = 'x ind' 
    6571   ENDELSE 
    6672   IF ytype EQ  'geographic' then begin 
     
    7177      latt1 = firstyt 
    7278      latt2 = lastyt 
    73       ytitle = 'y index' 
     79      ytitle = 'y ind' 
    7480   ENDELSE 
    7581;------------------------------------------------ 
     
    8894      6:boxzoom = Value 
    8995      Else:BEGIN  
    90          rien = report('Mauvaise Definition de Boxzoom') 
     96         rien = report('Wrong Definition of Boxzoom') 
    9197      END 
    9298   ENDCASE 
     
    187193   ENDELSE 
    188194; 
    189 ; 
    190195   if n_elements(boxzoom) EQ 4 then return 
    191196; 
    192 ; la profondeur 
    193 ; 
    194    depthlev1id = widget_info(id,find_by_uname = 'depthlev1') 
    195    depthlev2id = widget_info(id,find_by_uname = 'depthlev2') 
    196    depth1id = widget_info(id,find_by_uname = 'depth1') 
    197    depth2id = widget_info(id,find_by_uname = 'depth2') 
    198    widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    199 ; a-t-on change de type de grille ?, faut=il changerl''axe verticale? 
    200    widget_control, findtopid(id),  get_uvalue = top_uvalue 
    201    zgrid = extractatt(top_uvalue, 'zgrid') 
    202    grid_t = zgrid EQ 'T' 
    203    if grid_t NE depthlev1_uval.grid_t then BEGIN 
    204       widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    205       depthlev1_uval.grid_t = grid_t 
    206       depthlev2_uval.grid_t = grid_t 
    207 ; 
    208       if grid_t then gdep = gdept ELSE gdep = gdepw 
     197; depth 
     198; 
     199   dthlv1id = widget_info(id, find_by_uname = 'dthlv1') 
     200   dthlv2id = widget_info(id, find_by_uname = 'dthlv2') 
     201   depth1id = widget_info(id, find_by_uname = 'depth1') 
     202   depth2id = widget_info(id, find_by_uname = 'depth2') 
     203; which type of point? 
     204   widget_control, dthlv1id, get_uvalue = dthlv1_uval 
     205; get the new axis 
     206   if dthlv1_uval.grid_t EQ 1 then gdep = gdept ELSE gdep = gdepw 
     207 ; Did we change the vertical axis? 
     208   widget_control, dthlv1id, get_value = dthlv1_value 
     209   gdep1 = floor(fix(dthlv1_value.combobox_value)) 
     210   IF array_equal(gdep1, floor(gdep)) NE 1 THEN BEGIN 
    209211      gdep1 = floor(gdep) 
    210212      gdep2 = ceil(gdep) 
    211       identique = where(gdep2-gdep1 EQ 0) 
    212       if identique[0] NE -1 then gdep2[identique] = gdep2[identique] +1 
    213       depthlev1_uval.value = gdep1 
    214       depthlev2_uval.value = gdep2 
    215 ; 
    216       widget_control, depthlev1id, set_value = {value:strtrim(gdep1, 1)} 
    217       widget_control, depthlev2id, set_value = {value:strtrim(gdep2, 1)} 
    218 ; 
    219       widget_control, depthlev1id, set_uvalue = depthlev1_uval 
    220       widget_control, depthlev2id, set_uvalue = depthlev2_uval 
    221    ENDIF ELSE BEGIN  
    222       gdep1 = depthlev1_uval.value 
    223       gdep2 = gdep1+1 
    224    ENDELSE 
     213      same = where(gdep2-gdep1 EQ 0) 
     214      if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
     215      widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} 
     216      widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} 
     217   ENDIF ELSE gdep2 = gdep1+1 
    225218; on s''assure que les profs donnees contiennent bien au moins un 
    226219; niveau. 
     
    238231   if indice1 EQ indice2 then BEGIN 
    239232      if (where(gdep1 GE boxzoom[4] AND gdep2 LE boxzoom[5]))[0]  EQ -1 then begin 
    240          indice1 = 0 > (indice1-(grid_t EQ 1)) 
     233         indice1 = 0 > (indice1-(dthlv1_uval.grid_t EQ 1)) 
    241234         indice2 = indice1 
    242235      endif 
     
    246239; maintenant que les values et les indexes sont definis proprement, 
    247240; on peut les appliquer 
    248    widget_control, depthlev1id, set_value = {droplist_select:indice1} 
    249    widget_control, depthlev2id, set_value = {droplist_select:indice2} 
     241   widget_control, dthlv1id, set_value = {combobox_select:indice1} 
     242   widget_control, dthlv2id, set_value = {combobox_select:indice2} 
    250243; controler les min et les max des sliders... 
    251244   if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
     
    265258FUNCTION cw_domain_get_value, id 
    266259   box = lonarr(6) 
    267    possiblecase = ['lon1', 'lon2','lat1', 'lat2','depth1','depth2'] 
     260   possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] 
    268261   for i = 0, 5 do begin 
    269       widget_control,widget_info(id,find_by_uname = possiblecase[i]) $ 
     262      widget_control, widget_info(id, find_by_uname = possiblecase[i]) $ 
    270263       , get_value = value 
    271264      box[i] = value.value 
     
    278271; help,  /struct, event 
    279272   if (where(tag_names(event) EQ 'OUT'))[0] NE -1 then if event.out NE 0 then return,  -1 
    280    widget_control, event.id, get_uvalue=uval 
     273   widget_control, event.id, get_uvalue = uval 
    281274   case uval.name of 
    282275      'lon1':widget_control,widget_info(event.handler,find_by_uname = 'lon2') $ 
     
    306299         widget_control, id, set_value = value.slider_min_max[1] 
    307300      END 
    308       'depthlev1':BEGIN 
     301      'dthlv1':BEGIN 
    309302; ids... 
    310303         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    311304         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    312          depthlev2id = widget_info(event.handler,find_by_uname = 'depthlev2') 
    313 ; faut-il changer depthlev2 ? 
    314          widget_control, depthlev2id, get_value = depthlev2_value 
    315          if depthlev2_value.droplist_select LT event.index then BEGIN 
    316 ; on redefinie la valeur de depthlev2id 
    317             widget_control, depthlev2id, set_value = {droplist_select:event.index} 
     305         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') 
     306; faut-il changer dthlv2 ? 
     307         widget_control, event.id, get_value = dthlv1_value 
     308         gdep1 = fix(dthlv1_value.combobox_value) 
     309         widget_control, dthlv2id, get_value = dthlv2_value 
     310         gdep2 = fix(dthlv2_value.combobox_value) 
     311         if dthlv2_value.combobox_index LT event.index then BEGIN 
     312; on redefinie la valeur de dthlv2id 
     313            widget_control, dthlv2id, set_value = {combobox_select:event.index} 
    318314; donc on redefinit la valeur et le max du slider 2 
    319             widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    320315            if event.index EQ jpk-1 then BEGIN  
    321316               max = max([gdept, gdepw]) 
    322317               max = strtrim(string(max,format='(e8.0)'), 1) 
    323318               max = float('1'+strmid(max, 1))+float(max) 
    324             ENDIF ELSE max = depthlev2_uval.value[event.index+1]-1 
     319            ENDIF ELSE max = gdep2[event.index+1]-1 
    325320            widget_control, depth2id $ 
    326              , set_value = {slider_max:max, value:depthlev2_uval.value[event.index]} 
     321             , set_value = {slider_max:max, value:gdep2[event.index]} 
    327322; du coup on redefinie donc le max du slider 1  
    328             widget_control, depth1id, set_value = {slider_max:uval.value[event.index]} 
     323            widget_control, depth1id, set_value = {slider_max:gdep1[event.index]} 
    329324         END  
    330325; on redefinie la valeur et le min du slider depth 1 
    331          if event.index EQ 0 then min = 0 ELSE min = uval.value[event.index-1]+1 
    332          widget_control, depth1id, set_value = {slider_min:min, value:uval.value[event.index]} 
     326         if event.index EQ 0 then min = 0 ELSE min = gdep1[event.index-1]+1 
     327         widget_control, depth1id, set_value = {slider_min:min, value:gdep1[event.index]} 
    333328; du coup on change aussi la valeur du min du slider depth 2 
    334          widget_control, depth2id, set_value = {slider_min:uval.value[event.index]+1} 
    335       END 
    336       'depthlev2':BEGIN 
     329         widget_control, depth2id, set_value = {slider_min:gdep1[event.index]+1} 
     330      END 
     331      'dthlv2':BEGIN 
    337332; ids... 
    338333         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    339334         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    340          depthlev1id = widget_info(event.handler,find_by_uname = 'depthlev1') 
    341 ; faut-il changer depthlev1 ? 
    342          widget_control, depthlev1id, get_value = depthlev1_value 
    343          if depthlev1_value.droplist_select GT event.index then BEGIN 
    344 ; on redefinie la valeur de depthlev1id 
    345             widget_control, depthlev1id, set_value = {droplist_select:event.index} 
     335         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') 
     336; faut-il changer dthlv1 ? 
     337         widget_control, dthlv1id, get_value = dthlv1_value 
     338         gdep1 = fix(dthlv1_value.combobox_value) 
     339         widget_control, event.id, get_value = dthlv2_value 
     340         gdep2 = fix(dthlv2_value.combobox_value) 
     341         if dthlv1_value.combobox_index GT event.index then BEGIN 
     342; on redefinie la valeur de dthlv1id 
     343            widget_control, dthlv1id, set_value = {combobox_select:event.index} 
    346344; donc on redefinit la valeur et le min du slider 1 
    347             widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    348             if event.index EQ 0 then min = 0 ELSE min = uval.value[event.index-1] 
     345            if event.index EQ 0 then min = 0 ELSE min = gdep2[event.index-1] 
    349346            widget_control, depth1id $ 
    350              , set_value = {slider_min:min, value:depthlev1_uval.value[event.index]} 
     347             , set_value = {slider_min:min, value:gdep1[event.index]} 
    351348; du coup on redefinie donc le min du slider 2 
    352             widget_control, depth2id, set_value = {slider_min:uval.value[event.index]} 
     349            widget_control, depth2id, set_value = {slider_min:gdep2[event.index]} 
    353350         END  
    354351; on redefinie la valeur et le max du slider depth 2 
     
    357354            max = strtrim(string(max,format='(e8.0)'), 1) 
    358355            max = float('1'+strmid(max, 1))+float(max) 
    359          ENDIF ELSE max = uval.value[event.index+1]-1 
    360          widget_control, depth2id, set_value = {slider_max:max, value:uval.value[event.index]} 
     356         ENDIF ELSE max = gdep2[event.index+1]-1 
     357         widget_control, depth2id, set_value = {slider_max:max, value:gdep2[event.index]} 
    361358; du coup on change aussi la valeur du max du slider depth 1 
    362          widget_control, depth1id, set_value = {slider_max:uval.value[event.index]-1} 
     359         widget_control, depth1id, set_value = {slider_max:gdep2[event.index]-1} 
    363360      END 
    364361      'depth1':BEGIN 
    365362; ids... 
    366363         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    367          depthlev1id = widget_info(event.handler,find_by_uname = 'depthlev1') 
    368 ; doit-on changer depthlev1 ? 
    369          widget_control, depthlev1id, get_value = depthlev1_value 
    370          widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    371          rien = where(depthlev1_uval.value LT event.value, indice) 
     364         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') 
     365; doit-on changer dthlv1 ? 
     366         widget_control, dthlv1id, get_value = dthlv1_value 
     367         gdep1 = fix(dthlv1_value.combobox_value) 
     368         rien = where(gdep1 LT event.value, indice) 
    372369         indice = indice < (jpk-1) 
    373          if indice NE depthlev1_value.droplist_select then begin 
     370         if indice NE dthlv1_value.combobox_index then begin 
    374371; on change le min de depth2 
    375             widget_control, depth2id, set_value = {slider_min:depthlev1_uval.value[indice]+1} 
    376 ; on redefinie la valeur de depthlev1id 
    377             widget_control, depthlev1id, set_value = {droplist_select:indice} 
     372            widget_control, depth2id, set_value = {slider_min:gdep1[indice]+1} 
     373; on redefinie la valeur de dthlv1id 
     374            widget_control, dthlv1id, set_value = {combobox_select:indice} 
    378375; donc on redefinit le min du slider 1 
    379             if indice EQ 0 then min = 0 ELSE min = depthlev1_uval.value[indice-1]+1 
     376            if indice EQ 0 then min = 0 ELSE min = gdep1[indice-1]+1 
    380377            widget_control, event.id, set_value = {slider_min:min} 
    381378         endif 
     
    384381; ids... 
    385382         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    386          depthlev2id = widget_info(event.handler,find_by_uname = 'depthlev2') 
    387 ; doit-on changer depthlev2 ? 
    388          widget_control, depthlev2id, get_value = depthlev2_value 
    389          widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    390          rien = where(depthlev2_uval.value LE event.value, indice) 
     383         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') 
     384; doit-on changer dthlv2 ? 
     385         widget_control, dthlv2id, get_value = dthlv2_value 
     386         gdep2 = fix(dthlv2_value.combobox_value) 
     387         rien = where(gdep2 LE event.value, indice) 
    391388         indice = 0 > (indice-1) 
    392          if indice NE depthlev2_value.droplist_select then begin 
     389         if indice NE dthlv2_value.combobox_index then begin 
    393390; on change le max de depth1 
    394             widget_control, depth1id, set_value = {slider_max:depthlev2_uval.value[indice]-1} 
    395 ; on redefinie la valeur de depthlev2id 
    396             widget_control, depthlev2id, set_value = {droplist_select:indice} 
     391            widget_control, depth1id, set_value = {slider_max:gdep2[indice]-1} 
     392; on redefinie la valeur de dthlv2id 
     393            widget_control, dthlv2id, set_value = {combobox_select:indice} 
    397394; donc on redefinit le max du slider 2 
    398395            if indice EQ jpk-1 then BEGIN  
     
    400397               max = strtrim(string(max,format='(e8.0)'), 1) 
    401398               max = float('1'+strmid(max, 1))+float(max) 
    402             ENDIF ELSE max = depthlev2_uval.value[indice+1]-1 
     399            ENDIF ELSE max = gdep2[indice+1]-1 
    403400            widget_control, event.id, set_value = {slider_max:max} 
    404401         endif 
     
    412409end 
    413410;********************************************************************* 
    414 FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, UNZOOM = unzoom, _extra = ex 
    415 ; 
    416 @common 
    417 ; cheking exclusive keywords 
    418    column = keyword_set(column)*(1-keyword_set(row)) 
    419    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
     411FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, _extra = ex 
     412; 
     413@cm_4mesh 
     414@cm_4data 
     415; 
    420416; def de la boxzoom 
    421    if NOT keyword_set(boxzoom) then boxzoom = [lon1, lon2, lat1, lat2 $ 
    422                                            , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] 
    423    Case N_Elements(Boxzoom) OF 
    424       0:boxzoom = [lon1, lon2, lat1, lat2, vert1, vert2] 
    425       1:boxzoom=[lon1, lon2, lat1, lat2, 0.,boxzoom[0]] 
    426       2:boxzoom=[lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] 
    427       4:boxzoom=[Boxzoom, vert1, vert2] 
    428       5:boxzoom=[Boxzoom[0:3], 0, Boxzoom[4]] 
    429       6: 
    430       Else: return, report('Mauvaise Definition de Boxzoom') 
    431    ENDCASE 
    432 ; 
    433    boxzoom[0] = floor(boxzoom[0]) 
    434    boxzoom[1] = ceil(boxzoom[1]) 
    435    boxzoom[2] = floor(boxzoom[2]) 
    436    boxzoom[3] = ceil(boxzoom[3]) 
    437    boxzoom[4] = floor(boxzoom[4]) 
    438    boxzoom[5] = ceil(boxzoom[5]) 
    439 ;------------------------------------------------ 
    440    if NOT keyword_set(uvalue) then uvalue = '' 
    441    if NOT keyword_set(uname) then uname = '' 
    442    base = widget_base(parent, /row  $ 
    443                       , space = 1,  xpad = 1,  ypad = 1 $ 
    444                       , EVENT_FUNC = 'cw_domain_event' $ 
    445                       , FUNC_GET_VALUE='cw_domain_get_value' $ 
    446                       , PRO_SET_VALUE='cw_domain_set_value' $ 
    447                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     417  Case N_Elements(Boxzoom) OF 
     418    0:boxzoom = [lon1, lon2, lat1, lat2 $ 
     419                 , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] 
     420    1:boxzoom = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] 
     421    2:boxzoom = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] 
     422    4:boxzoom = [Boxzoom, vert1, vert2] 
     423    5:boxzoom = [Boxzoom[0:3], 0, Boxzoom[4]] 
     424    6: 
     425    Else: return, report('Mauvaise Definition de Boxzoom') 
     426  ENDCASE 
     427  IF total(Boxzoom) EQ 0 THEN $ 
     428     boxzoom = [lon1, lon2, lat1, lat2, min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]])] 
     429; 
     430  boxzoom[0] = floor(boxzoom[0]) 
     431  boxzoom[1] = ceil(boxzoom[1]) 
     432  boxzoom[2] = floor(boxzoom[2]) 
     433  boxzoom[3] = ceil(boxzoom[3]) 
     434  boxzoom[4] = floor(boxzoom[4]) 
     435  boxzoom[5] = ceil(boxzoom[5]) 
     436;------------------------------------------------ 
     437  if NOT keyword_set(uvalue) then uvalue = '' 
     438  if NOT keyword_set(uname) then uname = '' 
     439  base = widget_base(parent, row = 2, space = 0 $ 
     440                     , EVENT_FUNC = 'cw_domain_event' $ 
     441                     , FUNC_GET_VALUE = 'cw_domain_get_value' $ 
     442                     , PRO_SET_VALUE = 'cw_domain_set_value' $ 
     443                     , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     444;------------------------------------------------ 
     445  baseh = widget_base(base, column = 1+keyword_set(unzoom), space = 0) 
     446;------------------------------------------------ 
     447  baseh1 = widget_base(baseh, row = 2, space = 0) 
    448448;-------------longitude--------------------------- 
    449    basehori = widget_base(base, ROW = row, COLUMN = column) 
    450 ;-------------longitude--------------------------- 
    451    min = floor(min([glamt,glamf], max = max)) 
    452    max = ceil(max) 
    453    lonbase = widget_base(basehori, /ROW, space = 1, xpad = 1, ypad = 1, uname = 'lonbase') 
    454    lon1id = cw_slider_pm(lonbase,value=min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ 
    455                        , uvalue={name:'lon1', strict:keyword_set(strict)},uname ='lon1' $ 
    456                        , title = 'lon1', minimum = min $ 
    457                        , maximum = (boxzoom[1] < max)-keyword_set(strict)) 
    458    lon2id = cw_slider_pm(lonbase,value=((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ 
    459                        , uvalue={name:'lon2', strict:keyword_set(strict)} $ 
    460                        , uname='lon2', title = 'lon2', maximum = max $ 
    461                        , minimum = (min > boxzoom[0])+keyword_set(strict)) 
    462    widget_control, lonbase, set_uvalue = {name:'geographic'} 
     449  min = floor(min([glamt, glamf], max = max)) 
     450  max = ceil(max) 
     451  IF max-min EQ 361 AND keyword_set(key_periodic) THEN max = max-1 
     452  lonbase = widget_base(baseh1, column = 2, space = 0, uname = 'lonbase', uvalue = {name:'geographic'}) 
     453  lon1id = cw_slider_pm(lonbase, value = min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ 
     454                        , uvalue = {name:'lon1', strict:keyword_set(strict)}, uname = 'lon1' $ 
     455                        , title = 'lon1', minimum = min $ 
     456                        , maximum = (boxzoom[1] < max)-keyword_set(strict)) 
     457  lon2id = cw_slider_pm(lonbase, value = ((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ 
     458                        , uvalue = {name:'lon2', strict:keyword_set(strict)} $ 
     459                        , uname = 'lon2', title = 'lon2', maximum = max $ 
     460                        , minimum = (min > boxzoom[0])+keyword_set(strict)) 
    463461;---------------latitude------------------------- 
    464    min = floor(min([gphit,gphif], max = max)) 
    465    max = ceil(max) 
    466    latbase = widget_base(basehori, /ROW, space = 1, xpad = 1, ypad = 1, uname = 'latbase') 
    467    lat1id = cw_slider_pm(latbase,value=min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ 
    468                        , uvalue={name:'lat1', strict:keyword_set(strict)},uname ='lat1' $ 
    469                        , title = 'lat1', minimum =min $ 
    470                        , maximum = ((boxzoom[3] < max)-keyword_set(strict))) 
    471    lat2id = cw_slider_pm(latbase,value=((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ 
    472                        , uvalue={name:'lat2', strict:keyword_set(strict)} $ 
    473                        , uname ='lat2', title = 'lat2' ,maximum =  max $ 
    474                        , minimum =(min > boxzoom[2])+keyword_set(strict)) 
    475    widget_control, latbase, set_uvalue = {name:'geographic'} 
     462  min = floor(min([gphit, gphif], max = max)) 
     463  max = ceil(max) 
     464  latbase = widget_base(baseh1, column = 2, space = 0, uname = 'latbase', uvalue = {name:'geographic'}) 
     465  lat1id = cw_slider_pm(latbase, value = min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ 
     466                        , uvalue = {name:'lat1', strict:keyword_set(strict)}, uname = 'lat1' $ 
     467                        , title = 'lat1', minimum = min $ 
     468                        , maximum = ((boxzoom[3] < max)-keyword_set(strict))) 
     469  lat2id = cw_slider_pm(latbase, value = ((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ 
     470                        , uvalue = {name:'lat2', strict:keyword_set(strict)} $ 
     471                        , uname = 'lat2', title = 'lat2', maximum =  max $ 
     472                        , minimum = (min > boxzoom[2])+keyword_set(strict)) 
    476473;----------------unzoom------------------------ 
    477    if keyword_set(unzoom) then rien = widget_button(basehori,value='unzoom', uvalue={name:'unzoom'}) 
     474  if keyword_set(unzoom) then rien = widget_button(baseh, value = 'unzoom', uvalue = {name:'unzoom'}, xsize = 60, ysize = 110) 
    478475;----------------depth------------------------ 
    479    basevert = widget_base(base, ROW = row, COLUMN = column) 
    480    basedepth = widget_base(basevert, /row) 
    481 ; 
    482    if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept 
    483    gdep1 = floor(gdep) 
    484    gdep2 = ceil(gdep) 
    485    identique = where(gdep2-gdep1 EQ 0) 
    486    if identique[0] NE -1 then gdep2[identique] = gdep2[identique] +1 
    487    sgdep1 = strtrim(gdep1, 1) 
    488    sgdep2 = strtrim(gdep2, 1) 
    489 ; 
    490    basedepthdrop = widget_base(basedepth, column = column,  row = row) 
    491 ; 
    492    dephtid=cw_droplist_pm(basedepthdrop,value=''+sgdep1, uvalue={name:'depthlev1', value:gdep1, grid_t:strupcase(vargrid) NE 'W'}, uname='depthlev1') 
    493    rien = where(gdep1 LT boxzoom[4], indice1) 
    494    indice1 = indice1 < (jpk-1) 
    495    widget_control, dephtid, set_value = {droplist_select:indice1} 
    496 ; 
    497    dephtid=cw_droplist_pm(basedepthdrop,value=''+sgdep2, uvalue={name:'depthlev2', value:gdep2, grid_t:strupcase(vargrid) NE 'W'}, uname='depthlev2') 
    498    rien = where(gdep2 LE boxzoom[5], indice2) 
    499    indice2 = indice1 > (indice2-1) 
    500    widget_control, dephtid, set_value = {droplist_select:indice2} 
    501 ; 
    502    basedepthslid = widget_base(basedepth, column = column,  row = row) 
    503 ; 
    504    if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
    505    max1 = (min1+1) > gdep1[indice2] 
    506    rien = cw_slider_pm(basedepthslid, value= min1 > boxzoom[4] < (boxzoom[5] < max1) $ 
    507                        , uvalue = {name:'depth1'}, uname = 'depth1' $ 
    508                        , title = 'depth1', minimum = min1, maximum = max1) 
    509 ; 
    510    min2 = gdep2[indice1] 
    511    if indice2 EQ jpk-1 then BEGIN  
    512       max2 = max([gdept, gdepw]) 
    513       max2 = strtrim(string(max2,format='(e8.0)'), 1) 
    514       max2 = float('1'+strmid(max2, 1))+float(max2) 
    515    ENDIF ELSE max2 = gdep1[indice2+1] 
    516    if max2 EQ min2 then max2 = min2+1 
    517    rien = cw_slider_pm(basedepthslid, value= (min2 > boxzoom[4]) > boxzoom[5] < max2 $ 
    518                        , uvalue={name:'depth2'}, minimum = min2 $ 
    519                        , uname = 'depth2', title = 'depth2' ,maximum =  max2) 
     476  basez = widget_base(base, column = 3, space = 0, /base_align_center) 
     477;------------------------------------------------ 
     478  basezdrp = widget_base(basez, row = 2, space = 0) 
     479; 
     480  if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept 
     481  gdep1 = floor(gdep) 
     482  gdep2 = ceil(gdep) 
     483  same = where(gdep2-gdep1 EQ 0) 
     484  if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
     485  sgdep1 = strtrim(gdep1, 1) 
     486  sgdep2 = strtrim(gdep2, 1) 
     487; 
     488  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep1, uvalue = {name:'dthlv1', grid_t:strupcase(vargrid) NE 'W'}, uname = 'dthlv1') 
     489  rien = where(gdep1 LT boxzoom[4], indice1) 
     490  indice1 = indice1 < (jpk-1) 
     491  widget_control, dephtid, set_value = {combobox_select:indice1} 
     492; 
     493  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep2, uvalue = {name:'dthlv2'}, uname = 'dthlv2') 
     494  rien = where(gdep2 LE boxzoom[5], indice2) 
     495  indice2 = indice1 > (indice2-1) 
     496  widget_control, dephtid, set_value = {combobox_select:indice2} 
     497; 
     498;------ 
     499;   basedepthslid = widget_base(base, column = 2, space = 0) 
     500  strminlen = max(strlen(strtrim(round([gdept, gdepw]), 1))) 
     501; 
     502  if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
     503  max1 = (min1+1) > gdep1[indice2] 
     504  rien = cw_slider_pm(basez, value = min1 > boxzoom[4] < (boxzoom[5] < max1) $ 
     505                      , uvalue = {name:'depth1'}, uname = 'depth1', strminlen = strminlen $ 
     506                      , title = 'z1', minimum = min1, maximum = max1) 
     507; 
     508  min2 = gdep2[indice1] 
     509  if indice2 EQ jpk-1 then BEGIN  
     510    max2 = max([gdept, gdepw]) 
     511    max2 = strtrim(string(max2, format = '(e8.0)'), 1) 
     512    max2 = float('1'+strmid(max2, 1))+float(max2) 
     513  ENDIF ELSE max2 = gdep1[indice2+1] 
     514  if max2 EQ min2 then max2 = min2+1 
     515  rien = cw_slider_pm(basez, value = (min2 > boxzoom[4]) > boxzoom[5] < max2 $ 
     516                      , uvalue = {name:'depth2'}, minimum = min2, maximum =  max2 $ 
     517                      , uname = 'depth2', title = 'z2', strminlen = strminlen) 
    520518;-------------------------------------------- 
    521519; 
    522 ; 
    523 ; 
    524    return, base 
     520  return, base 
    525521end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_pagelayout.pro

    r68 r69  
    11;********************************************************************* 
    22;********************************************************************* 
    3 FUNCTION cw_miseenpage_event, event 
     3FUNCTION cw_pagelayout_event, event 
    44 
    55   widget_control, event.id, get_uvalue=uval 
     
    4646      createhistory, event.top, smallin 
    4747;          
    48          options = extractatt(top_uvalue, 'options')    
    49          flags = extractatt(top_uvalue, 'optionsflag') 
    50          xlonindex = where(options EQ 'Longitude / x index') 
    51          xlonflag = flags[xlonindex, numdessinin] & xlonflag = xlonflag[0] 
    52          ylatindex = where(options EQ 'Latitude / y index') 
    53          ylatflag = flags[ylatindex, numdessinin] & ylatflag = ylatflag[0] 
     48      options = extractatt(top_uvalue, 'options')    
     49      flags = extractatt(top_uvalue, 'optionsflag') 
     50      flag = flags[*, numdessinin] 
    5451;          
    55       flag = [1, key_portrait, 0, 0, 0, 0] 
    56       flag[xlonindex] = xlonflag 
    57       flag[ylatindex] = ylatflag 
    58 ;          
    59 ; actualisation de la top_uvalue... 
     52; update and reset all values of the top_uvalue... 
    6053; 
    6154      *top_uvalue[1, findline(top_uvalue, 'smallin')] = smallin 
     
    6659      *top_uvalue[1, findline(top_uvalue, 'yenvs')] = replicate(!y, nbredessin) 
    6760; 
    68       old = (extractatt(top_uvalue, 'nameprocedures'))[numdessinin] 
    69       new = strarr(nbredessin) 
    70       new[0] = old 
    71       *top_uvalue[1, findline(top_uvalue, 'nameprocedures')] = new 
    72 ; 
    73       old = (extractatt(top_uvalue, 'types'))[numdessinin] 
    74       new = strarr(nbredessin) 
    75       new[0] = old 
    76       *top_uvalue[1, findline(top_uvalue, 'types')] = new 
    77 ; 
    78       old = (extractatt(top_uvalue,  'champs'))[*, numdessinin] 
    79       new = strarr(2, nbredessin) 
    80       new[*, 0] = old 
    81       *top_uvalue[1, findline(top_uvalue, 'champs')] = new 
    82 ; 
    83       old = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
    84       new = fltarr(6, nbredessin) 
    85       new[*, 0] = old 
    86       *top_uvalue[1, findline(top_uvalue, 'domaines')] = new 
    87 ; 
    88       old = (extractatt(top_uvalue, 'dates'))[*, numdessinin] 
    89       new = lonarr(2, nbredessin) 
    90       new[*, 0] = old 
    91       *top_uvalue[1, findline(top_uvalue, 'dates')] = new 
    92 ; 
    93       old = (extractatt(top_uvalue,  'prefixes'))[numdessinin] 
    94       new = strarr(nbredessin) 
    95       new[0] = old 
    96       *top_uvalue[1, findline(top_uvalue, 'prefixes')] = new 
    97 ; 
    98       new = flag#replicate(1, nbredessin) 
    99       *top_uvalue[1, findline(top_uvalue, 'optionsflag')] = new 
     61      *top_uvalue[1, findline(top_uvalue, 'nameprocedures')] = strarr(nbredessin) 
     62      *top_uvalue[1, findline(top_uvalue, 'types')] = strarr(nbredessin) 
     63      *top_uvalue[1, findline(top_uvalue, 'varinfo')] = strarr(2, nbredessin) 
     64      *top_uvalue[1, findline(top_uvalue, 'domaines')] = fltarr(6, nbredessin) 
     65      *top_uvalue[1, findline(top_uvalue, 'dates')] = lonarr(2, nbredessin) 
     66      *top_uvalue[1, findline(top_uvalue, 'txtcmd')] = strarr(nbredessin) 
     67      *top_uvalue[1, findline(top_uvalue, 'optionsflag')] = flag#replicate(1, nbredessin) 
    10068; 
    10169      ptr_free, extractatt(top_uvalue, 'exextra') 
     
    10876end 
    10977;********************************************************************* 
    110 FUNCTION cw_miseenpage, parent, small, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, UNZOOM = unzoom, _extra = ex 
    111 ; cheking exclusive keywords 
    112    column = keyword_set(column)*(1-keyword_set(row)) 
    113    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column) 
     78FUNCTION cw_pagelayout, parent, small, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, COLUMN = column, ROW = row, _extra = ex 
    11479;------------------------------------------------ 
    115    if NOT keyword_set(uvalue) then uvalue = '' 
    116    if NOT keyword_set(uname) then uname = '' 
    117    base = widget_base(parent, ROW = row, COLUMN = column  $ 
    118                       , EVENT_FUNC = 'cw_miseenpage_event' $ 
    119                       , FUNC_GET_VALUE='cw_miseenpage_get_value' $ 
    120                       , PRO_SET_VALUE='cw_miseenpage_set_value' $ 
    121                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     80  row = keyword_set(row)*(1-keyword_set(column))   
     81  if NOT keyword_set(uvalue) then uvalue = '' 
     82  if NOT keyword_set(uname) then uname = '' 
     83  base = widget_base(parent $ 
     84                     , EVENT_FUNC = 'cw_pagelayout_event' $ 
     85                     , FUNC_GET_VALUE = 'cw_pagelayout_get_value' $ 
     86                     , PRO_SET_VALUE = 'cw_pagelayout_set_value' $ 
     87                     , UVALUE = uvalue, UNAME = uname, space = 0, _extra = ex)    
    12288;------------------------------------------------ 
    123    IF n_elements(small) eq 0 then small = [1, 1, 1] 
    124    basedroplist = widget_base(base, /column, /align_center) 
    125    id=widget_droplist(basedroplist, value=strtrim(indgen(10)+1, 1), title ='column' $ 
    126                         , uvalue ={name:'column'}, uname='column') 
    127    widget_control, id, set_droplist_select = small[0]-1 
    128    id=widget_droplist(basedroplist, value=strtrim(indgen(10)+1, 1), title =' row ' $ 
    129                         , uvalue ={name:'row'}, uname='row') 
    130    widget_control, id, set_droplist_select = small[1]-1 
    131    basebutton = widget_base(base, /column, /align_center) 
    132    rien = widget_button(basebutton, value = 'Clear', uvalue ={name:'clear'}, uname='clear') 
    133    rien = widget_button(basebutton, value = 'Undo', uvalue ={name:'undo'}, uname='undo') 
     89  IF n_elements(small) eq 0 then small = [1, 1, 1] 
     90; 
     91  dummy = widget_label(base, value = 'cln', yoffset = 3) 
     92  id = widget_combobox(base, value = strtrim(indgen(9)+1, 1), uvalue = {name:'column'} $ 
     93                       , uname = 'column', xoffset = 20, xsize = 40) 
     94  widget_control, id, set_combobox_select = small[0]-1 
     95; 
     96  IF keyword_set(row) THEN BEGIN  
     97    xoff = 60 
     98    yoff = 0 
     99  ENDIF ELSE BEGIN  
     100    xoff = 0 
     101    yoff = 20 
     102  ENDELSE  
     103  dummy = widget_label(base, value = 'row', xoffset = xoff, yoffset = yoff+3) 
     104  id = widget_combobox(base, value = strtrim(indgen(9)+1, 1), uvalue = {name:'row'} $ 
     105                       , uname = 'row', xoffset = xoff+20, xsize = 40, yoffset = yoff) 
     106  widget_control, id, set_combobox_select = small[1]-1 
    134107;------------------------------------------------ 
    135108;------------------------------------------------ 
    136    return, base 
     109  return, base 
    137110end 
    138111;********************************************************************* 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_slider_pm.pro

    r51 r69  
    135135; end 
    136136;---------------------------------------------------------------------- 
     137FUNCTION decvalue, value 
     138  a = float(value[0]) 
     139  return, strtrim(string(floor(a) + 0.1*indgen(10), format = '(f15.1)'), 2) 
     140end 
     141;---------------------------------------------------------------------- 
     142FUNCTION decind, value 
     143  a = float(value[0]) 
     144  return, round(10*(a - floor(a))) ; !! computation accuracy 
     145end 
     146;---------------------------------------------------------------------- 
    137147PRO cw_slider_pm_set_value, id, value 
    138    SliderBarId = widget_info(id,find_by_uname = 'SliderBar') 
    139    if size(value, /type) eq 8 then BEGIN ; this is a structure 
    140       tagnames = tag_names(value) 
    141       for tag = 0, n_tags(value)-1 do begin 
    142          case strtrim(strlowcase(tagnames[tag]), 2) of 
    143             'slider_min':widget_control, SliderBarId, set_slider_min = value.slider_min 
    144             'slider_max':widget_control, SliderBarId, set_slider_max = value.slider_max 
    145             'value':widget_control, SliderBarId, set_value = value.value 
    146             ELSE:ras = report('mauvais nom de l''argument de la structure ds cw_slider_pm_set_value') 
    147          endcase 
    148       endfor 
    149    ENDIF ELSE widget_control, SliderBarId, set_value = value[0] 
    150    return 
     148  sbid = widget_info(id, find_by_uname = 'SliderBar') 
     149  dcid = widget_info(id, find_by_uname = 'decimal') 
     150  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     151  if size(value, /type) eq 8 then BEGIN ; this is a structure 
     152    tagnames = tag_names(value) 
     153    for tag = 0, n_tags(value)-1 do begin 
     154      case strtrim(strlowcase(tagnames[tag]), 2) of 
     155        'slider_min':BEGIN 
     156;          IF float(value.slider_min[0]) LT minmax[1] THEN BEGIN  
     157            minmax[0] = value.slider_min[0] 
     158            widget_control, sbid, set_slider_min = floor(float(value.slider_min[0])) 
     159            valuedc = float(widget_info(dcid, /combobox_gettext)) 
     160            IF valuedc LT value.slider_min THEN BEGIN 
     161              widget_control, sbid, set_value = floor(float(value.slider_min[0])) 
     162              widget_control, dcid, set_value = decvalue(value.slider_min) 
     163              widget_control, dcid, set_combobox_select = decind(value.slider_min) 
     164            ENDIF  
     165;          ENDIF  
     166        end 
     167        'slider_max':BEGIN 
     168;          IF float(value.slider_max[0]) GT minmax[0] THEN BEGIN  
     169            minmax[1] = value.slider_max[0] 
     170            widget_control, sbid, set_slider_max = ceil(float(value.slider_max[0])) 
     171            valuedc = float(widget_info(dcid, /combobox_gettext)) 
     172            IF valuedc GT value.slider_max THEN BEGIN 
     173              widget_control, sbid, set_value = ceil(float(value.slider_max[0])) 
     174              widget_control, dcid, set_value = decvalue(value.slider_max) 
     175              widget_control, dcid, set_combobox_select = decind(value.slider_max) 
     176            ENDIF  
     177;          ENDIF  
     178        end 
     179        'value':IF float(value.value[0]) GE minmax[0] $ 
     180          AND float(value.value[0]) LE minmax[1] THEN value2 = float(value.value[0]) 
     181        ELSE:ras = report('wrong tag name in argument "value" of cw_slider_pm_set_value') 
     182      endcase 
     183    endfor 
     184  ENDIF ELSE BEGIN  
     185    IF float(value[0]) GE minmax[0] $ 
     186      AND float(value[0]) LE minmax[1] THEN value2 = float(value[0]) 
     187  ENDELSE 
     188  IF n_elements(value2) NE 0 THEN BEGIN  
     189    widget_control, sbid, set_value = fix(value2) 
     190    widget_control, dcid, set_value = decvalue(value2) 
     191    widget_control, dcid, set_combobox_select = decind(value2) 
     192  ENDIF  
     193  return 
    151194end 
    152195;---------------------------------------------------------------------- 
    153196FUNCTION cw_slider_pm_get_value, id 
    154    SliderBarId = widget_info(id,find_by_uname = 'SliderBar') 
    155    widget_control, SliderBarId, get_value = value 
    156    return, {value:value, slider_min_max:widget_info(SliderBarId, /slider_min_max)} 
     197  sbid = widget_info(id, find_by_uname = 'SliderBar') 
     198  dcid = widget_info(id, find_by_uname = 'decimal') 
     199  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     200  value = float(widget_info(dcid, /combobox_gettext)) 
     201   return, {value:value, slider_min_max:minmax} 
    157202end 
    158203;---------------------------------------------------------------------- 
    159204FUNCTION cw_slider_pm_event, event 
    160    widget_control, event.id, get_uvalue=uval 
    161 ; 
    162    if uval EQ 'SliderBar' then $ 
    163     return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    164              , VALUE:event.value, OUT:0} 
    165 ; 
    166    SliderBarId = widget_info(event.handler,find_by_uname = 'SliderBar') 
    167    minmax = widget_info(SliderBarId, /SLIDER_MIN_MAX) 
    168    widget_control, SliderBarId, get_value = value 
    169    case uval OF 
    170       'plus':BEGIN 
    171          if value NE minmax[1] then widget_control, SliderBarId,set_value = value+1 
    172          return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    173                   , VALUE:(value+1) < minmax[1], OUT:long(value eq minmax[1])} 
    174       END 
    175       'minus':BEGIN 
    176          if value NE minmax[0] then widget_control, SliderBarId,set_value = value-1 
    177          return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    178                   , VALUE:0 > (value-1), OUT:-long(value EQ minmax[0])} 
    179       END 
    180    endcase 
    181 end 
    182 ;---------------------------------------------------------------------- 
    183 FUNCTION cw_slider_pm, parent, ROW = row, COLUMN = column, VERTICAL = vertical, UVALUE = uvalue, UNAME = uname, _extra = ex 
     205  widget_control, event.id, get_uvalue = uval 
     206; 
     207  sbid = widget_info(event.handler, find_by_uname = 'SliderBar') 
     208  dcid = widget_info(event.handler, find_by_uname = 'decimal') 
     209  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     210  IF uval EQ 'decimal' THEN value = float(event.str) $ 
     211  ELSE value = float(widget_info(dcid, /combobox_gettext)) 
     212  out = 0 ; defaut case 
     213  case uval OF 
     214    'plus': if (value + 1) LE minmax[1] then value2 = value + 1 ELSE out = 1 
     215    'minus':if (value - 1) GE minmax[0] then value2 = value - 1 ELSE out = -1 
     216    'SliderBar':if (event.value + value - floor(value)) LE minmax[1] THEN value2 = event.value + value - floor(value) 
     217    'decimal':BEGIN  
     218      CASE 1 OF 
     219        value GT minmax[1]: value2 = minmax[1] 
     220        value LT minmax[0]: value2 = minmax[0] 
     221        ELSE: 
     222      ENDCASE 
     223    END 
     224    ELSE: 
     225  ENDCASE 
     226  IF n_elements(value2) NE 0  THEN BEGIN 
     227    value = value2 
     228    widget_control, sbid, set_value = floor(value) 
     229    widget_control, dcid, set_value = decvalue(value) 
     230    widget_control, dcid, set_combobox_select = decind(value) 
     231  ENDIF 
     232  return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
     233           , VALUE:value, OUT:OUT} 
     234end 
     235;---------------------------------------------------------------------- 
     236FUNCTION cw_slider_pm, parent, MAXIMUM = maximum, MINIMUM = minimum $ 
     237                       , STRMINLEN = strminlen, VALUE = value, UVALUE = uvalue $ 
     238                       , UNAME = uname, title = title, _extra = ex 
    184239 
    185    IF (N_PARAMS() NE 1) THEN MESSAGE, 'Incorrect number of arguments' 
    186    ON_ERROR, 2                  ;return to caller 
     240  IF (N_PARAMS() NE 1) THEN MESSAGE, 'Incorrect number of arguments' 
     241  ON_ERROR, 2                   ;return to caller 
     242; 
     243  if n_elements(minimum) NE 0 then minimum = floor(minimum) ELSE minimum = 0 
     244  if n_elements(maximum) NE 0 then maximum = ceil(maximum) ELSE maximum = 100 
     245  if NOT keyword_set(title) then title = '    ' 
    187246; 
    188247; cheking exclusive keywords 
    189    column = (keyword_set(column)*(1-keyword_set(row))+keyword_set(vertical)) < 1 
    190    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
    191    if NOT keyword_set(uvalue) then uvalue = '' 
    192    if NOT keyword_set(uname) then uname = '' 
    193    base = widget_base(parent, space = 1, xpad = 1, ypad = 1 $ 
    194                       , EVENT_FUNC = 'cw_slider_pm_event' $ 
    195                       , FUNC_GET_VALUE='cw_slider_pm_get_value' $ 
    196                       , PRO_SET_VALUE='cw_slider_pm_set_value' $ 
    197                       , ROW = row, COLUMN = column, UVALUE = uvalue, UNAME = uname, _extra = ex)    
    198 ; 
    199    if keyword_set(vertical) then BEGIN 
    200       if keyword_set(row) then begin 
    201          nothing = widget_slider(base, /VERTICAL, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    202          base1 = widget_base(base, space = 1, xpad = 1, ypad = 1 $ 
    203                              , /column, /align_center) 
    204          nothing = widget_button(base1,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    205          nothing = widget_button(base1,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    206       ENDIF ELSE BEGIN  
    207          nothing = widget_button(base,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    208          nothing = widget_slider(base, /VERTICAL, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    209          nothing = widget_button(base,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    210       ENDELSE 
    211    ENDIF ELSE BEGIN 
    212       if keyword_set(row) then begin 
    213          nothing = widget_button(base,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    214          nothing = widget_slider(base, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    215          nothing = widget_button(base,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    216       ENDIF ELSE BEGIN  
    217          nothing = widget_slider(base, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    218          base1 = widget_base(base, space = 1, xpad = 1, ypad = 1 $ 
    219                              , /row, /align_center) 
    220          nothing = widget_button(base1,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    221          nothing = widget_button(base1,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    222       ENDELSE 
    223    ENDELSE 
    224 ; 
    225 ; 
    226    return, base 
    227 end 
     248  column = (keyword_set(column)*(1-keyword_set(row))+keyword_set(vertical)) < 1 
     249  row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
     250  if NOT keyword_set(uvalue) then uvalue = '' 
     251  if NOT keyword_set(uname) then uname = '' 
     252  base = widget_base(parent $ 
     253                     , EVENT_FUNC = 'cw_slider_pm_event' $ 
     254                     , FUNC_GET_VALUE = 'cw_slider_pm_get_value' $ 
     255                     , PRO_SET_VALUE = 'cw_slider_pm_set_value' $ 
     256                     , space = 0, UVALUE = uvalue, UNAME = uname, _extra = ex)    
     257; 
     258  mlen = (widget_info(base, string_size = 'm'))[0] 
     259 
     260  xsize = mlen*strlen(title) 
     261  dummyid = widget_label(base, value = title, xsize = xsize) 
     262  dummyid = widget_button(base, value = '-', uvalue = 'minus' $ 
     263                          , yoffset = 15, xsize = 15, ysize = 15) 
     264  dummyid = widget_button(base, value = '+', uvalue = 'plus' $ 
     265                          , xoffset = 15, yoffset = 15, xsize = 15, ysize = 15) 
     266  xoff = 30 > xsize 
     267  lenstr = max(strlen(strtrim([minimum, maximum], 1))) 
     268  if keyword_set(strminlen) then lenstr = strminlen > lenstr 
     269;  xsize = 35 + mlen*(lenstr+1)+3*(lenstr lt 4) 
     270  xsize = 35 + mlen*(lenstr+2) 
     271  dummyid = widget_combobox(base, value = decvalue(minimum) $ 
     272                            , UVALUE = 'decimal', UNAME = 'decimal' $ 
     273                            , xoffset = xoff, yoffset = 2, xsize = xsize) 
     274 
     275  dummyid = widget_slider(base, MAXIMUM = maximum, MINIMUM = minimum, UVALUE = 'SliderBar' $ 
     276                          , UNAME = 'SliderBar', /suppress_value, /drag $ 
     277                          , yoffset = 30, xsize = xoff + xsize) 
     278; 
     279  if keyword_set(value) then cw_slider_pm_set_value, base, value 
     280; 
     281  return, base 
     282end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_specifie.pro

    r51 r69  
    1414      if strtrim(autresautres, 2) NE '' then begin 
    1515         nothing = execute('autresautres = get_extra('+autresautres+')') 
     16;         autresautres = createfunc('get_extra('+autresautres+')') 
    1617         autres = mixstru(autres, autresautres) 
    1718      endif 
     
    3839   if strtrim(autres, 2) NE '' then $ 
    3940    rien = execute('exextra = get_extra('+autres+', _extra = exextra)') 
     41;    exextra = createfunc('get_extra('+autres+', _extra = exextra)') 
    4042   return, exextra 
    4143end 
     
    4749;------------------------------------------------------------ 
    4850;------------------------------------------------------------ 
    49    widget_control, event.id, get_uvalue = uval 
    50    widget_control, event.top, get_uvalue = top_uvalue 
    51    smallin = extractatt(top_uvalue, 'smallin') 
    52    numdessinin = smallin[2]-1 
    53    smallout = extractatt(top_uvalue, 'smallout') 
    54    numdessinout = smallout[2]-1 
     51  widget_control, event.id, get_uvalue = uval 
     52  widget_control, event.top, get_uvalue = top_uvalue 
     53  smallin = extractatt(top_uvalue, 'smallin') 
     54  numdessinin = smallin[2]-1 
     55  smallout = extractatt(top_uvalue, 'smallout') 
     56  numdessinout = smallout[2]-1 
    5557;------------------------------------------------------------ 
    56    case uval of 
    57       'default':BEGIN  
     58  case uval of 
     59    'default':BEGIN  
    5860;--------------- 
    5961; on trouve le nom de la variable: 
    6062;--------------- 
    61          champid = widget_info(event.top, find_by_uname = 'champ') 
    62          currentfile = extractatt(top_uvalue, 'currentfile') 
    63          listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
    64          varname = listvar[widget_info(champid, /droplist_select)] 
     63      vlstid = widget_info(base, find_by_uname = 'varlist') 
     64      fieldname = widget_info(vlstid, /combobox_gettext) 
    6565;--------------- 
    66          exextra = definedefaultextra(varname) 
    67          widget_control, widget_info(event.handler,find_by_uname='min'), set_value = strtrim(exextra.min, 1) 
    68          widget_control, widget_info(event.handler,find_by_uname='max'), set_value = strtrim(exextra.max, 1) 
    69          widget_control, widget_info(event.handler,find_by_uname='int'), set_value = strtrim(exextra.inter, 1) 
    70          widget_control, widget_info(event.handler,find_by_uname='palnum'), set_value = strtrim(exextra.lct, 1) 
    71          widget_control, widget_info(event.handler,find_by_uname='autres'), set_value = '' 
    72       END 
    73       'palcol':BEGIN  
    74          ind = fix(strmid(event.value, 0, strpos(event.value, '-'))) 
    75          widget_control, widget_info(event.handler,find_by_uname='palnum'), set_value = strtrim(ind, 1) 
    76       END 
    77       'ok': 
    78       ELSE: 
    79    endcase 
    80    return,{ID:event.handler, TOP:event.top, HANDLER:0L, OK:uval EQ 'ok'} 
     66      exextra = definedefaultextra(varname) 
     67      widget_control, widget_info(event.handler, find_by_uname = 'min'), set_value = strtrim(exextra.min, 1) 
     68      widget_control, widget_info(event.handler, find_by_uname = 'max'), set_value = strtrim(exextra.max, 1) 
     69      widget_control, widget_info(event.handler, find_by_uname = 'int'), set_value = strtrim(exextra.inter, 1) 
     70      widget_control, widget_info(event.handler, find_by_uname = 'palnum'), set_value = strtrim(exextra.lct, 1) 
     71      widget_control, widget_info(event.handler, find_by_uname = 'autres'), set_value = '' 
     72    END 
     73    'palcol':BEGIN  
     74      ind = fix(strmid(event.value, 0, strpos(event.value, '-'))) 
     75      widget_control, widget_info(event.handler, find_by_uname = 'palnum'), set_value = strtrim(ind, 1) 
     76    END 
     77    ELSE: 
     78  endcase 
     79  return, {ID:event.handler, TOP:event.top, HANDLER:0L, OK:uval EQ 'ok'} 
    8180end 
    8281;***************************************************** 
     
    8988   if NOT keyword_set(uvalue) then uvalue = '' 
    9089   if NOT keyword_set(uname) then uname = '' 
    91    base = widget_base(parent, ROW = row, COLUMN = column $ 
     90   base = widget_base(parent, space = 0, /frame $ 
    9291                      , EVENT_FUNC = 'cw_specifie_event' $ 
    9392                      , FUNC_GET_VALUE='cw_specifie_get_value' $ 
    9493                      , PRO_SET_VALUE='cw_specifie_set_value' $ 
    9594                      , UVALUE = uvalue, UNAME = uname, _extra = ex)    
    96 ; base1 pour specifier le min, le max et l''intervalle 
    97    base1 = widget_base(base, /row, /frame) 
    98    rien = widget_label(base1, value = 'Min') 
    99    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'min', uvalue = 'min') 
    100    rien = widget_label(base1, value = 'Max') 
    101    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'max', uvalue = 'max') 
    102    rien = widget_label(base1, value = 'Int') 
    103    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'int', uvalue = 'int') 
    104 ; base2 por specifier la palette de couleur (soit par numero soit ds 
    105 ; un menu deroulant) 
    106    if keyword_set(FORXXX) then base2 = widget_base(base, /row, /frame) ELSE base2 = base1 
    107    rien = widget_label(base2, value = 'Pal Numb') 
    108    if keyword_set(forxxx) then colvalue = '' ELSE colvalue = '39' 
    109    rien = widget_text(base2, value = colvalue, /editable, xsize = 3, uname = 'palnum', uvalue = 'palnum') 
    110    lct,  get_name = nomcouleur 
     95; base1  
     96   base1 = widget_base(base) 
     97   rien = widget_label(base1, value = 'Min', xoffset =  85, yoffset = 15) 
     98   rien = widget_label(base1, value = 'Max', xoffset = 145, yoffset = 15) 
     99   rien = widget_label(base1, value = 'Int', xoffset = 210, yoffset = 15) 
     100; 
     101   lct, get_name = nomcouleur 
    111102   nbrligne = 30 
    112103   nbrlist = n_elements(nomcouleur)/nbrligne 
    113104   nomcouleur = strtrim(sindgen(n_elements(nomcouleur)), 1)+'- '+nomcouleur 
    114105   nomcouleur = '0\'+nomcouleur 
    115    nomcouleur = ['1\color palette', nomcouleur] 
     106   nomcouleur = ['1\Color', nomcouleur] 
    116107   if nbrlist GT 1 then for i = 1,nbrlist do $ 
    117108    nomcouleur = [nomcouleur[0:nbrligne*i-1+i], '1\ ', nomcouleur[nbrligne*i+i:n_elements(nomcouleur)-1]] 
    118    rien = cw_pdmenu(base2,nomcouleur, /RETURN_NAME , uvalue = 'palcol', uname = 'palcol') 
     109   rien = cw_pdmenu(base1, nomcouleur, /RETURN_NAME , uvalue = 'palcol', uname = 'palcol', xoffset = 250, yoffset = 0) 
     110; base2 
     111   base2 = widget_base(base, column = 4+keyword_set(forxxx), yoffset = 30) 
     112   if keyword_set(forxxx) then rien = widget_button(base2,value='Default', uvalue = 'default', /frame, tooltip = 'see '+find('definedefaultextra')) 
     113   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'min', uvalue = 'min') 
     114   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'max', uvalue = 'max') 
     115   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'int', uvalue = 'int') 
     116   if keyword_set(forxxx) then colvalue = '' ELSE colvalue = '39' 
     117   rien = widget_text(base2, value = colvalue, /editable, xsize = 2, uname = 'palnum', uvalue = 'palnum') 
    119118 
    120 ; baseavantfin pour passer tous les mots cles possibles... 
     119 
     120 
    121121; widget text contennant les autres mots cles passe ds top_uvalue.exextra 
    122122; en reste-t-il? si oui, il faut les mettres sous forme de string 
     123    
     124   rien = widget_text(base, value = '  ', /editable, uname = 'autres', uvalue = 'autres', xsize = 54, ysize = 3, yoffset = 65, /wrap, /no_newline) 
    123125 
    124    baseavantfin = widget_base(base, /row, /frame) 
    125    rien = widget_label(baseavantfin, value = 'Keywords') 
    126    rien = widget_text(baseavantfin, value = '  ', /editable, uname = 'autres', uvalue = 'autres', scr_xsize = 400) 
    127    if keyword_set(forxxx)  then begin 
    128 ; basefin pour en finir, 2 boutons: Default/OK 
    129       basefin = widget_base(base, /row, /frame, /align_center) 
    130       rien = widget_button(basefin,value='Default', uvalue = 'default') 
    131       rien = widget_button(basefin,value='OK', uvalue = 'ok') 
    132 ; on intialise les widget_text: 
    133       cw_specifie_set_value, base, definedefaultextra('rien_du_tout') 
    134    endif 
     126    if keyword_set(forxxx) then cw_specifie_set_value, base, definedefaultextra('rien_du_tout') 
    135127 
    136128;------------------------------------------------ 
  • trunk/ToBeReviewed/WIDGET/xxx.pro

    r52 r69  
    6666   endif 
    6767; 
    68 ; 
    6968   options = extractatt(top_uvalue, 'options') 
    70    index = where(options EQ 'Ok button') & index = index[0] 
    71    currentplot = (extractatt(top_uvalue, 'smallout'))[2]-1 
    72    okbutton = extractatt(top_uvalue, 'optionsflag') 
    73    okbutton = okbutton[index, currentplot] 
    7469   case uval.name OF 
    7570      'menubar':xxxmenubar_event, event 
    7671      'ok':nouveaudessin = 1 
    77       'specifie':nouveaudessin = event.ok*(1-okbutton) 
    78       'action':nouveaudessin = 1-okbutton 
     72      'specifie': 
     73      'action': 
    7974      'calendar1':BEGIN 
    8075         date2id = widget_info(event.top, find_by_uname = 'calendar2') 
    8176         widget_control, date2id, get_value = date2 
    8277         if event.value GT date2 then widget_control, date2id, set_value = event.value 
    83  
    84          nouveaudessin = 1-okbutton 
    8578      END 
    8679      'calendar2':BEGIN 
     
    8881         widget_control, date1id, get_value = date1 
    8982         if event.value LT date1 then widget_control, date1id, set_value = event.value 
    90  
    91          nouveaudessin = 1-okbutton 
    92       END 
    93       'domain':nouveaudessin = 1-okbutton 
    94       'champ':BEGIN 
     83      END 
     84      'domain': 
     85      'varlist':BEGIN 
    9586         currentfile  = extractatt(top_uvalue, 'currentfile') 
    9687         listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
    9788         name = listvar[event.index] 
    9889         changefield, event.top, name 
    99          nouveaudessin = 1-okbutton 
    100       END 
    101       'nom_exp':nouveaudessin = 1-okbutton 
     90      END 
     91      'txtcmd': 
    10292      'filelist':BEGIN 
    103          filelist = extractatt(top_uvalue, 'filelist') 
    104          newfilename = filelist[event.index] 
    105          changefile, event.top, newfilename 
     93         changefile, event.top, event.index 
    10694      END 
    10795      'ActiverFenetre':BEGIN 
     
    123111            'inutile':return 
    124112            'long':longclickaction, event 
    125             'single':BEGIN  
    126                print, quelclick.type 
    127             END 
     113            'single':singleclickaction, event 
    128114            'double':doubleclickaction, event 
    129115         endcase 
     
    139125;------------------------------------------------------------ 
    140126;------------------------------------------------------------ 
    141 PRO xxx, BOXZOOM = boxzoom, CALLERWIDID = CallerWidId, DATE1 = date1, DATE2 = date2, SMALL = small, MULTISTRUCTURE = multistructure, REDRAW = redraw, SEPARATE = separate, UVALUE = uvalue, RESTORE = restore, _EXTRA = ex 
    142 ;------------------------------------------------------------ 
    143 @common 
    144 ;------------------------------------------------------------ 
    145 ; initialisation de l''environnement 
    146 ;------------------------------------------------------------ 
    147    reinitplt 
    148 ;------------------------------------------------------------ 
    149 ; on va recupere la uvalue attache au widget qui a 
    150 ; appele le nouveau widget que l''on est en train de mettre en place 
    151    if keyword_set(restore) then BEGIN 
    152       restore = isafile(filename = restore, iodir = homedir, _extra = ex) 
    153       if size(restore, /type) NE 7 then restore = 0 ELSE BEGIN  
    154          restore, isafile(file = restore, iodir = homedir, _extra = ex) 
    155          newgrid = *(extractatt(uvalue, 'meshparameters'))[0] 
    156          change = changegrid(newgrid) 
    157       ENDELSE  
    158    endif 
    159    if n_elements(CallerWidId) NE 0 THEN $ 
    160     widget_control, CallerWidId, get_uvalue = uvalue ELSE CallerWidId = 0 
    161 ;------------------------------------------------------------ 
    162 ; on commmence la definition du widget... 
    163 ;------------------------------------------------------------ 
    164 ; sa base 
    165    base = widget_base(column = 1-(key_portrait OR keyword_set(SEPARATE)) $ 
    166                       , row = key_portrait OR keyword_set(SEPARATE), title='xxx' $ 
    167                       , GROUP_LEADER = group, /tracking_events, uname = 'base', mbar = mbarid) 
    168 ; la barre de menu 
    169    if keyword_set(uvalue) then begin 
    170       options = extractatt(uvalue, 'options') 
    171    ENDIF ELSE options = ['Ok button', 'Portrait/Landscape', 'Overlay', 'Vecteur', 'Longitude / x index', 'Latitude / y index'] 
    172    xxxmenubar, mbarid, options = options 
    173 ;------------------------------------------------------------ 
    174 ; on passe a la definition de tout ce qui est au dessus du dessin 
    175 ;------------------------------------------------------------ 
    176 ; base contenant les boutons au dessus, a gauche du dessin 
    177    base1 = widget_base(base, /column) 
    178    base1bis = widget_base(base1, column = key_portrait OR keyword_set(SEPARATE) $ 
    179                           , row = 1-(key_portrait OR keyword_set(SEPARATE))) 
    180 ;------------------------------------------------------------ 
    181 ; sous base separant les boutons du widget_domain 
    182    base11=widget_base(base1bis, /row)  
    183 ; 
    184    base111=widget_base(base11,  /column)  
     127PRO xxx, datafilename, idlfile, argspro, CALLERWIDID = CallerWidId $ 
     128         , REDRAW = redraw, SEPARATE = separate, UVALUE = uvalue $ 
     129         , RESTORE = restore, _EXTRA = ex 
     130;------------------------------------------------------------ 
     131@all_cm 
     132;------------------------------------------------------------ 
     133; reinitialize the !p, !x, !y, !z variables 
     134;------------------------------------------------------------ 
     135  reinitplt 
     136;------------------------------------------------------------ 
     137; we get back the uvalue of the widget that called xxx to create a new widget 
     138  if keyword_set(restore) then BEGIN 
     139    restore = isafile(filename = restore, iodir = homedir, _extra = ex) 
     140    if size(restore, /type) NE 7 then restore = 0 ELSE BEGIN  
     141      restore, isafile(file = restore, iodir = homedir, _extra = ex) 
     142      newgrid = *(extractatt(uvalue, 'meshparameters'))[0] 
     143      change = changegrid(newgrid) 
     144    ENDELSE  
     145  endif 
     146  if n_elements(CallerWidId) NE 0 THEN $ 
     147     widget_control, CallerWidId, get_uvalue = uvalue ELSE CallerWidId = 0 
     148;------------------------------------------------------------ 
     149;------------------------------------------------------------ 
     150; liste des fichiers que l''on veut regarder 
     151; 
     152  if keyword_set(uvalue) then BEGIN  
     153    currentfile = extractatt(uvalue, 'currentfile') 
     154    filelist = extractatt(uvalue, 'filelist') 
     155    fileparameters = extractatt(uvalue, 'fileparameters') 
     156    readparameters = extractatt(uvalue, 'readparameters') 
     157    meshparameters = extractatt(uvalue, 'meshparameters') 
     158  ENDIF ELSE BEGIN 
     159    newfile = selectfile(datafilename, idlfile, argspro, _extra = ex) 
     160    if size(newfile, /type) NE 8 then return 
     161    fileparameters = ptrarr(1, /allocate_heap) 
     162    *fileparameters[0] = newfile.fileparameters 
     163    readparameters = ptrarr(1, /allocate_heap) 
     164    *readparameters[0] = newfile.readparameters 
     165    meshparameters = ptrarr(1, /allocate_heap) 
     166    *meshparameters[0] = newfile.meshparameters 
     167    currentfile = 0 
     168    filelist = newfile.fileparameters.filename 
     169  ENDELSE 
     170; 
     171  if keyword_set(uvalue) THEN BEGIN  
     172    smallin = extractatt(uvalue, 'smallin') 
     173    smallout = extractatt(uvalue, 'smallout') 
     174  ENDIF ELSE BEGIN  
     175    smallin = [1, 1, 1] 
     176    smallout = [1, 1, 1] 
     177  ENDELSE  
     178  nbredessin = smallin[0]*smallin[1] 
     179  numdessinin = smallin[2]-1 
     180; warning flg definition must be consistent with cw_pdmenu argument 
     181; see also flag definition in cw_pagelayout 
     182  if keyword_set(uvalue) then BEGIN  
     183    flag = extractatt(uvalue, 'optionsflag') 
     184    key_portrait = flag[0, numdessinin] 
     185  ENDIF ELSE flag = [key_portrait, 0, 0, 0, 0]#replicate(1, nbredessin) 
     186 
     187;------------------------------------------------------------ 
     188;------------------------------------------------------------ 
     189; We start the widget definition 
     190;------------------------------------------------------------ 
     191;------------------------------------------------------------ 
     192; 
     193; widget and screen size 
     194  scrsize = get_screen_size()*0.95 
     195  windsize = givewindowsize() 
     196  xxxsize = [windsize[0] * (1-keyword_set(separate)) + 350, windsize[1]] 
     197; 
     198;------------------------------------------------------------ 
     199; The top base 
     200;------------------------------------------------------------ 
     201  IF xxxsize[0] LE scrsize[0] AND xxxsize[1] LE scrsize[1] THEN BEGIN  
     202    base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $ 
     203                       , uname = 'base', space = 0) 
     204  ENDIF ELSE BEGIN  
     205    base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $ 
     206                       , uname = 'base', space = 0 $ 
     207                       , xsize = xxxsize[0], ysize = xxxsize[1] $ 
     208                       , x_scroll_size = (xxxsize[0] < scrsize[0]) $ 
     209                       , y_scroll_size = (xxxsize[1] < scrsize[1])) 
     210  ENDELSE 
     211 
     212;------------------------------------------------------------ 
     213; combobox for plots choice 
     214;------------------------------------------------------------ 
     215  xoff = 0 
     216  yoff = 0 
     217  pltlst = ['plt', 'pltz', 'pltz_diag', 'pltt', 'pltt_diag' $ 
     218            , 'xy', 'xz', 'yz', 'xt', 'yt', 'zt' $ 
     219            , 'x', 'y', 'z', 't'] 
     220  actid = widget_combobox(base, value = pltlst, uname = 'action', uvalue = {name:'action'} $ 
     221                            , xoffset = xoff+5, yoffset = yoff+4, xsize = 80) 
     222  if keyword_set(uvalue) then BEGIN 
     223    selectact = (extractatt(uvalue, 'types'))[numdessinin] 
     224    selectact = (where(pltlst EQ selectact))[0] 
     225    widget_control, actid, set_combobox_select = 0 > selectact  
     226  ENDIF ELSE selectfile = 0 
     227 
     228;------------------------------------------------------------ 
     229; menu/options 
     230;------------------------------------------------------------ 
     231  xoff = xoff + 100 
     232  if keyword_set(uvalue) then begin 
     233    options = extractatt(uvalue, 'options') 
     234  ENDIF ELSE options = ['Portrait/Landscape', 'Overlay', 'Vecteur' $ 
     235                        , 'Longitude / x index', 'Latitude / y index'] 
     236 
     237   desc = [ '1\File', $ 
     238            '0\Open' , $ 
     239            '0\New xxx' , $ 
     240            '2\Quit', $ 
     241            '1\Save as' , $ 
     242            '0\PostScript' , $ 
     243            '0\Animated gif' , $ 
     244            '0\Gif' , $ 
     245            '0\IDL procedure', $ 
     246            '0\RESTORE kwd of xxx', $ 
     247            '2\Print to prompt', $ 
     248            '1\Flag options'] 
     249   descsuite = options 
     250   if n_elements(descsuite) GE 2 then $ 
     251    descsuite[0:n_elements(descsuite)-2] = '0\'+descsuite[0:n_elements(descsuite)-2] 
     252   descsuite[n_elements(descsuite)-1] = '2\'+descsuite[n_elements(descsuite)-1] 
     253   desc = [desc, descsuite] 
     254; 
     255   menu = cw_pdmenu(base, desc, /RETURN_NAME, uname = 'menubar', uvalue = {name:'menubar'} $ 
     256                    , xoffset = xoff, yoffset = yoff) 
     257 
     258;------------------------------------------------------------ 
     259; Ok button 
     260;------------------------------------------------------------ 
     261  yoff = yoff + 37 
     262  xoff = 5 
    185263; boutton 'OK' 
    186    baseok = widget_base(base111, /row, /align_right $ 
    187                         , map = 0, uname = 'base ok button') 
    188    rien = widget_button(baseok, /align_right, value = ' OK ', uvalue = {name:'ok'}, /frame) 
    189 ; droplist des types de plots possibles 
    190    graphtype = ['plt','pltz', 'pltt', 'xy', 'xz', 'yz', 'xt', 'yt', 'zt', 'x', 'y', 'z', 't'] 
    191    graphtypeid = widget_droplist(base111, value = graphtype, uname = 'action', uvalue = {name:'action', choix:graphtype}) 
    192 ; configuration de la page 
    193    if n_elements(small) eq 0 then BEGIN  
    194       smallin = [1, 1, 1] 
    195       smallout = [1, 1, 1] 
    196    endif 
    197    if keyword_set(uvalue) then begin 
    198       smallin = extractatt(uvalue, 'smallin') 
    199       smallout = extractatt(uvalue, 'smallout') 
    200    endif 
    201    nbredessin = smallin[0]*smallin[1] 
    202    numdessinin = smallin[2]-1 
    203 ; 
    204    rien = cw_miseenpage(base11, smallin, /row, /frame) 
    205 ; mapping du boutton 'OK' 
    206    if keyword_set(uvalue) then flag = extractatt(uvalue,'optionsflag') $ 
    207 ;   ELSE flag = [0, key_portrait, 0, 1, 0, 0, 0]#replicate(1, smallin[2]-1) 
    208    ELSE flag = [1, key_portrait, 0, 0, 0, 0]#replicate(1, nbredessin) 
    209    currentflag = flag[*, smallin[2]-1] 
    210    widget_control, baseok, map = currentflag[0] 
    211 ; 
    212 ; liste des fichiers que l''on veut regarder 
    213 ; 
    214    if keyword_set(uvalue) then BEGIN  
    215       currentfile = extractatt(uvalue,'currentfile') 
    216       filelist = extractatt(uvalue,'filelist') 
    217       fileparameters = extractatt(uvalue,'fileparameters') 
    218       readparameters = extractatt(uvalue,'readparameters') 
    219       meshparameters = extractatt(uvalue,'meshparameters') 
    220    ENDIF ELSE BEGIN 
    221       if keyword_set(multistructure) then newfile = multistructure ELSE newfile = selectfile() 
    222       if size(newfile, /type) NE 8 then return 
    223       fileparameters = ptrarr(1, /allocate_heap) 
    224       *fileparameters[0] = newfile.fileparameters 
    225       readparameters = ptrarr(1, /allocate_heap) 
    226       *readparameters[0] = newfile.readparameters 
    227       meshparameters = ptrarr(1, /allocate_heap) 
    228       *meshparameters[0] = newfile.meshparameters 
    229       currentfile = 0 
    230       filelist = newfile.fileparameters.filename 
    231    ENDELSE 
    232 ; liste des fichiers 
    233    rien = widget_list(base11, value = filelist, uname = 'filelist', uvalue = {name:'filelist'}, scr_xsize = 100) 
    234 ; specification de l''operation que l''on veut faire sur les fichiers 
    235    if keyword_set(CallerWidId) then begin 
    236       widget_control, widget_info(CallerWidId, find_by_uname = 'nom_exp'), get_value = value 
    237       value = value[0] 
    238    ENDIF ELSE value = varexp 
    239    rien=widget_text(base11, value = value, uvalue={name:'nom_exp'}, uname='nom_exp', /editable) 
    240 ; liste des variables 
    241    currentlistvar = (*fileparameters[currentfile]).listvar 
    242 ; 
    243    if keyword_set(separate) then basechamp = widget_base(base1bis, /row)  
    244    base12=widget_base(base1bis, /row , uname = 'base12')  
    245    if NOT keyword_set(separate) then basechamp = base12 
    246 ; 
    247    rien=widget_droplist(basechamp, value=currentlistvar, title ='champ' $ 
    248                         , uvalue ={name:'champ'}, uname='champ') 
    249    if keyword_set(CallerWidId) then begin 
    250       selectvar = widget_info(widget_info(CallerWidId, find_by_uname = 'champ'), /droplist_select) 
    251    ENDIF ELSE selectvar = 0 
    252    widget_control, rien, set_droplist_select = selectvar 
    253 ; calendrier 
    254    currentcalendar = (*fileparameters[currentfile]).time_counter 
    255    if keyword_set(CallerWidId) then begin 
    256       widget_control, widget_info(CallerWidId, find_by_uname = 'calendar1'), get_value = date1 
    257       widget_control, widget_info(CallerWidId, find_by_uname = 'calendar2'), get_value = date2 
    258       date1 = juldate(date1) 
    259       date2 = juldate(date2) 
    260    ENDIF 
    261    rien = cw_calendar(base12,currentcalendar, date1, uname = 'calendar1', uvalue = {name:'calendar1'}, /frame) 
    262    rien = cw_calendar(base12,currentcalendar, date2, uname = 'calendar2', uvalue = {name:'calendar2'}, /frame) 
    263 ;------------------------------------------------------------ 
    264 ; 2eme ligne 
    265 ;------------------------------------------------------------ 
    266    vargrid = strupcase((*fileparameters[currentfile]).listgrid[selectvar]) 
    267    IF vargrid EQ 'W' then zgrid = 'W' ELSE zgrid = 'T' 
    268    rien = cw_domain(base1, uname = 'domain', uvalue = {name:'domain'}, /unzoom, /frame, boxzoom = boxzoom, row = 1-(key_portrait OR keyword_set(SEPARATE)), column = key_portrait OR keyword_set(SEPARATE)) 
    269 ;------------------------------------------------------------ 
    270 ; 3eme ligne 
    271 ;------------------------------------------------------------ 
    272    rien = cw_specifie(base1, uname = 'specifie', uvalue = {name:'specifie'}, /frame, column = key_portrait OR keyword_set(SEPARATE), /forxxx) 
    273    if keyword_set(CallerWidId) then BEGIN 
    274       widget_control, widget_info(CallerWidId, find_by_uname = 'specifie'), get_value = specifie_value 
    275       widget_control, widget_info(base, find_by_uname = 'specifie'), set_value = specifie_value 
    276    ENDIF 
    277 ;------------------------------------------------------------ 
    278 ; partie graph 
    279 ;------------------------------------------------------------ 
    280    if keyword_set(separate) then $ 
    281     basegraph = widget_base(title = 'xxx window',  group_leader = base, uvalue = base) $ 
    282    ELSE basegraph = widget_base(base, /row) 
    283     
    284    windsize = givewindowsize() 
    285    graphid = widget_draw(basegraph, uname = 'graph' $ 
    286                          , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ 
    287                          , /button_events, retain = 2 $ 
    288                          , xsize=windsize[0], ysize=windsize[1]) 
    289    if keyword_set(separate) then begin 
    290       widget_control,basegraph,/realize 
    291       xmanager,'xxx',basegraph, /no_block 
    292    endif 
    293 ;------------------------------------------------------------ 
    294 ;------------------------------------------------------------ 
    295 ;    base3 = widget_base(base, row = 1-key_portrait, column = key_portrait, /align_right) 
    296 ; ;------------------------------------------------------------ 
    297 ;    base31 = widget_base(base3, row = 1-key_portrait, column = key_portrait, /align_right, map = 0, uname = 'base ok button') 
    298 ;    rien = widget_button(base31, /align_right, value = ' OK ', uvalue = {name:'ok'}, /frame) 
    299 ;   rien = cw_to(base3, /frame, row = 1-key_portrait, column = key_portrait) 
    300 ;   rien = cw_conclu(base3, /align_right, row = 1-key_portrait, column = key_portrait, /frame) 
    301 ;------------------------------------------------------------ 
    302 ;execution de la fentre de base et des sous-fenetres 
    303    widget_control,base,/realize 
    304 ;------------------------------------------------------------ 
    305    if keyword_set(uvalue) then BEGIN ; 
     264  baseok = widget_button(base, value = ' OK ', uvalue = {name:'ok'}, uname = 'ok button' $ 
     265                         , /frame, xoffset = xoff, yoffset = yoff) 
     266 
     267;------------------------------------------------------------ 
     268; Page Layout 
     269;------------------------------------------------------------ 
     270; page layout 
     271  xoff = xoff + 65 
     272  dummyid = cw_pagelayout(base, smallin, /row, /frame, xoffset = xoff, yoffset = yoff) 
     273; 
     274;------------------------------------------------------------ 
     275; List of Variables 
     276;------------------------------------------------------------ 
     277  xoff = xoff + 140 
     278  currentlistvar = (*fileparameters[currentfile]).listvar 
     279  vlstid = widget_combobox(base, value = currentlistvar, uvalue = {name:'varlist'} $ 
     280                           , uname = 'varlist', xoffset = xoff, yoffset = yoff+1) 
     281  if keyword_set(uvalue) then BEGIN 
     282    selectvar = (extractatt(uvalue, 'varinfo'))[1, numdessinin] 
     283    selectvar = (where(currentlistvar EQ selectvar))[0] 
     284    widget_control, vlstid, set_combobox_select = 0 > selectvar  
     285  ENDIF ELSE selectvar = 0 
     286;------------------------------------------------------------ 
     287; List of files 
     288;------------------------------------------------------------ 
     289  yoff = yoff + 35 
     290  flstid = widget_combobox(base, value = file_basename(filelist), uname = 'filelist' $ 
     291                           , xsize = 345, yoffset = yoff, uvalue = {name:'filelist'}) 
     292  if keyword_set(uvalue) then BEGIN 
     293    selectfile = (extractatt(uvalue, 'varinfo'))[0, numdessinin] 
     294    selectfile = (where(file_basename(filelist) EQ selectfile))[0] 
     295    widget_control, flstid, set_combobox_select = 0 > selectfile  
     296  ENDIF ELSE selectfile = 0 
     297;------------------------------------------------------------ 
     298; Text for computation 
     299;------------------------------------------------------------ 
     300  yoff = yoff + 32 
     301; computation done on the files... 
     302  if keyword_set(uvalue) then txtvalue = (extractatt(uvalue, 'txtcmd'))[numdessinin] $ 
     303  ELSE txtvalue = varexp 
     304  dummyid = widget_text(base, value = txtvalue, uvalue = {name:'txtcmd'}, uname = 'txtcmd' $ 
     305                        , /editable, yoffset = yoff, xsize = 54, /frame) 
     306;------------------------------------------------------------ 
     307; Calendar 
     308;------------------------------------------------------------ 
     309  yoff = yoff + 40 
     310  currentcalendar = (*fileparameters[currentfile]).time_counter 
     311  key_caltype = (*fileparameters[currentfile]).caltype 
     312  fakecal = (*fileparameters[currentfile]).fakecal 
     313  if keyword_set(uvalue) then begin 
     314    dates = (extractatt(uvalue, 'dates'))[*, numdessinin] 
     315    date1 = date2jul(dates[0]) 
     316    date2 = date2jul(dates[1]) 
     317  ENDIF 
     318  basecalid = widget_base(base, column = 2, space = 0, yoffset = yoff, uname = 'basecal') 
     319  dummyid = cw_calendar(basecalid, currentcalendar, date1, FAKECAL = fakecal, uname = 'calendar1', uvalue = {name:'calendar1'}, /frame) 
     320  dummyid = cw_calendar(basecalid, currentcalendar, date2, FAKECAL = fakecal, uname = 'calendar2', uvalue = {name:'calendar2'}, /frame) 
     321;------------------------------------------------------------ 
     322; Domain  
     323;------------------------------------------------------------ 
     324  yoff = yoff + 60 
     325  vargrid = strupcase((*fileparameters[currentfile]).listgrid[selectvar]) 
     326  IF vargrid EQ 'W' then zgrid = 'W' ELSE zgrid = 'T' 
     327  if keyword_set(uvalue) then boxzoom = (extractatt(uvalue, 'domaines'))[*, numdessinin] 
     328  dummyid = cw_domain(base, uname = 'domain', uvalue = {name:'domain'}, /unzoom, /frame $ 
     329                      , boxzoom = boxzoom, yoffset = yoff, xoffset = 15) 
     330;------------------------------------------------------------ 
     331; Plots specifications 
     332;------------------------------------------------------------ 
     333  yoff = yoff + 230 
     334  speid = cw_specifie(base, uname = 'specifie', uvalue = {name:'specifie'}, /frame, /column $ 
     335                      , /forxxx, yoffset = yoff) 
     336  if keyword_set(uvalue) then BEGIN 
     337    exextra = *((extractatt(uvalue, 'exextra'))[numdessinin]) 
     338    IF n_elements(exextra) NE 0 THEN widget_control, speid, set_value = exextra 
     339  ENDIF 
     340;------------------------------------------------------------ 
     341; drawing part 
     342;------------------------------------------------------------ 
     343  if keyword_set(separate) then $ 
     344     basegraph = widget_base(title = 'xxx window',  group_leader = base, uvalue = base) $ 
     345  ELSE basegraph = base 
     346   
     347  graphid = widget_draw(basegraph, uname = 'graph', /button_events, retain = 2 $ 
     348                        , uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $ 
     349                        , xoffset = 350*(1-keyword_set(separate)) $ 
     350                        , xsize = windsize[0], ysize = windsize[1]); , tooltip = 'toto') 
     351;------------------------------------------------------------ 
     352; realize the widget 
     353;------------------------------------------------------------ 
     354  widget_control, base, /realize 
     355  if keyword_set(separate) then begin 
     356    widget_control, basegraph, /realize 
     357    xmanager, 'xxx', basegraph, /no_block 
     358  endif 
     359 
     360;------------------------------------------------------------ 
     361  if keyword_set(uvalue) then BEGIN ; 
    306362; on recopie le pointeur uvalue dans top_uvalue. 
    307363; Attention, il faut completement redefinir top_uvalue a partir des 
     
    310366; surlesquelles il pointe on detruit aussi les variables sur 
    311367; lesquelles pointent top_uvalue. 
    312       case 1 of 
    313          keyword_set(redraw):BEGIN 
    314             top_uvalue = uvalue 
    315             widget_control, base, set_uvalue = top_uvalue 
     368    case 1 of 
     369      keyword_set(redraw):BEGIN 
     370        top_uvalue = uvalue 
     371        widget_control, base, set_uvalue = top_uvalue 
    316372; we find homedir 
    317             homedir = isadirectory(io = homedir, title = 'Bad definition of homedir') 
    318 ; portrait ou landscape ??? 
    319             options = extractatt(top_uvalue, 'options')    
    320             optionsflag = extractatt(top_uvalue, 'optionsflag') 
    321             portrait = (optionsflag[where(options EQ 'Portrait/Landscape'), 0])[0] 
     373        homedir = isadirectory(io = homedir, title = 'Bad definition of homedir') 
    322374; on recupere la liste des instructions 
    323             globalcommand = extractatt(top_uvalue, 'globalcommand') 
     375        globalcommand = extractatt(top_uvalue, 'globalcommand') 
    324376; on complete par le premiere et les dernieres lignes du programme 
    325             createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
    326                        , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ 
    327                        , KWDUSED = ', /noerase, PORTRAIT = portrait' 
    328          END 
    329          keyword_set(restore):begin 
    330             top_uvalue = uvalue 
    331             widget_control, base, set_uvalue = top_uvalue 
    332             widget_control, graphid,get_value=win 
    333             wshow, win 
    334             wset, win 
    335             tv, image, /true 
     377        createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 
     378                   , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $ 
     379                   +', PORTRAIT = portrait, LANDSCAPE = landscape' $ 
     380                   , /noerase 
     381      END 
     382      keyword_set(restore):begin 
     383        top_uvalue = uvalue 
     384        widget_control, base, set_uvalue = top_uvalue 
     385        widget_control, graphid, get_value = win 
     386        wshow, win 
     387        wset, win 
     388        tv, image, /true 
    336389; etat des widgets 
    337             updatewidget, base 
     390        updatewidget, base 
    338391; menage 
    339          END 
    340          ELSE:BEGIN 
    341             top_uvalue = ptrarr(2, 29, /allocate_heap) 
    342             FOR i =  0, 28 do *top_uvalue[0, i] = *uvalue[0, i] 
    343             FOR i =  0, 14 do *top_uvalue[1, i] = *uvalue[1, i] 
    344             FOR i = 18, 27 do *top_uvalue[1, i] = *uvalue[1, i] 
    345             numfile = n_elements(extractatt(uvalue, 'filelist'))  
    346             *top_uvalue[1, 15] = ptrarr(numfile, /allocate_heap) 
    347             *top_uvalue[1, 16] = ptrarr(numfile, /allocate_heap) 
    348             *top_uvalue[1, 17] = ptrarr(numfile, /allocate_heap) 
    349             for i = 0, numfile-1 do begin 
    350                *(*top_uvalue[1, 15])[i] = *(*uvalue[1, 15])[i]  
    351                *(*top_uvalue[1, 16])[i] = *(*uvalue[1, 16])[i]  
    352                *(*top_uvalue[1, 17])[i] = *(*uvalue[1, 17])[i]  
    353             endfor 
    354             *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap) 
    355             for i = 0, nbredessin-1 do *(*top_uvalue[1, 28])[i] = *(*uvalue[1, 28])[i]  
    356             widget_control, base, set_uvalue = top_uvalue 
     392      END 
     393      ELSE:BEGIN 
     394        top_uvalue = ptrarr(2, 29, /allocate_heap) 
     395        FOR i =  0, 28 do *top_uvalue[0, i] = *uvalue[0, i] 
     396        FOR i =  0, 14 do *top_uvalue[1, i] = *uvalue[1, i] 
     397        FOR i = 18, 27 do *top_uvalue[1, i] = *uvalue[1, i] 
     398        numfile = n_elements(extractatt(uvalue, 'filelist'))  
     399        *top_uvalue[1, 15] = ptrarr(numfile, /allocate_heap) 
     400        *top_uvalue[1, 16] = ptrarr(numfile, /allocate_heap) 
     401        *top_uvalue[1, 17] = ptrarr(numfile, /allocate_heap) 
     402        for i = 0, numfile-1 do begin 
     403          *(*top_uvalue[1, 15])[i] = *(*uvalue[1, 15])[i]  
     404          *(*top_uvalue[1, 16])[i] = *(*uvalue[1, 16])[i]  
     405          *(*top_uvalue[1, 17])[i] = *(*uvalue[1, 17])[i]  
     406        endfor 
     407        *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap) 
     408        for i = 0, nbredessin-1 do *(*top_uvalue[1, 28])[i] = *(*uvalue[1, 28])[i]  
     409        widget_control, base, set_uvalue = top_uvalue 
    357410; copie l''ecran du widget de uvalue dans celui de top_uvalue 
    358             if keyword_set(CallerWidId)  then begin 
    359                widget_control, extractatt(uvalue, 'graphid'),get_value=win 
    360                wshow, win 
    361                wset, win 
    362                image = tvrd(/true) 
    363                widget_control, graphid,get_value=win 
    364                wshow, win 
    365                wset, win 
    366                tv, image, /true 
    367             ENDIF 
    368          END 
    369       endcase 
    370       *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid 
    371 ; 
    372    ENDIF ELSE BEGIN 
     411        if keyword_set(CallerWidId)  then begin 
     412          widget_control, extractatt(uvalue, 'graphid'), get_value = win 
     413          wshow, win 
     414          wset, win 
     415          image = tvrd(/true) 
     416          widget_control, graphid, get_value = win 
     417          wshow, win 
     418          wset, win 
     419          tv, image, /true 
     420        ENDIF 
     421      END 
     422    endcase 
     423    *top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid 
     424; 
     425  ENDIF ELSE BEGIN 
    373426; sinon on va definit tous les elements que l''on acroche au widget 
    374427; grace a la top_uvalue qui est un tableau de pointeurs a 2 colonnes: 
     
    376429; on initialie tous ces elements. 
    377430; variables concernant le widget ds sa generalite 
    378       if NOT keyword_set(ex)  then ex = {nothing:0} 
     431    if NOT keyword_set(ex)  then ex = {nothing:0} 
    379432; variables se rapportant aux differents fichiers que l''on peut lire 
    380433; variables specifiques a chaque dessin 
    381 ; 
    382       types = strarr(nbredessin) 
    383       champs = strarr(2, nbredessin)       
    384       domaines = fltarr(6, nbredessin) 
    385       nameprocedures = strarr(nbredessin) 
    386       dates = lonarr(2, nbredessin) 
    387       prefixes = strarr(nbredessin) 
    388       exextra = ptrarr(nbredessin, /allocate_heap) 
     434;       
     435     
    389436; creation du pointeur que l''on va attache au widget. 
    390       top_uvalue = ptrarr(2, 29, /allocate_heap) 
     437    top_uvalue = ptrarr(2, 29, /allocate_heap) 
    391438; variables se rapportant au widget en general 
    392       *top_uvalue[0, 0] = 'options' & *top_uvalue[1, 0] = options 
    393       *top_uvalue[0, 1] = 'smallin' & *top_uvalue[1, 1] = smallin 
    394       *top_uvalue[0, 2] = 'smallout' & *top_uvalue[1, 2] = smallout 
    395       *top_uvalue[0, 3] = 'graphid' & *top_uvalue[1, 3] = graphid 
    396       *top_uvalue[0, 4] = 'alreadyvector' & *top_uvalue[1, 4] = -1 
    397       *top_uvalue[0, 5] = 'alreadyover' & *top_uvalue[1, 5] = -1 
    398       *top_uvalue[0, 6] = 'alreadyread' & *top_uvalue[1, 6] = -1 
    399       *top_uvalue[0, 7] = 'currentreadcommand' & *top_uvalue[1, 7] = '' 
    400       *top_uvalue[0, 8] = 'globalcommand' & *top_uvalue[1, 8] = '' 
    401       *top_uvalue[0, 9] = 'globaloldcommand' & *top_uvalue[1, 9] = '' 
    402       *top_uvalue[0, 10] = 'zgrid' & *top_uvalue[1, 10] = zgrid 
    403       *top_uvalue[0, 11] = 'noticebase' & *top_uvalue[1, 11] = 0l 
    404       *top_uvalue[0, 12] = 'extra' & *top_uvalue[1, 12] = ex 
     439    *top_uvalue[0, 0] = 'options' & *top_uvalue[1, 0] = options 
     440    *top_uvalue[0, 1] = 'smallin' & *top_uvalue[1, 1] = smallin 
     441    *top_uvalue[0, 2] = 'smallout' & *top_uvalue[1, 2] = smallout 
     442    *top_uvalue[0, 3] = 'graphid' & *top_uvalue[1, 3] = graphid 
     443    *top_uvalue[0, 4] = 'alreadyvector' & *top_uvalue[1, 4] = -1 
     444    *top_uvalue[0, 5] = 'alreadyover' & *top_uvalue[1, 5] = -1 
     445    *top_uvalue[0, 6] = 'alreadyread' & *top_uvalue[1, 6] = -1 
     446    *top_uvalue[0, 7] = 'currentreadcmd' & *top_uvalue[1, 7] = '' 
     447    *top_uvalue[0, 8] = 'globalcommand' & *top_uvalue[1, 8] = '' 
     448    *top_uvalue[0, 9] = 'globaloldcommand' & *top_uvalue[1, 9] = '' 
     449    *top_uvalue[0, 10] = 'no more used' & *top_uvalue[1, 10] = 9999 
     450    *top_uvalue[0, 11] = 'noticebase' & *top_uvalue[1, 11] = 0l 
     451    *top_uvalue[0, 12] = 'extra' & *top_uvalue[1, 12] = ex 
    405452; variables se rapportant aux differents fichiers que l''on peut lire 
    406       *top_uvalue[0, 13] = 'currentfile' & *top_uvalue[1, 13] = currentfile 
    407       *top_uvalue[0, 14] = 'filelist' & *top_uvalue[1, 14] = filelist 
    408       *top_uvalue[0, 15] = 'fileparameters' & *top_uvalue[1, 15] = fileparameters 
    409       *top_uvalue[0, 16] = 'readparameters' & *top_uvalue[1, 16] = readparameters 
    410       *top_uvalue[0, 17] = 'meshparameters' & *top_uvalue[1, 17] = meshparameters 
     453    *top_uvalue[0, 13] = 'currentfile' & *top_uvalue[1, 13] = currentfile 
     454    *top_uvalue[0, 14] = 'filelist' & *top_uvalue[1, 14] = filelist 
     455    *top_uvalue[0, 15] = 'fileparameters' & *top_uvalue[1, 15] = fileparameters 
     456    *top_uvalue[0, 16] = 'readparameters' & *top_uvalue[1, 16] = readparameters 
     457    *top_uvalue[0, 17] = 'meshparameters' & *top_uvalue[1, 17] = meshparameters 
    411458; variables se rapportant aux differents dessins que l''on peut faire 
    412       *top_uvalue[0, 18] = 'penvs' & *top_uvalue[1, 18] = replicate(!p, nbredessin) 
    413       *top_uvalue[0, 19] = 'xenvs' & *top_uvalue[1, 19] = replicate(!x, nbredessin) 
    414       *top_uvalue[0, 20] = 'yenvs' & *top_uvalue[1, 20] = replicate(!y, nbredessin) 
    415       *top_uvalue[0, 21] = 'nameprocedures' & *top_uvalue[1, 21] = nameprocedures 
    416       *top_uvalue[0, 22] = 'types' & *top_uvalue[1, 22] = types 
    417       *top_uvalue[0, 23] = 'champs' & *top_uvalue[1, 23] = champs 
    418       *top_uvalue[0, 24] = 'domaines' & *top_uvalue[1, 24] = domaines 
    419       *top_uvalue[0, 25] = 'dates' & *top_uvalue[1, 25] = dates 
    420       *top_uvalue[0, 26] = 'prefixes' & *top_uvalue[1, 26] = prefixes 
    421       *top_uvalue[0, 27] = 'optionsflag' & *top_uvalue[1, 27] = flag 
    422       *top_uvalue[0, 28] = 'exextra' & *top_uvalue[1, 28] = exextra 
    423 ; 
    424       widget_control, base, set_uvalue = top_uvalue 
    425       createhistory, base, smallin 
    426 ; 
    427    ENDELSE  
    428 ;------------------------------------------------------------ 
    429    xmanager,'xxx',base, /no_block 
    430 ;------------------------------------------------------------ 
    431 ;------------------------------------------------------------ 
    432    return 
     459    *top_uvalue[0, 18] = 'penvs' & *top_uvalue[1, 18] = replicate(!p, nbredessin) 
     460    *top_uvalue[0, 19] = 'xenvs' & *top_uvalue[1, 19] = replicate(!x, nbredessin) 
     461    *top_uvalue[0, 20] = 'yenvs' & *top_uvalue[1, 20] = replicate(!y, nbredessin) 
     462    *top_uvalue[0, 21] = 'nameprocedures' & *top_uvalue[1, 21] = strarr(nbredessin) 
     463    *top_uvalue[0, 22] = 'types' & *top_uvalue[1, 22] = strarr(nbredessin) 
     464    *top_uvalue[0, 23] = 'varinfo' & *top_uvalue[1, 23] = strarr(2, nbredessin)     
     465    *top_uvalue[0, 24] = 'domaines' & *top_uvalue[1, 24] = fltarr(6, nbredessin) 
     466    *top_uvalue[0, 25] = 'dates' & *top_uvalue[1, 25] = lonarr(2, nbredessin) 
     467    *top_uvalue[0, 26] = 'txtcmd' & *top_uvalue[1, 26] = strarr(nbredessin) 
     468    *top_uvalue[0, 27] = 'optionsflag' & *top_uvalue[1, 27] = flag 
     469    *top_uvalue[0, 28] = 'exextra' & *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap) 
     470; 
     471    widget_control, base, set_uvalue = top_uvalue 
     472    createhistory, base, smallin 
     473; 
     474  ENDELSE  
     475;------------------------------------------------------------ 
     476  xmanager, 'xxx', base, /no_block 
     477;------------------------------------------------------------ 
     478;------------------------------------------------------------ 
     479  return 
    433480end 
Note: See TracChangeset for help on using the changeset viewer.