comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL 8 NG widget problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL 8 NG widget problem [message #74728] Tue, 01 February 2011 04:02 Go to next message
vanessa_c is currently offline  vanessa_c
Messages: 1
Registered: February 2011
Junior Member
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
Re: IDL 8 NG widget problem [message #74790 is a reply to message #74728] Wed, 02 February 2011 00:21 Go to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 2 fév, 01:18, Chris Torrence <gorth...@gmail.com> wrote:
> On Feb 1, 9:22 am, caroline cox <caroline.co...@gmail.com> wrote:
>
>
>
>> 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.
>
> Hi,
>
> In IDL 8.1 we are adding a "Delete" method to the new graphics - it
> will delete just that graphic. We are also adding a GetData/SetData
> method, so you can change the data on an existing graphic (like a
> Plot) and all of the properties will stay the same.
>
> For now, in IDL 8.0, you can use the undocumented "PutData" method:
>   p = plot(/test)
>   p.PutData, findgen(2,100)
> The first column is the X values, and the second is the Y values.
>
> Hope this helps!
>
> -Chris
> ITTVIS

The question is how a NG Window can be cleared.
Before last message from Chris Torrence, I was thinking to draw, just
before your plot in each menu branch, a white image, i.e.:
p=image(bytarr(graphicWin.DIMENSIONS)+255B,/DEVICE,/CURRENT)
Not very elegant, but it seems to work.
No help, of course, from the present ITTVIS documentation, which is
our main problem !
alx.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Contour Plot w/ Colorbar
Next Topic: idl -vm and args / full idl and args

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:52:32 PDT 2025

Total time taken to generate the page: 0.00491 seconds