1 Attachment(s)
QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Hello, I am implementing a curve widget in which the user can drag the curve by mouse move operations. The problem is the returned x dimension is not accurate in plot coordinates, there is no problem in the mapped y coordinate. There is always a shift or gap in the x dimension of the selected point(I guess this gap is about the width of the y-Axis ruler), please see the problem and the gap in my image attachment. Also I attach the code below.
I am using QwtPlotPicker::getInvTransform as,
Code:
class myCurveWidget
: public QwtPlot{
/////////
}
{
//////////
}
{
myCurvePicker picker(this->canvas());
QPointF mappedPt
= picker.
getInvTransform(mousePoint
);
if(mappedPt.x() < 0)
mappedPt.setX(0);
else if(mappedPt.x() > 255)
mappedPt.setX(255);
if(mappedPt.y() < 0)
mappedPt.setY(0);
else if(mappedPt.y() > 255)
mappedPt.setY(255);
return mappedPt;
}
How can I map to exact plot coordinates?
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Quote:
Originally Posted by
hakiim35
I am using QwtPlotPicker::getInvTransform ...
This method doesn't exist in the Qwt library.
Uwe
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Strange. I am using the 5.2.1 version and it does exist in that version. So what would you advise me to use?
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
The last version I think ^^.
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Quote:
Originally Posted by
hakiim35
Strange. I am using the 5.2.1 version and it does exist in that version. So what would you advise me to use?
QwtPlotPicker has a method invTransform - if you see a method getInvTransform you are probably working with a version, that has been patched by someone. Try to find the author of this patch and ask him/her what it is about.
Uwe
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Ok, I think I must explain where getInvTransform() comes from. As you said QwtPlotPicker has invTransform() method, but it is protected so I can't call it from my other classes, so the method getInvTransform() is a very simple public method calling invTransform() of its basic class 'QwtPlotPicker', so that other classes can use it.
So, now, do you have any idea about why invTransform() returns x-value including the width of y-axis ruler part?
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
use
Code:
QPointF mappedPt
= picker.
getInvTransform(mousePoint
) - picker.
getInvTransform(0);
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Hello, I tried but it didnt give correct result. I guess, the value you subtracted is the zero point in pixel coordinates, but I want to get the zero point in plot coordinates..
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Don't use a picker here - it's a QObject, that needs event processing - something, that is not happening the way you wrote your code.
Instead do something like this:
Code:
{
const double x
= canvasMap
( QwtPlot::xBottom ).
invTransform( mousePoint.
x() );
const double y
= canvasMap
( QwtPlot::yLeft ).
invTransform( mousePoint.
y() );
...
}
I'm not 100% sure if this already solves your problem, but at least it's better than using a picker and it should be easier to find out what is going on. If the bug is still there you should check p1, p2, s1, s2 of the maps to see if there are pending updates of the scales because of a missing replot.
Uwe
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Hello, it didnt help either..but I will try to investigate it deeper..
By the way, isnt it possible to retrieve the width of the vertical ruler on the left part of the widget?
Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates
Quote:
Originally Posted by
hakiim35
Hello, it didnt help either..but I will try to investigate it deeper..
Again: check p1, p2, s1, s2 !
Uwe