Hi,
I would appreciate any idea on how to detect a mouseover when the user hover the mouse pointer over any part of a plot.
To draw the plot, I'm drawing lines from point to point so a solution based on comparing the mouse position and the points would leave out the hovering over the connecting lines.
I then tried using wxDC::GetPixel. It solves the problem of detecting any part of the plot but I have to call refresh to make something happen (show coordinates)
Thanks
Plotting and mouseover
Re: Plotting and mouseover
Would it? You have an equation for the lines, do you not? You pretty much have to in order to draw them.kayamel wrote:Hi,
I would appreciate any idea on how to detect a mouseover when the user hover the mouse pointer over any part of a plot.
To draw the plot, I'm drawing lines from point to point so a solution based on comparing the mouse position and the points would leave out the hovering over the connecting lines.
So, something like:
Code: Select all
if (abs(eq(pt.x) - pt.y) <= hit_tolerance)
Hi,
No I don't plot a function actually.
I'm taking a data file with columns of x and y's and just plot them.
Unless there is some preset function in wxWidgets or anything else, I don't think I'll take the pain of developing something to try and get all the points by which a line passes. Also I'll have to apply it on every segment between every two points. Only then would I be able to make the hit check. Which would leave me with still having to call refresh constantly if I want the coordinates to pop-up automatically
No I don't plot a function actually.
I'm taking a data file with columns of x and y's and just plot them.
Unless there is some preset function in wxWidgets or anything else, I don't think I'll take the pain of developing something to try and get all the points by which a line passes. Also I'll have to apply it on every segment between every two points. Only then would I be able to make the hit check. Which would leave me with still having to call refresh constantly if I want the coordinates to pop-up automatically
Ok, I gave this a thought and I have come to a problem :
If I have two points that have adjacent x coordinates but very different y coordinates (or vice versa), the screen display would approximate the segment with a few horizontal or vertical lines.
In real math, I would get fractional coordinates for the points in between but that won't be the case with pixels. Just rounding up the results is not guaranteed to give me the same display as on the screen.
If I have two points that have adjacent x coordinates but very different y coordinates (or vice versa), the screen display would approximate the segment with a few horizontal or vertical lines.
In real math, I would get fractional coordinates for the points in between but that won't be the case with pixels. Just rounding up the results is not guaranteed to give me the same display as on the screen.
Yes, you need to do some scaling and rounding to find the pixels. Furthermore, you probably don't actually want only those pixels in the line but to be within some margin of error. Otherwise you make it too difficult to grab the line.kayamel wrote:Ok, I gave this a thought and I have come to a problem :
If I have two points that have adjacent x coordinates but very different y coordinates (or vice versa), the screen display would approximate the segment with a few horizontal or vertical lines.
In real math, I would get fractional coordinates for the points in between but that won't be the case with pixels. Just rounding up the results is not guaranteed to give me the same display as on the screen.
It seems to me that what you need is indeed the point/slope formula but you just need to do more work to translate that then maybe you know how to do? Anyway, this is a problem that's independent of GUI framework; I don't think you'll find anything in wx that will do it for you.