;+
;
; @file_comments
; see Mini Guide for Basic Commands in the XXX Program
;
; @categories
;
; @param EVENT
;
; @returns
;
; @uses
;
; @restrictions
;
; @examples
;
; @history
;
; @version
; $Id$
;
;-
PRO xxx_event, event
;
compile_opt idl2, strictarrsubs
;
@common
;------------------------------------------------------------
; = widget_info(event.top,find_by_uname = '')
; What is the type of event ?
; if event.id EQ 622 then help, event, /struct
widget_control, event.id, get_uvalue=uval
if (tag_names(event, /structure_name))[0] EQ 'WIDGET_TRACKING' then uval = {name:'ActiverFenetre'}
if keyword_set(uval) EQ 0 then return
;help, event, /struct
;help, uval , /struct
; case on the type of event
widget_control, event.top, get_uvalue = top_uvalue
; If we activate the keyword separate at the call of xxx
if size(top_uvalue, /type) EQ 3 then begin
event.top = top_uvalue
widget_control, event.top, get_uvalue = top_uvalue
endif
; we delete the small widget created by notice.pro if it exists
noticebase = extractatt(top_uvalue, 'noticebase')
if noticebase NE 0 then BEGIN
widget_control, noticebase, /destroy
*top_uvalue[1, findline(top_uvalue, 'noticebase')] = 0l
endif
;
options = extractatt(top_uvalue, 'options')
case uval.name OF
'menubar':xxxmenubar_event, event
'ok':nouveaudessin = 1
'specifie':
'action':
'calendar1':BEGIN
date2id = widget_info(event.top, find_by_uname = 'calendar2')
widget_control, date2id, get_value = date2
if event.value GT date2 then widget_control, date2id, set_value = event.value
END
'calendar2':BEGIN
date1id = widget_info(event.top, find_by_uname = 'calendar1')
widget_control, date1id, get_value = date1
if event.value LT date1 then widget_control, date1id, set_value = event.value
END
'domain':
'varlist':BEGIN
currentfile = extractatt(top_uvalue, 'currentfile')
listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar
name = listvar[event.index]
changefield, event.top, name
END
'txtcmd':
'filelist':BEGIN
changefile, event.top, event.index
END
'ActiverFenetre':BEGIN
if event.enter EQ 1 AND !d.name NE 'PS' then BEGIN
; graphid = widget_info(event.top,find_by_uname = 'graph')
graphid = extractatt(top_uvalue, 'graphid')
widget_control,graphid,get_value=win
wset, win
widget_control,event.top,get_uvalue=top_uvalue
numdessinin = (extractatt(top_uvalue, 'smallin'))[2]-1
!p = (extractatt(top_uvalue, 'penvs'))[numdessinin]
!x = (extractatt(top_uvalue, 'xenvs'))[numdessinin]
!y = (extractatt(top_uvalue, 'yenvs'))[numdessinin]
endif
END
'graph':BEGIN
quelclick = identifyclick(event)
case quelclick.type of
'inutile':return
'long':longclickaction, event
'single':singleclickaction, event
'double':doubleclickaction, event
endcase
END
endcase
if keyword_set(nouveaudessin) then letsdraw, event.top
return
end
;
;+
;
; @file_comments
; A maximum of possibilities with a minimum of clics
;
; @categories
; Widget
;
; @param DATAFILENAME
;
; @param IDLFILE
;
; @param ARGSPRO
;
; @keyword SEPARATE
; To separate the button part and the drawing part in 2 windows.
; Useful for small screens, but be careful to do not saturate the
; video memory of some antiquated Tx.
;
; @keyword RESTORE
; 'toto.dat' or toto.dat is a file created at the time of a precedent
; use of xxx thanks to the command "Widget" of the menu "save as".
;
; @keyword _EXTRA
; Used to pass keywords
;
; @keyword CALLERWIDID
;
; @keyword REDRAW
;
;
; @keyword SEPARATE
;
;
; @keyword UVALUE
; The user value to be associated with the widget.
;
; @uses
; common
;
; @history
; Sebastien Masson (smasson\@lodyc.jussieu.fr)
;
; @version
; $Id$
;
; @todo
; seb: documenter le reste des keywords
;
;-
PRO xxx, datafilename, idlfile, argspro, CALLERWIDID=callerwidid $
, REDRAW=redraw, SEPARATE=separate, UVALUE=uvalue $
, RESTORE=restore, _EXTRA=ex
;
compile_opt idl2, strictarrsubs
;
@all_cm
;------------------------------------------------------------
; reinitialize the !p, !x, !y, !z variables
;------------------------------------------------------------
reinitplt
;------------------------------------------------------------
; we get back the uvalue of the widget that called xxx to create a new widget
if keyword_set(restore) then BEGIN
restore = isafile(filename = restore, iodir = homedir, _extra = ex)
if size(restore, /type) NE 7 then restore = 0 ELSE BEGIN
restore, isafile(file = restore, iodir = homedir, _extra = ex)
newgrid = *(extractatt(uvalue, 'meshparameters'))[0]
change = changegrid(newgrid)
ENDELSE
endif
if n_elements(CallerWidId) NE 0 THEN $
widget_control, CallerWidId, get_uvalue = uvalue ELSE CallerWidId = 0
;------------------------------------------------------------
;------------------------------------------------------------
; list of files we want to look at
;
if keyword_set(uvalue) then BEGIN
currentfile = extractatt(uvalue, 'currentfile')
filelist = extractatt(uvalue, 'filelist')
fileparameters = extractatt(uvalue, 'fileparameters')
readparameters = extractatt(uvalue, 'readparameters')
meshparameters = extractatt(uvalue, 'meshparameters')
ENDIF ELSE BEGIN
newfile = selectfile(datafilename, idlfile, argspro, _extra = ex)
if size(newfile, /type) NE 8 then return
fileparameters = ptrarr(1, /allocate_heap)
*fileparameters[0] = newfile.fileparameters
readparameters = ptrarr(1, /allocate_heap)
*readparameters[0] = newfile.readparameters
meshparameters = ptrarr(1, /allocate_heap)
*meshparameters[0] = newfile.meshparameters
currentfile = 0
filelist = newfile.fileparameters.filename
ENDELSE
;
if keyword_set(uvalue) THEN BEGIN
smallin = extractatt(uvalue, 'smallin')
smallout = extractatt(uvalue, 'smallout')
ENDIF ELSE BEGIN
smallin = [1, 1, 1]
smallout = [1, 1, 1]
ENDELSE
nbredessin = smallin[0]*smallin[1]
numdessinin = smallin[2]-1
; warning flg definition must be consistent with cw_pdmenu argument
; see also flag definition in cw_pagelayout
if keyword_set(uvalue) then BEGIN
flag = extractatt(uvalue, 'optionsflag')
key_portrait = flag[0, numdessinin]
ENDIF ELSE flag = [key_portrait, 0, 0, 0, 0]#replicate(1, nbredessin)
;------------------------------------------------------------
;------------------------------------------------------------
; We start the widget definition
;------------------------------------------------------------
;------------------------------------------------------------
;
; widget and screen size
scrsize = get_screen_size()*0.95
windsize = givewindowsize()
xxxsize = [windsize[0] * (1-keyword_set(separate)) + 350, windsize[1]]
;
;------------------------------------------------------------
; The top base
;------------------------------------------------------------
IF xxxsize[0] LE scrsize[0] AND xxxsize[1] LE scrsize[1] THEN BEGIN
base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $
, uname = 'base', space = 0)
ENDIF ELSE BEGIN
base = widget_base(title = 'xxx', GROUP_LEADER = group, /tracking_events $
, uname = 'base', space = 0 $
, xsize = xxxsize[0], ysize = xxxsize[1] $
, x_scroll_size = (xxxsize[0] < scrsize[0]) $
, y_scroll_size = (xxxsize[1] < scrsize[1]))
ENDELSE
;------------------------------------------------------------
; combobox for plots choice
;------------------------------------------------------------
xoff = 0
yoff = 0
pltlst = ['plt', 'pltv' $
, 'pltz', 'pltz diag up', 'pltz diag dn' $
, 'pltt', 'pltt diag up', 'pltt diag dn' $
, 'xy', 'xz', 'yz', 'xt', 'yt', 'zt' $
, 'x', 'y', 'z', 't']
actid = widget_combobox(base, value = pltlst, uname = 'action', uvalue = {name:'action'} $
, xoffset = xoff+5, yoffset = yoff+4, xsize = 90)
if keyword_set(uvalue) then BEGIN
selectact = (extractatt(uvalue, 'types'))[numdessinin]
selectact = (where(pltlst EQ selectact))[0]
widget_control, actid, set_combobox_select = 0 > selectact
ENDIF ELSE selectfile = 0
;------------------------------------------------------------
; menu/options
;------------------------------------------------------------
xoff = xoff + 110
if keyword_set(uvalue) then begin
options = extractatt(uvalue, 'options')
ENDIF ELSE options = ['Portrait/Landscape', 'Overlay', 'Vecteur' $
, 'Longitude / x index', 'Latitude / y index']
desc = [ '1\File', $
'0\Open' , $
'0\New xxx' , $
'2\Quit', $
'1\Save as' , $
'0\PostScript' , $
'0\Animated gif' , $
'0\Gif' , $
'0\IDL procedure', $
'0\RESTORE kwd of xxx', $
'2\Print to prompt', $
'1\Flag options']
descsuite = options
if n_elements(descsuite) GE 2 then $
descsuite[0:n_elements(descsuite)-2] = '0\'+descsuite[0:n_elements(descsuite)-2]
descsuite[n_elements(descsuite)-1] = '2\'+descsuite[n_elements(descsuite)-1]
desc = [desc, descsuite]
;
menu = cw_pdmenu(base, desc, /RETURN_NAME, uname = 'menubar', uvalue = {name:'menubar'} $
, xoffset = xoff, yoffset = yoff)
;------------------------------------------------------------
; Ok button
;------------------------------------------------------------
yoff = yoff + 37
xoff = 5
; button 'OK'
baseok = widget_button(base, value = ' OK ', uvalue = {name:'ok'}, uname = 'ok button' $
, /frame, xoffset = xoff, yoffset = yoff)
;------------------------------------------------------------
; Page Layout
;------------------------------------------------------------
; page layout
xoff = xoff + 65
dummyid = cw_pagelayout(base, smallin, /row, /frame, xoffset = xoff, yoffset = yoff)
;
;------------------------------------------------------------
; List of Variables
;------------------------------------------------------------
xoff = xoff + 140
currentlistvar = (*fileparameters[currentfile]).listvar
vlstid = widget_combobox(base, value = currentlistvar, uvalue = {name:'varlist'} $
, uname = 'varlist', xoffset = xoff, yoffset = yoff+1)
if keyword_set(uvalue) then BEGIN
selectvar = (extractatt(uvalue, 'varinfo'))[1, numdessinin]
selectvar = (where(currentlistvar EQ selectvar))[0]
widget_control, vlstid, set_combobox_select = 0 > selectvar
ENDIF ELSE selectvar = 0
;------------------------------------------------------------
; List of files
;------------------------------------------------------------
yoff = yoff + 35
flstid = widget_combobox(base, value = file_basename(filelist), uname = 'filelist' $
, xsize = 345, yoffset = yoff, uvalue = {name:'filelist'})
if keyword_set(uvalue) then BEGIN
selectfile = (extractatt(uvalue, 'varinfo'))[0, numdessinin]
selectfile = (where(file_basename(filelist) EQ selectfile))[0]
widget_control, flstid, set_combobox_select = 0 > selectfile
ENDIF ELSE selectfile = 0
;------------------------------------------------------------
; Text for computation
;------------------------------------------------------------
yoff = yoff + 32
; computation done on the files...
if keyword_set(uvalue) then txtvalue = (extractatt(uvalue, 'txtcmd'))[numdessinin] $
ELSE txtvalue = '"' + varexp + '"'
dummyid = widget_text(base, value = txtvalue, uvalue = {name:'txtcmd'}, uname = 'txtcmd' $
, /editable, yoffset = yoff, xsize = 54, /frame)
;------------------------------------------------------------
; Calendar
;------------------------------------------------------------
yoff = yoff + 40
currentcalendar = (*fileparameters[currentfile]).time_counter
key_caltype = (*fileparameters[currentfile]).caltype
fakecal = (*fileparameters[currentfile]).fakecal
if keyword_set(uvalue) then begin
dates = (extractatt(uvalue, 'dates'))[*, numdessinin]
date1 = date2jul(dates[0])
date2 = date2jul(dates[1])
ENDIF
basecalid = widget_base(base, column = 2, space = 0, yoffset = yoff, uname = 'basecal')
dummyid = cw_calendar(basecalid, currentcalendar, date1, FAKECAL = fakecal, uname = 'calendar1', uvalue = {name:'calendar1'}, /frame)
dummyid = cw_calendar(basecalid, currentcalendar, date2, FAKECAL = fakecal, uname = 'calendar2', uvalue = {name:'calendar2'}, /frame)
;------------------------------------------------------------
; Domain
;------------------------------------------------------------
yoff = yoff + 60
vargrid = strupcase((*fileparameters[currentfile]).listgrid[selectvar])
IF vargrid EQ 'W' then zgrid = 'W' ELSE zgrid = 'T'
if keyword_set(uvalue) then boxzoom = (extractatt(uvalue, 'domaines'))[*, numdessinin]
dummyid = cw_domain(base, uname = 'domain', uvalue = {name:'domain'}, /unzoom, /frame $
, boxzoom = boxzoom, yoffset = yoff, xoffset = 15)
;------------------------------------------------------------
; Plots specifications
;------------------------------------------------------------
yoff = yoff + 230
speid = cw_specifie(base, uname = 'specifie', uvalue = {name:'specifie'}, /frame, /column $
, /forxxx, yoffset = yoff)
if keyword_set(uvalue) then BEGIN
exextra = *((extractatt(uvalue, 'exextra'))[numdessinin])
IF n_elements(exextra) NE 0 THEN widget_control, speid, set_value = exextra
ENDIF
;------------------------------------------------------------
; drawing part
;------------------------------------------------------------
if keyword_set(separate) then $
basegraph = widget_base(title = 'xxx window', group_leader = base, uvalue = base) $
ELSE basegraph = base
graphid = widget_draw(basegraph, uname = 'graph', /button_events, retain = 2 $
, uvalue = {name:'graph', press:0, click:0, x:[0., 0.], y:[0., 0.]} $
, xoffset = 350*(1-keyword_set(separate)) $
, xsize = windsize[0], ysize = windsize[1]); , tooltip = 'toto')
;------------------------------------------------------------
; realize the widget
;------------------------------------------------------------
widget_control, base, /realize
if keyword_set(separate) then begin
widget_control, basegraph, /realize
xmanager, 'xxx', basegraph, /no_block
endif
;------------------------------------------------------------
if keyword_set(uvalue) then BEGIN ;
; We recopy the pointer uvalue in top_uvalue.
; Beware, we have to redefine completely top_value from variables
; pointed by uvalue. Otherwise, if we simply do top_value = uvalue,
; when we delete by uvalue and variables on which it point, we
; also delete variables on which point top_value.
case 1 of
keyword_set(redraw):BEGIN
top_uvalue = uvalue
widget_control, base, set_uvalue = top_uvalue
; we find homedir
homedir = isadirectory(io = homedir, title = 'Bad definition of homedir')
; We recuperae the list of instructions
globalcommand = extractatt(top_uvalue, 'globalcommand')
; We complete by first and last lines of the program
createpro, globalcommand, filename = myuniquetmpdir + 'xxx2ps.pro' $
, KWDLIST = ', NOERASE = noerase, POSTSCRIPT = postscript' $
+', PORTRAIT = portrait, LANDSCAPE = landscape' $
, /noerase
END
keyword_set(restore):begin
top_uvalue = uvalue
widget_control, base, set_uvalue = top_uvalue
widget_control, graphid, get_value = win
wshow, win
wset, win
tv, image, /true
; widgets's state
updatewidget, base
;
END
ELSE:BEGIN
top_uvalue = ptrarr(2, 29, /allocate_heap)
FOR i = 0, 28 do *top_uvalue[0, i] = *uvalue[0, i]
FOR i = 0, 14 do *top_uvalue[1, i] = *uvalue[1, i]
FOR i = 18, 27 do *top_uvalue[1, i] = *uvalue[1, i]
numfile = n_elements(extractatt(uvalue, 'filelist'))
*top_uvalue[1, 15] = ptrarr(numfile, /allocate_heap)
*top_uvalue[1, 16] = ptrarr(numfile, /allocate_heap)
*top_uvalue[1, 17] = ptrarr(numfile, /allocate_heap)
for i = 0, numfile-1 do begin
*(*top_uvalue[1, 15])[i] = *(*uvalue[1, 15])[i]
*(*top_uvalue[1, 16])[i] = *(*uvalue[1, 16])[i]
*(*top_uvalue[1, 17])[i] = *(*uvalue[1, 17])[i]
endfor
*top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap)
for i = 0, nbredessin-1 do *(*top_uvalue[1, 28])[i] = *(*uvalue[1, 28])[i]
widget_control, base, set_uvalue = top_uvalue
; Copy the screen of the widget of uvalue in top_value's one
if keyword_set(CallerWidId) then begin
widget_control, extractatt(uvalue, 'graphid'), get_value = win
wshow, win
wset, win
image = tvrd(/true)
widget_control, graphid, get_value = win
wshow, win
wset, win
tv, image, /true
ENDIF
END
endcase
*top_uvalue[1, findline(top_uvalue, 'graphid')] = graphid
;
ENDIF ELSE BEGIN
; Otherwise we will define all elements we will hook at the widget
; thanks to the top_value which is a pointer array with 2
; columns: names and variables.
; We initialize all these elements.
; Variables concerning the widget in its generality.
if NOT keyword_set(ex) then ex = {nothing:0}
; variables se rapportant aux differents fichiers que l''on peut lire
; variables specifiques a chaque dessin
;
; creation of the pointer we will hook at the widget.
top_uvalue = ptrarr(2, 29, /allocate_heap)
; variables refering to the widget
*top_uvalue[0, 0] = 'options' & *top_uvalue[1, 0] = options
*top_uvalue[0, 1] = 'smallin' & *top_uvalue[1, 1] = smallin
*top_uvalue[0, 2] = 'smallout' & *top_uvalue[1, 2] = smallout
*top_uvalue[0, 3] = 'graphid' & *top_uvalue[1, 3] = graphid
*top_uvalue[0, 4] = 'alreadyvector' & *top_uvalue[1, 4] = -1
*top_uvalue[0, 5] = 'alreadyover' & *top_uvalue[1, 5] = -1
*top_uvalue[0, 6] = 'alreadyread' & *top_uvalue[1, 6] = -1
*top_uvalue[0, 7] = 'currentreadcmd' & *top_uvalue[1, 7] = ''
*top_uvalue[0, 8] = 'globalcommand' & *top_uvalue[1, 8] = ''
*top_uvalue[0, 9] = 'globaloldcommand' & *top_uvalue[1, 9] = ''
*top_uvalue[0, 10] = 'no more used' & *top_uvalue[1, 10] = 9999
*top_uvalue[0, 11] = 'noticebase' & *top_uvalue[1, 11] = 0l
*top_uvalue[0, 12] = 'extra' & *top_uvalue[1, 12] = ex
; variables refering to different files we can read
*top_uvalue[0, 13] = 'currentfile' & *top_uvalue[1, 13] = currentfile
*top_uvalue[0, 14] = 'filelist' & *top_uvalue[1, 14] = filelist
*top_uvalue[0, 15] = 'fileparameters' & *top_uvalue[1, 15] = fileparameters
*top_uvalue[0, 16] = 'readparameters' & *top_uvalue[1, 16] = readparameters
*top_uvalue[0, 17] = 'meshparameters' & *top_uvalue[1, 17] = meshparameters
; variables refering to different drawing we can do
*top_uvalue[0, 18] = 'penvs' & *top_uvalue[1, 18] = replicate(!p, nbredessin)
*top_uvalue[0, 19] = 'xenvs' & *top_uvalue[1, 19] = replicate(!x, nbredessin)
*top_uvalue[0, 20] = 'yenvs' & *top_uvalue[1, 20] = replicate(!y, nbredessin)
*top_uvalue[0, 21] = 'nameprocedures' & *top_uvalue[1, 21] = strarr(nbredessin)
*top_uvalue[0, 22] = 'types' & *top_uvalue[1, 22] = strarr(nbredessin)
*top_uvalue[0, 23] = 'varinfo' & *top_uvalue[1, 23] = strarr(2, nbredessin)
*top_uvalue[0, 24] = 'domaines' & *top_uvalue[1, 24] = fltarr(6, nbredessin)
*top_uvalue[0, 25] = 'dates' & *top_uvalue[1, 25] = lonarr(2, nbredessin)
*top_uvalue[0, 26] = 'txtcmd' & *top_uvalue[1, 26] = strarr(nbredessin)
*top_uvalue[0, 27] = 'optionsflag' & *top_uvalue[1, 27] = flag
*top_uvalue[0, 28] = 'exextra' & *top_uvalue[1, 28] = ptrarr(nbredessin, /allocate_heap)
;
widget_control, base, set_uvalue = top_uvalue
createhistory, base, smallin
;
ENDELSE
;------------------------------------------------------------
xmanager, 'xxx', base, /no_block
;------------------------------------------------------------
;------------------------------------------------------------
return
end