| Re: Compound Widgets [message #67789 is a reply to message #13082] |
Mon, 31 August 2009 07:08   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Bill writes:
> I've been creating my own widgets sucessfully for a while but want
> to leverage existing compound widgets for common tasks (duh). My
> problem is I do not understand how to incorporate them into my
> applications -- for example, I would like to use the cw_light_editor.
>
> I add it to a base widget (triggered by a menu event):
>
> Pro edit_lighting, event
>
> ;Retreive pointer to structure of parameters to be passed between
> events
> Widget_Control, event.top, GET_UVALUE=info
>
> ;Create base widget for light editor
> lightingBase=Widget_Base(COLUMN=1, TITLE='Lighting', GROUP_LEADER=
> (*info).tlb, UNAME='lightingBase')
>
> ;Create compound widget, add my light object
> lightEditor = cw_light_editor(lightingBase, light=(*info).oLight0)
>
> ;Realize the base/compound widget
> Widget_Control, lightingBase, /REALIZE
>
> End
>
> My light object is simply:
>
> ;Create light object (oLight0 is added to the parameter structure)
> oLight0 = Obj_New('IDLgrLight')
>
> ;Set some properties
> oLight0->SetProperty, $
> INTENSITY= 0.500000, $
> LOCATION= [10.0000000, 10.0000000, 20.0000000], $
> TYPE= 2 ;Directional
>
> ;Add the light to my model object
> oModel->Add, oLight0
>
> When I run this, my application freezes and IDL throws a fatal error.
>
> What am I doing wrong? I've looked at the xdice.pro example and David
> Fanning's book, but still can't figure out what is going on.
I don't know. I had to add an XMANAGER to your code to get
the Light Editor to work on my Windows machine. It doesn't
freeze or throw a fatal error. Of course, it doesn't update
the display as I finagle the lights, but I pretty much
expected that. I have to cause an event in my main application
to make the change "take". But it does seem to do that.
One alternative, I guess, would be to use the CW_Light_Control
compound widget you can find embedded into FSC_Surface:
http://www.dfanning.com/programs/fsc_surface.pro
It is not as sophisticated as the ITTVIS one, but it does
give you the ability to turn lights on/off, set the intensity,
and change their color. And the events can propagate to the
"parent" so that updates are instantaneous.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|