source: trunk/buildinit.pro @ 67

Last change on this file since 67 was 67, checked in by pinsard, 18 years ago

miscellaneous modifications according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

  • Property svn:executable set to *
File size: 18.9 KB
Line 
1;+
2; NAME:
3;
4;
5;
6; PURPOSE:
7;
8;
9;
10; CATEGORY:
11;
12;
13;
14; CALLING SEQUENCE:
15;
16;
17;
18; INPUTS:
19;
20;
21;
22; OPTIONAL INPUTS:
23;
24;
25;
26; KEYWORD PARAMETERS:
27;
28;
29;
30; OUTPUTS:
31;
32;
33;
34; OPTIONAL OUTPUTS:
35;
36;
37;
38; COMMON BLOCKS:
39;
40;
41;
42; SIDE EFFECTS:
43;
44;
45;
46; RESTRICTIONS:
47;
48;
49;
50; PROCEDURE:
51;
52;
53;
54; EXAMPLE:
55;
56;
57;
58; MODIFICATION HISTORY:
59;
60;-
61;
62;----------------------------------------------------------
63;----------------------------------------------------------
64;
65; slightly mofified version of cw_field...
66FUNCTION CW_FIELD2, Parent, COLUMN=Column, ROW=Row, $
67    EVENT_FUNC = efun, $
68    FLOATING=Float, INTEGER=Int, LONG=Long, STRING=String, $
69    FONT=LabelFont, FRAME=Frame, TITLE=Title, UVALUE=UValue, VALUE=TextValueIn, $
70    RETURN_EVENTS=ReturnEvents, ALL_EVENTS=AllUpdates, $
71    FIELDFONT=FieldFont, NOEDIT=NoEdit, TEXT_FRAME=Text_Frame, $
72    XSIZE=XSize, YSIZE=YSize, UNAME=uname
73;   FLOOR=vmin, CEILING=vmax
74  resolve_routine, 'cw_field', /compile_full_file, /is_function
75    ;   Examine our keyword list and set default values
76    ;   for keywords that are not explicitly set.
77
78    Column      = KEYWORD_SET(Column)
79    Row         = 1 - Column
80    AllEvents       = 1 - KEYWORD_SET(NoEdit)
81
82    ; Enum Update { None, All, CRonly }
83    Update      = 0
84    IF KEYWORD_SET(AllUpdates) THEN Update  = 1
85    IF KEYWORD_SET(ReturnEvents) THEN Update    = 2
86
87    IF N_ELEMENTS(efun) LE 0 THEN efun = ''
88    IF N_ELEMENTS(Title) EQ 0 THEN Title='Input Field:'
89    TextValue = (N_ELEMENTS(TextValueIn) gt 0) ? TextValueIn : ''
90    ; Convert non-string values to strings.
91    if (SIZE(TextValue, /TNAME) ne 'STRING') then $
92        TextValue = STRTRIM(TextValue,2)
93    IF N_ELEMENTS(YSize) EQ 0 THEN YSize=1
94    IF N_ELEMENTS(uname) EQ 0 THEN uname='CW_FIELD_UNAME'
95
96    Type    = 0 ; string is default
97    IF KEYWORD_SET(Float) THEN  Type    = 1
98    IF KEYWORD_SET(Int) THEN    Type    = 2
99    IF KEYWORD_SET(Long) THEN   Type    = 3
100
101    ;   Don't allow multiline non string widgets
102    if (Type ne 0) then $
103        YSize=1
104    YSize = YSize > 1
105
106    ;   Build Widget
107
108    Base    = WIDGET_BASE(Parent, ROW=Row, COLUMN=Column, UVALUE=UValue, $
109            EVENT_FUNC='CW_FIELD_EVENT', $
110            PRO_SET_VALUE='CW_FIELD_SET', $
111            FUNC_GET_VALUE='CW_FIELD_GET', $
112            FRAME=Frame, UNAME=uname )
113    FOR i = 0, n_elements(title)-1 DO $
114      Label   = WIDGET_LABEL(Base, VALUE = Title[i], FONT = LabelFont, $
115                             UNAME = uname+'_LABEL', /align_left)
116    Text    = WIDGET_TEXT(Base, VALUE = TextValue, $
117            XSIZE=XSize, YSIZE=YSize, FONT=FieldFont, $
118            ALL_EVENTS=AllEvents, $
119            EDITABLE=(AllEvents AND TYPE EQ 0), $
120            FRAME=Text_Frame , $
121            UNAME=uname+'_TEXT')
122
123            ; NO_ECHO=(AllEvents AND (TYPE NE 0)))
124
125    ; Save our internal state in the first child widget
126    State   = {     $
127    efun: efun,         $
128    TextId:Text,        $
129    Title:Title,        $
130    Update:Update,      $
131    Type:Type       $
132    }
133    WIDGET_CONTROL, WIDGET_INFO(Base, /CHILD), SET_UVALUE=State, /NO_COPY
134    RETURN, Base
135  END
136;
137;----------------------------------------------------------
138;----------------------------------------------------------
139;
140PRO printerdef_event, event
141; get back the ids of the cw_field widgets
142  widget_control, event.id, get_uvalue = cwids
143  IF size(cwids, /n_dimensions) EQ 1 THEN cwids = reform(cwids, 3, 1)
144help, cwids
145  dims = size(cwids, /dimensions)
146help,  dims
147print,  dims
148  results = strarr(dims)
149  FOR i = 0, dims[1]-1 DO BEGIN
150    widget_control, cwids[0, i], get_value = res & results[0, i] = res
151    widget_control, cwids[1, i], get_value = res & results[1, i] = res
152    widget_control, cwids[2, i], get_value = res & results[2, i] = res
153  ENDFOR
154  nothing = where(results EQ '', count)
155  IF count NE 0 THEN BEGIN
156    nothing = dialog_message('Some of the text box are still empty', dialog_parent = event.top, /information)
157    return
158  ENDIF
159; now we give the result to buildinit.pro by using the pointer uvalue
160   widget_control, event.top, get_uvalue = ptresult
161   *ptresult = temporary(results)
162; we destroy the widget
163   widget_control, event.top, /destroy
164  RETURN
165END
166;
167;----------------------------------------------------------
168;----------------------------------------------------------
169;
170PRO papsize_event, event
171; get back the ids of the cw_field widgets
172  widget_control, event.id, get_uvalue = uvalue
173  IF uvalue[0] NE 'ok' THEN return
174  idist = widget_info(event.top, find_by_uname = 'list')
175  id = widget_info(idist, /list_select)
176  widget_control, idist, get_uvalue = selected
177  selected = selected[id]
178  selected = strsplit(selected, /extract)
179; now we give the result to buildinit.pro by using the pointer uvalue
180   widget_control, event.top, get_uvalue = ptresult
181   *ptresult = [float(selected[3]), float(selected[4])]
182; we destroy the widget
183   widget_control, event.top, /destroy
184  RETURN
185END
186;
187;----------------------------------------------------------
188;----------------------------------------------------------
189;
190PRO xask_event, event
191; now we give the answer to buildinit.pro by using the pointer uvalue
192   widget_control, event.top, get_uvalue = ptranswer
193   *ptranswer = event.value
194; we destroy the widget
195   widget_control, event.top, /destroy
196  RETURN
197END
198;
199;----------------------------------------------------------
200;----------------------------------------------------------
201;
202FUNCTION xask, _extra = ex
203  base = widget_base()
204  field = cw_field2(base, /frame, /return_events, /column, _extra = ex)
205  ptranswer = ptr_new(/allocate_heap)
206; we realize the widget and wait for an answer
207  widget_control, base, /realize, set_uvalue = ptranswer
208  xmanager, 'xask', base
209; we get the answer
210  answer = *ptranswer
211; we freeing the pointer
212  ptr_free, ptranswer
213  RETURN, answer
214END
215;
216;----------------------------------------------------------
217;----------------------------------------------------------
218;
219FUNCTION getdir, title = title, nomark = nomark, nowrite = nowrite
220 
221  REPEAT BEGIN
222    dir = dialog_pickfile(/directory, /must_exist, title = title)
223; make sure dir is ok, check read/write access and directory separator mark
224    dir = file_search(dir, /test_directory, /test_read $
225                      , test_write = 1 - keyword_set(nowrite) $
226                      , mark_directory = 1 - keyword_set(nomark))
227    dir = dir[0]
228  ENDREP UNTIL dir NE ''
229
230  RETURN, dir
231END
232;
233;----------------------------------------------------------
234;----------------------------------------------------------
235;
236PRO buildinit
237;
238  IF fix(strmid(!version.release, 0, 1)) LT 6 THEN BEGIN
239    print, '                   *** ***** ***'
240    print, '                   *** ERROR ***'
241    print, '                   *** ***** ***'
242    print, 'This version of SAXO needs at least IDL version 6.0'
243    print, '                   *** ***** ***'
244    print, '                   *** ERROR ***'
245    print, '                   *** ***** ***'
246    return
247  ENDIF
248  IF lmgr(/demo) EQ 1 THEN BEGIN
249    print, 'impossible to use buildinit in demo mode'
250    return
251  ENDIF
252;
253  init = [';' $
254          , '; This is the initialisation file.' $
255          , '; it defines the !path and the defaut values of some of the common variables' $
256          , ';' $
257          , '; this is supposed to speed-up IDL...' $
258          , ';' $
259          , '; a = fltarr(1000,1000,100)' $
260          , '; a = 0' $
261          , ';' $
262          , '; path definition' $
263          , ';']
264;
265; define "myIDL" directory
266  myIDL = getdir(title = 'Select the home directory (my IDL)', /nomark)
267; define "SAXO" directory
268  saxodir = getdir(title = 'Select SAXO directory', /nomark, /nowrite)
269; define the !path
270  init = [init, '!path = expand_path(''+'' + '''+myIDL+''') $' $
271          , '      + '':'' + expand_path(''+'' + '''+saxodir+''') $' $
272          , '      + '':'' + expand_path(''+'' + !dir)']
273;
274; should we keep the compatibility with the old version?
275;
276  yes = dialog_message(['shall we keep the compatibility' $
277                        , 'with the old version ?'], /question, /default_no)
278  yes = strlowcase(yes)
279 
280  init = [init $
281          , ';' $
282          , '; compatibility with the old version' $
283          , ';' $
284          , 'keep_compatibility, ' + strtrim(fix(yes EQ 'yes'), 2)]
285;
286; define all the commons
287;
288  init = [init $
289          , ';' $
290          , '; define all the commons' $
291          , ';' $
292          , '@all_cm']
293;
294; define default directories
295;
296  init = [init $
297          , ';' $
298          , '; define default directories' $
299          , ';' $
300          , 'homedir = isadirectory('''+myIDL+'/'', title = ''Select the default HOME directory'')']
301  iodir = getdir(title = 'Select the default IO directory')
302  init = [init $
303          , 'iodir = isadirectory('''+iodir+''', title = ''Select the default IO directory'')']
304  psdir = getdir(title = 'Select the default postscripts directory')
305  init = [init $
306          , 'psdir = isadirectory('''+psdir+''', title = ''Select the default postscripts directory'')']
307  imagedir = getdir(title = 'Select the default images directory')
308  init = [init $
309          , 'imagedir = isadirectory('''+imagedir+''', title = ''Select the default images directory'')']
310  animdir = getdir(title = 'Select the default animations directory')
311  init = [init $
312          , 'animdir = isadirectory('''+animdir+''', title = ''Select the default animations directory'')']
313;
314; number of printer
315;
316  ptnumb = xask(title = 'Number of accessible printers', value = 0, /long)
317;
318; define all the printer parameters
319;
320  init = [init $
321          , ';' $
322          , '; define printer parameters' $
323          , ';' ]
324;
325  IF ptnumb NE 0 THEN BEGIN
326    base = widget_base(/column, /frame)
327    cwids = lonarr(3, ptnumb)
328    FOR i = 0, ptnumb-1 DO BEGIN
329      subbase = widget_base(base, /row)
330      cwids[0, i] = cw_field(subbase, /string $
331                             , Title = 'printer_human_names['+strtrim(i, 2)+'] = ')
332      cwids[1, i] = cw_field(subbase, /string $
333                             , Title = 'printer_machine_names['+strtrim(i, 2)+'] = ')
334      cwids[2, i] = cw_field(subbase, /string, value = '\lpr -P' $
335                             , Title = 'printer_machine_names['+strtrim(i, 2)+'] = ')
336    ENDFOR
337    trash = widget_button(base, value = 'ok', uvalue = cwids)
338    ptresult = ptr_new(/allocate_heap)
339; we realize the widget and wait for an answer
340    widget_control, base, /realize, set_uvalue = ptresult
341    xmanager, 'printerdef', base
342;
343    init = [init $
344            , 'printer_human_names = strarr('+strtrim(ptnumb, 2)+')' $
345            , 'printer_machine_names = strarr('+strtrim(ptnumb, 2)+')' $
346            , 'print_command = strarr('+strtrim(ptnumb, 2)+')']
347    FOR i = 0, ptnumb-1 DO BEGIN
348      init = [init $
349              , 'printer_human_names['+strtrim(i, 2)+'] = ''' $
350              + (*ptresult)[0, i]+'''' $
351              , 'printer_machine_names['+strtrim(i, 2)+'] = ''' $
352              + (*ptresult)[1, i]+'''' $
353              , 'print_command['+strtrim(i, 2)+'] = ''' $
354              + (*ptresult)[2, i]+'''']
355    ENDFOR
356; we freeing the pointer
357    ptr_free, ptresult
358  ENDIF ELSE BEGIN
359    init = [init $
360            , 'printer_human_names = ''''' $
361            , 'printer_machine_names = ''''' $
362            , 'print_command = ''''']
363  ENDELSE
364;
365; Colors
366;
367  init = [init $
368          , ';' $
369          , '; colors ...' $
370          , ';' $
371          , 'device, decomposed = 0' $
372          , 'device, retain = 2']
373;
374; default color tables
375;
376  loadct, get_names = names
377
378  ntables = 40
379  title = ['               --------------------------------------               ' $
380           , '               --- Choose the default color table ---               ' $
381           , '               --------------------------------------               ', '']
382; the following lines come from loadct procedure...
383  nlines = (ntables + 2) / 3    ;# of lines to print
384  nend = nlines - ((nlines*3) - ntables)
385  for i = 0, nend-1 do $        ;Print each line
386    title = [title $
387             , string(format = "(i2,'- ',a17, 3x, i2,'- ',a17, 3x, i2,'- ',a17)" $
388                      , i, names[i], i+nlines, names[i+nlines] $
389                      , i+2*nlines < (ntables-1) $
390                      , names[i+2*nlines < (ntables-1)])]
391  if (nend lt nlines) then begin
392    for i = nend, nlines-1 do $
393      title = [title $
394               , string(format = "(i2,'- ',a17, 3x, i2,'- ',a17)", $
395                        i, names[i], i+nlines, names[i+nlines])]
396  ENDIF
397  title = [title, '']
398  ctnumb = 0 > xask(title = title, value = 39, /long) < 39
399;
400  init = [init $
401          , 'lct, '+strtrim(ctnumb, 2)]
402;
403; postscript position
404;
405  yes = dialog_message(['the default postscript position', 'is landscape?'], /question)
406  init = [init $
407          , ';' $
408          , '; postscript parameters ...' $
409          , ';' $
410          , 'key_portrait = '+strtrim(fix(strlowcase(yes) NE 'yes'), 2)]
411;
412; paper size
413;
414  list = ['a0           33.0556    46.7778    83.9611   118.816' $
415          , 'a1           23.3889    33.0556    59.4078   83.9611' $
416          , 'a2           16.5278    23.3889    41.9806   59.4078' $
417          , 'a3           11.6944    16.5278    29.7039   41.9806' $
418          , 'a4           8.26389    11.6944    20.9903   29.7039' $
419          , 'a5           5.84722    8.26389    14.8519   20.9903' $
420          , 'a6           4.125      5.84722    10.4775   14.8519' $
421          , 'a7           2.91667    4.125      7.40833   10.4775' $
422          , 'a8           2.05556    2.91667    5.22111   7.40833' $
423          , 'a9           1.45833    2.05556    3.70417   5.22111' $
424          , 'a10          1.02778    1.45833    2.61056   3.70417' $
425          , 'b0           39.3889    55.6667    100.048   141.393' $
426          , 'b1           27.8333    39.3889    70.6967   100.048' $
427          , 'b2           19.6944    27.8333    50.0239   70.6967' $
428          , 'b3           13.9167    19.6944    35.3483   50.0239' $
429          , 'b4           9.84722    13.9167    25.0119   35.3483' $
430          , 'b5           6.95833    9.84722    17.6742   25.0119' $
431          , 'archA        9          12         22.86     30.48' $
432          , 'archB        12         18         30.48     45.72' $
433          , 'archC        18         24         45.72     60.96' $
434          , 'archD        24         36         60.96     91.44' $
435          , 'archE        36         48         91.44     121.92' $
436          , 'flsa         8.5        13         21.59     33.02' $
437          , 'flse         8.5        13         21.59     33.02' $
438          , 'halfletter   5.5        8.5        13.97     21.59' $
439          , 'note         7.5        10         19.05     25.4' $
440          , 'letter       8.5        11         21.59     27.94' $
441          , 'legal        8.5        14         21.59     35.56' $
442          , '11x17        11         17         27.94     43.18' $
443          , 'ledger       17         11         43.18     27.94']
444  base = widget_base(/column)
445  trash = widget_label(base, value = '--- Select the paper size ---')
446  trash = widget_label(base, value = '')
447  trash = widget_label(base, value = 'PAPERSIZE    X inches   Y inches   X cm      Y cm', /align_left, uvalue = 'dummy')
448  listid = widget_list(base, value = list, uvalue = list, uname = 'list', ysize = n_elements(list) < 15)
449  widget_control, listid, set_list_select = 4
450  trash = widget_button(base, value = 'ok', uvalue = 'ok')
451  ptresult = ptr_new(/allocate_heap)
452; we realize the widget and wait for an answer
453  widget_control, base, /realize, set_uvalue = ptresult
454  xmanager, 'papsize', base
455;
456  papsize = *ptresult
457; we freeing the pointer
458  ptr_free, ptresult
459  init = [init $
460          , 'page_size = [' + strtrim(papsize[0], 2) $
461          + ', ' +strtrim(papsize[1], 2) + ']']
462;
463; window size
464;
465  title = ['         --- Size of the Window ---', '' $
466           , 'The size of window (in cm) is given by:' $
467           , 'windowsize_scale * page_size, with ' $
468           , 'page_size = [' + strtrim(papsize[0], 2)+ ', ' +strtrim(papsize[1], 2) + ']' $
469           , 'Please select a value for windowsize_scale ']
470  wsize_scale = xask(title = title, value = 1, /floating)
471  init = [init, 'windowsize_scale = ' + strtrim(wsize_scale, 2)]
472 
473;
474; postscript archiving...
475;
476  title = ['     --- Select the default postscript archiving method ---', ''$
477           , '0 : never archive the postscript' $
478           , '1 : always archive the postscript when printed' $
479           , '2 : ask if the postscript must be archived each time its printed', '']
480  archive_ps = 0 > xask(title = title, value = 0, /long) < 2
481  init = [init $
482          , 'archive_ps = '+strtrim(archive_ps, 2) $
483          , ';' $
484          , ';========================================================' $
485          , '; end of the part that should be modified by the users...' $
486          , ';========================================================' $
487          , ';' $
488          , '; default definitions of many other common parameters...' $
489          , 'jpiglo = 1L' $
490          , 'jpjglo = 1L' $
491          , 'jpkglo = 1L' $
492          , 'jpidta = jpiglo' $
493          , 'jpjdta = jpjglo' $
494          , 'jpkdta = jpjglo' $
495          , 'jpi = 1L' $
496          , 'jpj = 1L' $
497          , 'jpk = 1L' $
498          , 'jpt = 1L' $
499          , 'time = 0L' $
500          , 'ixminmesh = -1L' $
501          , 'ixmaxmesh = -1L' $
502          , 'iyminmesh = -1L' $
503          , 'iymaxmesh = -1L' $
504          , 'izminmesh = -1L' $
505          , 'izmaxmesh = -1L' $
506          , 'ixmindta = 0L' $
507          , 'ixmaxdta = jpidta-1' $
508          , 'iymindta = 0L' $
509          , 'iymaxdta = jpjdta-1' $
510          , 'izmindta = 0L' $
511          , 'izmaxdta = jpkdta-1' $
512          , 'key_shift = 0L' $
513          , 'key_periodic = 0L' $
514          , 'key_yreverse = 0L' $
515          , 'key_zreverse = 0L' $
516          , 'key_stride = [1, 1, 1]' $
517          , 'ccmeshparameters ={filename:''No File'', filetype:''nothing'' $' $
518          , ', jpiglo:jpiglo, jpjglo:jpjglo, jpkglo:jpkglo $' $
519          , ', jpi:jpi, jpj:jpj, jpk:jpk $' $
520          , ', ixminmesh:ixminmesh, ixmaxmesh:ixmaxmesh $' $
521          , ', iyminmesh:iyminmesh, iymaxmesh:iymaxmesh $' $
522          , ', izminmesh:izminmesh, izmaxmesh:izmaxmesh $' $
523          , ', key_shift:key_shift, key_periodic:key_periodic $' $
524          , ', triangulation:-1, boundary:[-180, 180]}' $
525          , 'ccreadparameters = {funclec_name:''No File'' $' $
526          , ', jpidta:jpidta, jpjdta:jpjdta, jpkdta:jpkdta $' $
527          , ', ixmindta:ixmindta, ixmaxdta:ixmaxdta $' $
528          , ', iymindta:iymindta, iymaxdta:iymaxdta $' $
529          , ', izmindta:izmindta, izmaxdta:izmaxdta}' $
530          , 'lon1 = 0' $
531          , 'lon2 = 1' $
532          , 'lat1 = 0' $
533          , 'lat2 = 1' $
534          , 'vert1 = 0' $
535          , 'vert2 = 1' $
536          , 'valmask = 1.e20' $
537          , 'vargrid = ''T''' $
538          , 'varname = ''''' $     
539          , 'varexp = ''''' $
540          , 'varunit = ''''' $
541          , 'vardate= ''0''' $
542          , '@updateold' $
543          , ';' ]
544
545  filename = xask(title = ['name of the init file', '(written in homedir: ' + myIDL + ')'], value = 'init.pro', /string)
546  journal, myIDL + '/' + filename
547  FOR i = 0, n_elements(init)-1 DO journal, init[i]
548  journal
549
550  RETURN
551END
Note: See TracBrowser for help on using the repository browser.