1 | PRO changefile, base, newfilename, BOXZOOM = boxzoom, DATE1 = date1, DATE2 = date2, FIELDNAME = fieldname |
---|
2 | ; |
---|
3 | ; |
---|
4 | compile_opt idl2, strictarrsubs |
---|
5 | ; |
---|
6 | widget_control, base, /hourglass |
---|
7 | widget_control, base, get_uvalue = top_uvalue |
---|
8 | filelist = extractatt(top_uvalue, 'filelist') |
---|
9 | IF size(newfilename, /type) EQ 7 THEN newfile = (where(filelist EQ newfilename))[0] $ |
---|
10 | ELSE newfile = newfilename ; it is already the index of the new file |
---|
11 | if newfile EQ -1 then begin |
---|
12 | nothing = report('invalid filename') |
---|
13 | return |
---|
14 | endif |
---|
15 | oldfile = extractatt(top_uvalue, 'currentfile') |
---|
16 | oldfilename = filelist[oldfile] |
---|
17 | |
---|
18 | ; did we really change the file??? |
---|
19 | if oldfile EQ newfile AND NOT (keyword_set(BOXZOOM) OR keyword_set(DATE1) OR keyword_set(DATE2) OR keyword_set(FIELDNAME)) then return |
---|
20 | |
---|
21 | ;-------------- |
---|
22 | widget_control, base, update = 0 |
---|
23 | ;-------------- |
---|
24 | ; |
---|
25 | ; we update currentfile element of the top_uvalue |
---|
26 | ; |
---|
27 | *top_uvalue[1, findline(top_uvalue, 'currentfile')] = newfile |
---|
28 | ; |
---|
29 | ; Calendar |
---|
30 | ; |
---|
31 | oldcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).time_counter |
---|
32 | newcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).time_counter |
---|
33 | ; Did we change the calendar? |
---|
34 | if array_equal(oldcalendar, newcalendar) NE 1 then begin |
---|
35 | @cm_4cal |
---|
36 | ; for key_caltype |
---|
37 | key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).caltype |
---|
38 | ; fake or real calendar??? |
---|
39 | fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).fakecal |
---|
40 | ; Which dates were selected? |
---|
41 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
42 | if NOT keyword_set(date1) then widget_control, date1id, get_value = date1 |
---|
43 | jdate1 = date2jul(date1) |
---|
44 | if (where(newcalendar EQ jdate1))[0] EQ -1 then jdate1 = newcalendar[0] |
---|
45 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
46 | if NOT keyword_set(date2) then widget_control, date2id, get_value = date2 |
---|
47 | jdate2 = date2jul(date2) |
---|
48 | if (where(newcalendar EQ jdate2))[0] EQ -1 then jdate2 = date1 |
---|
49 | if jdate2 LT jdate1 THEN jdate2 = jdate1 |
---|
50 | widget_control, date1id, /destroy |
---|
51 | widget_control, date2id, /destroy |
---|
52 | basecal = widget_info(base, find_by_uname = 'basecal') |
---|
53 | rien = cw_calendar(basecal, newcalendar, jdate1, uname = 'calendar1' $ |
---|
54 | , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame) |
---|
55 | rien = cw_calendar(basecal, newcalendar, jdate2, uname = 'calendar2' $ |
---|
56 | , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame) |
---|
57 | ENDIF ELSE BEGIN |
---|
58 | if keyword_set(date1) then begin |
---|
59 | date1id = widget_info(base, find_by_uname = 'calendar1') |
---|
60 | widget_control, date1id, set_value = date1 |
---|
61 | endif |
---|
62 | if keyword_set(date2) then begin |
---|
63 | date2id = widget_info(base, find_by_uname = 'calendar2') |
---|
64 | widget_control, date2id, set_value = date2 |
---|
65 | endif |
---|
66 | ENDELSE |
---|
67 | ; |
---|
68 | ; Grid parameters and domain |
---|
69 | ; |
---|
70 | newgrid = *(extractatt(top_uvalue, 'meshparameters'))[newfile] |
---|
71 | change = changegrid(newgrid) |
---|
72 | if change OR keyword_set(boxzoom) then BEGIN |
---|
73 | if NOT keyword_set(boxzoom) then boxzoom = -1 |
---|
74 | domainid = widget_info(base, find_by_uname = 'domain') |
---|
75 | widget_control, domainid, set_value = boxzoom |
---|
76 | endif |
---|
77 | ; |
---|
78 | ; file name |
---|
79 | ; |
---|
80 | IF oldfile NE newfile THEN BEGIN |
---|
81 | flstid = widget_info(base, find_by_uname = 'filelist') |
---|
82 | widget_control, flstid, set_combobox_select = newfile |
---|
83 | ENDIF |
---|
84 | ; |
---|
85 | ; Variables name |
---|
86 | ; |
---|
87 | vlstid = widget_info(base, find_by_uname = 'varlist') |
---|
88 | oldfieldname = widget_info(vlstid, /combobox_gettext) |
---|
89 | ; did we really change the liste of variables? |
---|
90 | oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar |
---|
91 | newlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).listvar |
---|
92 | if array_equal(oldlistvar, newlistvar) NE 1 THEN $ |
---|
93 | widget_control, vlstid, set_value = newlistvar |
---|
94 | ; set the liste of variables to the new variable name |
---|
95 | if keyword_set(fieldname) then newfieldname = fieldname ELSE newfieldname = oldfieldname |
---|
96 | indexvar = where(newlistvar EQ newfieldname) & indexvar = 0 > indexvar[0] |
---|
97 | widget_control, vlstid, set_combobox_select = indexvar |
---|
98 | newfieldname = newlistvar[indexvar] |
---|
99 | ; did we change the name of the variable? |
---|
100 | if newfieldname NE oldfieldname then BEGIN |
---|
101 | changefield, base, newfieldname, BOXZOOM = boxzoom |
---|
102 | ENDIF |
---|
103 | ; |
---|
104 | ;-------------- |
---|
105 | widget_control, base, update = 1 |
---|
106 | ;-------------- |
---|
107 | return |
---|
108 | end |
---|