Is there a way to get the bounding rect of a QwtPlotItem in widget coordinates?
The reason I'm asking is I want to create a generic way of selecting QwtPlotItems with the mouse (no matter what type they are)
Is there a way to get the bounding rect of a QwtPlotItem in widget coordinates?
The reason I'm asking is I want to create a generic way of selecting QwtPlotItems with the mouse (no matter what type they are)
The bounding rectangle can be mapped to widget coordinates using: QwtPlot::canvasMap() and QwtScaleMap::transform().
Uwe
StrikeByte (16th September 2015)
Hello Uwe thanks for pointing me into the right direction
At the moment I'm still havinging some problems with the bounding rect of a VLine QwtPlotMarker it only returns a rect with a size of 1x1
I'm using qwt-6.1-multiaxes
This is the code I'm using to transform the bounding rect
Qt Code:
QRectF boundingRect = QwtScaleMap::transform(m_plot->canvasMap((*it)->xAxis()),m_plot->canvasMap((*it)->yAxis()),(*it)->boundingRect());To copy to clipboard, switch view to plain text mode
Basically this is a problem of the implementation of QwtPlotMarker::boundingRect(), that always returns the bounding rectangle of a point ( size is ( 0, 0 ), not ( 1, 1 ) ! ). The correct bounding rectangle for a VLine should be ( 0, -1 ), where the -1 indicates, that the autoscaler shouldn't take care of it vertically. You could fix this by overloading QwtPlotMarker::boundingRect().
Then your code has to check the horizontal and vertical intervals independently. Then in case of your VLine all clicks at a specific x coordinate do match regardless of the y coordinate.
Uwe
Bookmarks