On Feb 1, 1:48 pm, Gray <grayliketheco...@gmail.com> wrote:
> On Feb 1, 7:02 am, vanessa_c <cjncvc2...@gmail.com> wrote:
>
>
>
>
>
>> I am trying to create a widget using the new IDL 8 plot function and
>> widget_window. I'd like to be able to display different plots in the
>> widget window and each time I choose a different menu button, have a
>> fresh plot appear. I am using /current to make each plot appear in
>> the same widget window. However, I'm having trouble with the plots
>> simply being plotted over each other within the graphics window. I've
>> played around with using /overplot but I don't think it helps because
>> I need to have multiple plots on the screen. There isnt this problem
>> when I use the old graphics (widget_draw), with the code not very
>> different to the one I am using now. Perhaps I am missing something
>> that clears the current plot?
>
>> Thanks.
>
>> PRO
>> barebones_event, ev
>> WIDGET_CONTROL, ev.id, GET_UVALUE = uval
>> WIDGET_CONTROL, ev.top, GET_UVALUE = state
>> case uval of
>> 'menu1': BEGIN
>> ; Retrieve the newly-created Window object.
>> WIDGET_CONTROL
>> , state.Draw, GET_VALUE = graphicWin
>> ; Make sure this is the current window
>> graphicWin.
>> SELECT
>> p=
>> plot([0,10],[5,5],title='plot1',/current,yrange=[0,6],layout =[2,2,1])
>> p=
>> plot([0,10],[5,5],title='plot1',/current,yrange=[0,6],layout =[2,2,4])
>> END
>> 'menu2': BEGIN
>> WIDGET_CONTROL
>> , state.Draw, GET_VALUE = graphicWin
>> ; Make sure this is the current window
>> graphicWin.
>> SELECT
>> p2=
>> plot([0,10],[15,15],title='plot2',/
>> current,yrange=[0,20],layout=[2,2,2])
>> p2=
>> plot([0,10],[15,15],title='plot2',/
>> current,yrange=[0,6],layout=[2,2,4])
>> END
>> ;buttons
>> 'Cancel': WIDGET_CONTROL, ev.top, /DESTROY
>
>> ELSE :
>> ENDCASE
>> WIDGET_CONTROL, state.base, SET_UVALUE = state
>> END
>
>> PRO
>> barebones
>> ; menu bar widget
>> base =
>> WIDGET_BASE(MBAR=bar, TITLE='test', row = 1)
>> menu1 =
>> WIDGET_BUTTON(bar, VALUE='menu', UVALUE='menu', /MENU)
>> men1but1 =
>> WIDGET_BUTTON(menu1, VALUE='menu1', UVALUE='menu1')
>> men1but2 =
>> WIDGET_BUTTON(menu1, VALUE='menu2', UVALUE='menu2')
>> draw = WIDGET_WINDOW(base, UVALUE='draw', UNAME='DRAW')
>> bbase =
>> WIDGET_BASE(base, column = 1, frame =1, title = 'OPTIONS')
>> bsize =
>> 75
>> buttb =
>> widget_button(bbase, value = 'Cancel', uvalue = 'Cancel', $
>> xsize = bsize, /align_center, yoffset =
>> 30)
>
>> DEVICE, decomposed=0
>> state = { base:base, $
>> draw:draw $
>
>> }
>
>> WIDGET_CONTROL, base, SET_UVALUE = state
>> WIDGET_CONTROL, base, /REALIZE
>> XMANAGER, 'barebones', base
>> END
>
> I think what you want is the p.hide property.- Hide quoted text -
>
> - Show quoted text -
thanks, but I am not sure that will help. I have shown a simplified
version of my program here. I actually call other functions from the
menu buttons and I guess I want the function to make sure that if
there is something already plotted in the widget space then it clears
it and starts a fresh plot. I use widget_control, draw, get_value=win
then win.select to plot in the current window. Is there anything that
I can use here to clear the current plot? I have tried win.refresh.
|