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, 16 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
Line 
1;+
2;
3; @file_comments
4;
5; @categories
6; Compound widget
7;
8; @param ID
9;
10; @param VALUE
11; It is the default tick mark value (a floating-point number).
12;
13; @returns
14;
15; @uses
16;
17; @restrictions
18;
19; @examples
20;
21; @history
22;
23; @version
24; $Id$
25;
26;-
27PRO cw_slide_slice_set_value, id, value
28;
29  compile_opt idl2, strictarrsubs
30;
31@common
32   topid = findtopid(id)
33   domainid = widget_info(topid, find_by_uname = 'domain')
34   widget_control, domainid, get_value = boxzoom
35   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
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
42      mini = floor(min([glamt, glamf], max = maxi))
43      maxi = ceil(maxi)-thickness
44      widget_control, sliderid, set_value = {slider_min:mini, slider_max:maxi, value:boxzoom[0]<maxi}
45      thickness = boxzoom[1]-boxzoom[0]
46   ENDIF ELSE BEGIN
47      mini = floor(min([gphit, gphif], max = maxi))
48      maxi = ceil(maxi)-thickness
49      widget_control, sliderid, set_value = {slider_min:mini, slider_max:maxi, value:boxzoom[2]<maxi}
50      thickness = boxzoom[3]-boxzoom[2]
51   ENDELSE
52   thicknessval = thicknessuval.choix
53   index = where(thicknessval EQ thickness) & index = index[0]
54   if index EQ -1 then BEGIN
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
63;
64;+
65;
66; @file_comments
67;
68; @categories
69; Compound widget
70;
71; @param EVENT
72;
73; @returns
74;
75; @uses
76;
77; @restrictions
78;
79; @examples
80;
81; @history
82;
83; @version
84; $Id$
85;
86;-
87FUNCTION cw_slide_slice_event,  event
88;
89  compile_opt idl2, strictarrsubs
90;
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')
97   widget_control, domainid, get_value = boxzoom
98   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
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
105      if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
106      if type EQ 'y' then BEGIN
107         mini = floor(min([glamt, glamf], max = maxi))
108         maxi = ceil(maxi)-thickness
109      ENDIF ELSE BEGIN
110         mini = floor(min([gphit, gphif], max = maxi))
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
121;       domdef, boxzoom, gridtype = 'T'
122;       if unite EQ 'degre' then BEGIN
123;          if strpos(type,'y') NE -1 then begin
124;             mini = floor(min([glamt, glamf], max = maxi))
125;             maxi = ceil(maxi)
126; print, lon1, mini, maxi
127;             widget_control, sliderid, set_value = {value:lon1, slider_min_max:[mini, maxi]}
128;          ENDIF ELSE BEGIN
129;             mini = floor(min([gphit, glamf], max = maxi))
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
135; print, 'ds if',firstxt, 0, jpi-1
136;             widget_control, sliderid, set_value = {value:firstxt, slider_min_max:[0, jpi-1]}
137;          ENDIF ELSE BEGIN
138;             widget_control, sliderid, set_value = {value:firstyt, slider_min_max:[0, jpj-1]}
139;          ENDELSE
140;       ENDELSE
141;    endif
142;
143;   if unite EQ 'degre' then BEGIN
144   if type EQ 'y' then begin
145      boxzoom[0] = slider &  boxzoom[1] = slider+thickness
146   ENDIF ELSE BEGIN
147      boxzoom[2] = slider &  boxzoom[3] = slider+thickness
148   ENDELSE
149;    ENDIF ELSE BEGIN
150;       if strpos(type,'y') NE -1 then begin
151;          boxzoom[0] = glamt[slider, 0] &  boxzoom[1] = glamf[slider+thickness, 0]
152;       ENDIF ELSE BEGIN
153;          boxzoom[2] = gphit[0, slider] &  boxzoom[3] = gphif[0, slider+thickness]
154;       ENDELSE
155;    ENDELSE
156   widget_control, domainid, set_value = boxzoom
157   return, {CW_SLIDE_SLICE, ID:event.handler, TOP:event.top, HANDLER:0L}
158end
159;
160;+
161;
162; @file_comments
163;
164;
165; @categories
166; Compound widget
167;
168; @param PARENT {in}{required}
169; The widget ID of the parent widget.
170;
171; @keyword BOXZOOM
172; Vector indicating the geographic zone on which we want to cut the map.
173; If BOXZOOM has :
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]]
178;   6 elements: The extraction is made on Boxzoom
179; Where lon1, lon2,lat1,lat2 are global variables defined at the last
180; <pro>domdef</pro> !
181;
182; @keyword COLUMN
183; Buttons will be arranged in the number of columns
184; specified by this keyword.
185;
186; @keyword FRAME
187; Specifies the width of the frame to be drawn around the base.
188;
189; @keyword ROW
190; Buttons will be arranged in the number of rows
191; specified by this keyword.
192;
193; @keyword UVALUE
194; The user value to be associated with the widget.
195;
196; @keyword UNAME
197; The user name to be associated with the widget.
198;
199; @keyword _EXTRA
200; Used to pass keywords
201;
202; @returns
203;
204; @uses
205;
206; @restrictions
207;
208; @examples
209;
210; @history
211;
212; @version
213; $Id$
214;
215; @todo
216; seb: documenter
217;
218;-
219FUNCTION cw_slide_slice, parent, BOXZOOM=boxzoom, UVALUE=uvalue, UNAME=uname $
220                       , FRAME=frame, ROW=row, COLUMN=column, _EXTRA=ex
221;
222  compile_opt idl2, strictarrsubs
223;
224@common
225;------------------------------------------------
226; checking exclusive keywords
227   column = keyword_set(column)*(1-keyword_set(row))
228   row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)
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 $
237                      , FRAME = frame, _extra = ex)
238;------------------------------------------------
239   if NOT keyword_set(boxzoom) then boxzoom = [lon1, lon2, lat1, lat2]
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;
246   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
247   if type EQ 'y' then BEGIN
248      mini = floor(min([glamt, glamf], max = maxi))
249      thickness = boxzoom[1]-boxzoom[0]
250      maxi = ceil(maxi)-thickness
251      rien = cw_slider_pm(base, minimum = mini, maximum = (mini+1) > maxi $
252                          , value = mini > boxzoom[0] < maxi, /column, uname = 'slider' $
253                          , uvalue = {name:'slider'})
254   ENDIF ELSE BEGIN
255      mini = floor(min([gphit, gphif], max = maxi))
256      thickness = boxzoom[3]-boxzoom[2]
257      maxi = ceil(maxi)-thickness
258      rien = cw_slider_pm(base, minimum = mini, maximum =  (mini+1) > maxi $
259                          , value = mini > boxzoom[2] < maxi, /column, uname = 'slider' $
260                          , uvalue = {name:'slider'})
261   ENDELSE
262   index = where(thicknessval EQ thickness) & index = index[0]
263   if index EQ -1 then BEGIN
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}
270
271;   if type EQ 'xt' then begin
272;       mini = floor(min([glamt,glamf], max = maxi))
273;       maxi = ceil(maxi)
274;    ENDIF ELSE BEGIN
275;       mini = floor(min([gphit,gphif], max = maxi))
276;       maxi = ceil(maxi)
277;    ENDELSE
278
279;------------------------------------------------
280   return, base
281end
Note: See TracBrowser for help on using the repository browser.