| Re: IDLgrPlot and Widget event [message #54212 is a reply to message #54140] |
Sat, 26 May 2007 07:12   |
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
|
|
|
|