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

Home » Public Forums » archive » passing values to cw_fslider
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
passing values to cw_fslider [message #58868] Thu, 21 February 2008 12:18
astroboy2k is currently offline  astroboy2k
Messages: 34
Registered: July 2007
Member
Hello.

I'm trying to write a program in which changes in the quantity
associated with one widget are reflected in the values of other
widgets, and I am at a loss to do this. In fact, I'm not sure it even
can be done.

In the example below, I have slider widgets for mass, volume, and
density. If I change the volume slider, the mass is held constant and
a new value for the density is calculated. Etc.

The new values for volume, mass, and density are stored in the info
structure correctly, it seems. However, the position of the other two
sliders are not changed.

Is there anyway to do this? I really am stumped on this one.

Thanks,

Mark











;---------------------------------------------------------
pro pro_1, event
;change volume and density, mass remains constant
widget_control,event.top,get_uvalue=pinfo

density = event.value
volume = (*pinfo).mass/density

(*pinfo).density =density
(*pinfo).volume =volume

sub_print,pinfo
widget_control, event.top, set_uvalue=pinfo

end

;---------------------------------------------------------
pro pro_2, event
;change volume and density, mass remains constant
widget_control,event.top,get_uvalue=pinfo

volume =event.value
density =(*pinfo).mass/volume

(*pinfo).density =density
(*pinfo).volume =volume

sub_print,pinfo
widget_control, event.top, set_uvalue=pinfo

end


;---------------------------------------------------------
pro pro_3, event
;change mass, density remains constant
widget_control,event.top,get_uvalue=pinfo

mass = event.value
volume = mass/(*pinfo).density

(*pinfo).mass =mass
(*pinfo).volume =volume

sub_print,pinfo
widget_control, event.top, set_uvalue=pinfo

end

;---------------------------------------------------------
pro sub_print,pinfo
print,''
print,'density = ',(*pinfo).density
print,'volume = ',(*pinfo).volume
print,'mass = ',(*pinfo).mass

end


;*********************************************************** ********************************
;*********************************************************** ********************************

pro junk,xxx

;the idea here is you have three widgets for mass, volume, and density
;if you slide one, the values for the other two change.
;I'd like to have the position of the sliders in the widgets change to
reflect the
;new values....




tlb =widget_base(title='JUNK PROGRAM',column=1,
mbar=menubaseid)
drawid =widget_draw(tlb,xsize=600,ysize=400)

slide_00 =widget_base(tlb,row=4)

slide_dens = widget_base(slide_00,event_pro='pro_1')
fslide_dens = cw_fslider(slide_dens,value=5.,min=0.1,
max=10.,title='DENSITY: gm/cc')

slide_vol = widget_base(slide_00,event_pro='pro_2')
fslide_vol = cw_fslider(slide_vol,value=8.,min=0.1,
max=10.,title='volume: cm-cubed')

slide_mass = widget_base(slide_00,event_pro='pro_3')
fslide_mass = cw_fslider(slide_mass,value=40.,min=0.1,
max=100.,title='mass: grams')



widget_control, tlb,/realize
widget_control, drawid, get_value=window


info ={ drawid:drawid, $
window:window, $
volume :5., $
density :8., $
mass :40. }

pinfo=ptr_new(info)


;none of this seems to work
widget_control,fslide_dens,get_uvalue=density
widget_control,fslide_vol, get_uvalue=volume
widget_control,fslide_mass,get_uvalue=mass

;widget_control,fslide_dens,get_uvalue=(*pinfo).density
;widget_control,fslide_vol, get_uvalue=(*pinfo).volume
;widget_control,fslide_mass,get_uvalue=(*pinfo).mass


widget_control,fslide_dens,set_uvalue=(*pinfo).density
widget_control,fslide_vol, set_uvalue=(*pinfo).volume
widget_control,fslide_mass,set_uvalue=(*pinfo).mass

;end of non-working code



wset,(*pinfo).window
plot, findgen(10)


widget_control,tlb, set_uvalue=pinfo




xmanager,'junk_manager',tlb,/no_block



return
end
[Message index]
 
Read Message
Previous Topic: New netCDF Browser
Next Topic: question: IDL for incorporating text files in hyperspectral band math

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

Current Time: Wed Oct 08 18:18:31 PDT 2025

Total time taken to generate the page: 0.00378 seconds