;+ ; GRAFF_FUNCT ; Define a function to graffer. ; ; Usage: ; graff_funct, pdefs ; ; Argument: ; pdefs struct in/out The Graffer plot structure ; ; History: ; Original: 6/8/95; SJT ; Add timer event to push to front if obscured: 23/8/95; SJT ;- function Funct_event, event widget_control, event.id, get_uvalue = but iexit = 0 funct = '' numpts = 0 range = fltarr(2) case but of 'ACTION': begin if (event.value eq 1) then begin widget_control, event.handler, get_uvalue = uvs, /no_copy widget_control, uvs.fid, get_value = funct widget_control, uvs.nid, get_value = numpts widget_control, uvs.minid, get_value = rng range(0) = rng widget_control, uvs.maxid, get_value = rng range(1) = rng endif iexit = event.value end 'POP': begin widget_control, event.top, /show widget_control, event.id, timer = 2. end endcase return, {id:event.id, top:event.top, handler:event.handler, $ Exited:iexit, funct:funct, numpts:numpts, range:range} end pro Graff_funct, pdefs, y_funct=y_funct uvs = { $ Fid: 0l, $ Nid: 0l, $ Minid: 0l, $ Maxid: 0l $ } ; Find if the dataset is already defined as a function handle_value, pdefs.data, data, /no_copy handle_value, data(pdefs.cset).xydata, xydata, /no_copy if (data(pdefs.cset).type eq -1 or data(pdefs.cset).type eq -2) then begin funct = xydata.funct range = xydata.range numpts = data(pdefs.cset).ndata dflag = 0b endif else begin funct = '' range = fltarr(2) numpts = 25 dflag = (data(pdefs.cset).ndata gt 0) endelse widget_control, pdefs.ids.graffer, sensitive = 0 tlb = widget_base(title = 'Graffer Function Plot', group_leader = $ pdefs.ids.graffer) base = widget_base(tlb, /column) ; The actual function definition if (dflag) then $ junk = widget_text(base, xsize = 50, ysize = 4, value = $ ['CURRENT DATA SET IS XY DATA OR A', $ 'PARAMETRIC FUNCTION ENTERING A', $ 'FUNCTION WILL OVERWRITE IT', $ 'USE "CANCEL" NOW TO KEEP IT' $ ] $ ) uvs.fid = graff_enter(base, /no_event, xsize = 40, value = funct, label $ = 'Function:') ; X axis range if (keyword_set(y_funct)) then ax = 'Y' $ else ax = 'X' rgb = widget_base(base, /row, uvalue = 'POP') uvs.minid = graff_enter(rgb, /no_event, /float, xsize = 10, uvalue = $ 'MIN', value = range(0), format = "(g10.3)", $ label = ax+' axis range: Min:') uvs.maxid = graff_enter(rgb, /float, /no_event, xsize = 10, uvalue = $ 'MAX', value = range(1), format = "(g10.3)", $ label = ' Max:') ; Number of points uvs.nid = graff_enter(base, /int, /no_event, xsize = 5, uvalue = $ 'NUM', value = numpts, format = "(I0)", $ label = 'Number of X values:') ; Control junk = cw_bgroup(base, ['Do it', 'Cancel'], /row, uvalue = 'ACTION', $ button_uvalue = [1, -1]) ; Realise and do RYO event handling widget_control, tlb, /real widget_control, base, set_uvalue = uvs, event_func = 'funct_event', $ /no_copy widget_control, rgb, timer = 2. repeat begin ev = widget_event(base) endrep until (ev.exited ne 0) widget_control, tlb, /destroy widget_control, pdefs.ids.graffer, sensitive = 1 if (ev.exited eq -1) then begin ; The DONT button handle_value, data(pdefs.cset).xydata, xydata, /no_copy, /set handle_value, pdefs.data, data, /no_copy, /set return endif xydata = {range:ev.range, funct:ev.funct} data(pdefs.cset).ndata = ev.numpts if (keyword_set(y_funct)) then data(pdefs.cset).type = -2 $ else data(pdefs.cset).type = -1 handle_value, data(pdefs.cset).xydata, xydata, /no_copy, /set handle_value, pdefs.data, data, /no_copy, /set end