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

Home » Public Forums » archive » Button_events and data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Button_events and data [message #11179 is a reply to message #10980] Wed, 25 February 1998 00:00 Go to previous message
David L. Windt is currently offline  David L. Windt
Messages: 9
Registered: June 1997
Junior Member
<HTML>
&nbsp;

<P>Bernard Puc wrote:
<BLOCKQUOTE TYPE=CITE>Hello,

<P> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; I'm looking for pointers
on how to do the following:&nbsp; I have a line
<BR>plot in a draw widget.&nbsp; I want to click the pointer on the plot
and have
<BR>a vertical line drawn at the nearest datapoint to the mouseclick.
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; widget_draw returns the
cursor location in device coordinates and I
<BR>need to translate that into dataspace coordinates.
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Going one step further,
ideally, I'd like to have a vertical line
<BR>follow the cursor around the draw widget at all times, jumping from
<BR>datapoint to datapoint.&nbsp; I suspect someone has already written
such a
<BR>thing...

<P>Any help appreciated.

<P>-Bernard Puc
<BR>puc@gsfc.nasa.gov</BLOCKQUOTE>
&nbsp; Assuming you're plotting X vs Y, and have captured a draw widget
event
<BR>called EVENT...

<P>You can use CONVERT_COORD to first convert the draw widget event to
<BR>data coordinates:

<P>CC=CONVERT_COORD(EVENT.X,EVENT.Y,/DEVICE,/TO_DATA)

<P>You might then try my VALUE_TO_INDEX function to get the x data index
<BR>corresponding to the x value closest to the widget event (i.e., the
<BR>mouse click):

<P>X_INDEX=VALUE_TO_INDEX(X,CC(0))

<P>and then plot the vertical line using PLOTS:

<P>PLOTS,[0,0]+X(X_INDEX),!Y.CRANGE

<P>(Or if you like, this can all be done in one line, as in:
<BR>PLOTS,[0,0]+ $
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X(VALUE_TO_INDEX(X,(CONVERT_COORD(EVENT.X,EVENT.Y,
$
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
/DEVICE,/TO_DATA))(0))), $
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !Y.CRANGE
<BR>)

<P>To have a vertical line that follows the mouse around will require
<BR>a bit more work, but it could make use of the same methods as above.

<P>VALUE_TO_INDEX, as well as all my other thrilling idl programs can be
<BR>found at <A HREF="http://www.bell-labs.com/user/windt/idl">www.bell-labs.com/user/windt/idl</A>.&nbsp;
In particular, you might
<BR>also be interested in TRACK_PLOT - it doesn't draw lines, but it
<BR>provides live X and Y values in a text widget as you move the mouse
<BR>over an x,y plot.&nbsp; It might make a reasonable starting point for
<BR>doing what you want to do with vertical lines.

<P>David Windt
<BR>windt@bell-labs.com
<BR>&nbsp;</HTML>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: read a .PCD file
Next Topic: How much for new PV-WAVE package for Win95.

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

Current Time: Sat Nov 29 08:10:13 PST 2025

Total time taken to generate the page: 0.00952 seconds