source: trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_domain.pro

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 24.6 KB
Line 
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; @file_comments
42;
43; @categories
44; Compound widget
45;
46; @param ID
47;
48; @param VALUE
49; It is the default tick mark value (a floating-point number).
50;
51; @returns
52;
53; @uses
54;
55; @restrictions
56;
57; @examples
58;
59; @history
60;
61; @version
62; $Id$
63;
64;-
65PRO cw_domain_set_value, id, value
66;
67  compile_opt idl2, strictarrsubs
68;
69@cm_4mesh
70;
71   topid = findtopid(id)
72   widget_control, topid, get_uvalue = top_uvalue
73;------------------------------------------------
74; make sure that we have the good grid stored in the cm_4mesh common parameters.
75   currentfile = extractatt(top_uvalue, 'currentfile')
76   currentgrid = *(extractatt(top_uvalue, 'meshparameters'))[currentfile]
77   change = changegrid(currentgrid)
78;------------------------------------------------
79; What is the type of boxzoom ?
80   currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1
81   options = extractatt(top_uvalue, 'options')
82   flags = extractatt(top_uvalue, 'optionsflag')
83   flags = flags[*, currentplot]
84   IF (flags[where(options EQ 'Longitude / x index')])[0] EQ 0 THEN $
85    xtype = 'geographic' ELSE xtype = 'index'
86   IF (flags[where(options EQ 'Latitude / y index')])[0] EQ 0 THEN $
87    ytype = 'geographic' ELSE ytype = 'index'
88;------------------------------------------------
89; How to complete the boxzoom ?
90   IF xtype EQ  'geographic' then begin
91      lonn1 = lon1
92      lonn2 = lon2
93      xtitle = 'lon'
94   ENDIF ELSE BEGIN
95      lonn1 = firstxt
96      lonn2 = lastxt
97      xtitle = 'x ind'
98   ENDELSE
99   IF ytype EQ  'geographic' then begin
100      latt1 = lat1
101      latt2 = lat2
102      ytitle = 'lat'
103   ENDIF ELSE BEGIN
104      latt1 = firstyt
105      latt2 = lastyt
106      ytitle = 'y ind'
107   ENDELSE
108;------------------------------------------------
109   vertf1 = floor(min([gdepw[0], gdept[0]]))
110   vertf2 = ceil(max([gdepw[0], gdept[0]]))
111;------------------------------------------------
112   Case N_Elements(Value) OF
113      0:boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2]
114      1:BEGIN
115         if value EQ -1 then boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2] $
116         ELSE boxzoom=[lonn1, lonn2, latt1, latt2, 0.,value[0]]
117      END
118      2:boxzoom=[lonn1, lonn2, latt1, latt2, value[0],value[1]]
119      4:boxzoom=[Value]
120      5:boxzoom=[Value[0:3], 0, Value[4]]
121      6:boxzoom = Value
122      Else:BEGIN
123         rien = report('Wrong Definition of Boxzoom')
124      END
125   ENDCASE
126;------------------------------------------------
127   boxzoom[0] = floor(boxzoom[0])
128   boxzoom[1] = ceil(boxzoom[1])
129   boxzoom[2] = floor(boxzoom[2])
130   boxzoom[3] = ceil(boxzoom[3])
131   if n_elements(boxzoom GE 5) then begin
132      boxzoom[4] = floor(boxzoom[4])
133      boxzoom[5] = ceil(boxzoom[5])
134   endif
135;------------------------------------------------
136;------------------------------------------------
137   widget_control,widget_info(id,find_by_uname = 'lon1'), get_uvalue = uvalue
138   strict = uvalue.strict
139;
140; Longitudes
141;
142; Possible min and max
143   if xtype EQ 'geographic' then BEGIN
144      min = floor(min([glamt,glamf], max = max))
145      max = ceil(max)
146   ENDIF ELSE BEGIN
147      min = 0
148      max = jpi-1
149   ENDELSE
150; widgets's id
151   lon1id = widget_info(id,find_by_uname = 'lon1')
152   lon2id = widget_info(id,find_by_uname = 'lon2')
153; Do we have to change the type of x axis: longitude/index
154   lonbase = widget_info(id,find_by_uname = 'lonbase')
155   widget_control, lonbase,  get_uvalue = lonbase_uvalue
156   if lonbase_uvalue.name NE xtype then BEGIN
157      widget_control, lonbase, update = 0
158; We break everything
159      widget_control, lon1id, /destroy
160      widget_control, lon2id, /destroy
161; We reconstruct
162      lon1id = cw_slider_pm(lonbase,value=min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $
163                            , uvalue={name:'lon1', strict:keyword_set(strict)},uname ='lon1' $
164                            , title = xtitle+'1', minimum = min $
165                            , maximum = (boxzoom[1] < max)-keyword_set(strict))
166      lon2id = cw_slider_pm(lonbase,value=((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $
167                            , uvalue={name:'lon2', strict:keyword_set(strict)} $
168                            , uname='lon2', title = xtitle+'2', maximum = max $
169                            , minimum = (min > boxzoom[0])+keyword_set(strict))
170      widget_control, lonbase, set_uvalue = {name:xtype}
171      widget_control, lonbase, update = 1
172   ENDIF ELSE BEGIN
173; The new value  they will have
174      cursorvalue1 = min > boxzoom[0] < ((boxzoom[1] < max)-strict)
175      cursorvalue2 = ((min > boxzoom[0])+strict) > boxzoom[1] < max
176; We change slider's boundaries
177      widget_control, lon1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict}
178      widget_control, lon2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max}
179; We attribute the new value
180      widget_control, lon1id , set_value = cursorvalue1
181      widget_control, lon2id, set_value = cursorvalue2
182   ENDELSE
183;
184; Latitudes
185;
186; Possible min and max
187   if ytype EQ 'geographic' then begin
188      min = floor(min([gphit,gphif], max = max))
189      max = ceil(max)
190   ENDIF ELSE BEGIN
191      min = 0
192      max = jpj-1
193   ENDELSE
194; Do we have to change the type of y axis: latitude/index
195   latbase = widget_info(id,find_by_uname = 'latbase')
196   widget_control, latbase,  get_uvalue = latbase_uvalue
197   lat1id = widget_info(id,find_by_uname = 'lat1')
198   lat2id = widget_info(id,find_by_uname = 'lat2')
199   if latbase_uvalue.name NE ytype then BEGIN
200      widget_control, latbase, update = 0
201      widget_control, lat1id, /destroy
202      widget_control, lat2id, /destroy
203      lat1id = cw_slider_pm(latbase,value=min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $
204                            , uvalue={name:'lat1', strict:keyword_set(strict)},uname ='lat1' $
205                            , title = ytitle+'1', minimum =min $
206                            , maximum = ((boxzoom[3] < max)-keyword_set(strict)))
207      lat2id = cw_slider_pm(latbase,value=((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $
208                            , uvalue={name:'lat2', strict:keyword_set(strict)} $
209                            , uname ='lat2', title = ytitle+'2' ,maximum =  max $
210                            , minimum =(min > boxzoom[2])+keyword_set(strict))
211      widget_control, latbase, set_uvalue = {name:ytype}
212      widget_control, latbase, update = 1
213   ENDIF ELSE BEGIN
214      cursorvalue1 = min > boxzoom[2] < ((boxzoom[3] < max)-strict)
215      cursorvalue2 = ((min > boxzoom[2])+strict) > boxzoom[3] < max
216      widget_control, lat1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict}
217      widget_control, lat2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max}
218      widget_control, lat1id, set_value = cursorvalue1
219      widget_control, lat2id, set_value = cursorvalue2
220   ENDELSE
221;
222   if n_elements(boxzoom) EQ 4 then return
223;
224; depth
225;
226   dthlv1id = widget_info(id, find_by_uname = 'dthlv1')
227   dthlv2id = widget_info(id, find_by_uname = 'dthlv2')
228   depth1id = widget_info(id, find_by_uname = 'depth1')
229   depth2id = widget_info(id, find_by_uname = 'depth2')
230; which type of point?
231   widget_control, dthlv1id, get_uvalue = dthlv1_uval
232; get the new axis
233   if dthlv1_uval.grid_t EQ 1 then gdep = gdept ELSE gdep = gdepw
234 ; Did we change the vertical axis?
235   widget_control, dthlv1id, get_value = dthlv1_value
236   gdep1 = floor(fix(dthlv1_value.combobox_value))
237   IF array_equal(gdep1, floor(gdep)) NE 1 THEN BEGIN
238      gdep1 = floor(gdep)
239      gdep2 = ceil(gdep)
240;;       same = where(gdep2-gdep1 EQ 0)
241;;       if same[0] NE -1 then gdep2[same] = gdep2[same] + 1
242      widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)}
243      widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)}
244   ENDIF ELSE gdep2 = gdep1+1
245; We make sure that given depths contains at least one level.
246   if boxzoom[4] GT boxzoom[5] then begin
247      rien = boxzoom[4]
248      boxzoom[4] = boxzoom[5]
249      boxzoom[5] = rien
250   endif
251;
252   rien = where(gdep1 LT boxzoom[4], indice1)
253   indice1 = indice1 < (jpk-1)
254   rien = where(gdep2 LE boxzoom[5], indice2)
255   indice2 = indice1 > (indice2-1)
256;
257   if indice1 EQ indice2 then BEGIN
258      if (where(gdep1 GE boxzoom[4] AND gdep2 LE boxzoom[5]))[0]  EQ -1 then begin
259         indice1 = 0 > (indice1-(dthlv1_uval.grid_t EQ 1))
260         indice2 = indice1
261      endif
262      boxzoom[4] = gdep1[indice1]
263      boxzoom[5] = boxzoom[4]+1
264   endif
265; Now, values and indexes are properly defined.
266; So we can apply them
267   widget_control, dthlv1id, set_value = {combobox_select:indice1}
268   widget_control, dthlv2id, set_value = {combobox_select:indice2}
269; control mins and maxs of sliders...
270   if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1]
271   max1 = (min1+1) > gdep1[indice2]
272   widget_control, depth1id, set_value = {slider_min:min1, slider_max:max1, value:boxzoom[4]}
273   min2 = gdep2[indice1]
274   if indice2 EQ jpk-1 then BEGIN
275      max2 = max([gdept, gdepw])
276      max2 = strtrim(string(max2,format='(e8.0)'), 1)
277      max2 = float('1'+strmid(max2, 1))+float(max2)
278   ENDIF ELSE max2 = gdep1[indice2+1]
279   widget_control, depth2id, set_value = {slider_min:min2, slider_max:max2, value:boxzoom[5]}
280;
281   return
282end
283;
284;+
285;
286; @file_comments
287;
288; @categories
289; Compound widget
290;
291; @param ID
292;
293; @returns
294;
295; @uses
296;
297; @restrictions
298;
299; @examples
300;
301; @history
302;
303; @version
304; $Id$
305;
306;-
307FUNCTION cw_domain_get_value, id
308;
309  compile_opt idl2, strictarrsubs
310;
311   box = fltarr(6)
312   possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2']
313   for i = 0, 5 do begin
314      widget_control, widget_info(id, find_by_uname = possiblecase[i]) $
315       , get_value = value
316      box[i] = value.value
317    ENDFOR
318   return, box
319end
320;+
321;
322; @file_comments
323;
324; @categories
325; Compound widget
326;
327; @param EVENT
328;
329; @returns
330;
331; @uses
332;
333; @restrictions
334;
335; @examples
336;
337; @history
338;
339; @version
340; $Id$
341;
342;-
343FUNCTION cw_domain_event, event
344;
345  compile_opt idl2, strictarrsubs
346;
347@common
348; help,  /struct, event
349   if (where(tag_names(event) EQ 'OUT'))[0] NE -1 then if event.out NE 0 then return,  -1
350   widget_control, event.id, get_uvalue = uval
351   case uval.name of
352      'lon1':widget_control,widget_info(event.handler,find_by_uname = 'lon2') $
353       , set_value = {slider_min:event.value+uval.strict}
354      'lon2':widget_control,widget_info(event.handler,find_by_uname = 'lon1') $
355       , set_value = {slider_max:event.value-uval.strict}
356      'lat1':widget_control,widget_info(event.handler,find_by_uname = 'lat2') $
357       , set_value = {slider_min:event.value+uval.strict}
358      'lat2':widget_control,widget_info(event.handler,find_by_uname = 'lat1') $
359       , set_value = {slider_max:event.value-uval.strict}
360      'unzoom':BEGIN
361         id = widget_info(event.handler,find_by_uname = 'lon1')
362         widget_control, id, get_value = value
363         widget_control, id, set_value = {slider_min:value.slider_min_max[0]}
364         widget_control, id, set_value = value.slider_min_max[0]
365         id = widget_info(event.handler,find_by_uname = 'lat1')
366         widget_control, id, get_value = value
367         widget_control, id, set_value = {slider_min:value.slider_min_max[0]}
368         widget_control, id, set_value = value.slider_min_max[0]
369         id = widget_info(event.handler,find_by_uname = 'lon2')
370         widget_control, id, get_value = value
371         widget_control, id, set_value = {slider_max:value.slider_min_max[1]}
372         widget_control, id, set_value = value.slider_min_max[1]
373         id = widget_info(event.handler,find_by_uname = 'lat2')
374         widget_control, id, get_value = value
375         widget_control, id, set_value = {slider_max:value.slider_min_max[1]}
376         widget_control, id, set_value = value.slider_min_max[1]
377      END
378      'dthlv1':BEGIN
379; ids...
380         depth1id = widget_info(event.handler,find_by_uname = 'depth1')
381         depth2id = widget_info(event.handler,find_by_uname = 'depth2')
382         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2')
383; Do we have to change dthlv2 ?
384         widget_control, event.id, get_value = dthlv1_value
385         gdep1 = fix(dthlv1_value.combobox_value)
386         widget_control, dthlv2id, get_value = dthlv2_value
387         gdep2 = fix(dthlv2_value.combobox_value)
388         if dthlv2_value.combobox_index LT event.index then BEGIN
389; We redefine the dthlv2id's value
390            widget_control, dthlv2id, set_value = {combobox_select:event.index}
391; So we redefine the value and the max of the slider 2
392            if event.index EQ jpk-1 then BEGIN
393               max = max([gdept, gdepw])
394               max = strtrim(string(max,format='(e8.0)'), 1)
395               max = float('1'+strmid(max, 1))+float(max)
396            ENDIF ELSE max = gdep2[event.index+1]-1
397            widget_control, depth2id $
398             , set_value = {slider_max:max, value:gdep2[event.index]}
399; So we redefine the max of the slider 1
400            widget_control, depth1id, set_value = {slider_max:gdep1[event.index]}
401         END
402; We redefine the value and the min of the slider depth1
403         if event.index EQ 0 then min = 0 ELSE min = gdep1[event.index-1]+1
404         widget_control, depth1id, set_value = {slider_min:min, value:gdep1[event.index]}
405; S we change the value of the min of the slider depth 2
406         widget_control, depth2id, set_value = {slider_min:gdep1[event.index]+1}
407      END
408      'dthlv2':BEGIN
409; ids...
410         depth1id = widget_info(event.handler,find_by_uname = 'depth1')
411         depth2id = widget_info(event.handler,find_by_uname = 'depth2')
412         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1')
413; Do we have to change dthlv1 ?
414         widget_control, dthlv1id, get_value = dthlv1_value
415         gdep1 = fix(dthlv1_value.combobox_value)
416         widget_control, event.id, get_value = dthlv2_value
417         gdep2 = fix(dthlv2_value.combobox_value)
418         if dthlv1_value.combobox_index GT event.index then BEGIN
419; We redefine the value of dthlv1id
420            widget_control, dthlv1id, set_value = {combobox_select:event.index}
421; So we redefine the value and the min of the slider 1
422            if event.index EQ 0 then min = 0 ELSE min = gdep2[event.index-1]
423            widget_control, depth1id $
424             , set_value = {slider_min:min, value:gdep1[event.index]}
425; Se we redefine the min of the slider 2
426            widget_control, depth2id, set_value = {slider_min:gdep2[event.index]}
427         END
428; We redefine the value and the max of the slider depth 2
429         if event.index EQ jpk-1 then BEGIN
430            max = max([gdept, gdepw])
431            max = strtrim(string(max,format='(e8.0)'), 1)
432            max = float('1'+strmid(max, 1))+float(max)
433         ENDIF ELSE max = gdep2[event.index+1]-1
434         widget_control, depth2id, set_value = {slider_max:max, value:gdep2[event.index]}
435; So we change the value of the max of the slider depth 1
436         widget_control, depth1id, set_value = {slider_max:gdep2[event.index]-1}
437      END
438      'depth1':BEGIN
439; ids...
440         depth2id = widget_info(event.handler,find_by_uname = 'depth2')
441         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1')
442; Do we have to change dthlv1 ?
443         widget_control, dthlv1id, get_value = dthlv1_value
444         gdep1 = fix(dthlv1_value.combobox_value)
445         rien = where(gdep1 LT event.value, indice)
446         indice = indice < (jpk-1)
447         if indice NE dthlv1_value.combobox_index then begin
448; We change the min of depth2
449            widget_control, depth2id, set_value = {slider_min:gdep1[indice]+1}
450; We redefine the value of dthlv1id
451            widget_control, dthlv1id, set_value = {combobox_select:indice}
452; So we redefine the min of the slider 1
453            if indice EQ 0 then min = 0 ELSE min = gdep1[indice-1]+1
454            widget_control, event.id, set_value = {slider_min:min}
455         endif
456      END
457      'depth2':BEGIN
458; ids...
459         depth1id = widget_info(event.handler,find_by_uname = 'depth1')
460         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2')
461; Do we have to change dthlv2 ?
462         widget_control, dthlv2id, get_value = dthlv2_value
463         gdep2 = fix(dthlv2_value.combobox_value)
464         rien = where(gdep2 LE event.value, indice)
465         indice = 0 > (indice-1)
466         if indice NE dthlv2_value.combobox_index then begin
467; We change the min of depth1
468            widget_control, depth1id, set_value = {slider_max:gdep2[indice]-1}
469; We redefine the value of dthlv2id
470            widget_control, dthlv2id, set_value = {combobox_select:indice}
471; So we redefine the min of the slider 2
472            if indice EQ jpk-1 then BEGIN
473               max = max([gdept, gdepw])
474               max = strtrim(string(max,format='(e8.0)'), 1)
475               max = float('1'+strmid(max, 1))+float(max)
476            ENDIF ELSE max = gdep2[indice+1]-1
477            widget_control, event.id, set_value = {slider_max:max}
478         endif
479      END
480      ELSE:
481   ENDCASE
482;    slidesliceid = widget_info(event.top, find_by_uname = 'slide_slice')
483;    if slidesliceid NE 0 then widget_control, slidesliceid, set_value = 1
484   return,{ID:event.handler, TOP:event.top, HANDLER:0L $
485           , BOX:cw_domain_get_value(event.handler)}
486end
487;
488;+
489;
490; @file_comments
491;
492; @categories
493; Compound widget
494;
495; @param PARENT {in}{required}
496; The widget ID of the parent widget.
497;
498; @keyword UVALUE
499; The user value to be associated with the widget.
500;
501; @keyword UNAME
502; The user name to be associated with the widget.
503;
504; @keyword STRICT
505;
506; @keyword UNZOOM
507;
508; @keyword BOXZOOM
509; Vector indicating the geographic zone on which we want to cut the map.
510; If BOXZOOM has :
511;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
512;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
513;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
514;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
515;   6 elements: The extraction is made on Boxzoom
516; Where lon1, lon2,lat1,lat2 are global variables defined at the last
517; <pro>domdef</pro>!
518;
519; @keyword _EXTRA
520; Used to pass keywords
521;
522; @returns
523;
524; @uses
525;
526; @restrictions
527;
528; @examples
529;
530; @history
531;
532; @version
533; $Id$
534;
535; @todo
536; seb: Documenter
537;
538;-
539FUNCTION cw_domain, parent, BOXZOOM=boxzoom, STRICT=strict $
540                  , UVALUE=uvalue, UNAME=uname, UNZOOM=unzoom, _EXTRA=ex
541;
542  compile_opt idl2, strictarrsubs
543;
544@cm_4mesh
545@cm_4data
546;
547; Definition of the boxzoom
548  Case N_Elements(Boxzoom) OF
549    0:boxzoom = [lon1, lon2, lat1, lat2 $
550                 , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ]
551    1:boxzoom = [lon1, lon2, lat1, lat2, 0., boxzoom[0]]
552    2:boxzoom = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]]
553    4:boxzoom = [Boxzoom, vert1, vert2]
554    5:boxzoom = [Boxzoom[0:3], 0, Boxzoom[4]]
555    6:
556    Else: return, report('Mauvaise Definition de Boxzoom')
557  ENDCASE
558  IF total(Boxzoom) EQ 0 THEN $
559     boxzoom = [lon1, lon2, lat1, lat2, min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]])]
560;
561  boxzoom[0] = floor(boxzoom[0])
562  boxzoom[1] = ceil(boxzoom[1])
563  boxzoom[2] = floor(boxzoom[2])
564  boxzoom[3] = ceil(boxzoom[3])
565  boxzoom[4] = floor(boxzoom[4])
566  boxzoom[5] = ceil(boxzoom[5])
567;------------------------------------------------
568  if NOT keyword_set(uvalue) then uvalue = ''
569  if NOT keyword_set(uname) then uname = ''
570  base = widget_base(parent, row = 2, space = 0 $
571                     , EVENT_FUNC = 'cw_domain_event' $
572                     , FUNC_GET_VALUE = 'cw_domain_get_value' $
573                     , PRO_SET_VALUE = 'cw_domain_set_value' $
574                     , UVALUE = uvalue, UNAME = uname, _extra = ex)
575;------------------------------------------------
576  baseh = widget_base(base, column = 1+keyword_set(unzoom), space = 0)
577;------------------------------------------------
578  baseh1 = widget_base(baseh, row = 2, space = 0)
579;-------------longitude---------------------------
580  min = floor(min([glamt, glamf], max = max))
581  max = ceil(max)
582  IF max-min GT 360 AND keyword_set(key_periodic) THEN max = min+360
583  lonbase = widget_base(baseh1, column = 2, space = 0, uname = 'lonbase', uvalue = {name:'geographic'})
584  lon1id = cw_slider_pm(lonbase, value = min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $
585                        , uvalue = {name:'lon1', strict:keyword_set(strict)}, uname = 'lon1' $
586                        , title = 'lon1', minimum = min $
587                        , maximum = (boxzoom[1] < max)-keyword_set(strict))
588  lon2id = cw_slider_pm(lonbase, value = ((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $
589                        , uvalue = {name:'lon2', strict:keyword_set(strict)} $
590                        , uname = 'lon2', title = 'lon2', maximum = max $
591                        , minimum = (min > boxzoom[0])+keyword_set(strict))
592;---------------latitude-------------------------
593  min = floor(min([gphit, gphif], max = max))
594  max = ceil(max)
595  latbase = widget_base(baseh1, column = 2, space = 0, uname = 'latbase', uvalue = {name:'geographic'})
596  lat1id = cw_slider_pm(latbase, value = min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $
597                        , uvalue = {name:'lat1', strict:keyword_set(strict)}, uname = 'lat1' $
598                        , title = 'lat1', minimum = min $
599                        , maximum = ((boxzoom[3] < max)-keyword_set(strict)))
600  lat2id = cw_slider_pm(latbase, value = ((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $
601                        , uvalue = {name:'lat2', strict:keyword_set(strict)} $
602                        , uname = 'lat2', title = 'lat2', maximum =  max $
603                        , minimum = (min > boxzoom[2])+keyword_set(strict))
604;----------------unzoom------------------------
605  if keyword_set(unzoom) then rien = widget_button(baseh, value = 'unzoom', uvalue = {name:'unzoom'}, xsize = 60, ysize = 110)
606;----------------depth------------------------
607  basez = widget_base(base, column = 3, space = 0, /base_align_center)
608;------------------------------------------------
609  basezdrp = widget_base(basez, row = 2, space = 0)
610;
611  if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept
612  gdep1 = floor(gdep)
613  gdep2 = ceil(gdep)
614;;   same = where(gdep2-gdep1 EQ 0)
615;;   if same[0] NE -1 then gdep2[same] = gdep2[same] +1
616  sgdep1 = strtrim(gdep1, 1)
617  sgdep2 = strtrim(gdep2, 1)
618;
619  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep1, uvalue = {name:'dthlv1', grid_t:strupcase(vargrid) NE 'W'}, uname = 'dthlv1')
620  rien = where(gdep1 LT boxzoom[4], indice1)
621  indice1 = indice1 < (jpk-1)
622  widget_control, dephtid, set_value = {combobox_select:indice1}
623;
624  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep2, uvalue = {name:'dthlv2'}, uname = 'dthlv2')
625  rien = where(gdep2 LE boxzoom[5], indice2)
626  indice2 = indice1 > (indice2-1)
627  widget_control, dephtid, set_value = {combobox_select:indice2}
628;
629;------
630;   basedepthslid = widget_base(base, column = 2, space = 0)
631  strminlen = max(strlen(strtrim(round([gdept, gdepw]), 1)))
632;
633  if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1]
634  max1 = (min1+1) > gdep1[indice2]
635  rien = cw_slider_pm(basez, value = min1 > boxzoom[4] < (boxzoom[5] < max1) $
636                      , uvalue = {name:'depth1'}, uname = 'depth1', strminlen = strminlen $
637                      , title = 'z1', minimum = min1, maximum = max1)
638;
639  min2 = gdep2[indice1]
640  if indice2 EQ jpk-1 then max2 = ceil(max([gdept, gdepw])) $
641  ELSE max2 = gdep1[indice2+1]
642  if floor(max2) LE floor(min2) then max2 = min2+1
643  rien = cw_slider_pm(basez, value = (min2 > boxzoom[4]) > boxzoom[5] < max2 $
644                      , uvalue = {name:'depth2'}, minimum = min2, maximum =  max2 $
645                      , uname = 'depth2', title = 'z2', strminlen = strminlen)
646;--------------------------------------------
647;
648  return, base
649end
Note: See TracBrowser for help on using the repository browser.