Re: Widgets and contour plots [message #42191 is a reply to message #42165] |
Wed, 05 January 2005 05:10  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Clive Cook wrote:
> Hi,
>
> I am trying to write a widget program were buy passing the cursor over a
> contour plot a varying 2d plot changes according to the value where the
> cursor lies. I have a contour window with two boxes below that display the
> corresponding x and y values from the cursor location. So, i want to take
> the x value to produce a corresponding plot of the contour values against
> the y value.
>
> How do i take the x value and use that to generate a new plot?
>
Hi,
I'm not sure I completely understand what your needs are. In general, you can
transform your mouse location into data space location using CONVERT_COORD.
From there you have to have some way of 'getting' the interpolated values of
your contour for that location. You can use the well known Fanningistic
approach to storing valuable program info in the the top level base's UVALUE
property.
Is that close?
Ben
***START***
MyDrawEvent, ev
;get your valuable info
Widget_Control, ev.top, GET_UVALUE = info, /NO_COPY
;set the current device state to match the draw widget's
Widget_Control, ev.ID, GET_VALUE = winNum
Wset, winNum
;convert from cursor coords to data coords
xy = CONVERT_COORD(ev.x, ev.y, /DEVICE, /TO_DATA)
;pass your favorite routine to 'get' you contour data
theseContourValues = GetMyContourValues(info.ContourData, xy)
;set the current window to you other window for plotting
Widget_Control, info.myOtherDrawWidget, GET_VALUE = myOtherWinNum
Wset, myOtherWindowNumber
;plot 'contour values against the y value.'
Plot, XY[1], theseContourValues
;put your valuable info back in a safe place
Widget_Control, ev.top, SET_UVALUE = info, /NO_COPY
End ;myDrawEvent
****FINI***
|
|
|