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

Last change on this file since 495 was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

  • 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;    if uval.name EQ 'unite' then begin
120;       domdef, boxzoom, gridtype = 'T'
121;       if unite EQ 'degre' then BEGIN
122;          if strpos(type,'y') NE -1 then begin
123;             mini = floor(min([glamt, glamf], max = maxi))
124;             maxi = ceil(maxi)
125; print, lon1, mini, maxi
126;             widget_control, sliderid, set_value = {value:lon1, slider_min_max:[mini, maxi]}
127;          ENDIF ELSE BEGIN
128;             mini = floor(min([gphit, glamf], max = maxi))
129;             maxi = ceil(maxi)
130;             widget_control, sliderid, set_value = {value:lat1, slider_min_max:[mini, maxi]}
131;          ENDELSE
132;       ENDIF ELSE BEGIN
133;          if strpos(type,'y') NE -1 then BEGIN
134; print, 'ds if',firstxt, 0, jpi-1
135;             widget_control, sliderid, set_value = {value:firstxt, slider_min_max:[0, jpi-1]}
136;          ENDIF ELSE BEGIN
137;             widget_control, sliderid, set_value = {value:firstyt, slider_min_max:[0, jpj-1]}
138;          ENDELSE
139;       ENDELSE
140;    endif
141;
142;   if unite EQ 'degre' then BEGIN
143   if type EQ 'y' then begin
144      boxzoom[0] = slider &  boxzoom[1] = slider+thickness
145   ENDIF ELSE BEGIN
146      boxzoom[2] = slider &  boxzoom[3] = slider+thickness
147   ENDELSE
148;    ENDIF ELSE BEGIN
149;       if strpos(type,'y') NE -1 then begin
150;          boxzoom[0] = glamt[slider, 0] &  boxzoom[1] = glamf[slider+thickness, 0]
151;       ENDIF ELSE BEGIN
152;          boxzoom[2] = gphit[0, slider] &  boxzoom[3] = gphif[0, slider+thickness]
153;       ENDELSE
154;    ENDELSE
155   widget_control, domainid, set_value = boxzoom
156   return, {CW_SLIDE_SLICE, ID:event.handler, TOP:event.top, HANDLER:0L}
157end
158;
159;+
160;
161; @file_comments
162;
163; @categories
164; Compound widget
165;
166; @param PARENT {in}{required}
167; The widget ID of the parent widget.
168;
169; @keyword BOXZOOM
170; Vector indicating the geographic zone on which we want to cut the map.
171; If BOXZOOM has :
172;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
173;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
174;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
175;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
176;   6 elements: The extraction is made on Boxzoom
177; Where lon1, lon2,lat1,lat2 are global variables defined at the last
178; <pro>domdef</pro> !
179;
180; @keyword COLUMN
181; Buttons will be arranged in the number of columns
182; specified by this keyword.
183;
184; @keyword FRAME
185; Specifies the width of the frame to be drawn around the base.
186;
187; @keyword ROW
188; Buttons will be arranged in the number of rows
189; specified by this keyword.
190;
191; @keyword UVALUE
192; The user value to be associated with the widget.
193;
194; @keyword UNAME
195; The user name to be associated with the widget.
196;
197; @keyword _EXTRA
198; Used to pass keywords
199;
200; @returns
201;
202; @uses
203;
204; @restrictions
205;
206; @examples
207;
208; @history
209;
210; @version
211; $Id$
212;
213; @todo
214; seb: documenter
215;
216;-
217FUNCTION cw_slide_slice, parent, BOXZOOM=boxzoom, UVALUE=uvalue, UNAME=uname $
218                       , FRAME=frame, ROW=row, COLUMN=column, _EXTRA=ex
219;
220  compile_opt idl2, strictarrsubs
221;
222@common
223;------------------------------------------------
224; checking exclusive keywords
225   column = keyword_set(column)*(1-keyword_set(row))
226   row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)
227   if NOT keyword_set(uvalue) then uvalue = ''
228   if NOT keyword_set(uname) then uname = ''
229;
230   base = widget_base(parent, ROW = row, COLUMN = column  $
231                      , EVENT_FUNC = 'cw_slide_slice_event' $
232                      , FUNC_GET_VALUE='cw_slide_slice_get_value' $
233                      , PRO_SET_VALUE='cw_slide_slice_set_value' $
234                      , ROW = row, COLUMN = column, UVALUE = uvalue, UNAME = uname $
235                      , FRAME = frame, _extra = ex)
236;------------------------------------------------
237   if NOT keyword_set(boxzoom) then boxzoom = [lon1, lon2, lat1, lat2]
238;    rien = cw_bgroup(base, ['degre', 'points'],/exclusive, /column, uname = 'unite', uvalue = {name:'unite'}, /return_name, set_value = 0, /no_release)
239   thicknessval = indgen(21)+1
240   thicknessval = string(thicknessval)
241   for i = 0, n_elements(thicknessval)-1 do thicknessval[i] = strtrim(thicknessval[i], 1)
242   droplistid = cw_droplist_pm(base, value = thicknessval, uname = 'thickness', uvalue = {name:'thickness', choix:thicknessval})
243;
244   if boxzoom[1]-boxzoom[0] LT boxzoom[3]-boxzoom[2] then type = 'y' ELSE type = 'x'
245   if type EQ 'y' then BEGIN
246      mini = floor(min([glamt, glamf], max = maxi))
247      thickness = boxzoom[1]-boxzoom[0]
248      maxi = ceil(maxi)-thickness
249      rien = cw_slider_pm(base, minimum = mini, maximum = (mini+1) > maxi $
250                          , value = mini > boxzoom[0] < maxi, /column, uname = 'slider' $
251                          , uvalue = {name:'slider'})
252   ENDIF ELSE BEGIN
253      mini = floor(min([gphit, gphif], max = maxi))
254      thickness = boxzoom[3]-boxzoom[2]
255      maxi = ceil(maxi)-thickness
256      rien = cw_slider_pm(base, minimum = mini, maximum =  (mini+1) > maxi $
257                          , value = mini > boxzoom[2] < maxi, /column, uname = 'slider' $
258                          , uvalue = {name:'slider'})
259   ENDELSE
260   index = where(thicknessval EQ thickness) & index = index[0]
261   if index EQ -1 then BEGIN
262      index = 20
263      thicknessval[20] = strtrim(thickness, 1)
264      widget_control, droplistid, set_value = thicknessval
265      widget_control, droplistid, set_uvalue ={name:'thickness', choix:thicknessval}
266   endif
267   widget_control, droplistid, set_value = {droplist_select:index}
268
269;   if type EQ 'xt' then begin
270;       mini = floor(min([glamt,glamf], max = maxi))
271;       maxi = ceil(maxi)
272;    ENDIF ELSE BEGIN
273;       mini = floor(min([gphit,gphif], max = maxi))
274;       maxi = ceil(maxi)
275;    ENDELSE
276
277;------------------------------------------------
278   return, base
279end
Note: See TracBrowser for help on using the repository browser.