2 Attachment(s)
How to use QwtPlotPicker to track some selected points?
Hello,
I have posted a lot and I got a lot of help here. I need another one. I'm plotting graphs with dotted line and tracking using QwtPlotPicker, but it tracks the plot area and I would like to track only some selected points. My code to track the whole area is:
Code:
plot->canvas());
picker
->setRubberBandPen
(QColor(Qt
::darkMagenta));
picker
->setRubberBand
(QwtPicker::CrossRubberBand);
picker
->setTrackerPen
(QColor(Qt
::green));
As I said, this code tracks the whole plotting area and I want to track just some points that I have saved in my QVector. For example, the draw below is showing the picker tracking some part of the plotting area and showing the x and y axis value:
Attachment 7476
And I would like to show the value according by the points that I have, the tracking would show something just when the mouse is on the place that the point is equal to some point of my vector. I have the line and the dots, the dots are my values, when the user pass the mouse on a dot the picker would show the value:
Attachment 7477
Is it possible to enable the picker just for some points? If yes, someone can help me giving me a tipp, I have no idea how to set the picker to track just some selected points.
Thanks in advance
Best Regards
Re: How to use QwtPlotPicker to track some selected points?
Not out of a box.
You could use closestPoint() but that's prone to errors.
But you can easily implement something like that yourself.
For example - install event filter on the canvas, on mouse move transform cursor screen position to the canvas coordinates, see if any point in your vector is at that position (or close enough) and if it is - display whatever you want.
Re: How to use QwtPlotPicker to track some selected points?
Thanks Spitfire, I implemmented as you said and it's working. But it's not enough for what I wanted.
The problem is that I have a lot of points, and when I have this verification while I'm moving the mouse, the tracking gets slow.
And there is another problem that I don't know how to solve, my values are sometimes like -0.0020001201 and when I use invTransform the values that I get from the x and y axis are not gonna be equal my values, and I need to check if they are equal and not just close, because the user has to know the exactly value of one point.
Did you understand what I mean?
If you have any idea, please tell me, I'm out of ideas right now.
thanks
Re: How to use QwtPlotPicker to track some selected points?
Quote:
Originally Posted by
cesroc
Thanks Spitfire, I implemmented as you said and it's working. But it's not enough for what I wanted.
The problem is that I have a lot of points, and when I have this verification while I'm moving the mouse, the tracking gets slow.
closestPoint() is not "prone to errors" - but slow. It iterates over all curves an all points. So what you have to do is to implement a faster lookup using the characteristics of your data ( f.e if they are in increasing x order ) or by introducing some sort of spatial index - like f.e. a quadtree.
Quote:
Originally Posted by
cesroc
And there is another problem that I don't know how to solve, my values are sometimes like -0.0020001201 and when I use invTransform the values that I get from the x and y axis are not gonna be equal my values, and I need to check if they are equal and not just close, because the user has to know the exactly value of one point.
Your screen is a matrix of pixels ( f.e 1280x1024 ) and a mouse click is a position in integer coordinates !
Uwe
Re: How to use QwtPlotPicker to track some selected points?
I appologize for 'prone to errrors'.
I ment that if you're looking for point along Y axis closes to the mouse cursor then closestPoint() won't work, which is what the OP has asked for.
Mea culpa.
cesroc
And how it is slow? How many points we're talking about?
Re: How to use QwtPlotPicker to track some selected points?
Hello Spitfire,
In the best case around 70.000, but when I add all curves it's more than 1.000.000.
I had another idea, but I'm not sure yet if it's gonna work and help me.
I was thinking about scan only the x-axis and based on the x-axis I get the index to get the closest y-axis and then jump the marker to the closest point to make easier for the user.
What do you think? Possible? Would it be faster?
Thanks for helping me
Re: How to use QwtPlotPicker to track some selected points?
Because in my approach every point (and there's up to 20M on the plot at a time) after some calculations can be converted to an index in the data set finding actual values is fast an easy but I don't know if it would work for you.
Any chance you could get me a file with example of your data (70k+)?
I wonder how my approach would work with it, and if it would I could share some code with you.