Hello. Can you please tell whether you can use, qwt To make the something like this:
tr3.jpg
Ie when you click on the chart, find the Y coordinate of the curve?
Hello. Can you please tell whether you can use, qwt To make the something like this:
tr3.jpg
Ie when you click on the chart, find the Y coordinate of the curve?
no, you can't (without implementing that by yourself). a curve is basically a series of points. QwtPlotCurve can give you the nearest point to a specified coordinate.
If you want exactly the y-value for any x-value, you have to find the x coordinates x_left and x_right of the nearest points where your x0 is in the middle. the curve is a straight line between these two points. now you need the y-values y_left and y_right of these two points. Then you can calculate the y0 using some triangulation.
hth,
Felix
Thanks, connected Qwtpicker:
Qt Code:
myPlot->canvas()); int cp; cp = curv1->closestPoint(d_picker->trackerPosition()); psetInterval->setNum(cp); To copy to clipboard, switch view to plain text mode
I want to get the X coordinate in the label psetInterval. I tried all the signals picker, but psetInterval displayed an all-time, the number "1"Qt Code:
void TrendTop::UpdVizir() { int cp; cp = curv1->closestPoint(d_picker->trackerPosition()); psetInterval->setNum(cp); }To copy to clipboard, switch view to plain text mode
How can I fix it?
QwtPicker::trackerPosition is a point in widget - not in plot coordinates.
Instead use a picker with a QwtPickerClickPointMachine and connect to "QwtPlotPicker::selected( const QPointF &pos )"
Here you get the clicked point translated in plot coordinates - not some widget coordinate that is used for displaying the tracker text !
Also note that QwtPlotCurve::closestPoint returns the index of a point - not a plot coordinate !
Uwe
oddytz1989 (14th February 2012)
I corrected:
But anyway, nothing has changed.Qt Code:
myPlot->canvas()); d_picker->setStateMachine(picker_m); To copy to clipboard, switch view to plain text mode
Of course not - how should it work, when you throw away the coordinate of the selected signal and connect it to the same wrong UpdVizir slot.
Uwe
Could you tell what I need to fix?
Qt Code:
To copy to clipboard, switch view to plain text mode
Qt Code:
void TrendTop::UpdVizir() { int cp; cp = curv1->closestPoint(d_picker->trackerPosition()); psetInterval->setNum(cp); }To copy to clipboard, switch view to plain text mode
Sorry I wrote nonsense of course QwtPlotCurve::closestPoint want a point in widget coordinates. You have to write something like this:
andQt Code:
To copy to clipboard, switch view to plain text mode
Qt Code:
{ if ( points.size() != 1 ) return; // should never happen for point selections double dist; int index = curv1->closestPoint( points[0], &dist ); if ( index >= 0 && dist <= ... ) { .... } }To copy to clipboard, switch view to plain text mode
oddytz1989 (14th February 2012)
Biiiiig thanks. The last question. How on the chart when you click the mouse show a vertical line?. I wrote:
But nothing works.Qt Code:
To copy to clipboard, switch view to plain text mode
Check the bode example. It uses a crosshair instead of a vertical line - but the rest should be the same.
Uwe
oddytz1989 (15th February 2012)
Bookmarks