source: trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_slide_slice.pro @ 327

Last change on this file since 327 was 327, checked in by pinsard, 17 years ago

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.9 KB
RevLine 
[157]1;+
[231]2;
[157]3; @file_comments
4;
5; @categories
6; Compound widget
[226]7;
[157]8; @param ID
9;
10; @param VALUE
11; It is the default tick mark value (a floating-point number).
12;
13; @returns
[226]14;
[157]15; @uses
[226]16;
[157]17; @restrictions
[226]18;
[157]19; @examples
[226]20;
[157]21; @history
[226]22;
23; @version
[157]24; $Id$
[325]25;
[157]26;-
[231]27PRO cw_slide_slice_set_value, id, value
28;
[114]29  compile_opt idl2, strictarrsubs
30;
[2]31@common
32   topid = findtopid(id)
33   domainid = widget_info(topid, find_by_uname = 'domain')
[51]34   widget_control, domainid, get_value = boxzoom
35   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
[2]36   thickid  = widget_info(topid, find_by_uname = 'thickness')
37   widget_control, thickid, get_uvalue = thicknessuval
38   widget_control, thickid, get_value = thickness
39   thickness = thicknessuval.choix[thickness.droplist_select]
40   sliderid = widget_info(topid, find_by_uname = 'slider')
41   if type EQ 'y' then BEGIN
[51]42      mini = floor(min([glamt, glamf], max = maxi))
[2]43      maxi = ceil(maxi)-thickness
[51]44      widget_control, sliderid, set_value = {slider_min:mini, slider_max:maxi, value:boxzoom[0]<maxi}
45      thickness = boxzoom[1]-boxzoom[0]
[226]46   ENDIF ELSE BEGIN
[51]47      mini = floor(min([gphit, gphif], max = maxi))
[2]48      maxi = ceil(maxi)-thickness
[51]49      widget_control, sliderid, set_value = {slider_min:mini, slider_max:maxi, value:boxzoom[2]<maxi}
50      thickness = boxzoom[3]-boxzoom[2]
[2]51   ENDELSE
52   thicknessval = thicknessuval.choix
53   index = where(thicknessval EQ thickness) & index = index[0]
[226]54   if index EQ -1 then BEGIN
[2]55      index = 20
56      thicknessval[20] = strtrim(thickness, 1)
57      widget_control, thickid, set_value = thicknessval
58      widget_control, thickid, set_uvalue ={name:'thickness', choix:thicknessval}
59   endif
60   widget_control, thickid, set_value = {droplist_select:index}
61   return
62end
[231]63;
[157]64;+
[231]65;
[157]66; @file_comments
67;
68; @categories
69; Compound widget
[226]70;
[157]71; @param EVENT
72;
[226]73; @returns
[157]74;
75; @uses
[226]76;
[157]77; @restrictions
[226]78;
[157]79; @examples
[226]80;
[157]81; @history
[226]82;
83; @version
[157]84; $Id$
[325]85;
[157]86;-
[2]87FUNCTION cw_slide_slice_event,  event
[114]88;
89  compile_opt idl2, strictarrsubs
90;
[2]91@common
92   widget_control, event.id, get_uvalue=uval
93   domainid = widget_info(event.top, find_by_uname = 'domain')
94   thickid  = widget_info(event.handler, find_by_uname = 'thickness')
95   sliderid = widget_info(event.handler, find_by_uname = 'slider')
96;   uniteid  = widget_info(event.handler, find_by_uname = 'unite')
[51]97   widget_control, domainid, get_value = boxzoom
98   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
[2]99   widget_control, thickid, get_uvalue = thicknessuval
100   widget_control, thickid, get_value = thickness
101   thickness = thicknessuval.choix[thickness.droplist_select]
102   widget_control, sliderid, get_value = slider & slider = slider.value
103
104   if uval.name EQ 'thickness' then begin
[51]105      if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
[2]106      if type EQ 'y' then BEGIN
[51]107         mini = floor(min([glamt, glamf], max = maxi))
[2]108         maxi = ceil(maxi)-thickness
[226]109      ENDIF ELSE BEGIN
[51]110         mini = floor(min([gphit, gphif], max = maxi))
[2]111         maxi = ceil(maxi)-thickness
112      ENDELSE
113      slider = slider<maxi
114      widget_control, sliderid, set_value = {slider_min:mini, slider_max:maxi, value:slider}
115   endif
116
117;   widget_control, uniteid, get_value = unite
118;
119;
120;    if uval.name EQ 'unite' then begin
[51]121;       domdef, boxzoom, gridtype = 'T'
[2]122;       if unite EQ 'degre' then BEGIN
123;          if strpos(type,'y') NE -1 then begin
[51]124;             mini = floor(min([glamt, glamf], max = maxi))
[2]125;             maxi = ceil(maxi)
126; print, lon1, mini, maxi
127;             widget_control, sliderid, set_value = {value:lon1, slider_min_max:[mini, maxi]}
[226]128;          ENDIF ELSE BEGIN
[51]129;             mini = floor(min([gphit, glamf], max = maxi))
[2]130;             maxi = ceil(maxi)
131;             widget_control, sliderid, set_value = {value:lat1, slider_min_max:[mini, maxi]}
132;          ENDELSE
133;       ENDIF ELSE BEGIN
134;          if strpos(type,'y') NE -1 then BEGIN
[51]135; print, 'ds if',firstxt, 0, jpi-1
136;             widget_control, sliderid, set_value = {value:firstxt, slider_min_max:[0, jpi-1]}
[226]137;          ENDIF ELSE BEGIN
[51]138;             widget_control, sliderid, set_value = {value:firstyt, slider_min_max:[0, jpj-1]}
[2]139;          ENDELSE
140;       ENDELSE
141;    endif
142;
143;   if unite EQ 'degre' then BEGIN
144   if type EQ 'y' then begin
[51]145      boxzoom[0] = slider &  boxzoom[1] = slider+thickness
[226]146   ENDIF ELSE BEGIN
[51]147      boxzoom[2] = slider &  boxzoom[3] = slider+thickness
[226]148   ENDELSE
[2]149;    ENDIF ELSE BEGIN
150;       if strpos(type,'y') NE -1 then begin
[51]151;          boxzoom[0] = glamt[slider, 0] &  boxzoom[1] = glamf[slider+thickness, 0]
[226]152;       ENDIF ELSE BEGIN
[51]153;          boxzoom[2] = gphit[0, slider] &  boxzoom[3] = gphif[0, slider+thickness]
[226]154;       ENDELSE
[2]155;    ENDELSE
[51]156   widget_control, domainid, set_value = boxzoom
[2]157   return, {CW_SLIDE_SLICE, ID:event.handler, TOP:event.top, HANDLER:0L}
158end
[231]159;
[150]160;+
[231]161;
[150]162; @file_comments
163;
164;
165; @categories
[157]166; Compound widget
[150]167;
168; @param PARENT {in}{required}
169; The widget ID of the parent widget.
170;
171; @keyword BOXZOOM
[226]172; Vector indicating the geographic zone on which we want to cut the map.
173; If BOXZOOM has :
[150]174;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
175;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
176;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
177;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
[226]178;   6 elements: The extraction is made on Boxzoom
[254]179; Where lon1, lon2,lat1,lat2 are global variables defined at the last
180; <pro>domdef</pro> !
[150]181;
182; @keyword COLUMN
183; Buttons will be arranged in the number of columns
184; specified by this keyword.
[226]185;
[150]186; @keyword FRAME
187; Specifies the width of the frame to be drawn around the base.
[226]188;
[150]189; @keyword ROW
190; Buttons will be arranged in the number of rows
191; specified by this keyword.
[226]192;
[150]193; @keyword UVALUE
194; The user value to be associated with the widget.
[226]195;
[150]196; @keyword UNAME
197; The user name to be associated with the widget.
[226]198;
[150]199; @keyword _EXTRA
[231]200; Used to pass keywords
[226]201;
[150]202; @returns
[226]203;
[150]204; @uses
[226]205;
[150]206; @restrictions
[226]207;
[150]208; @examples
[226]209;
[150]210; @history
[226]211;
212; @version
[150]213; $Id$
[226]214;
[150]215; @todo
216; seb: documenter
217;
218;-
[327]219FUNCTION cw_slide_slice, parent, BOXZOOM=boxzoom, UVALUE=uvalue, UNAME=uname $
220                       , FRAME=frame, ROW=row, COLUMN=column, _EXTRA=ex
[114]221;
222  compile_opt idl2, strictarrsubs
223;
[2]224@common
225;------------------------------------------------
[226]226; checking exclusive keywords
[2]227   column = keyword_set(column)*(1-keyword_set(row))
[226]228   row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)
[2]229   if NOT keyword_set(uvalue) then uvalue = ''
230   if NOT keyword_set(uname) then uname = ''
231;
232   base = widget_base(parent, ROW = row, COLUMN = column  $
233                      , EVENT_FUNC = 'cw_slide_slice_event' $
234                      , FUNC_GET_VALUE='cw_slide_slice_get_value' $
235                      , PRO_SET_VALUE='cw_slide_slice_set_value' $
236                      , ROW = row, COLUMN = column, UVALUE = uvalue, UNAME = uname $
[226]237                      , FRAME = frame, _extra = ex)
[2]238;------------------------------------------------
[51]239   if NOT keyword_set(boxzoom) then boxzoom = [lon1, lon2, lat1, lat2]
[2]240;    rien = cw_bgroup(base, ['degre', 'points'],/exclusive, /column, uname = 'unite', uvalue = {name:'unite'}, /return_name, set_value = 0, /no_release)
241   thicknessval = indgen(21)+1
242   thicknessval = string(thicknessval)
243   for i = 0, n_elements(thicknessval)-1 do thicknessval[i] = strtrim(thicknessval[i], 1)
244   droplistid = cw_droplist_pm(base, value = thicknessval, uname = 'thickness', uvalue = {name:'thickness', choix:thicknessval})
245;
[51]246   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
[2]247   if type EQ 'y' then BEGIN
[51]248      mini = floor(min([glamt, glamf], max = maxi))
249      thickness = boxzoom[1]-boxzoom[0]
[2]250      maxi = ceil(maxi)-thickness
251      rien = cw_slider_pm(base, minimum = mini, maximum = (mini+1) > maxi $
[51]252                          , value = mini > boxzoom[0] < maxi, /column, uname = 'slider' $
[2]253                          , uvalue = {name:'slider'})
[226]254   ENDIF ELSE BEGIN
[51]255      mini = floor(min([gphit, gphif], max = maxi))
256      thickness = boxzoom[3]-boxzoom[2]
[2]257      maxi = ceil(maxi)-thickness
258      rien = cw_slider_pm(base, minimum = mini, maximum =  (mini+1) > maxi $
[51]259                          , value = mini > boxzoom[2] < maxi, /column, uname = 'slider' $
[2]260                          , uvalue = {name:'slider'})
261   ENDELSE
262   index = where(thicknessval EQ thickness) & index = index[0]
[226]263   if index EQ -1 then BEGIN
[2]264      index = 20
265      thicknessval[20] = strtrim(thickness, 1)
266      widget_control, droplistid, set_value = thicknessval
267      widget_control, droplistid, set_uvalue ={name:'thickness', choix:thicknessval}
268   endif
269   widget_control, droplistid, set_value = {droplist_select:index}
[226]270
[2]271;   if type EQ 'xt' then begin
[51]272;       mini = floor(min([glamt,glamf], max = maxi))
[2]273;       maxi = ceil(maxi)
[226]274;    ENDIF ELSE BEGIN
[51]275;       mini = floor(min([gphit,gphif], max = maxi))
[2]276;       maxi = ceil(maxi)
277;    ENDELSE
[231]278
[2]279;------------------------------------------------
280   return, base
281end
Note: See TracBrowser for help on using the repository browser.