[2] | 1 | ; IDL> testwid |
---|
| 2 | ; PRO testwid_event, event |
---|
| 3 | ; ; help, event, /struct |
---|
| 4 | ; Id = widget_info(event.top,find_by_uname = 'c''est lui') |
---|
| 5 | ; widget_control, event.id, get_uvalue=uval |
---|
| 6 | ; if n_elements(uval) EQ 0 then return |
---|
| 7 | ; case uval of |
---|
| 8 | ; 'done':widget_control, event.top, /destroy |
---|
| 9 | ; 'set':BEGIN |
---|
| 10 | ; widget_control, event.id, get_value = value & value = value[0] |
---|
[51] | 11 | ; nothing = execute('boxzoom ='+value) |
---|
| 12 | ; widget_control, Id, set_value = boxzoom |
---|
[2] | 13 | ; END |
---|
| 14 | ; 'get':BEGIN |
---|
| 15 | ; widget_control, Id, get_value = value |
---|
| 16 | ; print, value |
---|
| 17 | ; END |
---|
| 18 | ; ELSE: |
---|
| 19 | ; endcase |
---|
| 20 | ; return |
---|
| 21 | ; end |
---|
| 22 | ; PRO testwid, _extra = ex |
---|
| 23 | ; base=widget_base(/COLUMN) |
---|
| 24 | ; print, 'base=', base |
---|
| 25 | ; nothing = widget_label(base, value = 'beginning of the test') |
---|
| 26 | ; ; |
---|
| 27 | ; nothing = cw_domain(base,_extra = ex, uname = 'c''est lui', uvalue = 'c''est lui') |
---|
| 28 | ; print, 'cw_domain ID =', nothing |
---|
| 29 | ; ; |
---|
| 30 | ; nothing = widget_label(base, value = 'end of the test') |
---|
| 31 | ; nothing = widget_text(base, value = '[40, 100, -10, 10]', uvalue = 'set', /editable) |
---|
| 32 | ; nothing = widget_button(base, value = 'get', uvalue = 'get') |
---|
| 33 | ; nothing = widget_button(base, value = 'done', uvalue = 'done') |
---|
| 34 | ; widget_control, base, /REALIZE |
---|
| 35 | ; xmanager,'testwid', base |
---|
| 36 | ; return |
---|
| 37 | ; end |
---|
| 38 | ; |
---|
| 39 | ; |
---|
| 40 | ;********************************************************************* |
---|
[157] | 41 | ;+ |
---|
| 42 | ; @file_comments |
---|
| 43 | ; |
---|
| 44 | ; |
---|
| 45 | ; @categories |
---|
| 46 | ; Compound widget |
---|
| 47 | ; |
---|
| 48 | ; @param ID |
---|
| 49 | ; |
---|
| 50 | ; |
---|
| 51 | ; @param VALUE |
---|
| 52 | ; It is the default tick mark value (a floating-point number). |
---|
| 53 | ; |
---|
| 54 | ; @returns |
---|
| 55 | ; |
---|
| 56 | ; |
---|
| 57 | ; @uses |
---|
| 58 | ; |
---|
| 59 | ; |
---|
| 60 | ; @restrictions |
---|
| 61 | ; |
---|
| 62 | ; |
---|
| 63 | ; @examples |
---|
| 64 | ; |
---|
| 65 | ; |
---|
| 66 | ; @history |
---|
| 67 | ; |
---|
| 68 | ; |
---|
| 69 | ; @version |
---|
| 70 | ; $Id$ |
---|
| 71 | ;- |
---|
[2] | 72 | pro cw_domain_set_value, id, value |
---|
[114] | 73 | ; |
---|
| 74 | compile_opt idl2, strictarrsubs |
---|
| 75 | ; |
---|
[69] | 76 | @cm_4mesh |
---|
| 77 | ; |
---|
| 78 | topid = findtopid(id) |
---|
| 79 | widget_control, topid, get_uvalue = top_uvalue |
---|
[2] | 80 | ;------------------------------------------------ |
---|
[69] | 81 | ; make sure that we have the good grid stored in the cm_4mesh common parameters. |
---|
| 82 | currentfile = extractatt(top_uvalue, 'currentfile') |
---|
| 83 | currentgrid = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] |
---|
| 84 | change = changegrid(currentgrid) |
---|
| 85 | ;------------------------------------------------ |
---|
[150] | 86 | ; What is the type of boxzoom ? |
---|
[51] | 87 | currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 |
---|
[2] | 88 | options = extractatt(top_uvalue, 'options') |
---|
| 89 | flags = extractatt(top_uvalue, 'optionsflag') |
---|
| 90 | flags = flags[*, currentplot] |
---|
| 91 | IF (flags[where(options EQ 'Longitude / x index')])[0] EQ 0 THEN $ |
---|
| 92 | xtype = 'geographic' ELSE xtype = 'index' |
---|
| 93 | IF (flags[where(options EQ 'Latitude / y index')])[0] EQ 0 THEN $ |
---|
| 94 | ytype = 'geographic' ELSE ytype = 'index' |
---|
| 95 | ;------------------------------------------------ |
---|
[150] | 96 | ; How to complete the boxzoom ? |
---|
[2] | 97 | IF xtype EQ 'geographic' then begin |
---|
| 98 | lonn1 = lon1 |
---|
| 99 | lonn2 = lon2 |
---|
| 100 | xtitle = 'lon' |
---|
| 101 | ENDIF ELSE BEGIN |
---|
[51] | 102 | lonn1 = firstxt |
---|
| 103 | lonn2 = lastxt |
---|
[69] | 104 | xtitle = 'x ind' |
---|
[2] | 105 | ENDELSE |
---|
| 106 | IF ytype EQ 'geographic' then begin |
---|
| 107 | latt1 = lat1 |
---|
| 108 | latt2 = lat2 |
---|
| 109 | ytitle = 'lat' |
---|
| 110 | ENDIF ELSE BEGIN |
---|
[51] | 111 | latt1 = firstyt |
---|
| 112 | latt2 = lastyt |
---|
[69] | 113 | ytitle = 'y ind' |
---|
[2] | 114 | ENDELSE |
---|
| 115 | ;------------------------------------------------ |
---|
[51] | 116 | vertf1 = floor(min([gdepw[0], gdept[0]])) |
---|
| 117 | vertf2 = ceil(max([gdepw[0], gdept[0]])) |
---|
[2] | 118 | ;------------------------------------------------ |
---|
| 119 | Case N_Elements(Value) OF |
---|
[51] | 120 | 0:boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2] |
---|
[2] | 121 | 1:BEGIN |
---|
[51] | 122 | if value EQ -1 then boxzoom = [lonn1, lonn2, latt1, latt2, vertf1, vertf2] $ |
---|
| 123 | ELSE boxzoom=[lonn1, lonn2, latt1, latt2, 0.,value[0]] |
---|
[2] | 124 | END |
---|
[51] | 125 | 2:boxzoom=[lonn1, lonn2, latt1, latt2, value[0],value[1]] |
---|
| 126 | 4:boxzoom=[Value] |
---|
| 127 | 5:boxzoom=[Value[0:3], 0, Value[4]] |
---|
| 128 | 6:boxzoom = Value |
---|
[2] | 129 | Else:BEGIN |
---|
[69] | 130 | rien = report('Wrong Definition of Boxzoom') |
---|
[2] | 131 | END |
---|
| 132 | ENDCASE |
---|
| 133 | ;------------------------------------------------ |
---|
[51] | 134 | boxzoom[0] = floor(boxzoom[0]) |
---|
| 135 | boxzoom[1] = ceil(boxzoom[1]) |
---|
| 136 | boxzoom[2] = floor(boxzoom[2]) |
---|
| 137 | boxzoom[3] = ceil(boxzoom[3]) |
---|
| 138 | if n_elements(boxzoom GE 5) then begin |
---|
| 139 | boxzoom[4] = floor(boxzoom[4]) |
---|
| 140 | boxzoom[5] = ceil(boxzoom[5]) |
---|
[2] | 141 | endif |
---|
| 142 | ;------------------------------------------------ |
---|
| 143 | ;------------------------------------------------ |
---|
| 144 | widget_control,widget_info(id,find_by_uname = 'lon1'), get_uvalue = uvalue |
---|
| 145 | strict = uvalue.strict |
---|
| 146 | ; |
---|
[150] | 147 | ; Longitudes |
---|
[2] | 148 | ; |
---|
[150] | 149 | ; Possible min and max |
---|
[51] | 150 | if xtype EQ 'geographic' then BEGIN |
---|
| 151 | min = floor(min([glamt,glamf], max = max)) |
---|
[2] | 152 | max = ceil(max) |
---|
| 153 | ENDIF ELSE BEGIN |
---|
| 154 | min = 0 |
---|
| 155 | max = jpi-1 |
---|
| 156 | ENDELSE |
---|
[150] | 157 | ; widgets's id |
---|
[2] | 158 | lon1id = widget_info(id,find_by_uname = 'lon1') |
---|
| 159 | lon2id = widget_info(id,find_by_uname = 'lon2') |
---|
[150] | 160 | ; Do we have to change the type of x axis: longitude/index |
---|
[2] | 161 | lonbase = widget_info(id,find_by_uname = 'lonbase') |
---|
| 162 | widget_control, lonbase, get_uvalue = lonbase_uvalue |
---|
| 163 | if lonbase_uvalue.name NE xtype then BEGIN |
---|
| 164 | widget_control, lonbase, update = 0 |
---|
[150] | 165 | ; We break everything |
---|
[2] | 166 | widget_control, lon1id, /destroy |
---|
| 167 | widget_control, lon2id, /destroy |
---|
[150] | 168 | ; We reconstruct |
---|
[51] | 169 | lon1id = cw_slider_pm(lonbase,value=min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ |
---|
[2] | 170 | , uvalue={name:'lon1', strict:keyword_set(strict)},uname ='lon1' $ |
---|
| 171 | , title = xtitle+'1', minimum = min $ |
---|
[51] | 172 | , maximum = (boxzoom[1] < max)-keyword_set(strict)) |
---|
| 173 | lon2id = cw_slider_pm(lonbase,value=((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ |
---|
[2] | 174 | , uvalue={name:'lon2', strict:keyword_set(strict)} $ |
---|
| 175 | , uname='lon2', title = xtitle+'2', maximum = max $ |
---|
[51] | 176 | , minimum = (min > boxzoom[0])+keyword_set(strict)) |
---|
[2] | 177 | widget_control, lonbase, set_uvalue = {name:xtype} |
---|
| 178 | widget_control, lonbase, update = 1 |
---|
| 179 | ENDIF ELSE BEGIN |
---|
[150] | 180 | ; The new value they will have |
---|
[51] | 181 | cursorvalue1 = min > boxzoom[0] < ((boxzoom[1] < max)-strict) |
---|
| 182 | cursorvalue2 = ((min > boxzoom[0])+strict) > boxzoom[1] < max |
---|
[150] | 183 | ; We change slider's boundaries |
---|
[2] | 184 | widget_control, lon1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict} |
---|
| 185 | widget_control, lon2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max} |
---|
[150] | 186 | ; We attribute the new value |
---|
[2] | 187 | widget_control, lon1id , set_value = cursorvalue1 |
---|
| 188 | widget_control, lon2id, set_value = cursorvalue2 |
---|
| 189 | ENDELSE |
---|
| 190 | ; |
---|
[150] | 191 | ; Latitudes |
---|
[2] | 192 | ; |
---|
[150] | 193 | ; Possible min and max |
---|
[2] | 194 | if ytype EQ 'geographic' then begin |
---|
[51] | 195 | min = floor(min([gphit,gphif], max = max)) |
---|
[2] | 196 | max = ceil(max) |
---|
| 197 | ENDIF ELSE BEGIN |
---|
| 198 | min = 0 |
---|
| 199 | max = jpj-1 |
---|
| 200 | ENDELSE |
---|
[150] | 201 | ; Do we have to change the type of y axis: latitude/index |
---|
[2] | 202 | latbase = widget_info(id,find_by_uname = 'latbase') |
---|
| 203 | widget_control, latbase, get_uvalue = latbase_uvalue |
---|
| 204 | lat1id = widget_info(id,find_by_uname = 'lat1') |
---|
| 205 | lat2id = widget_info(id,find_by_uname = 'lat2') |
---|
| 206 | if latbase_uvalue.name NE ytype then BEGIN |
---|
| 207 | widget_control, latbase, update = 0 |
---|
| 208 | widget_control, lat1id, /destroy |
---|
| 209 | widget_control, lat2id, /destroy |
---|
[51] | 210 | lat1id = cw_slider_pm(latbase,value=min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ |
---|
[2] | 211 | , uvalue={name:'lat1', strict:keyword_set(strict)},uname ='lat1' $ |
---|
| 212 | , title = ytitle+'1', minimum =min $ |
---|
[51] | 213 | , maximum = ((boxzoom[3] < max)-keyword_set(strict))) |
---|
| 214 | lat2id = cw_slider_pm(latbase,value=((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ |
---|
[2] | 215 | , uvalue={name:'lat2', strict:keyword_set(strict)} $ |
---|
| 216 | , uname ='lat2', title = ytitle+'2' ,maximum = max $ |
---|
[51] | 217 | , minimum =(min > boxzoom[2])+keyword_set(strict)) |
---|
[2] | 218 | widget_control, latbase, set_uvalue = {name:ytype} |
---|
| 219 | widget_control, latbase, update = 1 |
---|
| 220 | ENDIF ELSE BEGIN |
---|
[51] | 221 | cursorvalue1 = min > boxzoom[2] < ((boxzoom[3] < max)-strict) |
---|
| 222 | cursorvalue2 = ((min > boxzoom[2])+strict) > boxzoom[3] < max |
---|
[2] | 223 | widget_control, lat1id, set_value = {slider_min:min, slider_max:cursorvalue2-strict} |
---|
| 224 | widget_control, lat2id, set_value = {slider_min:cursorvalue1+strict, slider_max:max} |
---|
| 225 | widget_control, lat1id, set_value = cursorvalue1 |
---|
| 226 | widget_control, lat2id, set_value = cursorvalue2 |
---|
| 227 | ENDELSE |
---|
| 228 | ; |
---|
[51] | 229 | if n_elements(boxzoom) EQ 4 then return |
---|
[2] | 230 | ; |
---|
[69] | 231 | ; depth |
---|
[2] | 232 | ; |
---|
[69] | 233 | dthlv1id = widget_info(id, find_by_uname = 'dthlv1') |
---|
| 234 | dthlv2id = widget_info(id, find_by_uname = 'dthlv2') |
---|
| 235 | depth1id = widget_info(id, find_by_uname = 'depth1') |
---|
| 236 | depth2id = widget_info(id, find_by_uname = 'depth2') |
---|
| 237 | ; which type of point? |
---|
| 238 | widget_control, dthlv1id, get_uvalue = dthlv1_uval |
---|
| 239 | ; get the new axis |
---|
| 240 | if dthlv1_uval.grid_t EQ 1 then gdep = gdept ELSE gdep = gdepw |
---|
| 241 | ; Did we change the vertical axis? |
---|
| 242 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
| 243 | gdep1 = floor(fix(dthlv1_value.combobox_value)) |
---|
| 244 | IF array_equal(gdep1, floor(gdep)) NE 1 THEN BEGIN |
---|
[2] | 245 | gdep1 = floor(gdep) |
---|
| 246 | gdep2 = ceil(gdep) |
---|
[172] | 247 | ;; same = where(gdep2-gdep1 EQ 0) |
---|
| 248 | ;; if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 |
---|
[69] | 249 | widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} |
---|
| 250 | widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} |
---|
| 251 | ENDIF ELSE gdep2 = gdep1+1 |
---|
[150] | 252 | ; We make sure that given depthes contain at least one level. |
---|
[51] | 253 | if boxzoom[4] GT boxzoom[5] then begin |
---|
| 254 | rien = boxzoom[4] |
---|
| 255 | boxzoom[4] = boxzoom[5] |
---|
| 256 | boxzoom[5] = rien |
---|
[2] | 257 | endif |
---|
| 258 | ; |
---|
[51] | 259 | rien = where(gdep1 LT boxzoom[4], indice1) |
---|
[2] | 260 | indice1 = indice1 < (jpk-1) |
---|
[51] | 261 | rien = where(gdep2 LE boxzoom[5], indice2) |
---|
[2] | 262 | indice2 = indice1 > (indice2-1) |
---|
| 263 | ; |
---|
| 264 | if indice1 EQ indice2 then BEGIN |
---|
[51] | 265 | if (where(gdep1 GE boxzoom[4] AND gdep2 LE boxzoom[5]))[0] EQ -1 then begin |
---|
[69] | 266 | indice1 = 0 > (indice1-(dthlv1_uval.grid_t EQ 1)) |
---|
[2] | 267 | indice2 = indice1 |
---|
| 268 | endif |
---|
[51] | 269 | boxzoom[4] = gdep1[indice1] |
---|
| 270 | boxzoom[5] = boxzoom[4]+1 |
---|
[2] | 271 | endif |
---|
[150] | 272 | ; Now, values and indexes are proprely defined. |
---|
| 273 | ; So we can apply them |
---|
[69] | 274 | widget_control, dthlv1id, set_value = {combobox_select:indice1} |
---|
| 275 | widget_control, dthlv2id, set_value = {combobox_select:indice2} |
---|
[150] | 276 | ; control mins and maxs of sliders... |
---|
[2] | 277 | if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] |
---|
| 278 | max1 = (min1+1) > gdep1[indice2] |
---|
[51] | 279 | widget_control, depth1id, set_value = {slider_min:min1, slider_max:max1, value:boxzoom[4]} |
---|
[2] | 280 | min2 = gdep2[indice1] |
---|
| 281 | if indice2 EQ jpk-1 then BEGIN |
---|
| 282 | max2 = max([gdept, gdepw]) |
---|
| 283 | max2 = strtrim(string(max2,format='(e8.0)'), 1) |
---|
| 284 | max2 = float('1'+strmid(max2, 1))+float(max2) |
---|
| 285 | ENDIF ELSE max2 = gdep1[indice2+1] |
---|
[51] | 286 | widget_control, depth2id, set_value = {slider_min:min2, slider_max:max2, value:boxzoom[5]} |
---|
[2] | 287 | ; |
---|
| 288 | return |
---|
| 289 | end |
---|
| 290 | ;********************************************************************* |
---|
[157] | 291 | ;+ |
---|
| 292 | ; @file_comments |
---|
| 293 | ; |
---|
| 294 | ; |
---|
| 295 | ; @categories |
---|
| 296 | ; Compound widget |
---|
| 297 | ; |
---|
| 298 | ; @param ID |
---|
| 299 | ; |
---|
| 300 | ; |
---|
| 301 | ; @returns |
---|
| 302 | ; |
---|
| 303 | ; |
---|
| 304 | ; @uses |
---|
| 305 | ; |
---|
| 306 | ; |
---|
| 307 | ; @restrictions |
---|
| 308 | ; |
---|
| 309 | ; |
---|
| 310 | ; @examples |
---|
| 311 | ; |
---|
| 312 | ; |
---|
| 313 | ; @history |
---|
| 314 | ; |
---|
| 315 | ; |
---|
| 316 | ; @version |
---|
| 317 | ; $Id$ |
---|
| 318 | ;- |
---|
[2] | 319 | FUNCTION cw_domain_get_value, id |
---|
[114] | 320 | ; |
---|
| 321 | compile_opt idl2, strictarrsubs |
---|
| 322 | ; |
---|
[172] | 323 | box = fltarr(6) |
---|
[69] | 324 | possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] |
---|
[2] | 325 | for i = 0, 5 do begin |
---|
[69] | 326 | widget_control, widget_info(id, find_by_uname = possiblecase[i]) $ |
---|
[2] | 327 | , get_value = value |
---|
| 328 | box[i] = value.value |
---|
[172] | 329 | ENDFOR |
---|
[2] | 330 | return, box |
---|
| 331 | end |
---|
| 332 | ;********************************************************************* |
---|
[157] | 333 | ;+ |
---|
| 334 | ; @file_comments |
---|
| 335 | ; |
---|
| 336 | ; |
---|
| 337 | ; @categories |
---|
| 338 | ; Compound widget |
---|
| 339 | ; |
---|
| 340 | ; @param EVENT |
---|
| 341 | ; |
---|
| 342 | ; |
---|
| 343 | ; @returns |
---|
| 344 | ; |
---|
| 345 | ; |
---|
| 346 | ; @uses |
---|
| 347 | ; |
---|
| 348 | ; |
---|
| 349 | ; @restrictions |
---|
| 350 | ; |
---|
| 351 | ; |
---|
| 352 | ; @examples |
---|
| 353 | ; |
---|
| 354 | ; |
---|
| 355 | ; @history |
---|
| 356 | ; |
---|
| 357 | ; |
---|
| 358 | ; @version |
---|
| 359 | ; $Id$ |
---|
| 360 | ;- |
---|
[2] | 361 | FUNCTION cw_domain_event, event |
---|
[114] | 362 | ; |
---|
| 363 | compile_opt idl2, strictarrsubs |
---|
| 364 | ; |
---|
[2] | 365 | @common |
---|
| 366 | ; help, /struct, event |
---|
| 367 | if (where(tag_names(event) EQ 'OUT'))[0] NE -1 then if event.out NE 0 then return, -1 |
---|
[69] | 368 | widget_control, event.id, get_uvalue = uval |
---|
[2] | 369 | case uval.name of |
---|
| 370 | 'lon1':widget_control,widget_info(event.handler,find_by_uname = 'lon2') $ |
---|
| 371 | , set_value = {slider_min:event.value+uval.strict} |
---|
| 372 | 'lon2':widget_control,widget_info(event.handler,find_by_uname = 'lon1') $ |
---|
| 373 | , set_value = {slider_max:event.value-uval.strict} |
---|
| 374 | 'lat1':widget_control,widget_info(event.handler,find_by_uname = 'lat2') $ |
---|
| 375 | , set_value = {slider_min:event.value+uval.strict} |
---|
| 376 | 'lat2':widget_control,widget_info(event.handler,find_by_uname = 'lat1') $ |
---|
| 377 | , set_value = {slider_max:event.value-uval.strict} |
---|
| 378 | 'unzoom':BEGIN |
---|
| 379 | id = widget_info(event.handler,find_by_uname = 'lon1') |
---|
| 380 | widget_control, id, get_value = value |
---|
| 381 | widget_control, id, set_value = {slider_min:value.slider_min_max[0]} |
---|
| 382 | widget_control, id, set_value = value.slider_min_max[0] |
---|
| 383 | id = widget_info(event.handler,find_by_uname = 'lat1') |
---|
| 384 | widget_control, id, get_value = value |
---|
| 385 | widget_control, id, set_value = {slider_min:value.slider_min_max[0]} |
---|
| 386 | widget_control, id, set_value = value.slider_min_max[0] |
---|
| 387 | id = widget_info(event.handler,find_by_uname = 'lon2') |
---|
| 388 | widget_control, id, get_value = value |
---|
| 389 | widget_control, id, set_value = {slider_max:value.slider_min_max[1]} |
---|
| 390 | widget_control, id, set_value = value.slider_min_max[1] |
---|
| 391 | id = widget_info(event.handler,find_by_uname = 'lat2') |
---|
| 392 | widget_control, id, get_value = value |
---|
| 393 | widget_control, id, set_value = {slider_max:value.slider_min_max[1]} |
---|
| 394 | widget_control, id, set_value = value.slider_min_max[1] |
---|
| 395 | END |
---|
[69] | 396 | 'dthlv1':BEGIN |
---|
[2] | 397 | ; ids... |
---|
| 398 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
| 399 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
[69] | 400 | dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') |
---|
[150] | 401 | ; Do we have to change dthlv2 ? |
---|
[69] | 402 | widget_control, event.id, get_value = dthlv1_value |
---|
| 403 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
| 404 | widget_control, dthlv2id, get_value = dthlv2_value |
---|
| 405 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
| 406 | if dthlv2_value.combobox_index LT event.index then BEGIN |
---|
[150] | 407 | ; We redefine the dthlv2id's value |
---|
[69] | 408 | widget_control, dthlv2id, set_value = {combobox_select:event.index} |
---|
[150] | 409 | ; So we redefine the value and the max of the slider 2 |
---|
[2] | 410 | if event.index EQ jpk-1 then BEGIN |
---|
| 411 | max = max([gdept, gdepw]) |
---|
| 412 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
| 413 | max = float('1'+strmid(max, 1))+float(max) |
---|
[69] | 414 | ENDIF ELSE max = gdep2[event.index+1]-1 |
---|
[2] | 415 | widget_control, depth2id $ |
---|
[69] | 416 | , set_value = {slider_max:max, value:gdep2[event.index]} |
---|
[150] | 417 | ; So we redefine the max of the slider 1 |
---|
[69] | 418 | widget_control, depth1id, set_value = {slider_max:gdep1[event.index]} |
---|
[2] | 419 | END |
---|
[150] | 420 | ; We redefine the value and the min of the slider depth1 |
---|
[69] | 421 | if event.index EQ 0 then min = 0 ELSE min = gdep1[event.index-1]+1 |
---|
| 422 | widget_control, depth1id, set_value = {slider_min:min, value:gdep1[event.index]} |
---|
[150] | 423 | ; S we change the value of the min of the slider depth 2 |
---|
[69] | 424 | widget_control, depth2id, set_value = {slider_min:gdep1[event.index]+1} |
---|
[2] | 425 | END |
---|
[69] | 426 | 'dthlv2':BEGIN |
---|
[2] | 427 | ; ids... |
---|
| 428 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
| 429 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
[69] | 430 | dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') |
---|
[150] | 431 | ; Do we have to change dthlv1 ? |
---|
[69] | 432 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
| 433 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
| 434 | widget_control, event.id, get_value = dthlv2_value |
---|
| 435 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
| 436 | if dthlv1_value.combobox_index GT event.index then BEGIN |
---|
[150] | 437 | ; We redfine the value of dthlv1id |
---|
[69] | 438 | widget_control, dthlv1id, set_value = {combobox_select:event.index} |
---|
[150] | 439 | ; So we redefine the value and the min of the slider 1 |
---|
[69] | 440 | if event.index EQ 0 then min = 0 ELSE min = gdep2[event.index-1] |
---|
[2] | 441 | widget_control, depth1id $ |
---|
[69] | 442 | , set_value = {slider_min:min, value:gdep1[event.index]} |
---|
[150] | 443 | ; Se we redefine the min of the slider 2 |
---|
[69] | 444 | widget_control, depth2id, set_value = {slider_min:gdep2[event.index]} |
---|
[2] | 445 | END |
---|
[150] | 446 | ; We redefine the value and the max of the slider depth 2 |
---|
[2] | 447 | if event.index EQ jpk-1 then BEGIN |
---|
| 448 | max = max([gdept, gdepw]) |
---|
| 449 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
| 450 | max = float('1'+strmid(max, 1))+float(max) |
---|
[69] | 451 | ENDIF ELSE max = gdep2[event.index+1]-1 |
---|
| 452 | widget_control, depth2id, set_value = {slider_max:max, value:gdep2[event.index]} |
---|
[150] | 453 | ; So we change the value of the max of the slider depth 1 |
---|
[69] | 454 | widget_control, depth1id, set_value = {slider_max:gdep2[event.index]-1} |
---|
[2] | 455 | END |
---|
| 456 | 'depth1':BEGIN |
---|
| 457 | ; ids... |
---|
| 458 | depth2id = widget_info(event.handler,find_by_uname = 'depth2') |
---|
[69] | 459 | dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') |
---|
[150] | 460 | ; Do we have to change dthlv1 ? |
---|
[69] | 461 | widget_control, dthlv1id, get_value = dthlv1_value |
---|
| 462 | gdep1 = fix(dthlv1_value.combobox_value) |
---|
| 463 | rien = where(gdep1 LT event.value, indice) |
---|
[2] | 464 | indice = indice < (jpk-1) |
---|
[69] | 465 | if indice NE dthlv1_value.combobox_index then begin |
---|
[150] | 466 | ; We change the min of depth2 |
---|
[69] | 467 | widget_control, depth2id, set_value = {slider_min:gdep1[indice]+1} |
---|
[150] | 468 | ; We redefine the value of dthlv1id |
---|
[69] | 469 | widget_control, dthlv1id, set_value = {combobox_select:indice} |
---|
[150] | 470 | ; So we redefine the min of the slider 1 |
---|
[69] | 471 | if indice EQ 0 then min = 0 ELSE min = gdep1[indice-1]+1 |
---|
[2] | 472 | widget_control, event.id, set_value = {slider_min:min} |
---|
| 473 | endif |
---|
| 474 | END |
---|
| 475 | 'depth2':BEGIN |
---|
| 476 | ; ids... |
---|
| 477 | depth1id = widget_info(event.handler,find_by_uname = 'depth1') |
---|
[69] | 478 | dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') |
---|
[150] | 479 | ; Do we have to change dthlv2 ? |
---|
[69] | 480 | widget_control, dthlv2id, get_value = dthlv2_value |
---|
| 481 | gdep2 = fix(dthlv2_value.combobox_value) |
---|
| 482 | rien = where(gdep2 LE event.value, indice) |
---|
[2] | 483 | indice = 0 > (indice-1) |
---|
[69] | 484 | if indice NE dthlv2_value.combobox_index then begin |
---|
[150] | 485 | ; We change the min of depth1 |
---|
[69] | 486 | widget_control, depth1id, set_value = {slider_max:gdep2[indice]-1} |
---|
[150] | 487 | ; We redefine the value of dthlv2id |
---|
[69] | 488 | widget_control, dthlv2id, set_value = {combobox_select:indice} |
---|
[150] | 489 | ; So we redefine the min of the slider 2 |
---|
[2] | 490 | if indice EQ jpk-1 then BEGIN |
---|
| 491 | max = max([gdept, gdepw]) |
---|
| 492 | max = strtrim(string(max,format='(e8.0)'), 1) |
---|
| 493 | max = float('1'+strmid(max, 1))+float(max) |
---|
[69] | 494 | ENDIF ELSE max = gdep2[indice+1]-1 |
---|
[2] | 495 | widget_control, event.id, set_value = {slider_max:max} |
---|
| 496 | endif |
---|
| 497 | END |
---|
| 498 | ELSE: |
---|
| 499 | ENDCASE |
---|
| 500 | ; slidesliceid = widget_info(event.top, find_by_uname = 'slide_slice') |
---|
| 501 | ; if slidesliceid NE 0 then widget_control, slidesliceid, set_value = 1 |
---|
| 502 | return,{ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 503 | , BOX:cw_domain_get_value(event.handler)} |
---|
| 504 | end |
---|
| 505 | ;********************************************************************* |
---|
[150] | 506 | ;+ |
---|
| 507 | ; @file_comments |
---|
| 508 | ; |
---|
| 509 | ; |
---|
| 510 | ; @categories |
---|
[157] | 511 | ; Compound widget |
---|
[150] | 512 | ; |
---|
| 513 | ; @param PARENT {in}{required} |
---|
| 514 | ; The widget ID of the parent widget. |
---|
| 515 | ; |
---|
| 516 | ; @keyword UVALUE |
---|
| 517 | ; The user value to be associated with the widget. |
---|
| 518 | ; |
---|
| 519 | ; @keyword UNAME |
---|
| 520 | ; The user name to be associated with the widget. |
---|
| 521 | ; |
---|
| 522 | ; @keyword STRICT |
---|
| 523 | ; |
---|
| 524 | ; |
---|
| 525 | ; @keyword UNZOOM |
---|
| 526 | ; |
---|
| 527 | ; |
---|
| 528 | ; @keyword BOXZOOM |
---|
| 529 | ; Vector indicating the geographic zone on which we want to cut the map. |
---|
| 530 | ; If BOXZOOM has : |
---|
| 531 | ; 1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] |
---|
| 532 | ; 2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] |
---|
| 533 | ; 4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])] |
---|
| 534 | ; 5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
| 535 | ; 6 elements: The extraction is made on Boxzoom |
---|
| 536 | ; Where lon1, lon2,lat1,lat2 are global variables defined at the last domdef! |
---|
| 537 | ; |
---|
| 538 | ; @keyword _EXTRA |
---|
| 539 | ; Used to pass your keywords |
---|
| 540 | ; |
---|
| 541 | ; @returns |
---|
| 542 | ; |
---|
| 543 | ; |
---|
| 544 | ; @uses |
---|
| 545 | ; |
---|
| 546 | ; |
---|
| 547 | ; @restrictions |
---|
| 548 | ; |
---|
| 549 | ; |
---|
| 550 | ; @examples |
---|
| 551 | ; |
---|
| 552 | ; |
---|
| 553 | ; @history |
---|
| 554 | ; |
---|
| 555 | ; |
---|
| 556 | ; @version |
---|
| 557 | ; $Id$ |
---|
| 558 | ; |
---|
| 559 | ; @todo |
---|
| 560 | ; seb: Documenter |
---|
| 561 | ; |
---|
| 562 | ;- |
---|
[69] | 563 | FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, _extra = ex |
---|
[2] | 564 | ; |
---|
[114] | 565 | ; |
---|
| 566 | compile_opt idl2, strictarrsubs |
---|
| 567 | ; |
---|
[69] | 568 | @cm_4mesh |
---|
| 569 | @cm_4data |
---|
| 570 | ; |
---|
[150] | 571 | ; Definition of the boxzoom |
---|
[69] | 572 | Case N_Elements(Boxzoom) OF |
---|
| 573 | 0:boxzoom = [lon1, lon2, lat1, lat2 $ |
---|
| 574 | , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] |
---|
| 575 | 1:boxzoom = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] |
---|
| 576 | 2:boxzoom = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] |
---|
| 577 | 4:boxzoom = [Boxzoom, vert1, vert2] |
---|
| 578 | 5:boxzoom = [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
| 579 | 6: |
---|
| 580 | Else: return, report('Mauvaise Definition de Boxzoom') |
---|
| 581 | ENDCASE |
---|
| 582 | IF total(Boxzoom) EQ 0 THEN $ |
---|
| 583 | boxzoom = [lon1, lon2, lat1, lat2, min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]])] |
---|
[2] | 584 | ; |
---|
[69] | 585 | boxzoom[0] = floor(boxzoom[0]) |
---|
| 586 | boxzoom[1] = ceil(boxzoom[1]) |
---|
| 587 | boxzoom[2] = floor(boxzoom[2]) |
---|
| 588 | boxzoom[3] = ceil(boxzoom[3]) |
---|
| 589 | boxzoom[4] = floor(boxzoom[4]) |
---|
| 590 | boxzoom[5] = ceil(boxzoom[5]) |
---|
[2] | 591 | ;------------------------------------------------ |
---|
[69] | 592 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
| 593 | if NOT keyword_set(uname) then uname = '' |
---|
| 594 | base = widget_base(parent, row = 2, space = 0 $ |
---|
| 595 | , EVENT_FUNC = 'cw_domain_event' $ |
---|
| 596 | , FUNC_GET_VALUE = 'cw_domain_get_value' $ |
---|
| 597 | , PRO_SET_VALUE = 'cw_domain_set_value' $ |
---|
| 598 | , UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
| 599 | ;------------------------------------------------ |
---|
| 600 | baseh = widget_base(base, column = 1+keyword_set(unzoom), space = 0) |
---|
| 601 | ;------------------------------------------------ |
---|
| 602 | baseh1 = widget_base(baseh, row = 2, space = 0) |
---|
[2] | 603 | ;-------------longitude--------------------------- |
---|
[69] | 604 | min = floor(min([glamt, glamf], max = max)) |
---|
| 605 | max = ceil(max) |
---|
[114] | 606 | IF max-min GT 360 AND keyword_set(key_periodic) THEN max = min+360 |
---|
[69] | 607 | lonbase = widget_base(baseh1, column = 2, space = 0, uname = 'lonbase', uvalue = {name:'geographic'}) |
---|
| 608 | lon1id = cw_slider_pm(lonbase, value = min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ |
---|
| 609 | , uvalue = {name:'lon1', strict:keyword_set(strict)}, uname = 'lon1' $ |
---|
| 610 | , title = 'lon1', minimum = min $ |
---|
| 611 | , maximum = (boxzoom[1] < max)-keyword_set(strict)) |
---|
| 612 | lon2id = cw_slider_pm(lonbase, value = ((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ |
---|
| 613 | , uvalue = {name:'lon2', strict:keyword_set(strict)} $ |
---|
| 614 | , uname = 'lon2', title = 'lon2', maximum = max $ |
---|
| 615 | , minimum = (min > boxzoom[0])+keyword_set(strict)) |
---|
[2] | 616 | ;---------------latitude------------------------- |
---|
[69] | 617 | min = floor(min([gphit, gphif], max = max)) |
---|
| 618 | max = ceil(max) |
---|
| 619 | latbase = widget_base(baseh1, column = 2, space = 0, uname = 'latbase', uvalue = {name:'geographic'}) |
---|
| 620 | lat1id = cw_slider_pm(latbase, value = min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ |
---|
| 621 | , uvalue = {name:'lat1', strict:keyword_set(strict)}, uname = 'lat1' $ |
---|
| 622 | , title = 'lat1', minimum = min $ |
---|
| 623 | , maximum = ((boxzoom[3] < max)-keyword_set(strict))) |
---|
| 624 | lat2id = cw_slider_pm(latbase, value = ((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ |
---|
| 625 | , uvalue = {name:'lat2', strict:keyword_set(strict)} $ |
---|
| 626 | , uname = 'lat2', title = 'lat2', maximum = max $ |
---|
| 627 | , minimum = (min > boxzoom[2])+keyword_set(strict)) |
---|
[2] | 628 | ;----------------unzoom------------------------ |
---|
[69] | 629 | if keyword_set(unzoom) then rien = widget_button(baseh, value = 'unzoom', uvalue = {name:'unzoom'}, xsize = 60, ysize = 110) |
---|
[2] | 630 | ;----------------depth------------------------ |
---|
[69] | 631 | basez = widget_base(base, column = 3, space = 0, /base_align_center) |
---|
| 632 | ;------------------------------------------------ |
---|
| 633 | basezdrp = widget_base(basez, row = 2, space = 0) |
---|
[2] | 634 | ; |
---|
[69] | 635 | if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept |
---|
| 636 | gdep1 = floor(gdep) |
---|
| 637 | gdep2 = ceil(gdep) |
---|
[172] | 638 | ;; same = where(gdep2-gdep1 EQ 0) |
---|
| 639 | ;; if same[0] NE -1 then gdep2[same] = gdep2[same] +1 |
---|
[69] | 640 | sgdep1 = strtrim(gdep1, 1) |
---|
| 641 | sgdep2 = strtrim(gdep2, 1) |
---|
[2] | 642 | ; |
---|
[69] | 643 | dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep1, uvalue = {name:'dthlv1', grid_t:strupcase(vargrid) NE 'W'}, uname = 'dthlv1') |
---|
| 644 | rien = where(gdep1 LT boxzoom[4], indice1) |
---|
| 645 | indice1 = indice1 < (jpk-1) |
---|
| 646 | widget_control, dephtid, set_value = {combobox_select:indice1} |
---|
[2] | 647 | ; |
---|
[69] | 648 | dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep2, uvalue = {name:'dthlv2'}, uname = 'dthlv2') |
---|
| 649 | rien = where(gdep2 LE boxzoom[5], indice2) |
---|
| 650 | indice2 = indice1 > (indice2-1) |
---|
| 651 | widget_control, dephtid, set_value = {combobox_select:indice2} |
---|
[2] | 652 | ; |
---|
[69] | 653 | ;------ |
---|
| 654 | ; basedepthslid = widget_base(base, column = 2, space = 0) |
---|
| 655 | strminlen = max(strlen(strtrim(round([gdept, gdepw]), 1))) |
---|
[2] | 656 | ; |
---|
[69] | 657 | if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] |
---|
| 658 | max1 = (min1+1) > gdep1[indice2] |
---|
| 659 | rien = cw_slider_pm(basez, value = min1 > boxzoom[4] < (boxzoom[5] < max1) $ |
---|
| 660 | , uvalue = {name:'depth1'}, uname = 'depth1', strminlen = strminlen $ |
---|
| 661 | , title = 'z1', minimum = min1, maximum = max1) |
---|
[2] | 662 | ; |
---|
[69] | 663 | min2 = gdep2[indice1] |
---|
[167] | 664 | if indice2 EQ jpk-1 then max2 = ceil(max([gdept, gdepw])) $ |
---|
| 665 | ELSE max2 = gdep1[indice2+1] |
---|
| 666 | if floor(max2) LE floor(min2) then max2 = min2+1 |
---|
[69] | 667 | rien = cw_slider_pm(basez, value = (min2 > boxzoom[4]) > boxzoom[5] < max2 $ |
---|
| 668 | , uvalue = {name:'depth2'}, minimum = min2, maximum = max2 $ |
---|
| 669 | , uname = 'depth2', title = 'z2', strminlen = strminlen) |
---|
[2] | 670 | ;-------------------------------------------- |
---|
| 671 | ; |
---|
[69] | 672 | return, base |
---|
[2] | 673 | end |
---|