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

Home » Public Forums » archive » IDLgrPlot and Widget event
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDLgrPlot and Widget event [message #54140] Fri, 25 May 2007 08:16 Go to next message
Laurens is currently offline  Laurens
Messages: 41
Registered: May 2006
Member
Hi All,

After much irritation from not being able to write a universal class for
drawing every kind of curve, (as usual) David's suggestion to me a few
months ago did the trick;

All measures are normalized to 0->1 so Axis, Curve/Plot and Symbols, all
are scaled to that 0-> scale; the curve draws fine.

Now, I am catching the MOTION event from the mouse cursor; I want to
have something like a crosshair to accentuate the position of the mouse
cursor (see link for example img).
Catching the event and drawing the polylines almost goed well, except
for the fact that I don't seem to be able to position the lines at the
right place. I guess this has to do since the event.x delivers me the
pixel-position on the widget, say 98. But 98 is a bit tough to fit onto
a scale of 0->1.

So the actual question: how do I get from an event.x or event.y to a
position in my normalized plot?

Code I now have:

============================================================ ==
*xAxis->GetProperty, CRange=xrange
*yAxis->GetProperty, CRange=yrange

self.View->GetProperty, VIEWPLANE_RECT = viewplane

position = [0.20, 0.15, 0.925, 0.925]

xs = Normalize(xrange, Position=[position[0], position[2]])
ys = Normalize(yrange, Position=[position[1], position[3]])

; Scale the plot data and axes into 0->1.

*(xLine)->SetProperty, XCoord_Conv=xs
*(yLine)->SetProperty, YCoord_Conv=ys

fraction = 1 ; ??? <-- how to get something useful here...

scaledX = mean( event.x )
scaledY = mean( fraction * event.y )

; Plot lines
*(xLine)->SetProperty, Color=self->Get("Ccrosshair"), Thick=1,
DATA=[[scaledX, yrange[0], 0], [scaledX, yrange[1], 0]]

*(yLine)->SetProperty, Color=self->Get("Ccrosshair"), Thick=1,
DATA=[[xrange[0], scaledY, 0], [xrange[1], scaledY, 0]]
============================================================ ====

Look at the img to get my point:
http://sophorus.mine.nu/idlgrplot_cursorpos.jpg


If someone with a fresh mind has any suggestions: please...

Thanks a bunch..

Laurens
Re: IDLgrPlot and Widget event [message #54212 is a reply to message #54140] Sat, 26 May 2007 07:12 Go to previous message
Laurens is currently offline  Laurens
Messages: 41
Registered: May 2006
Member
David Fanning wrote:
> Laurens writes:
>
>> After much irritation from not being able to write a universal class for
>> drawing every kind of curve, (as usual) David's suggestion to me a few
>> months ago did the trick;
>>
>> All measures are normalized to 0->1 so Axis, Curve/Plot and Symbols, all
>> are scaled to that 0-> scale; the curve draws fine.
>>
>> Now, I am catching the MOTION event from the mouse cursor; I want to
>> have something like a crosshair to accentuate the position of the mouse
>> cursor (see link for example img).
>> Catching the event and drawing the polylines almost goed well, except
>> for the fact that I don't seem to be able to position the lines at the
>> right place. I guess this has to do since the event.x delivers me the
>> pixel-position on the widget, say 98. But 98 is a bit tough to fit onto
>> a scale of 0->1.
>>
>> So the actual question: how do I get from an event.x or event.y to a
>> position in my normalized plot?
>
> Unless I am missing something terribly obvious, don't you
> just divide the point by the size of the window in pixels
> to get the normalized location?
>
> dims = oWindow -> GetDimensions()
> xNormal = event.x / Float(dims[0])
> yNormal = event.y / Float(dims[1])
>
> Cheers,
>
> David
grrrr, You're not the one who is missing the obvious :) Though it's not
an exact match to what I need (there seems to be some difference in
y-direction, but I guess that's because the curve is smaller than the
viewplane...
Anyhow; thanks mate ;)

Cheers, Laurens
Re: IDLgrPlot and Widget event [message #54237 is a reply to message #54140] Fri, 25 May 2007 09:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Laurens writes:

> After much irritation from not being able to write a universal class for
> drawing every kind of curve, (as usual) David's suggestion to me a few
> months ago did the trick;
>
> All measures are normalized to 0->1 so Axis, Curve/Plot and Symbols, all
> are scaled to that 0-> scale; the curve draws fine.
>
> Now, I am catching the MOTION event from the mouse cursor; I want to
> have something like a crosshair to accentuate the position of the mouse
> cursor (see link for example img).
> Catching the event and drawing the polylines almost goed well, except
> for the fact that I don't seem to be able to position the lines at the
> right place. I guess this has to do since the event.x delivers me the
> pixel-position on the widget, say 98. But 98 is a bit tough to fit onto
> a scale of 0->1.
>
> So the actual question: how do I get from an event.x or event.y to a
> position in my normalized plot?

Unless I am missing something terribly obvious, don't you
just divide the point by the size of the window in pixels
to get the normalized location?

dims = oWindow -> GetDimensions()
xNormal = event.x / Float(dims[0])
yNormal = event.y / Float(dims[1])

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Using colorbar with multiple plots and !p.multi
Next Topic: Anyone using IUE software library in IDL?

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

Current Time: Wed Oct 08 11:43:44 PDT 2025

Total time taken to generate the page: 0.00539 seconds