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

Last change on this file since 371 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

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