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

Home » Public Forums » archive » Re: Line-Mouse widget tool
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: Line-Mouse widget tool [message #43256 is a reply to message #43234] Tue, 29 March 2005 14:42 Go to previous message
Robert Barnett is currently offline  Robert Barnett
Messages: 70
Registered: May 2004
Member
David,

I render a direct graphics plot onto a widget_draw.
How do you transform a mouse click event which is specified in pixels to
data-space when using direct graphics? I can compute it from the
xmargin, ymargin, xtick_get, ytick_get, xsize and ysize. But, surely
there must be an easier way?

Here is an excerpt from my code:

; ev - The event struct
; draw_id - The Widget_Draw
; return_kewyords - Keywords returned from plot

xcharsize = 6.0
ycharsize = 10.0

geometry = widget_info(self.draw_id, /geometry)

; Calculate the corresponding x,y value coordinate on the plot
evx = ev.x - xmargin[0] * xcharsize
evy = ev.y - ymargin[0] * ycharsize
evwidth = geometry.xsize - total(xmargin) * xcharsize
evheight = geometry.ysize - total(ymargin) * ycharsize

xtickget = *return_keywords.xtick_get
ytickget = *return_keywords.ytick_get

xmaxtick = N_ELEMENTS(xtickget) - 1
ymaxtick = N_ELEMENTS(ytickget) - 1
x = xtickget[0] + (xtickget[xmaxtick] - xtickget[0]) * evx / evwidth
y = ytickget[0] + (ytickget[ymaxtick] - ytickget[0]) * evy / evheight

return, [x, y]




David Fanning wrote:

> Howard S. Cohl writes:
>
>
>> Oh, one more thing, if it's not too difficult, is to build into the
>> widget the capability to use curved line segments (splines, or polynomials
>> perhaps) as well as straight lines and be able to output either the
>> equation of the curve or output a the numerical set of N values for the
>> curved line segment.
>>
>
> Oh, well, a little more than an hour, then. :-)
>
> Cheers,
>
> David
>
>


--

nrb@
Robbie Barnett
imag
Research Assistant
wsahs
Nuclear Medicine & Ultrasound
nsw
Westmead Hospital
gov
Sydney Australia
au
+61 2 9845 7223
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: idl images and EXIF header
Next Topic: Line-Mouse widget tool

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

Current Time: Sat Oct 11 02:17:37 PDT 2025

Total time taken to generate the page: 0.40399 seconds