1 | ; IDL> testwid |
---|
2 | ; PRO testwid_event, event |
---|
3 | ; ; help, event, /struct |
---|
4 | ; Id = widget_info(event.top,find_by_uname = 'c''est lui') |
---|
5 | ; widget_control, event.id, get_uvalue=uval |
---|
6 | ; if n_elements(uval) EQ 0 then return |
---|
7 | ; case uval of |
---|
8 | ; 'done':widget_control, event.top, /destroy |
---|
9 | ; 'set':BEGIN |
---|
10 | ; widget_control, event.id, get_value = value & value = value[0] |
---|
11 | ; nothing = execute('boxzoom ='+value) |
---|
12 | ; widget_control, Id, set_value = boxzoom |
---|
13 | ; END |
---|
14 | ; 'get':BEGIN |
---|
15 | ; widget_control, Id, get_value = value |
---|
16 | ; print, value |
---|
17 | ; END |
---|
18 | ; ELSE: |
---|
19 | ; endcase |
---|
20 | ; return |
---|
21 | ; end |
---|
22 | ; PRO testwid, _extra = ex |
---|
23 | ; base=widget_base(/COLUMN) |
---|
24 | ; print, 'base=', base |
---|
25 | ; nothing = widget_label(base, value = 'beginning of the test') |
---|
26 | ; ; |
---|
27 | ; nothing = cw_domain(base,_extra = ex, uname = 'c''est lui', uvalue = 'c''est lui') |
---|
28 | ; print, 'cw_domain ID =', nothing |
---|
29 | ; ; |
---|
30 | ; nothing = widget_label(base, value = 'end of the test') |
---|
31 | ; nothing = widget_text(base, value = '[40, 100, -10, 10]', uvalue = 'set', /editable) |
---|
32 | ; nothing = widget_button(base, value = 'get', uvalue = 'get') |
---|
33 | ; nothing = widget_button(base, value = 'done', uvalue = 'done') |
---|
34 | ; widget_control, base, /REALIZE |
---|
35 | ; xmanager,'testwid', base |
---|
36 | ; return |
---|
37 | ; end |
---|
38 | ; |
---|
39 | ; |
---|
40 | ;********************************************************************* |
---|
41 | pro cw_domain_set_value, id, value |
---|
42 | ; |
---|
43 | compile_opt idl2, strictarrsubs |
---|
44 | ; |
---|
45 | @cm_4mesh |
---|
46 | ; |
---|
47 | topid = findtopid(id) |
---|
48 | widget_control, topid, get_uvalue = top_uvalue |
---|
49 | ;------------------------------------------------ |
---|
50 | ; make sure that we have the good grid stored in the cm_4mesh common parameters. |
---|
51 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
52 | currentgrid = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] |
---|
53 | change = changegrid(currentgrid) |
---|
54 | ;------------------------------------------------ |
---|
55 | ; quel est le type de boxzoom? |
---|
56 | currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
57 | options = extractatt(top_uvalue, 'options') |
---|
58 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
59 | flags = flags[*, currentplot] |
---|
60 | IF (flags[where(options EQ 'Longitude / x index')])[0] EQ 0 THEN $ |
---|
61 | xtype = 'geographic' ELSE xtype = 'index' |
---|
62 | IF (flags[where(options EQ 'Latitude / y index')])[0] EQ 0 THEN $ |
---|
63 | ytype = 'geographic' ELSE ytype = 'index' |
---|
64 | ;------------------------------------------------ |
---|
65 | ; comment completer la boxzoom? |
---|
66 | IF xtype EQ 'geographic' then begin |
---|
67 | lonn1 = lon1 |
---|
68 | lonn2 = lon2 |
---|
69 | xtitle = 'lon' |
---|
70 | ENDIF ELSE BEGIN |
---|
71 | lonn1 = firstxt |
---|
72 | lonn2 = lastxt |
---|
73 | xtitle = 'x ind' |
---|
74 | ENDELSE |
---|
75 | IF ytype EQ 'geographic' then begin |
---|
76 | latt1 = lat1 |
---|
77 | latt2 = lat2 |
---|
78 | ytitle = 'lat' |
---|
79 | ENDIF ELSE BEGIN |
---|
80 | latt1 = firstyt |
---|
81 | latt2 = lastyt |
---|
82 | ytitle = 'y ind' |
---|
83 | ENDELSE |
---|
84 | ;------------------------------------------------ |
---|
85 | vertf1 = floor(min([gdepw[0], gdept[0]])) |
---|
86 | vertf2 = ceil(max([gdepw[0], gdept[0]])) |
---|
87 | ;------------------------------------------------ |
---|
88 | Case N_Elements(Value) OF |
---|
89 | 0:boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2] |
---|
90 | 1:BEGIN |
---|
91 | if value EQ -1 then boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2] $ |
---|
92 | ELSE boxzoom=[lonn1, lonn2, latt1, latt2, 0.,value[0]] |
---|
93 | END |
---|
94 | 2:boxzoom=[lonn1, lonn2, latt1, latt2, value[0],value[1]] |
---|
95 | 4:boxzoom=[Value] |
---|
96 | 5:boxzoom=[Value[0:3], 0, Value[4]] |
---|
97 | 6:boxzoom = Value |
---|
98 | Else:BEGIN |
---|
99 | rien = report('Wrong Definition of Boxzoom') |
---|
100 | END |
---|
101 | ENDCASE |
---|
102 | ;------------------------------------------------ |
---|
103 | boxzoom[0] = floor(boxzoom[0]) |
---|
104 | boxzoom[1] = ceil(boxzoom[1]) |
---|
105 | boxzoom[2] = floor(boxzoom[2]) |
---|
106 | boxzoom[3] = ceil(boxzoom[3]) |
---|
107 | if n_elements(boxzoom GE 5) then begin |
---|
108 | boxzoom[4] = floor(boxzoom[4]) |
---|
109 | boxzoom[5] = ceil(boxzoom[5]) |
---|
110 | endif |
---|
111 | ;------------------------------------------------ |
---|
112 | ;------------------------------------------------ |
---|
113 | widget_control,widget_info(id,find_by_uname = 'lon1'), get_uvalue = uvalue |
---|
114 | strict = uvalue.strict |
---|
115 | ; |
---|
116 | ; les longitudes |
---|
117 | ; |
---|
118 | ; min et max possible |
---|
119 | if xtype EQ 'geographic' then BEGIN |
---|
120 | min = floor(min([glamt,glamf], max = max)) |
---|
121 | max = ceil(max) |
---|
122 | ENDIF ELSE BEGIN |
---|
123 | min = 0 |
---|
124 | max = jpi-1 |
---|
125 | ENDELSE |
---|
126 | ; les id des widgets |
---|
127 | lon1id = widget_info(id,find_by_uname = 'lon1') |
---|
128 | lon2id = widget_info(id,find_by_uname = 'lon2') |
---|
129 | ; doit-on changer de type d''axe x: longitude/index |
---|
130 | lonbase = widget_info(id,find_by_uname = 'lonbase') |
---|
131 | widget_control, lonbase, get_uvalue = lonbase_uvalue |
---|
132 | if lonbase_uvalue.name NE xtype then BEGIN |
---|
133 | widget_control, lonbase, update = 0 |
---|
134 | ; on casse tout |
---|
135 | widget_control, lon1id, /destroy |
---|
136 | widget_control, lon2id, /destroy |
---|
137 | ; on reconstruit |
---|
138 | lon1id = cw_slider_pm(lonbase,value=min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ |
---|
139 | , uvalue={name:'lon1', strict:keyword_set(strict)},uname ='lon1' $ |
---|
140 | , title = xtitle+'1', minimum = min $ |
---|
141 | , maximum = (boxzoom[1] < max)-keyword_set(strict)) |
---|
142 | lon2id = cw_slider_pm(lonbase,value=((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ |
---|
143 | , uvalue={name:'lon2', strict:keyword_set(strict)} $ |
---|
144 | , uname='lon2', title = xtitle+'2', maximum = max $ |
---|
145 | , minimum = (min > boxzoom[0])+keyword_set(strict)) |
---|
146 | widget_control, lonbase, set_uvalue = {name:xtype} |
---|
147 | widget_control, lonbase, update = 1 |
---|
148 | ENDIF ELSE BEGIN |
---|
149 | ; la nouvelle valeur qu''ils vont avoir |
---|
150 | cursorvalue1 = min > boxzoom[0] < ((boxzoom[1] < max)-strict) |
---|
151 | cursorvalue2 = ((min > boxzoom[0])+strict) > boxzoom[1] < max |
---|
152 | ; on change les bornes des slider |
---|
153 | widget_control, lon1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict} |
---|
154 | widget_control, lon2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max} |
---|
155 | ; on attribut la nouvelle valeur |
---|
156 | widget_control, lon1id , set_value = cursorvalue1 |
---|
157 | widget_control, lon2id, set_value = cursorvalue2 |
---|
158 | ENDELSE |
---|
159 | ; |
---|
160 | ; les latitudes |
---|
161 | ; |
---|
162 | ; min et max possible |
---|
163 | if ytype EQ 'geographic' then begin |
---|
164 | min = floor(min([gphit,gphif], max = max)) |
---|
165 | max = ceil(max) |
---|
166 | ENDIF ELSE BEGIN |
---|
167 | min = 0 |
---|
168 | max = jpj-1 |
---|
169 | ENDELSE |
---|
170 | ; doit-on changer de type d''axe y: latitude/index |
---|
171 | latbase = widget_info(id,find_by_uname = 'latbase') |
---|
172 | widget_control, latbase, get_uvalue = latbase_uvalue |
---|
173 | lat1id = widget_info(id,find_by_uname = 'lat1') |
---|
174 | lat2id = widget_info(id,find_by_uname = 'lat2') |
---|
175 | if latbase_uvalue.name NE ytype then BEGIN |
---|
176 | widget_control, latbase, update = 0 |
---|
177 | widget_control, lat1id, /destroy |
---|
178 | widget_control, lat2id, /destroy |
---|
179 | lat1id = cw_slider_pm(latbase,value=min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ |
---|
180 | , uvalue={name:'lat1', strict:keyword_set(strict)},uname ='lat1' $ |
---|
181 | , title = ytitle+'1', minimum =min $ |
---|
182 | , maximum = ((boxzoom[3] < max)-keyword_set(strict))) |
---|
183 | lat2id = cw_slider_pm(latbase,value=((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ |
---|
184 | , uvalue={name:'lat2', strict:keyword_set(strict)} $ |
---|
185 | , uname ='lat2', title = ytitle+'2' ,maximum = max $ |
---|
186 | , minimum =(min > boxzoom[2])+keyword_set(strict)) |
---|
187 | widget_control, latbase, set_uvalue = {name:ytype} |
---|
188 | widget_control, latbase, update = 1 |
---|
189 | ENDIF ELSE BEGIN |
---|
190 | cursorvalue1 = min > boxzoom[2] < ((boxzoom[3] < max)-strict) |
---|
191 | cursorvalue2 = ((min > boxzoom[2])+strict) > boxzoom[3] < max |
---|
192 | widget_control, lat1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict} |
---|
193 | widget_control, lat2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max} |
---|
194 | widget_control, lat1id, set_value = cursorvalue1 |
---|
195 | widget_control, lat2id, set_value = cursorvalue2 |
---|
196 | ENDELSE |
---|
197 | ; |
---|
198 | if n_elements(boxzoom) EQ 4 then return |
---|
199 | ; |
---|
200 | ; depth |
---|
201 | ; |
---|
202 | dthlv1id = widget_info(id, find_by_uname = 'dthlv1') |
---|
203 | dthlv2id = widget_info(id, find_by_uname = 'dthlv2') |
---|
204 | depth1id = widget_info(id, find_by_uname = 'depth1') |
---|
205 | depth2id = widget_info(id, find_by_uname = 'depth2') |
---|
206 | ; which type of point? |
---|
207 | widget_control, dthlv1id, get_uvalue = dthlv1_uval |
---|
208 | ; get the new axis |
---|
209 | if dthlv1_uval.grid_t EQ 1 then gdep = gdept ELSE gdep = gdepw |
---|
210 | ; Did we change the vertical axis? |
---|
211 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
212 | gdep1 = floor(fix(dthlv1_value.combobox_value)) |
---|
213 | IF array_equal(gdep1, floor(gdep)) NE 1 THEN BEGIN |
---|
214 | gdep1 = floor(gdep) |
---|
215 | gdep2 = ceil(gdep) |
---|
216 | same = where(gdep2-gdep1 EQ 0) |
---|
217 | if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 |
---|
218 | widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} |
---|
219 | widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} |
---|
220 | ENDIF ELSE gdep2 = gdep1+1 |
---|
221 | ; on s''assure que les profs donnees contiennent bien au moins un |
---|
222 | ; niveau. |
---|
223 | if boxzoom[4] GT boxzoom[5] then begin |
---|
224 | rien = boxzoom[4] |
---|
225 | boxzoom[4] = boxzoom[5] |
---|
226 | boxzoom[5] = rien |
---|
227 | endif |
---|
228 | ; |
---|
229 | rien = where(gdep1 LT boxzoom[4], indice1) |
---|
230 | indice1 = indice1 < (jpk-1) |
---|
231 | rien = where(gdep2 LE boxzoom[5], indice2) |
---|
232 | indice2 = indice1 > (indice2-1) |
---|
233 | ; |
---|
234 | if indice1 EQ indice2 then BEGIN |
---|
235 | if (where(gdep1 GE boxzoom[4] AND gdep2 LE boxzoom[5]))[0] EQ -1 then begin |
---|
236 | indice1 = 0 > (indice1-(dthlv1_uval.grid_t EQ 1)) |
---|
237 | indice2 = indice1 |
---|
238 | endif |
---|
239 | boxzoom[4] = gdep1[indice1] |
---|
240 | boxzoom[5] = boxzoom[4]+1 |
---|
241 | endif |
---|
242 | ; maintenant que les values et les indexes sont definis proprement, |
---|
243 | ; on peut les appliquer |
---|
244 | widget_control, dthlv1id, set_value = {combobox_select:indice1} |
---|
245 | widget_control, dthlv2id, set_value = {combobox_select:indice2} |
---|
246 | ; controler les min et les max des sliders... |
---|
247 | if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] |
---|
248 | max1 = (min1+1) > gdep1[indice2] |
---|
249 | widget_control, depth1id, set_value = {slider_min:min1, slider_max:max1, value:boxzoom[4]} |
---|
250 | min2 = gdep2[indice1] |
---|
251 | if indice2 EQ jpk-1 then BEGIN |
---|
252 | max2 = max([gdept, gdepw]) |
---|
253 | max2 = strtrim(string(max2,format='(e8.0)'), 1) |
---|
254 | max2 = float('1'+strmid(max2, 1))+float(max2) |
---|
255 | ENDIF ELSE max2 = gdep1[indice2+1] |
---|
256 | widget_control, depth2id, set_value = {slider_min:min2, slider_max:max2, value:boxzoom[5]} |
---|
257 | ; |
---|
258 | return |
---|
259 | end |
---|
260 | ;********************************************************************* |
---|
261 | FUNCTION cw_domain_get_value, id |
---|
262 | ; |
---|
263 | compile_opt idl2, strictarrsubs |
---|
264 | ; |
---|
265 | box = lonarr(6) |
---|
266 | possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] |
---|
267 | for i = 0, 5 do begin |
---|
268 | widget_control, widget_info(id, find_by_uname = possiblecase[i]) $ |
---|
269 | , get_value = value |
---|
270 | box[i] = value.value |
---|
271 | endfor |
---|
272 | return, box |
---|
273 | end |
---|
274 | ;********************************************************************* |
---|
275 | FUNCTION cw_domain_event, event |
---|
276 | ; |
---|
277 | compile_opt idl2, strictarrsubs |
---|
278 | ; |
---|
279 | @common |
---|
280 | ; help, /struct, event |
---|
281 | if (where(tag_names(event) EQ 'OUT'))[0] NE -1 then if event.out NE 0 then return, -1 |
---|
282 | widget_control, event.id, get_uvalue = uval |
---|
283 | case uval.name of |
---|
284 | 'lon1':widget_control,widget_info(event.handler,find_by_uname = 'lon2') $ |
---|
285 | , set_value = {slider_min:event.value+uval.strict} |
---|
286 | 'lon2':widget_control,widget_info(event.handler,find_by_uname = 'lon1') $ |
---|
287 | , set_value = {slider_max:event.value-uval.strict} |
---|
288 | 'lat1':widget_control,widget_info(event.handler,find_by_uname = 'lat2') $ |
---|
289 | , set_value = {slider_min:event.value+uval.strict} |
---|
290 | 'lat2':widget_control,widget_info(event.handler,find_by_uname = 'lat1') $ |
---|
291 | , set_value = {slider_max:event.value-uval.strict} |
---|
292 | 'unzoom':BEGIN |
---|
293 | id = widget_info(event.handler,find_by_uname = 'lon1') |
---|
294 | widget_control, id, get_value = value |
---|
295 | widget_control, id, set_value = {slider_min:value.slider_min_max[0]} |
---|
296 | widget_control, id, set_value = value.slider_min_max[0] |
---|
297 | id = widget_info(event.handler,find_by_uname = 'lat1') |
---|
298 | widget_control, id, get_value = value |
---|
299 | widget_control, id, set_value = {slider_min:value.slider_min_max[0]} |
---|
300 | widget_control, id, set_value = value.slider_min_max[0] |
---|
301 | id = widget_info(event.handler,find_by_uname = 'lon2') |
---|
302 | widget_control, id, get_value = value |
---|
303 | widget_control, id, set_value = {slider_max:value.slider_min_max[1]} |
---|
304 | widget_control, id, set_value = value.slider_min_max[1] |
---|
305 | id = widget_info(event.handler,find_by_uname = 'lat2') |
---|
306 | widget_control, id, get_value = value |
---|
307 | widget_control, id, set_value = {slider_max:value.slider_min_max[1]} |
---|
308 | widget_control, id, set_value = value.slider_min_max[1] |
---|
309 | END |
---|
310 | 'dthlv1':BEGIN |
---|
311 | ; ids... |
---|
312 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
313 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
314 | dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') |
---|
315 | ; faut-il changer dthlv2 ? |
---|
316 | widget_control, event.id, get_value = dthlv1_value |
---|
317 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
318 | widget_control, dthlv2id, get_value = dthlv2_value |
---|
319 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
320 | if dthlv2_value.combobox_index LT event.index then BEGIN |
---|
321 | ; on redefinie la valeur de dthlv2id |
---|
322 | widget_control, dthlv2id, set_value = {combobox_select:event.index} |
---|
323 | ; donc on redefinit la valeur et le max du slider 2 |
---|
324 | if event.index EQ jpk-1 then BEGIN |
---|
325 | max = max([gdept, gdepw]) |
---|
326 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
327 | max = float('1'+strmid(max, 1))+float(max) |
---|
328 | ENDIF ELSE max = gdep2[event.index+1]-1 |
---|
329 | widget_control, depth2id $ |
---|
330 | , set_value = {slider_max:max, value:gdep2[event.index]} |
---|
331 | ; du coup on redefinie donc le max du slider 1 |
---|
332 | widget_control, depth1id, set_value = {slider_max:gdep1[event.index]} |
---|
333 | END |
---|
334 | ; on redefinie la valeur et le min du slider depth 1 |
---|
335 | if event.index EQ 0 then min = 0 ELSE min = gdep1[event.index-1]+1 |
---|
336 | widget_control, depth1id, set_value = {slider_min:min, value:gdep1[event.index]} |
---|
337 | ; du coup on change aussi la valeur du min du slider depth 2 |
---|
338 | widget_control, depth2id, set_value = {slider_min:gdep1[event.index]+1} |
---|
339 | END |
---|
340 | 'dthlv2':BEGIN |
---|
341 | ; ids... |
---|
342 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
343 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
344 | dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') |
---|
345 | ; faut-il changer dthlv1 ? |
---|
346 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
347 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
348 | widget_control, event.id, get_value = dthlv2_value |
---|
349 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
350 | if dthlv1_value.combobox_index GT event.index then BEGIN |
---|
351 | ; on redefinie la valeur de dthlv1id |
---|
352 | widget_control, dthlv1id, set_value = {combobox_select:event.index} |
---|
353 | ; donc on redefinit la valeur et le min du slider 1 |
---|
354 | if event.index EQ 0 then min = 0 ELSE min = gdep2[event.index-1] |
---|
355 | widget_control, depth1id $ |
---|
356 | , set_value = {slider_min:min, value:gdep1[event.index]} |
---|
357 | ; du coup on redefinie donc le min du slider 2 |
---|
358 | widget_control, depth2id, set_value = {slider_min:gdep2[event.index]} |
---|
359 | END |
---|
360 | ; on redefinie la valeur et le max du slider depth 2 |
---|
361 | if event.index EQ jpk-1 then BEGIN |
---|
362 | max = max([gdept, gdepw]) |
---|
363 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
364 | max = float('1'+strmid(max, 1))+float(max) |
---|
365 | ENDIF ELSE max = gdep2[event.index+1]-1 |
---|
366 | widget_control, depth2id, set_value = {slider_max:max, value:gdep2[event.index]} |
---|
367 | ; du coup on change aussi la valeur du max du slider depth 1 |
---|
368 | widget_control, depth1id, set_value = {slider_max:gdep2[event.index]-1} |
---|
369 | END |
---|
370 | 'depth1':BEGIN |
---|
371 | ; ids... |
---|
372 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
373 | dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') |
---|
374 | ; doit-on changer dthlv1 ? |
---|
375 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
376 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
377 | rien = where(gdep1 LT event.value, indice) |
---|
378 | indice = indice < (jpk-1) |
---|
379 | if indice NE dthlv1_value.combobox_index then begin |
---|
380 | ; on change le min de depth2 |
---|
381 | widget_control, depth2id, set_value = {slider_min:gdep1[indice]+1} |
---|
382 | ; on redefinie la valeur de dthlv1id |
---|
383 | widget_control, dthlv1id, set_value = {combobox_select:indice} |
---|
384 | ; donc on redefinit le min du slider 1 |
---|
385 | if indice EQ 0 then min = 0 ELSE min = gdep1[indice-1]+1 |
---|
386 | widget_control, event.id, set_value = {slider_min:min} |
---|
387 | endif |
---|
388 | END |
---|
389 | 'depth2':BEGIN |
---|
390 | ; ids... |
---|
391 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
392 | dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') |
---|
393 | ; doit-on changer dthlv2 ? |
---|
394 | widget_control, dthlv2id, get_value = dthlv2_value |
---|
395 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
396 | rien = where(gdep2 LE event.value, indice) |
---|
397 | indice = 0 > (indice-1) |
---|
398 | if indice NE dthlv2_value.combobox_index then begin |
---|
399 | ; on change le max de depth1 |
---|
400 | widget_control, depth1id, set_value = {slider_max:gdep2[indice]-1} |
---|
401 | ; on redefinie la valeur de dthlv2id |
---|
402 | widget_control, dthlv2id, set_value = {combobox_select:indice} |
---|
403 | ; donc on redefinit le max du slider 2 |
---|
404 | if indice EQ jpk-1 then BEGIN |
---|
405 | max = max([gdept, gdepw]) |
---|
406 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
407 | max = float('1'+strmid(max, 1))+float(max) |
---|
408 | ENDIF ELSE max = gdep2[indice+1]-1 |
---|
409 | widget_control, event.id, set_value = {slider_max:max} |
---|
410 | endif |
---|
411 | END |
---|
412 | ELSE: |
---|
413 | ENDCASE |
---|
414 | ; slidesliceid = widget_info(event.top, find_by_uname = 'slide_slice') |
---|
415 | ; if slidesliceid NE 0 then widget_control, slidesliceid, set_value = 1 |
---|
416 | return,{ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
417 | , BOX:cw_domain_get_value(event.handler)} |
---|
418 | end |
---|
419 | ;********************************************************************* |
---|
420 | FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, _extra = ex |
---|
421 | ; |
---|
422 | ; |
---|
423 | compile_opt idl2, strictarrsubs |
---|
424 | ; |
---|
425 | @cm_4mesh |
---|
426 | @cm_4data |
---|
427 | ; |
---|
428 | ; def de la boxzoom |
---|
429 | Case N_Elements(Boxzoom) OF |
---|
430 | 0:boxzoom = [lon1, lon2, lat1, lat2 $ |
---|
431 | , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] |
---|
432 | 1:boxzoom = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] |
---|
433 | 2:boxzoom = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] |
---|
434 | 4:boxzoom = [Boxzoom, vert1, vert2] |
---|
435 | 5:boxzoom = [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
436 | 6: |
---|
437 | Else: return, report('Mauvaise Definition de Boxzoom') |
---|
438 | ENDCASE |
---|
439 | IF total(Boxzoom) EQ 0 THEN $ |
---|
440 | boxzoom = [lon1, lon2, lat1, lat2, min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]])] |
---|
441 | ; |
---|
442 | boxzoom[0] = floor(boxzoom[0]) |
---|
443 | boxzoom[1] = ceil(boxzoom[1]) |
---|
444 | boxzoom[2] = floor(boxzoom[2]) |
---|
445 | boxzoom[3] = ceil(boxzoom[3]) |
---|
446 | boxzoom[4] = floor(boxzoom[4]) |
---|
447 | boxzoom[5] = ceil(boxzoom[5]) |
---|
448 | ;------------------------------------------------ |
---|
449 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
450 | if NOT keyword_set(uname) then uname = '' |
---|
451 | base = widget_base(parent, row = 2, space = 0 $ |
---|
452 | , EVENT_FUNC = 'cw_domain_event' $ |
---|
453 | , FUNC_GET_VALUE = 'cw_domain_get_value' $ |
---|
454 | , PRO_SET_VALUE = 'cw_domain_set_value' $ |
---|
455 | , UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
456 | ;------------------------------------------------ |
---|
457 | baseh = widget_base(base, column = 1+keyword_set(unzoom), space = 0) |
---|
458 | ;------------------------------------------------ |
---|
459 | baseh1 = widget_base(baseh, row = 2, space = 0) |
---|
460 | ;-------------longitude--------------------------- |
---|
461 | min = floor(min([glamt, glamf], max = max)) |
---|
462 | max = ceil(max) |
---|
463 | IF max-min GT 360 AND keyword_set(key_periodic) THEN max = min+360 |
---|
464 | lonbase = widget_base(baseh1, column = 2, space = 0, uname = 'lonbase', uvalue = {name:'geographic'}) |
---|
465 | lon1id = cw_slider_pm(lonbase, value = min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ |
---|
466 | , uvalue = {name:'lon1', strict:keyword_set(strict)}, uname = 'lon1' $ |
---|
467 | , title = 'lon1', minimum = min $ |
---|
468 | , maximum = (boxzoom[1] < max)-keyword_set(strict)) |
---|
469 | lon2id = cw_slider_pm(lonbase, value = ((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ |
---|
470 | , uvalue = {name:'lon2', strict:keyword_set(strict)} $ |
---|
471 | , uname = 'lon2', title = 'lon2', maximum = max $ |
---|
472 | , minimum = (min > boxzoom[0])+keyword_set(strict)) |
---|
473 | ;---------------latitude------------------------- |
---|
474 | min = floor(min([gphit, gphif], max = max)) |
---|
475 | max = ceil(max) |
---|
476 | latbase = widget_base(baseh1, column = 2, space = 0, uname = 'latbase', uvalue = {name:'geographic'}) |
---|
477 | lat1id = cw_slider_pm(latbase, value = min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ |
---|
478 | , uvalue = {name:'lat1', strict:keyword_set(strict)}, uname = 'lat1' $ |
---|
479 | , title = 'lat1', minimum = min $ |
---|
480 | , maximum = ((boxzoom[3] < max)-keyword_set(strict))) |
---|
481 | lat2id = cw_slider_pm(latbase, value = ((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ |
---|
482 | , uvalue = {name:'lat2', strict:keyword_set(strict)} $ |
---|
483 | , uname = 'lat2', title = 'lat2', maximum = max $ |
---|
484 | , minimum = (min > boxzoom[2])+keyword_set(strict)) |
---|
485 | ;----------------unzoom------------------------ |
---|
486 | if keyword_set(unzoom) then rien = widget_button(baseh, value = 'unzoom', uvalue = {name:'unzoom'}, xsize = 60, ysize = 110) |
---|
487 | ;----------------depth------------------------ |
---|
488 | basez = widget_base(base, column = 3, space = 0, /base_align_center) |
---|
489 | ;------------------------------------------------ |
---|
490 | basezdrp = widget_base(basez, row = 2, space = 0) |
---|
491 | ; |
---|
492 | if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept |
---|
493 | gdep1 = floor(gdep) |
---|
494 | gdep2 = ceil(gdep) |
---|
495 | same = where(gdep2-gdep1 EQ 0) |
---|
496 | if same[0] NE -1 then gdep2[same] = gdep2[same] +1 |
---|
497 | sgdep1 = strtrim(gdep1, 1) |
---|
498 | sgdep2 = strtrim(gdep2, 1) |
---|
499 | ; |
---|
500 | dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep1, uvalue = {name:'dthlv1', grid_t:strupcase(vargrid) NE 'W'}, uname = 'dthlv1') |
---|
501 | rien = where(gdep1 LT boxzoom[4], indice1) |
---|
502 | indice1 = indice1 < (jpk-1) |
---|
503 | widget_control, dephtid, set_value = {combobox_select:indice1} |
---|
504 | ; |
---|
505 | dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep2, uvalue = {name:'dthlv2'}, uname = 'dthlv2') |
---|
506 | rien = where(gdep2 LE boxzoom[5], indice2) |
---|
507 | indice2 = indice1 > (indice2-1) |
---|
508 | widget_control, dephtid, set_value = {combobox_select:indice2} |
---|
509 | ; |
---|
510 | ;------ |
---|
511 | ; basedepthslid = widget_base(base, column = 2, space = 0) |
---|
512 | strminlen = max(strlen(strtrim(round([gdept, gdepw]), 1))) |
---|
513 | ; |
---|
514 | if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] |
---|
515 | max1 = (min1+1) > gdep1[indice2] |
---|
516 | rien = cw_slider_pm(basez, value = min1 > boxzoom[4] < (boxzoom[5] < max1) $ |
---|
517 | , uvalue = {name:'depth1'}, uname = 'depth1', strminlen = strminlen $ |
---|
518 | , title = 'z1', minimum = min1, maximum = max1) |
---|
519 | ; |
---|
520 | min2 = gdep2[indice1] |
---|
521 | if indice2 EQ jpk-1 then BEGIN |
---|
522 | max2 = max([gdept, gdepw]) |
---|
523 | max2 = strtrim(string(max2, format = '(e8.0)'), 1) |
---|
524 | max2 = float('1'+strmid(max2, 1))+float(max2) |
---|
525 | ENDIF ELSE max2 = gdep1[indice2+1] |
---|
526 | if max2 EQ min2 then max2 = min2+1 |
---|
527 | rien = cw_slider_pm(basez, value = (min2 > boxzoom[4]) > boxzoom[5] < max2 $ |
---|
528 | , uvalue = {name:'depth2'}, minimum = min2, maximum = max2 $ |
---|
529 | , uname = 'depth2', title = 'z2', strminlen = strminlen) |
---|
530 | ;-------------------------------------------- |
---|
531 | ; |
---|
532 | return, base |
---|
533 | end |
---|