[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Communication between different widget bases

Michael Baca (mbaca@bos.fti-net.com) writes:
> I have a program that allows the user to view a TVSCL of a data cube with
> intensity obtained at (x,y) position (rows/columsn) over time. Typically the
> user plots the intensity at all positions at a single slice in time, i.e.
> TVSCL, A(*,*,n). I would like to allow the user to open a new window that
> will show the intensity plot vs. time for the position under the mouse
> pointer. Regrettably, I have already used up all of the space in my current
> WIDGET_BASE and I do not have room to add another draw widget. I would like
> to open a new WIDGET_BASE with a draw widget that will change as the mouse
> moves over the image.
> Does anyone have any suggestions? Most of the work I have done before
> spawned new WIDGET_BASEs that ran independent of the original one. I can
> already pop up a plot of the point under the mouse after a mouse release
> event, but that's not what I had in mind. I want the plot to change as the
> user moves the mouse to new positions. Is there any way to have real-time
> communication between two widget bases?

I guess there would probably be a dozen different ways
to do this. But the simplest is to just write the pop-up
window as a function that returns information you are
interested in. For example, if you call the function 
from within a widget event handler, it might be written
like this:

  FUNCTION INTENSITY_PLOT, time, intensity, Group_Leader=gleader
     tlb = Widget_Base(Group_Leader=gleader)
     drawID = Widget_Draw(tlb, XSize=400, YSize=400)
     Widget_Control, tlb, /Realize
     Widget_Control, drawID, Get_Value=wid
     WSet, wid
     Plot, time, intensity
   RETURN, {tlb:tlb, drawID:drawID, wid:wid}

Suppose you have a field in the info structure
of your main program where you store this information:

   info.iplot = Intensity_Plot(time, intensity, Group_Leader=event.top)

Then, when you want to update the plot, all you have to
do it this:

IF Widget_Valid(info.iplot.drawID) THEN BEGIN
   WSet, info.iplot.wid
   Plot, time, intensity
   info.iplot = Intensity_Plot(time, intensity, Group_Leader=event.top)

You might even want to close the pop-up window
for some reason:

   Widget_Control, info.iplot.tlb, /Destroy


David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155