You have to translate your values into widget coordinates ( = pixel positions ) and compare them with the mouse position also in widget coordinates.
Don't forget, that a screen is only a raster device !
Uwe
You have to translate your values into widget coordinates ( = pixel positions ) and compare them with the mouse position also in widget coordinates.
Don't forget, that a screen is only a raster device !
Uwe
Hi Uwe,
Thanks for the reply. I actually did it here is what I did...
But still its not showing me anything on plot...unless I increase my EPS value to really big like 1.0e10 then whole plot shows me "good"Qt Code:To copy to clipboard, switch view to plain text mode
I would really appreciate your help.
Cheers,
Last edited by wysota; 15th April 2010 at 13:37. Reason: missing [code] tags
This value is the acceptable radius around the position of a translated point in screen geometries ( = number of pixels ). An integer between 0-5 might be useful but something like 1.0e-4 makes no sense.
Overload QwtPlotPicker::trackerText(const QPoint &) instead of QwtPlotPicker::trackerText(const QwtDoublePoint &) and remove the first transformation. The rest of your code snippet looks o.k for me - assuming, that pos1 is the parameter you got from QwtPlotPicker::trackerText(const QwtDoublePoint &).
Before you post the next time I recommend to insert a qDebug statement printing the mouse position and one of your transformed curve points to see if they are in the same coordinate system.
Uwe
I got your point about EPS 1.0-e4 after seeing the transform values I also did the changes you mentioned earlier but still the result is the same its showing me label everywhere on plot...
Here is the transform value and Mouse position..
Mouse position is: 15,159 Transform values are:17,42
Cheers,
At least both look like reasonable positions now. The x coordinate seems to match, but the y coordinate not: 42 means your point is 42 pixels below the top border of the canvas.
- Assuming your mouse is over the point: which value (42 or 159) is wrong ?
- What is the geometry of the canvas ( is one of the y values the distance from the bottom ? )
- Is the picker attached to the same y axis as your curve ?
Uwe
Last edited by Uwe; 15th April 2010 at 14:52.
Hi Uwe,
I just figured out the problem was for loop so I just removed the loop out of the program and used distance function of vectors to get the index of the value and now its showing me the labels (problem solved)...but as I am showing label on the basis of pixel coordinates so its really hard to see the label cursor has to be on exact pixel coordinates. I am using Xcross as symbol. Is there any way that I can see label whenever cursor comes to the symbol.
Also how can I perform zooming with pixel coordinates?
I really appreciate your help.
Cheers,
?????but as I am showing label on the basis of pixel coordinates so its really hard to see the label cursor has to be on exact pixel coordinates.
Setting EPS to 0.5 + symbol.size and you will have matches for the bounding rectangle of the cross. If you need exact compares with the shape of a symbol you could paint the symbol on a bitmap translate its center to the mapped curve point and compare the mouse position with the corresponding bit.I am using Xcross as symbol. Is there any way that I can see label whenever cursor comes to the symbol.
The only thing that need to be done in pixel coordinates is the point matching algo. I don't see a reason to do anything else in pixel coordinates.Also how can I perform zooming with pixel coordinates?
Your code should be like this:
UweQt Code:
{ QwtText text; if ( isNearToACurvePoint(pos) ); return text; }To copy to clipboard, switch view to plain text mode
hamid ghous (17th April 2010)
Thanks Uwe for your help..
Hi Uwe,
Here is what I was trying to say about zooming; I was performing simple zooming by using following code:
I am not after complicated zooming just the simple one.
But Now when I zoom in,it doesn't show me the label on the point. Any idea how can I do it...
Regards,
Read this thread and do the same for your zoomer ( QwtPlotZoomer is derived from QwtPlotPicker ).
Uwe
Where is this thread?
It starts at the beginning of this page and ends at the bottom - are you serious ?
Uwe
sorry forgot to mention ...pos1 is the parameter or position I am getting from QwtPlotPicker::trackerText(const QPoint &) now..
Bookmarks