[150] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[150] | 3 | ; @file_comments |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; |
---|
| 7 | ; @param BASE {in}{required} |
---|
| 8 | ; The id of the widget where apply the drawing. |
---|
| 9 | ; |
---|
| 10 | ; @param NEWFILENAME |
---|
| 11 | ; |
---|
| 12 | ; @keyword BOXZOOM |
---|
[231] | 13 | ; Vector indicating the geographic zone on which we want to cut the map. |
---|
| 14 | ; If BOXZOOM has : |
---|
[150] | 15 | ; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] |
---|
| 16 | ; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] |
---|
| 17 | ; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])] |
---|
| 18 | ; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
[231] | 19 | ; 6 elements: The extraction is made on Boxzoom |
---|
[254] | 20 | ; Where lon1, lon2,lat1,lat2 are global variables defined at the last |
---|
| 21 | ; <pro>domdef</pro> ! |
---|
[231] | 22 | ; |
---|
[150] | 23 | ; @keyword DATE1 |
---|
[231] | 24 | ; |
---|
[150] | 25 | ; @keyword DATE2 |
---|
| 26 | ; |
---|
| 27 | ; @keyword FIELDNAME |
---|
[231] | 28 | ; |
---|
[150] | 29 | ; @returns |
---|
[231] | 30 | ; |
---|
[150] | 31 | ; @uses |
---|
[231] | 32 | ; |
---|
[150] | 33 | ; @restrictions |
---|
[231] | 34 | ; |
---|
[150] | 35 | ; @examples |
---|
[231] | 36 | ; |
---|
[150] | 37 | ; @history |
---|
[231] | 38 | ; |
---|
| 39 | ; @version |
---|
[150] | 40 | ; $Id$ |
---|
| 41 | ; |
---|
| 42 | ; @todo |
---|
| 43 | ; seb |
---|
| 44 | ; |
---|
| 45 | ;- |
---|
[262] | 46 | ; |
---|
[49] | 47 | PRO changefile, base, newfilename, BOXZOOM = boxzoom, DATE1 = date1, DATE2 = date2, FIELDNAME = fieldname |
---|
| 48 | ; |
---|
[114] | 49 | ; |
---|
| 50 | compile_opt idl2, strictarrsubs |
---|
| 51 | ; |
---|
[69] | 52 | widget_control, base, /hourglass |
---|
| 53 | widget_control, base, get_uvalue = top_uvalue |
---|
| 54 | filelist = extractatt(top_uvalue, 'filelist') |
---|
| 55 | IF size(newfilename, /type) EQ 7 THEN newfile = (where(filelist EQ newfilename))[0] $ |
---|
| 56 | ELSE newfile = newfilename ; it is already the index of the new file |
---|
| 57 | if newfile EQ -1 then begin |
---|
[114] | 58 | nothing = report('invalid filename') |
---|
[69] | 59 | return |
---|
| 60 | endif |
---|
| 61 | oldfile = extractatt(top_uvalue, 'currentfile') |
---|
| 62 | oldfilename = filelist[oldfile] |
---|
| 63 | |
---|
| 64 | ; did we really change the file??? |
---|
| 65 | if oldfile EQ newfile AND NOT (keyword_set(BOXZOOM) OR keyword_set(DATE1) OR keyword_set(DATE2) OR keyword_set(FIELDNAME)) then return |
---|
| 66 | |
---|
[2] | 67 | ;-------------- |
---|
[69] | 68 | widget_control, base, update = 0 |
---|
[2] | 69 | ;-------------- |
---|
| 70 | ; |
---|
[69] | 71 | ; we update currentfile element of the top_uvalue |
---|
[2] | 72 | ; |
---|
[69] | 73 | *top_uvalue[1, findline(top_uvalue, 'currentfile')] = newfile |
---|
[2] | 74 | ; |
---|
[69] | 75 | ; Calendar |
---|
[2] | 76 | ; |
---|
[69] | 77 | oldcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).time_counter |
---|
| 78 | newcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).time_counter |
---|
| 79 | ; Did we change the calendar? |
---|
| 80 | if array_equal(oldcalendar, newcalendar) NE 1 then begin |
---|
[231] | 81 | @cm_4cal |
---|
[74] | 82 | ; for key_caltype |
---|
[69] | 83 | key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).caltype |
---|
[74] | 84 | ; fake or real calendar??? |
---|
| 85 | fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).fakecal |
---|
[231] | 86 | ; Which dates were selected? |
---|
[69] | 87 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
| 88 | if NOT keyword_set(date1) then widget_control, date1id, get_value = date1 |
---|
| 89 | jdate1 = date2jul(date1) |
---|
| 90 | if (where(newcalendar EQ jdate1))[0] EQ -1 then jdate1 = newcalendar[0] |
---|
| 91 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
| 92 | if NOT keyword_set(date2) then widget_control, date2id, get_value = date2 |
---|
| 93 | jdate2 = date2jul(date2) |
---|
| 94 | if (where(newcalendar EQ jdate2))[0] EQ -1 then jdate2 = date1 |
---|
| 95 | if jdate2 LT jdate1 THEN jdate2 = jdate1 |
---|
| 96 | widget_control, date1id, /destroy |
---|
| 97 | widget_control, date2id, /destroy |
---|
| 98 | basecal = widget_info(base, find_by_uname = 'basecal') |
---|
| 99 | rien = cw_calendar(basecal, newcalendar, jdate1, uname = 'calendar1' $ |
---|
[74] | 100 | , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame) |
---|
[69] | 101 | rien = cw_calendar(basecal, newcalendar, jdate2, uname = 'calendar2' $ |
---|
[74] | 102 | , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame) |
---|
[231] | 103 | ENDIF ELSE BEGIN |
---|
[69] | 104 | if keyword_set(date1) then begin |
---|
[2] | 105 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
[69] | 106 | widget_control, date1id, set_value = date1 |
---|
| 107 | endif |
---|
| 108 | if keyword_set(date2) then begin |
---|
[2] | 109 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
[69] | 110 | widget_control, date2id, set_value = date2 |
---|
| 111 | endif |
---|
| 112 | ENDELSE |
---|
[2] | 113 | ; |
---|
[69] | 114 | ; Grid parameters and domain |
---|
[2] | 115 | ; |
---|
[69] | 116 | newgrid = *(extractatt(top_uvalue, 'meshparameters'))[newfile] |
---|
| 117 | change = changegrid(newgrid) |
---|
| 118 | if change OR keyword_set(boxzoom) then BEGIN |
---|
| 119 | if NOT keyword_set(boxzoom) then boxzoom = -1 |
---|
| 120 | domainid = widget_info(base, find_by_uname = 'domain') |
---|
| 121 | widget_control, domainid, set_value = boxzoom |
---|
| 122 | endif |
---|
| 123 | ; |
---|
| 124 | ; file name |
---|
| 125 | ; |
---|
[231] | 126 | IF oldfile NE newfile THEN BEGIN |
---|
[69] | 127 | flstid = widget_info(base, find_by_uname = 'filelist') |
---|
| 128 | widget_control, flstid, set_combobox_select = newfile |
---|
[231] | 129 | ENDIF |
---|
[69] | 130 | ; |
---|
| 131 | ; Variables name |
---|
| 132 | ; |
---|
| 133 | vlstid = widget_info(base, find_by_uname = 'varlist') |
---|
| 134 | oldfieldname = widget_info(vlstid, /combobox_gettext) |
---|
| 135 | ; did we really change the liste of variables? |
---|
| 136 | oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar |
---|
| 137 | newlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).listvar |
---|
| 138 | if array_equal(oldlistvar, newlistvar) NE 1 THEN $ |
---|
| 139 | widget_control, vlstid, set_value = newlistvar |
---|
| 140 | ; set the liste of variables to the new variable name |
---|
| 141 | if keyword_set(fieldname) then newfieldname = fieldname ELSE newfieldname = oldfieldname |
---|
| 142 | indexvar = where(newlistvar EQ newfieldname) & indexvar = 0 > indexvar[0] |
---|
| 143 | widget_control, vlstid, set_combobox_select = indexvar |
---|
| 144 | newfieldname = newlistvar[indexvar] |
---|
| 145 | ; did we change the name of the variable? |
---|
| 146 | if newfieldname NE oldfieldname then BEGIN |
---|
| 147 | changefield, base, newfieldname, BOXZOOM = boxzoom |
---|
| 148 | ENDIF |
---|
| 149 | ; |
---|
[2] | 150 | ;-------------- |
---|
[69] | 151 | widget_control, base, update = 1 |
---|
[2] | 152 | ;-------------- |
---|
[69] | 153 | return |
---|
[2] | 154 | end |
---|