pro mg_xplot_doplot, pstate
compile_opt strictarr
wset, (*pstate).drawID
plot, *(*pstate).x, *(*pstate).y, linestyle=(*pstate).linestyle, xstyle=1
end
pro mg_xplot_ls, event
compile_opt strictarr
widget_control, event.top, get_uvalue=pstate
(*pstate).linestyle = event.index
mg_xplot_doplot, pstate
end
pro mg_xplot_cleanup, tlb
compile_opt strictarr
widget_control, tlb, get_uvalue=pstate
ptr_free, (*pstate).x, (*pstate).y, pstate
end
pro mg_xplot, x, y, xsize=xsize, ysize=ysize
compile_opt strictarr
case n_params() of
0 : begin
_x = findgen(360) * !dtor
_y = sin(_x)
end
1 : begin
_y = x
_x = findgen(n_elements(_y))
end
2 : begin
_x = x
_y = y
end
endcase
_xsize = n_elements(xsize) eq 0 ? 500 : xsize
_ysize = n_elements(ysize) eq 0 ? _xsize / 1.62 : ysize
tlb = widget_base(title='Plot GUI', /column)
draw = widget_draw(tlb, xsize=_xsize, ysize=_ysize)
plottingOptions = widget_base(tlb, /row)
linestyles = ['solid', 'dotted', 'dashed', 'dash dot', 'dash dot dot', $
'long dashes']
linestyleDrop = widget_droplist(plottingOptions, value=linestyles, $
title='Linestyle', event_pro='mg_xplot_ls')
widget_control, tlb, /realize
widget_control, draw, get_value=drawID
state = { drawID: drawID, $
x: ptr_new(_x, /no_copy), $
y: ptr_new(_y, /no_copy), $
linestyle: 0L $
}
pstate = ptr_new(state, /no_copy)
widget_control, tlb, set_uvalue=pstate
mg_xplot_doplot, pstate
xmanager, 'mg_xplot', tlb, /no_block, cleanup='mg_xplot_cleanup'
end