Changeset 69 for trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX
- Timestamp:
- 05/11/06 12:35:53 (18 years ago)
- Location:
- trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX
- Files:
-
- 1 added
- 2 deleted
- 14 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/.idlwave_catalog
r68 r69 2 2 ;; IDLWAVE catalog for library saxo 3 3 ;; Automatically Generated -- do not edit. 4 ;; Created by idlwave_catalog on T ue Jan 24 17:06:1920064 ;; Created by idlwave_catalog on Thu May 4 08:42:55 2006 5 5 ;; 6 6 (setq idlwave-library-catalog-libname "saxo") 7 7 (setq idlwave-library-catalog-routines 8 '(("buildc ommand" fun nil (lib "buildcommand.pro" nil "saxo") "Result = %s(base)" (nil ("BOXZOOM") ("FORPLTH") ("FORPLTT") ("FORPLTZ")))9 ("buildreadc ommand" 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"))) 10 10 ("changefield" pro nil (lib "changefield.pro" nil "saxo") "%s, base, newfieldname" (nil ("BOXZOOM"))) 11 11 ("changefile" pro nil (lib "changefile.pro" nil "saxo") "%s, base, newfilename" (nil ("BOXZOOM") ("DATE1") ("DATE2") ("FIELDNAME"))) 12 12 ("createhistory" pro nil (lib "createhistory.pro" nil "saxo") "%s, base, small" (nil)) 13 ("cutc ommand" 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)) 14 14 ("definedefaultextra" fun nil (lib "definedefaultextra.pro" nil "saxo") "Result = %s(nomvariable)" (nil)) 15 15 ("doubleclickaction" pro nil (lib "doubleclickaction.pro" nil "saxo") "%s, event" (nil)) … … 18 18 ("identifyclick" fun nil (lib "identifyclick.pro" nil "saxo") "Result = %s(event)" (nil)) 19 19 ("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"))) 21 22 ("longclickaction" pro nil (lib "longclickaction.pro" nil "saxo") "%s, event" (nil)) 22 23 ("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(n omficher)" (nil ("_extra")))24 ("scanfile" fun nil (lib "scanfile.pro" nil "saxo") "Result = %s(namefile)" (nil ("_extra") ("GRID"))) 24 25 ("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)) 27 28 ("tracecadre" pro nil (lib "tracecadre.pro" nil "saxo") "%s, small" (nil ("erase") ("fill") ("out"))) 28 29 ("updatewidget" pro nil (lib "updatewidget.pro" nil "saxo") "%s, base" (nil ("NOBOXZOOM") ("NODATES") ("NOTYPE"))) 29 30 ("xcreateanim_event" pro nil (lib "xcreateanim.pro" nil "saxo") "%s, event" (nil)) 30 31 ("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 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:buildc ommand5 ; NAME:buildcmd 6 6 ; 7 7 ; PURPOSE:cette fonction reourne un string qui contient la commande de … … 32 32 ;------------------------------------------------------------ 33 33 ;------------------------------------------------------------ 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') 34 FUNCTION 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') 46 42 ; optionid = widget_info(base, find_by_uname = 'option') 47 43 ;------------------------------------------------------------ 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] 53 53 ;------------------------------------------------------------ 54 54 ;--------------- … … 56 56 ; et le type 57 57 ;--------------- 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 88 77 ; 89 78 ; recherche des options 90 79 ; 91 92 93 94 95 96 97 98 ; 99 100 101 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') 102 91 ; 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') 169 265 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 171 310 ; 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 349 328 ; 350 329 ;----------------------- … … 357 336 ; determination du nom de la boxzoom 358 337 ;--------------- 359 338 if NOT keyword_set(boxzoom) then widget_control, domainid, get_value = boxzoom 360 339 ; ecriture de celle-ci sous forme d''un string 361 362 340 box = '['+strtrim(boxzoom[0], 1) 341 for i = 1, (n_elements(boxzoom)-1) < (3+2*(strpos(type, 'z') EQ -1)) do $ 363 342 box = box+', '+strtrim(boxzoom[i], 1) 364 343 ; pour les [plots en z, box doit avoir par defaut 0,profmax 365 344 if strpos(type, 'z') NE -1 then BEGIN 366 345 ; 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 380 363 ;--------------- 381 364 ; on determine typein 382 365 ;--------------- 383 typein = ''''+type+'''' 366 IF strpos(type, '_diag') NE -1 THEN typein = ''''+strmid(type, 0, 4)+'''' $ 367 ELSE typein = ''''+type+'''' 384 368 ;--------------- 385 369 ;--------------- 386 370 ; determination de small 387 371 ;--------------- 388 372 ssmall = tostr(smallout) 389 373 ;------------------------------------------------------------ 390 374 ; on va definir le string qui contiendra la commande a executer par widgetdessine.pro 391 375 ;------------------------------------------------------------ 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'] 397 382 398 383 ; print, '---------------' 399 ; for i = 0, n_elements(C ommande)-1 do print, Commande[i]384 ; for i = 0, n_elements(Cmd)-1 do print, Cmd[i] 400 385 ; print, '---------------' 401 386 ;--------------- 402 387 ; on complete et/ou actualise la structure top_uvalue... 403 388 ;--------------- 404 405 406 407 (*top_uvalue[1, findline(top_uvalue, 'prefixes')])[numdessinout] = widcommand408 409 410 ;------------------------------------------------------------ 411 return, Commande389 (*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 412 397 end 413 398 -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/buildreadcmd.pro
r68 r69 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:buildreadc ommand5 ; NAME:buildreadcmd 6 6 ; 7 7 ; PURPOSE: … … 31 31 ;------------------------------------------------------------ 32 32 ;------------------------------------------------------------ 33 FUNCTION buildreadcommand, base, snameexp, procedure, type, BOXZOOM = boxzoom, COMPLETE = complete, NAMEFIELD = namefield 33 FUNCTION buildreadcmd, base, snameexp, procedure, type, BOXZOOM = boxzoom $ 34 , COMPLETE = complete, NAMEFIELD = namefield 35 ; 36 @cm_4cal ; for key_caltype 34 37 ;------------------------------------------------------------ 35 ; on recuper les ID des differents widgets38 ; get back widgets IDs 36 39 ;------------------------------------------------------------ 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') 43 44 ; optionid = widget_info(base, find_by_uname = 'option') 44 45 ;------------------------------------------------------------ 45 widget_control,base, get_uvalue = top_uvalue46 47 46 widget_control, base, get_uvalue = top_uvalue 47 numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1 48 numdessinout = (extractatt(top_uvalue, 'smallout'))[2]-1 48 49 ;--------------- 49 ; determination du nom du fichier50 ; name of the file 50 51 ;--------------- 51 52 53 54 52 currentfile = extractatt(top_uvalue, 'currentfile') 53 filelist = extractatt(top_uvalue, 'filelist') 54 filename = filelist[currentfile] 55 sfilename = ''''+filename+'''' 55 56 ;--------------- 56 ; on recupere le nom de lavariable57 ; name of the variable 57 58 ;--------------- 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+'''' 63 62 ; 64 ; recherche desoptions63 ; get the options 65 64 ; 66 67 68 69 70 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] 71 70 ; 72 73 74 75 76 77 if size(exextra, /type) EQ 8 then extra = mixstru(exextra,extra)78 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) 79 78 80 79 ;--------------- 81 ; determination de date1 etdate280 ; find date1 and date2 82 81 ;--------------- 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 84 94 ; 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) 104 101 ;--------------- 105 ; determination du nom de la boxzoom102 ; find boxzoom 106 103 ;--------------- 107 108 ; ecriture de celle-ci sous forme d''unstring109 110 111 box = box+', '+strtrim(boxzoom[i], 1)112 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 113 110 @common 114 111 min = min([gdept, gdepw], max = max) 115 112 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 118 119 ;--------------- 119 ; determination defunclec_name, readparameters, meshparameters120 ; find funclec_name, readparameters, meshparameters 120 121 ;--------------- 121 122 123 124 125 126 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) 127 128 ;------------------------------------------------------------ 128 129 ;------------------------------------------------------------ … … 131 132 ; la lecture 132 133 ;------------------------------------------------------------ 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 154 159 ; print, '::::::::::::::::::::::' 155 ; for i = 0, n_elements(C ommande)-1 do print, Commande[i]160 ; for i = 0, n_elements(Cmd)-1 do print, Cmd[i] 156 161 ; print, '::::::::::::::::::::::' 157 162 ;------------------------------------------------------------ 158 163 159 164 ;------------------------------------------------------------ 160 return, commande165 return, cmd 161 166 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/changefield.pro
r49 r69 1 1 PRO changefield, base, newfieldname, BOXZOOM = boxzoom 2 2 ; 3 3 widget_control, base, get_uvalue = top_uvalue 4 4 ; 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 14 18 ; 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 25 32 ; 26 33 return 27 34 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/changefile.pro
r49 r69 1 1 PRO changefile, base, newfilename, BOXZOOM = boxzoom, DATE1 = date1, DATE2 = date2, FIELDNAME = fieldname 2 2 ; 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 17 18 ;-------------- 18 19 widget_control, base, update = 0 19 20 ;-------------- 20 21 ; 21 ; on update l''element currentfile de latop_uvalue22 ; we update currentfile element of the top_uvalue 22 23 ; 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 27 25 ; 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 35 27 ; 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 45 61 ; 46 ; on s''occupe du calendrier62 ; Grid parameters and domain 47 63 ; 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 78 71 ; 79 ; parametres de la grille72 ; file name 80 73 ; 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 ; 88 98 ;-------------- 89 99 widget_control, base, update = 1 90 100 ;-------------- 91 101 return 92 102 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/createhistory.pro
r49 r69 6 6 globalcommand = extractatt(top_uvalue, 'globalcommand') 7 7 *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] 8 12 ; composition du text contennu ds history.pro 9 13 texte = ['@common' $ 10 14 , ' ' $ 11 , 'if n_elements(portrait) ne 0 then key_portrait = portrait' $12 , 'if n_elements(landscape) ne 0 then key_portrait = 1-landscape' $13 , ' ' $14 15 , 'if keyword_set(postscript) then begin' $ 15 16 , ' noerase = 1' $ 16 , ' openps, infowidget = infowidget '$17 , ' openps, infowidget = infowidget, portrait = ' + strtrim(portrait, 2) $ 17 18 , 'endif' $ 18 19 , ' ' $ … … 36 37 *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = texte 37 38 ;------------------------------------------------------------- 38 ; 39 ; for i = 0, n_elements(texte)-1 do print, texte[i] 39 40 ;------------------------------------------------------------- 40 41 return -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/cutcmd.pro
r68 r69 1 PRO cutc ommand, widcommand, toread, coef, numberofread, operation, nameexp, separator, add1 PRO cutcmd, widcmd, toread, numberofread, prefix, nameexp, ending 2 2 ; 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] 6 43 ; 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 = '' 35 47 ; 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 47 49 ; 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 86 51 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/doubleclickaction.pro
r49 r69 1 1 PRO doubleclickaction, event 2 2 ;------------------------------------------------------------ 3 widget_control, event.id , get_uvalue = uval4 widget_control, event.top, get_uvalue = top_uvalue3 widget_control, event.id , get_uvalue = uval 4 widget_control, event.top, get_uvalue = top_uvalue 5 5 ; on active la bonne fenetre 6 widget_control, event.id,get_value=win6 widget_control, event.id, get_value = win 7 7 wset, win 8 8 ; quel est le dessin selectionne?? … … 46 46 47 47 numdessin = numdessin-1 48 (*top_uvalue[1, findline(top_uvalue, ' champs')])[*, numdessin] = ['', '']48 (*top_uvalue[1, findline(top_uvalue, 'varinfo')])[*, numdessin] = ['', ''] 49 49 (*top_uvalue[1, findline(top_uvalue, 'dates')])[*, numdessin] = [0l, 0l] 50 50 (*top_uvalue[1, findline(top_uvalue, 'nameprocedures')])[numdessin] = '' 51 51 (*top_uvalue[1, findline(top_uvalue, 'types')])[numdessin] = '' 52 52 (*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] = '' 54 54 55 55 if numdessin EQ smallin[2] then $ -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/inserthistory.pro
r49 r69 19 19 globalcommand = [globalcommand[0:index1], text, globalcommand[index2:n_elements(globalcommand)-1]] 20 20 ; the new globalcommand 21 *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = globalcommand21 *top_uvalue[1, findline(top_uvalue, 'globalcommand')] = globalcommand 22 22 23 23 ;------------------------------------------------------------- -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/letsdraw.pro
r49 r69 35 35 ;------------------------------------------------------------ 36 36 37 PRO letsdraw, base, COMMANDE = commande, FORPLTH = forplth, FORPLTZ = forpltz, FORPLTT = forpltt,_extra = ex37 PRO letsdraw, base, COMMANDE = commande, _extra = ex 38 38 @common 39 39 ; on recupere la uvalue de base … … 43 43 ; help, top_uvalue.exextra, /struct 44 44 if NOT keyword_set(commande) then $ 45 commande = buildc ommand(base, FORPLTH=forplt, FORPLTZ=forpltz, FORPLTT=forpltt, _extra=ex)45 commande = buildcmd(base, _extra=ex) 46 46 if commande[0] EQ '' then return 47 47 ; on recupere la uvalue de base … … 88 88 createpro, ['@common' $ 89 89 , 'noerase = 1' $ 90 , ' portrait = '+portrait $90 , 'key_portrait = '+ portrait $ 91 91 , Commande] $ 92 92 , filename = myuniquetmpdir + 'xxx_oneplot.pro' -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/longclickaction.pro
r49 r69 1 1 PRO longclickaction, event 2 widget_control, event.id, get_uvalue=uval3 widget_control,event.top, get_uvalue = top_uvalue2 widget_control, event.id, get_uvalue = uval 3 widget_control, event.top, get_uvalue = top_uvalue 4 4 ; 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 23 54 ; 24 55 ;------------------------------------------------------------ 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 26 81 ;------------------------------------------------------------ 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 77 83 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/read_vermair.pro
r49 r69 1 FUNCTION read_vermair, name, debut,fin, nomexp, PARENT = parent, BOXZOOM=boxzoom, _EXTRA = ex1 FUNCTION read_vermair, name, debut, fin, nomexp, PARENT = parent, BOXZOOM=boxzoom, _EXTRA = ex 2 2 @common 3 3 ;------------------------------------------------------------ -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/scanfile.pro
r49 r69 9 9 ; 3) ce fichier contient une dimension infinie qui doit etre 10 10 ; celle qui se rapporte au temps et au mois 2 autres dimensions 11 ; dont les noms sont 'x','lon ','longitude' et 'y','lat' ou12 ; ' latitude' ou bien en majuscule.11 ; dont les noms sont 'x','lon...','xi_...' et 'y','lat...' ou 12 ; 'eta_...' ou bien en majuscule. 13 13 ; 4) il doit exiter ds ce fichier une unique variable n''ayant 14 14 ; qu''une dimension et etant la dimension temporelle. cette … … 26 26 ; je crois que c''est tout! 27 27 ; 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 ;------------------------------------------------------------ 34 FUNCTION scanfile, namefile, GRID = GRID, _extra = ex 31 35 @common 32 36 ;------------------------------------------------------------ 33 ; bidouille pour utiliser les mots cles (on passe par des variables34 ; declarees ds un common)35 ;------------------------------------------------------------36 37 res = -1 37 38 ;------------------------------------------------------------ 38 ; choix du nom du fichier39 ;------------------------------------------------------------ 40 nom = isafile(filename = nomficher, IODIRECTORY = iodir, _extra = ex)41 ;------------------------------------------------------------ 42 ; o uverture du fichier nom43 ;------------------------------------------------------------ 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) ; 49 50 ; 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) 61 74 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''' 77 80 stop 78 81 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''' 83 87 stop 84 88 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 92 100 ENDFOR 93 101 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 119 144 ; on lit l''axe des temps 120 ncdf_varget, cdfid, varid, time121 time = double(time)122 ncdf_attget, cdfid, varid, 'units', value145 ncdf_varget, cdfid, varid, time 146 time = double(time) 147 ncdf_attget, cdfid, varid, 'units', value 123 148 ; time_counter:units = "seconds since 0001-01-01 00:00:00" ; 124 149 ; time_counter:units = "hours since 0001-01-01 00:00:00" ; … … 126 151 ; time_counter:units = "months since 1979-01-01 00:00:00" ; 127 152 ; 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], '-') 132 157 ; 133 158 ; now we try to find the attribut called calendar... … … 135 160 ; If no, we suppose that the calendar is gregorian calendar 136 161 ; 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 144 170 ; notused = report('Unknown calendar: '+value+', we use greg calendar.') 145 key_caltype = 'greg'146 END147 ENDCASE148 ENDIF ELSE BEGIN171 key_caltype = 'greg' 172 END 173 ENDCASE 174 ENDIF ELSE BEGIN 149 175 ; notused = report('Unknown calendar, we use '+key_caltype+' calendar.') 150 IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg'151 ENDELSE176 IF n_elements(key_caltype) EQ 0 THEN key_caltype = 'greg' 177 ENDELSE 152 178 ; 153 179 ; ATTENTION il faut recuperer l''attribut calendar et ajuster time en … … 156 182 ; 157 183 ; 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} 183 222 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/selectfile.pro
r49 r69 4 4 @common 5 5 ; 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 50 141 end 51 142 ;********************************************************************* 52 FUNCTION selectfile 143 FUNCTION selectfile, datafilename, idlfile, argspro, _extra = ex 53 144 ; 54 145 @common 146 ;------------------------------------------------------------ 55 147 ;------------------------------------------------------------ 56 148 ; … … 61 153 ; du widget) n''est pas detruite est on peut recuperer le resultat! 62 154 ; 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} 97 242 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/singleclickaction.pro
r49 r69 1 PRO singleclickaction, event, quelclick 1 PRO singleclickaction, event 2 @cm_4mesh 3 @cm_4data 2 4 3 return 5 return 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 4 120 end -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/updatewidget.pro
r49 r69 18 18 ENDELSE 19 19 ;-------------- 20 ; domain e20 ; domain 21 21 ;-------------- 22 22 boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] … … 24 24 if keyword_set(noboxzoom) then boxzoom = 0 25 25 ;-------------- 26 ; champ: filename & nomvar26 ; varinfo: filename & namevar 27 27 ;-------------- 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] 30 30 ; 31 31 if filename NE '' OR nomvar NE '' THEN BEGIN … … 54 54 endif 55 55 ;-------------- 56 ; nomexp56 ; text command 57 57 ;-------------- 58 nomexp = (extractatt(top_uvalue, 'prefixes'))[numdessinin]59 if nomexpNE '' then begin60 nomexpid = widget_info(base, find_by_uname = 'nom_exp')61 widget_control, nomexpid, set_value = nomexp58 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 62 62 endif 63 63 ;-------------- … … 68 68 if graphtype NE '' then begin 69 69 actionid = widget_info(base,find_by_uname = 'action') 70 widget_control, actionid, get_ uvalue = action_uvalue71 widget_control, actionid, set_ droplist_select = (where(action_uvalue.choixEQ graphtype))[0]70 widget_control, actionid, get_value = action_value 71 widget_control, actionid, set_combobox_select = (where(action_value EQ graphtype))[0] 72 72 endif 73 73 endif -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xcreateanim.pro
r49 r69 15 15 ; 16 16 calendar = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).time_counter 17 key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[local_uvalue.indexfile]).caltype 17 18 ; 18 19 widget_control, widget_info(event.top, find_by_uname = 'Filename') $ … … 24 25 widget_control, widget_info(event.top, find_by_uname = 'debut') $ 25 26 , get_value = vdate1 26 index1 = where(calendar eq juldate(vdate1)) & index1 = index1[0]27 index1 = where(calendar eq date2jul(vdate1)) & index1 = index1[0] 27 28 if index1 EQ -1 then return 28 29 ; 29 30 widget_control, widget_info(event.handler, find_by_uname = 'fin') $ 30 31 , get_value = vdate2 31 index2 = where(calendar eq juldate(vdate2)) & index2 = index2[0]32 index2 = where(calendar eq date2jul(vdate2)) & index2 = index2[0] 32 33 if index2 EQ -1 OR index2 LE index1 then return 33 34 ; on detruit le widget avant de creer le fichier .ps … … 65 66 base = widget_base() 66 67 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: ') 68 69 widget_control,base,/realize 69 70 ; 70 71 ; commencement du fichier gif. ecriture d''une image vide 71 date = vairdate(calendar[index1], mensuel = mensuel, annuel= annuel)72 date = jul2date(calendar[index1]) 72 73 xxx2ps, /noerase, date1in = date, date2in = date 73 74 ; … … 98 99 ; 99 100 window, /free, /pixmap, xsize=xsize, ysize=ysize 100 date = vairdate(calendar[ind], mensuel = mensuel, annuel= annuel)101 date = jul2date(calendar[ind]) 101 102 xxx2ps, /noerase, date1 = date, date2 = date 102 103 ; … … 155 156 ; 156 157 filelist = extractatt(top_uvalue, 'filelist') 157 filenames = (extractatt(top_uvalue, ' champs'))[0, *]158 filenames = (extractatt(top_uvalue, 'varinfo'))[0, *] 158 159 filenames = reform(filenames) 159 160 filenames = filenames[uniq(filenames, sort(filenames))] … … 178 179 ; c''est possible de faire une animation 179 180 ; 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') 182 183 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') 184 185 if n_elements(animdir) EQ 0 then cd, current = animdir 185 186 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') 187 188 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') 189 190 rien = cw_calendar(base, calendar, calendar[n_elements(calendar)-1] $ 190 191 , uname = 'fin', uvalue = {name:'calendar'}, /frame) -
trunk/ToBeReviewed/WIDGET/AUTOUR_de_XXX/xxxmenubar_event.pro
r68 r69 4 4 5 5 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 13 14 ; on s''occupe de filelist 14 15 16 15 filelist = extractatt(top_uvalue, 'filelist') 16 filelist = [filelist, newfile.fileparameters.filename] 17 currentfile = n_elements(filelist)-1 17 18 ; on update le widget 18 19 widget_control, filelistid, set_value = filelist20 widget_control, filelistid, set_list_select = currentfile19 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 21 22 ; on update les elements filelist et currentfile de la top_uvalue 22 23 24 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 25 26 ; 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') 27 28 ; 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] 33 33 ; 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) 54 48 ; on update les elements fileparameters, readparameters et meshparameters de la top_uvalue 55 56 57 58 59 60 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 61 55 ; 62 63 64 65 66 67 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 68 62 ; 69 70 71 72 73 74 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 75 69 ; 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 98 137 ; portrait ou landscape ??? 99 100 101 102 ; on recupere la liste des instructions103 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') 104 143 ; 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 134 166 ; 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') 173 168 ; on le complete par un .dat 174 175 169 if rstrpos(filename, '.dat') NE strlen(filename)-4 then filename = filename+'.dat' 170 filename = isafile(file = filename, io = homedir, /new) 176 171 ; 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 204 190 ; fenetre separee ou fenetre collee au widget ? 205 191 if widget_info(event.top, find_by_uname = 'graph') EQ 0 then BEGIN 206 192 ; on tue la fenetre 207 208 193 graphid = extractatt(top_uvalue, 'graphid') 194 widget_control, widget_info(graphid, /parent), /destroy 209 195 ; on la recree 210 211 212 213 214 215 , xsize = windsize[0],ysize = windsize[1])216 widget_control,basegraph,/realize217 xmanager,'xxx',basegraph, /no_block196 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 218 204 ; on redessine ce qu''il y avait dedans 219 205 ; on recupere la liste des instructions 220 206 globalcommand = extractatt(top_uvalue, 'globalcommand') 221 207 ; on complete par le premiere et les dernieres lignes du programme 222 223 224 208 createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $ 209 , KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript, PORTRAIT = portrait, LANDSCAPE = landscape' $ 210 , KWDUSED = ', /noerase, PORTRAIT = portrait' 225 211 ; on reattribue l''element graphid de la top_uvalue 226 227 228 229 230 231 232 233 234 235 236 237 238 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') 239 225 ; on change le flag sur Longitude / x index 240 226 flag = 1-flags[index, numdessinin] & flag = flag[0] 241 227 ; on le reeatribue 242 243 244 245 246 247 248 249 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') 250 236 ; on change le flag sur Longitude / x index 251 237 flag = 1-flags[index, numdessinin] & flag = flag[0] 252 238 ; on le reeatribue 253 254 255 256 257 258 259 260 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') 261 247 ; on change le flag sur Longitude / x index 262 248 flag = 1-flags[index, numdessinin] & flag = flag[0] 263 249 ; on le reeatribue 264 250 (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 265 251 ; maintenant on va changer les sliders definissant la boxzoom 266 267 252 domainid = widget_info(event.top, find_by_uname = 'domain') 253 boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 268 254 ; 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 274 263 ; on fait un domdef pour retrouver le lon1 lon2 correspondant a la 275 264 ; boxzoom definie sur le widget... 276 277 , yindex = (flags[where(options EQ 'Latitude / y index'), numdessinin])[0]278 279 ENDIF ELSE BEGIN; xindex265 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 280 269 ; maintenant ion veut retrouver firstx, lastx correspondant a la 281 270 ; boxzoom definie sur le widget... 282 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,lastz285 286 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 287 276 ; on met a jour la top_uvalue 288 289 290 291 292 293 294 295 296 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') 297 286 ; on change le flag sur Latitude / y index 298 287 flag = 1-flags[index, numdessinin] & flag = flag[0] 299 288 ; on le reeatribue 300 289 (*top_uvalue[1, findline(top_uvalue, 'optionsflag')])[index, numdessinin] = flag 301 290 ; maintenant on va changer les sliders definissant la boxzoom 302 303 291 domainid = widget_info(event.top, find_by_uname = 'domain') 292 boxzoom = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 304 293 ; 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 310 302 ; on fait un domdef pour retrouver le lat1 lat2 correspondant a la 311 303 ; boxzoom definie sur le widget... 312 313 , xindex = (flags[where(options EQ 'Longitude / x index'), numdessinin])[0]314 315 ENDIF ELSE BEGIN; yindex304 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 316 308 ; maintenant ion veut retrouver firsty, lasty correspondant a la 317 309 ; boxzoom definie sur le widget... 318 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,lastz321 322 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 323 315 ; on met a jour la top_uvalue 324 325 326 end327 328 316 widget_control, domainid, get_value = boxzoom 317 (*top_uvalue[1, findline(top_uvalue, 'domaines')])[*, numdessinin] = boxzoom 318 END 319 endcase 320 return 329 321 end 330 ;------------------------------------------------331 PRO xxxmenubar, parent, OPTIONS =options, _EXTRA = ex332 ; 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 = options357 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 return367 end
Note: See TracChangeset
for help on using the changeset viewer.