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

Last change on this file since 157 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

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