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

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

corrections of some misspellings in some *.pro

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