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