[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Communication between different widget bases
- Subject: Re: Communication between different widget bases
- From: davidf(at)dfanning.com (David Fanning)
- Date: Fri, 2 Mar 2001 11:17:39 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <CxQn6.6680$JG.864426@news.shore.net>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23824
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}
END
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
ENDIF ELSE BEGIN
info.iplot = Intensity_Plot(time, intensity, Group_Leader=event.top)
ENDELSE
You might even want to close the pop-up window
for some reason:
Widget_Control, info.iplot.tlb, /Destroy
Cheers,
David
--
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