Menu

#255 QwtPlotShapeItem does not display line shapes (height or width = 0)

None
closed
None
5
2015-12-09
2015-12-05
magro
No

The class QwtPlotShapeItem is used to display various shapes. If the underlying QPainterPath only contains a horizontal or vertical line (two points with one identical coordinate each), its bouding box has a height or width of zero. In this case, the shape is not displayed on the canvas.

The reason is, that in QwtPlotShapeItem::draw (line 379 in qwt_plot_shapeitem.cpp), the command

d_data->boundingRect.intersects( cRect )

returns false, since the area of the boundingRect is zero.

This bug has already been posted in the QtCentre forum under: http://www.qtcentre.org/threads/64486-QwtPlotShapeItem-does-not-display-line-shapes-%28height-or-width-0%29

Cheers

Marc
itom.bitbucket.org

Discussion

  • magro

    magro - 2015-12-05

    If solved this bug by replacing the if-condition (line 395) by

    //verifies if d_data->boundingRect intersects with cRect even if d_data->boundingRect can have an area of zero in case of line shapes
    if ( !cRect.isNull() && \
             !d_data->boundingRect.isNull() && \
             (cRect.x() + cRect.width()) >= d_data->boundingRect.x() && \
             (d_data->boundingRect.x() + d_data->boundingRect.width()) >= cRect.x() && \
             (cRect.y() + cRect.height()) >= d_data->boundingRect.y() && \
             (d_data->boundingRect.y() + d_data->boundingRect.height()) >= cRect.y() )
    

    (see http://stackoverflow.com/questions/13390333/two-rectangles-intersection)

    This is almost the same than the original Qt code for the intersects method does. The isNull() check at the beginning is not necessary but is also done by Qt.

    Cheers
    Marc

     
  • Uwe Rathmann

    Uwe Rathmann - 2015-12-09

    The suggested fix still ignores the situation of being a point, so both isNull() checks can/must be left out. Beside that the check can be written slightly more readable using left/right/top/bottom.

    Fixed in all branches >= 6.1

     
  • Uwe Rathmann

    Uwe Rathmann - 2015-12-09
    • status: open --> closed
    • Group: -->
     

Anonymous
Anonymous

Add attachments
Cancel