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,
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;
}
class myCurveWidget : public QwtPlot
{
/////////
}
class myCurvePicker : public QwtPlotPicker
{
//////////
}
QPointF myCurveWidget::mapMousePoint(QPoint mousePoint)
{
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;
}
To copy to clipboard, switch view to plain text mode
How can I map to exact plot coordinates?
Bookmarks