source: trunk/SRC/ToBeReviewed/WIDGET/AUTOUR_de_XXX/changefile.pro @ 244

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

improvements/corrections of some *.pro headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1;+
2;
3; @file_comments
4;
5; @categories
6;
7; @param BASE {in}{required}
8; The id of the widget where apply the drawing.
9;
10; @param NEWFILENAME
11;
12; @keyword BOXZOOM
13; Vector indicating the geographic zone on which we want to cut the map.
14; If BOXZOOM has :
15;   1 element : The extraction is made on [lon1, lon2, lat1, lat2, 0.,boxzoom[0]]
16;   2 elements: The extraction is made on [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]]
17;   4 elements: The extraction is made on [Boxzoom, 0, max([gdept, gdepw])]
18;   5 elements: The extraction is made on [Boxzoom[0:3], 0, Boxzoom[4]]
19;   6 elements: The extraction is made on Boxzoom
20; Where lon1, lon2,lat1,lat2 are global variables defined at the last domdef!
21;
22; @keyword DATE1
23;
24; @keyword DATE2
25;
26; @keyword FIELDNAME
27;
28; @returns
29;
30; @uses
31;
32; @restrictions
33;
34; @examples
35;
36; @history
37;
38; @version
39; $Id$
40;
41; @todo
42; seb
43;
44;-
45PRO changefile, base, newfilename, BOXZOOM = boxzoom, DATE1 = date1, DATE2 = date2, FIELDNAME = fieldname
46;
47;
48  compile_opt idl2, strictarrsubs
49;
50  widget_control, base, /hourglass
51  widget_control, base, get_uvalue = top_uvalue
52  filelist = extractatt(top_uvalue, 'filelist')
53  IF size(newfilename, /type) EQ 7 THEN newfile = (where(filelist EQ newfilename))[0] $
54  ELSE newfile = newfilename    ; it is already the index of the new file
55  if newfile EQ -1 then begin
56    nothing = report('invalid filename')
57    return
58  endif
59  oldfile = extractatt(top_uvalue, 'currentfile')
60  oldfilename = filelist[oldfile]
61
62; did we really change the file???
63  if oldfile EQ newfile AND NOT (keyword_set(BOXZOOM) OR keyword_set(DATE1) OR keyword_set(DATE2) OR keyword_set(FIELDNAME)) then return
64
65;--------------
66  widget_control, base, update = 0
67;--------------
68;
69; we update currentfile element of the top_uvalue
70;
71  *top_uvalue[1, findline(top_uvalue, 'currentfile')] = newfile
72;
73; Calendar
74;
75  oldcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).time_counter
76  newcalendar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).time_counter
77; Did we change the calendar?
78  if array_equal(oldcalendar, newcalendar) NE 1 then begin
79@cm_4cal
80; for key_caltype
81    key_caltype = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).caltype
82; fake or real calendar???
83    fakecal = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).fakecal
84; Which dates were selected?
85    date1id = widget_info(base, find_by_uname = 'calendar1')
86    if NOT keyword_set(date1) then widget_control, date1id, get_value = date1
87    jdate1 = date2jul(date1)
88    if (where(newcalendar EQ jdate1))[0] EQ -1 then jdate1 = newcalendar[0]
89    date2id = widget_info(base, find_by_uname = 'calendar2')
90    if NOT keyword_set(date2) then widget_control, date2id, get_value = date2
91    jdate2 = date2jul(date2)
92    if (where(newcalendar EQ jdate2))[0] EQ -1 then jdate2 = date1
93    if jdate2 LT jdate1 THEN jdate2 = jdate1
94    widget_control, date1id, /destroy
95    widget_control, date2id, /destroy
96    basecal = widget_info(base, find_by_uname = 'basecal')
97    rien = cw_calendar(basecal, newcalendar, jdate1, uname = 'calendar1' $
98                       , FAKECAL = fakecal, uvalue = {name:'calendar1'}, /frame)
99    rien = cw_calendar(basecal, newcalendar, jdate2, uname = 'calendar2' $
100                       , FAKECAL = fakecal, uvalue = {name:'calendar2'}, /frame)
101  ENDIF ELSE BEGIN
102    if keyword_set(date1) then begin
103      date1id = widget_info(base, find_by_uname = 'calendar1')
104      widget_control, date1id, set_value = date1
105    endif
106    if keyword_set(date2) then begin
107      date2id = widget_info(base, find_by_uname = 'calendar2')
108      widget_control, date2id, set_value = date2
109    endif
110  ENDELSE
111;
112; Grid parameters and domain
113;
114  newgrid = *(extractatt(top_uvalue, 'meshparameters'))[newfile]
115  change = changegrid(newgrid)
116  if change OR keyword_set(boxzoom) then BEGIN
117    if NOT keyword_set(boxzoom) then boxzoom = -1
118    domainid = widget_info(base, find_by_uname = 'domain')
119    widget_control, domainid, set_value = boxzoom
120  endif
121;
122; file name
123;
124  IF oldfile NE newfile THEN BEGIN
125    flstid = widget_info(base, find_by_uname = 'filelist')
126    widget_control, flstid, set_combobox_select =  newfile
127  ENDIF
128;
129; Variables name
130;
131  vlstid = widget_info(base, find_by_uname = 'varlist')
132  oldfieldname = widget_info(vlstid, /combobox_gettext)
133; did we really change the liste of variables?
134  oldlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[oldfile]).listvar
135  newlistvar = (*(extractatt(top_uvalue, 'fileparameters'))[newfile]).listvar
136  if array_equal(oldlistvar, newlistvar) NE 1 THEN $
137     widget_control, vlstid, set_value = newlistvar
138; set the liste of variables to the new variable name
139  if keyword_set(fieldname) then newfieldname = fieldname ELSE newfieldname = oldfieldname
140  indexvar = where(newlistvar EQ newfieldname) & indexvar = 0 > indexvar[0]
141  widget_control, vlstid, set_combobox_select = indexvar
142  newfieldname = newlistvar[indexvar]
143; did we change the name of the variable?
144  if newfieldname NE oldfieldname then BEGIN
145    changefield, base, newfieldname, BOXZOOM = boxzoom
146  ENDIF
147;
148;--------------
149  widget_control, base, update = 1
150;--------------
151  return
152end
Note: See TracBrowser for help on using the repository browser.